:root {
  /* Рисограф: тёплая бумага и плашечные краски. Значения — sRGB-приближения
     плашек Pantone, точного соответствия между Pantone и экраном не бывает. */
  --paper: #F5F1E8;        /* полотно */
  --card: #FBF8F1;         /* закрытая карточка */
  --plate: #FFFDF7;        /* плашка со словом */
  --surface: #FBF8F1;      /* панели */
  --ink: #101820;          /* Black 6 C — обводка и текст */
  --muted: #6C7178;
  --line: #D9D3C5;
  --red: #CE0058;          /* Rubine Red C */
  --red-ink: #9E0044;
  --blue: #0085CA;         /* Process Blue C */
  --blue-ink: #00639A;
  --neutral: #D7D2CB;      /* Warm Gray 1 C */
  --neutral-ink: #B3ADA3;
  --assassin: #101820;     /* Black 6 C */
  --accent: #FFCD00;       /* 116 C */
  --accent-ink: #101820;
  --radius: 10px;
  --shadow: 3px 3px 0 var(--ink);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые display из правил ниже. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

/* ---------- общие ---------- */

.btn {
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover:not(:disabled) { background: #FFF; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .38; cursor: not-allowed; box-shadow: 2px 2px 0 var(--line); border-color: var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #FFD733; }
.btn.tiny {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 6px;
  width: 100%;
  line-height: 1.2;
  box-shadow: 2px 2px 0 var(--ink);
  overflow-wrap: break-word;
}

.error { color: var(--red); font-size: 13px; margin: 8px 0 0; }

/* Ошибка внизу страницы никем не читалась — теперь всплывает поверх доски. */
#error {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(92vw, 460px);
  margin: 0;
  padding: 9px 16px;
  text-align: center;
  font-weight: 600;
  color: var(--plate);
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 99px;
  box-shadow: var(--shadow);
}

.hint { color: var(--muted); font-size: 13px; text-align: center; min-height: 18px; margin: 8px 0 0; }

/* ---------- лобби ---------- */

.lobby { min-height: 100%; display: flex; overflow-y: auto; padding: 24px; }
.lobby-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 28px;
  margin: auto;
}
.lobby h1 { margin: 0 0 10px; font-size: 32px; letter-spacing: -.02em; }
.lobby .sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.lobby .field { margin-top: 20px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .join-row input {
  width: 100%;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.field input:focus, .join-row input:focus { box-shadow: 2px 2px 0 var(--red); }
#createBtn { width: 100%; margin-top: 6px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 20px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--line); }

.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.join-row .btn { flex: 0 0 auto; }

/* ---------- шапка ---------- */

.game { display: flex; flex-direction: column; height: 100%; }

.topbar {
  position: relative; /* якорь для выпадающего меню на телефоне */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--surface);
}

/* На широком экране — обычный ряд кнопок; в мобильном виде становится меню. */
.menu-drop { display: flex; gap: 8px; align-items: center; }
.chip.menu { font-size: 16px; line-height: 1; padding: 5px 11px; }

/* Полоса «Добавиться в команды»: только телефон, см. медиазапрос ниже. */
.teams-cta {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 14px;
  padding: 11px 14px;
  cursor: pointer;
}
.teams-cta:active { background: #FFD733; }
.teams-cta.on { background: var(--plate); font-weight: 600; }
.topbar-left, .topbar-right { display: flex; gap: 8px; align-items: center; min-width: 0; }
.topbar-left { justify-self: start; }
.topbar-right { justify-self: end; }
.topbar-center { display: flex; flex-direction: column; gap: 4px; align-items: center; }

.chip {
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip.code { font-weight: 800; letter-spacing: 3px; background: var(--ink); color: var(--paper); }
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.chip.relaxed { cursor: help; background: var(--accent); }

.race { display: flex; align-items: center; gap: 10px; }
.score {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
  text-align: center;
}
.score.red { color: var(--red); }
.score.blue { color: var(--blue); }

.race-bar {
  display: flex;
  width: 220px;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--line);
  border: 2px solid var(--ink);
}
.race-bar span { height: 100%; transition: width .35s ease; }
.race-red { background: var(--red); }
.race-blue { background: var(--blue); margin-left: auto; }

.turn-line { display: flex; align-items: center; gap: 7px; }
.turn { font-size: 12px; color: var(--muted); font-weight: 600; }
.turn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.turn-dot.red { background: var(--red); }
.turn-dot.blue { background: var(--blue); }
.turn-dot.live { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .turn-dot.live { animation: none; } }

/* ---------- симулятор стенда ---------- */

.sim-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--accent);
}
.sim-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; flex: 0 0 auto; }
.sim-note { font-size: 11px; color: #6B5A00; margin-left: auto; }
.sim-seats { display: flex; gap: 6px; flex-wrap: wrap; }

.sim-seat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
}
.sim-seat:hover { background: #FFF; }
.sim-seat.me { background: var(--ink); color: var(--paper); font-weight: 700; }
.sim-seat i { font-style: normal; font-size: 10px; color: var(--muted); }
.sim-seat.red i { color: var(--red); }
.sim-seat.blue i { color: var(--blue); }
.sim-seat.me i { color: var(--line); }

/* ---------- раскладка ---------- */

.layout { flex: 1; display: flex; min-height: 0; }

.side {
  width: 242px;
  flex: 0 0 242px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
}
.side.left { border-right: 2px solid var(--ink); }
.side.right { border-left: 2px solid var(--ink); }

.team-block { border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px; background: var(--card); box-shadow: var(--shadow); }
.team-block.red { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.team-block.blue { border-color: var(--blue); box-shadow: 3px 3px 0 var(--blue); }
.team-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.team-title { font-weight: 800; font-size: 14px; }
.team-block.red .team-title { color: var(--red); }
.team-block.blue .team-title { color: var(--blue); }
.team-left { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Название команды выглядит текстом, пока его не начали править. */
input.team-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 2px 5px;
  margin-left: -5px;
  outline: none;
  font-family: inherit;
}
input.team-title:not(:disabled):hover { border-color: var(--line); }
input.team-title:focus { border-color: currentColor; background: var(--plate); }
input.team-title:disabled { cursor: default; }

.team-tools { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

.roles { display: flex; flex-direction: column; gap: 10px; }
.role-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.role-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; min-height: 4px; }
.plist li { font-size: 13px; padding: 2px 0; display: flex; align-items: center; gap: 5px; }
.plist li.me { font-weight: 800; }
.plist li.off { opacity: .45; }
.plist li .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); flex: 0 0 auto; }
.plist li.off .dot { background: var(--line); }
.plist li .owner { color: var(--red); font-size: 10px; }
.plist li .host-mark { color: var(--ink); font-size: 11px; }
.plist li .bot-mark {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 3px;
}
.plist li .pass-host {
  background: none; border: none; padding: 0 2px;
  font-size: 11px; color: transparent; cursor: pointer;
}
.plist li:hover .pass-host { color: var(--muted); }
.plist li .pass-host:hover { color: var(--ink); }

.btn.lock { margin-bottom: 0; }
.team-block.locked .team-title::after { content: " \1F512"; font-size: 11px; }

.log-block { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }

/* ---------- правила ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 32, .45);
  animation: fade-in .16s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 20px 22px 22px;
  box-shadow: 6px 6px 0 var(--ink);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { color: var(--ink); background: var(--line); }

.rules { font-size: 13px; color: #3E444B; }
.rules p { margin: 0 0 11px; }
.rules b { color: var(--ink); font-weight: 700; }
.rules ul { list-style: none; margin: 0 0 11px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
/* Пункты про цвета — в одну строку с образцом, текстовые — с висячим маркером. */
.rules li { display: flex; align-items: center; gap: 8px; }
.rules li:not(:has(> .sw)) { display: list-item; margin-left: 17px; list-style: disc; }
.rules li::marker { color: var(--neutral-ink); }

/* Правила стали длинными — без заголовков в них не сориентироваться. */
.rules h3 {
  margin: 18px 0 7px;
  padding-top: 11px;
  border-top: 2px solid var(--line);
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink);
}
.rules-lead {
  padding: 10px 12px;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 600;
  color: var(--ink);
}

.sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 1.5px solid var(--ink); }
.sw.red { background: var(--red); }
.sw.blue { background: var(--blue); }
.sw.neutral { background: var(--neutral); }
.sw.assassin { background: var(--assassin); }

/* ---------- подсказка с определением ---------- */

.tip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tip b { font-size: 13px; }
.tip span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.tip i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--neutral-ink);
}
.tip a { font-size: 11px; color: var(--blue-ink); margin-top: 2px; }

/* ---------- журнал ---------- */

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: none; flex: 1; overflow-y: auto; font-size: 12px; }
.log li { color: var(--muted); }
.log li.red { color: var(--red); }
.log li.blue { color: var(--blue); }
.log li.clue { font-weight: 700; color: var(--ink); }

/* ---------- доска ---------- */

.board-wrap {
  flex: 1;
  min-width: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow-y: auto;
}

.banner {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  text-align: center;
  padding: 11px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 800;
  letter-spacing: .01em;
  animation: drop-in .35s ease-out;
}
.banner.red { background: var(--red); color: var(--plate); }
.banner.blue { background: var(--blue); color: var(--plate); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .banner { animation: none; } }

/* Кнопка новой партии живёт на цветном баннере — держим её светлой. */
.btn.again { padding: 6px 14px; font-size: 14px; background: var(--plate); color: var(--ink); }
.again-note { font-size: 12px; font-weight: 600; opacity: .85; }

/* ---------- подпись автора ---------- */

.credit {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}
.credit:hover { color: var(--ink); }
.credit-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.credit-text b { font-size: 13px; color: var(--ink); }
.credit-text i { font-style: normal; font-size: 11px; line-height: 1.35; }
.credit-logo {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  object-fit: cover;
}

/* На игровом экране подпись стоит в левом нижнем углу — прижимаем её ко дну рейла.
   Рейл узкий, поэтому знак и вторая строка чуть мельче, иначе «в лс» уезжает
   отдельной строкой. */
.side .credit { margin-top: auto; }
.side .credit-logo { width: 28px; height: 28px; }
.side .credit-text i { font-size: 10px; text-wrap: balance; }

.lobby-legal {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.rules-legal {
  display: block;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.rules-legal a { color: var(--muted); }

.board {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  perspective: 900px;
}

/* Карточка сделана по образу оригинала: слово всегда на белой плашке снизу,
   а над ней — фигура агента в краске команды. Слово не прыгает при вскрытии. */
.card {
  position: relative;
  aspect-ratio: 5 / 3.4;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  font-size: clamp(10px, 1.15vw, 14px);
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  text-align: center;
  cursor: default;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s;
}

/* Длинное слово переносилось по последней букве — кегль зависит от длины. */
.card.len-m { font-size: clamp(9px, 1.0vw, 13px); }
.card.len-l { font-size: clamp(8px, .9vw, 11px); letter-spacing: 0; }

.card .w {
  position: relative;
  z-index: 2;
  background: var(--plate);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 3px 4px;
  pointer-events: none;
}

.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.card.clickable:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }

/* Переворот в момент открытия: карточка должна ощущаться. */
@keyframes flip-open {
  0%   { transform: rotateY(0deg) scale(1); }
  45%  { transform: rotateY(90deg) scale(1.04); }
  100% { transform: rotateY(0deg) scale(1); }
}
.card.just-revealed { animation: flip-open .42s ease-out; }

/* Человечки-пиктограммы вспыхивают только в момент переворота. */
.card .pop {
  position: absolute;
  inset: 0;
  background-position: center 30%;
  background-repeat: no-repeat;
  background-size: auto 46%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.card.c-red .pop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='66' height='40' viewBox='0 0 66 40'%3E%3Cg fill='%23FBF8F1'%3E%3Crect x='6' y='32' width='9' height='8'/%3E%3Crect x='28' y='25' width='9' height='15'/%3E%3Crect x='50' y='18' width='9' height='22'/%3E%3Ccircle cx='10.5' cy='26' r='2.3'/%3E%3Cpath d='M7.0 32a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='32.5' cy='19' r='2.3'/%3E%3Cpath d='M29.0 25a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='54.5' cy='12' r='2.3'/%3E%3Cpath d='M51.0 18a3.5 3.5 0 0 1 7 0z'/%3E%3C/g%3E%3C/svg%3E"); }
.card.c-blue .pop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='44' viewBox='0 0 64 44'%3E%3Cg fill='%23FBF8F1'%3E%3Ccircle cx='12' cy='10' r='2.3'/%3E%3Cpath d='M8.5 16a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='38' cy='5' r='2.3'/%3E%3Cpath d='M34.5 11a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='54' cy='19' r='2.3'/%3E%3Cpath d='M50.5 25a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='22' cy='31' r='2.3'/%3E%3Cpath d='M18.5 37a3.5 3.5 0 0 1 7 0z'/%3E%3Ccircle cx='46' cy='35' r='2.3'/%3E%3Cpath d='M42.5 41a3.5 3.5 0 0 1 7 0z'/%3E%3C/g%3E%3C/svg%3E"); }
.card.c-neutral .pop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='58' height='40' viewBox='0 0 58 40'%3E%3Cg fill='%23101820'%3E%3Ccircle cx='29' cy='21' r='2.3'/%3E%3Cpath d='M25.5 27a3.5 3.5 0 0 1 7 0z'/%3E%3C/g%3E%3C/svg%3E"); }
.card.c-assassin .pop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='58' height='40' viewBox='0 0 58 40'%3E%3Cg fill='%23FBF8F1'%3E%3Ccircle cx='29' cy='21' r='2.3'/%3E%3Cpath d='M25.5 27a3.5 3.5 0 0 1 7 0z'/%3E%3C/g%3E%3C/svg%3E"); }

@keyframes pop-fade {
  0% { opacity: 0; transform: scale(.7); }
  35% { opacity: .5; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}
.card.just-revealed .pop { animation: pop-fade .95s ease-out; }

/* Чёрный агент — единственное место, где интерфейс повышает голос. */
@keyframes assassin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}
.board-wrap.assassin-hit { animation: assassin-shake .45s ease-out; }
.board-wrap.assassin-hit::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(16, 24, 32, .8) 100%);
  animation: fade-out 1.1s ease-out forwards;
}
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .card.just-revealed,
  .card.just-revealed .pop,
  .board-wrap.assassin-hit,
  .board-wrap.assassin-hit::after { animation: none; }
}

/* Паттерн данных проступает только на вскрытой карточке. Закрытая — чистая
   бумага со словом, как в настольном оригинале. */
.card.revealed::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 1;
}

.card.revealed.c-red { background: var(--red); }
.card.revealed.c-blue { background: var(--blue); }
.card.revealed.c-neutral { background: var(--neutral); }
.card.revealed.c-assassin { background: var(--assassin); }
.card.revealed.c-assassin .w { background: var(--assassin); color: var(--plate); border-color: var(--plate); }

.card.revealed.c-red::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 68' preserveAspectRatio='none'%3E%3Cg fill='%239E0044'%3E%3Crect x='5' y='34' width='9' height='34'/%3E%3Crect x='19' y='20' width='9' height='48'/%3E%3Crect x='33' y='42' width='9' height='26'/%3E%3Crect x='47' y='12' width='9' height='56'/%3E%3Crect x='61' y='30' width='9' height='38'/%3E%3Crect x='75' y='24' width='9' height='44'/%3E%3Crect x='89' y='38' width='9' height='30'/%3E%3C/g%3E%3C/svg%3E"); }
.card.revealed.c-blue::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 68' preserveAspectRatio='none'%3E%3Cg fill='%2300639A'%3E%3Crect x='5' y='26' width='9' height='42'/%3E%3Crect x='19' y='40' width='9' height='28'/%3E%3Crect x='33' y='16' width='9' height='52'/%3E%3Crect x='47' y='34' width='9' height='34'/%3E%3Crect x='61' y='22' width='9' height='46'/%3E%3Crect x='75' y='44' width='9' height='24'/%3E%3Crect x='89' y='28' width='9' height='40'/%3E%3C/g%3E%3C/svg%3E"); }
.card.revealed.c-neutral::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 68' preserveAspectRatio='none'%3E%3Cpath d='M0 12h100M0 26h100M0 40h100M0 54h100M14 0v68M28 0v68M42 0v68M56 0v68M70 0v68M84 0v68' stroke='%23B3ADA3' stroke-width='1' fill='none'/%3E%3Cpath d='M4 36 L20 34 L36 37 L52 33 L68 36 L84 34 L96 36' stroke='%23B3ADA3' stroke-width='4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.card.revealed.c-assassin::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 68' preserveAspectRatio='none'%3E%3Cg fill='%232B333C'%3E%3Crect x='5' y='10' width='9' height='58'/%3E%3Crect x='19' y='20' width='9' height='48'/%3E%3Crect x='33' y='32' width='9' height='36'/%3E%3Crect x='47' y='44' width='9' height='24'/%3E%3Crect x='61' y='54' width='9' height='14'/%3E%3Crect x='75' y='62' width='9' height='6'/%3E%3Crect x='89' y='65' width='9' height='3'/%3E%3C/g%3E%3C/svg%3E"); }

/* Ключ капитана: рамка в краске команды плюс бледная заливка — одной рамки
   мало, чтобы охватить свои карточки одним взглядом. Чёрный агент держит
   чернильную тень: цветная читалась как принадлежность команде. */
.card.key-red { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); background: #FBE3EE; }
.card.key-blue { border-color: var(--blue); box-shadow: 3px 3px 0 var(--blue); background: #DEEEF9; }
.card.key-neutral { border-color: var(--neutral-ink); box-shadow: 3px 3px 0 var(--neutral-ink); background: #EEEAE1; }
.card.key-assassin { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); background: #DFDBD1; }
.card.key-assassin .w { background: var(--assassin); color: var(--plate); border-color: var(--assassin); }
.card.key-assassin::after {
  content: "\2620";
  position: absolute;
  top: 3px; right: 7px;
  font-size: 14px;
  z-index: 3;
}

/* Открытая карточка «выбывает» из активной сетки, но остаётся читаемой. */
.card.revealed { box-shadow: 1px 1px 0 var(--ink); }
.card.revealed.dim { opacity: .82; }
.card.revealed.c-assassin.dim { opacity: 1; }

/* ---------- лобби внутри комнаты ---------- */

.lobby-panel {
  width: 100%;
  max-width: 980px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 16px 18px;
}
.lobby-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.lobby-panel h2 { margin: 0; font-size: 19px; }
.lobby-sub { margin: 0; color: var(--muted); font-size: 12px; }
.lobby-note {
  margin: 0 0 14px;
  padding: 9px 11px;
  background: var(--plate);
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Категории слева, настройки и старт справа: так панель не растёт вниз. */
.setup-grid { display: grid; grid-template-columns: 1fr 250px; gap: 18px; align-items: start; }
.setup-side { display: flex; flex-direction: column; gap: 14px; }

.setup-block + .setup-block { margin-top: 14px; }
.setup-side .setup-block + .setup-block { margin-top: 0; }
.setup-note { color: var(--muted); font-size: 11px; line-height: 1.35; margin: 4px 0 0; }

.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 8px; }
.cat-list.levels { grid-template-columns: 1fr; }

.cat {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  transition: box-shadow .12s, background .15s;
}
.cat:hover { box-shadow: 2px 2px 0 var(--ink); }
.cat.on { background: var(--accent); box-shadow: 2px 2px 0 var(--ink); }
.cat input { margin: 2px 0 0; accent-color: var(--ink); cursor: pointer; flex: 0 0 auto; }
.cat input:disabled { cursor: default; }
.cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-text b { font-size: 12px; font-weight: 700; line-height: 1.25; }
.cat-text i { font-style: normal; font-size: 10px; color: var(--muted); line-height: 1.3; }
.cat.on .cat-text i { color: #6B5A00; }

.checklist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.checklist li::before { margin-right: 6px; }
.checklist li.ok { color: #1F7A3D; font-weight: 600; }
.checklist li.ok::before { content: "\2713"; }
.checklist li.bad { color: var(--red); font-weight: 600; }
.checklist li.bad::before { content: "\2715"; }

#startBtn { width: 100%; }

/* ---------- действия ---------- */

.actions { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 42px; }
.clue-form { display: flex; gap: 8px; }
.clue-form input {
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  min-width: 220px;
}
.clue-form input:focus { box-shadow: 2px 2px 0 var(--red); }
.clue-form select { background: var(--plate); border: 2px solid var(--ink); border-radius: 8px; padding: 9px 10px; }

/* Загаданное слово — самое важное живое сообщение на экране. */
.clue-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 99px;
  box-shadow: var(--shadow);
  padding: 8px 10px 8px 22px;
}
.clue-word { font-size: 24px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.clue-count {
  background: var(--ink);
  color: var(--accent);
  border-radius: 99px;
  min-width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  padding: 0 8px;
}
.clue-left { font-size: 12px; color: #6B5A00; padding-right: 12px; font-weight: 600; }

.only-mobile { display: none; }

/* ---------- узкие экраны ---------- */

@media (max-width: 1100px) {
  .setup-grid { grid-template-columns: 1fr; gap: 14px; }
  .cat-list.levels { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 860px) {
  .only-mobile { display: inline-block; }
  /* Три блока в столбик зажимали доску, поэтому скроллим всю колонку целиком. */
  .layout { flex-direction: column; overflow-y: auto; }
  .side { width: 100%; flex: 0 0 auto; max-height: none; overflow: visible; }
  .board-wrap { overflow: visible; order: 2; padding: 10px; justify-content: flex-start; }
  .log { max-height: 220px; }
  .side.left, .side.right { border-right: none; border-left: none; border-bottom: 2px solid var(--ink); }
  .side.right { order: 3; border-bottom: none; border-top: 2px solid var(--ink); }
  .side[hidden] { display: none; }
  .side .credit { margin-top: 0; }

  /* Шапка занимала три ряда из-за подписей — ужимаем. */
  .topbar { padding: 7px 10px; gap: 8px; grid-template-columns: auto 1fr; }
  /* Раньше кнопки переносились на вторую строку, из-за чего правый блок
     становился двухрядным, а название уезжало в середину по высоте.
     Теперь справа только код комнаты и гамбургер — перенос не нужен. */
  .topbar-right { flex-wrap: nowrap; justify-content: flex-end; }
  .topbar-left { align-self: center; }
  .chip { padding: 4px 10px; font-size: 12px; }

  /* Вторичные действия прячем в меню: на маленьком экране они только шумели. */
  .menu-drop {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 10px;
    z-index: 60;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 200px;
    padding: 9px;
    background: var(--surface);
    border: 2px solid var(--ink);
    border-radius: 12px;
    box-shadow: var(--shadow);
  }
  .menu-drop.open { display: flex; }
  .menu-drop .chip { text-align: center; padding: 9px 12px; font-size: 13px; }

  .teams-cta { display: block; }
  .brand { font-size: 14px; }
  .turn { min-width: 0; font-size: 11px; }
  .topbar-center { order: 3; grid-column: 1 / -1; gap: 2px; }
  .race-bar { width: 44vw; }

  /* Симулятор в одну строку с горизонтальной прокруткой. */
  .sim-bar { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; }
  .sim-note { display: none; }
  .sim-seats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sim-seats::-webkit-scrollbar { display: none; }
  .sim-seat { flex: 0 0 auto; }
  .sim-seat i { display: none; }

  .board { gap: 5px; }
  .card {
    aspect-ratio: 1 / 1;
    font-size: clamp(9px, 2.9vw, 14px);
    border-radius: 8px;
    /* По бокам отдаём плашке всё, что можно: каждые два пикселя ширины —
       это ещё одно слово, которое влезает в строку. */
    padding: 3px 1px;
    letter-spacing: 0;
  }
  /* Восьмибуквенное слово не помещалось в плашку и рвалось посередине:
     на телефоне отдаём ему всю ширину и убираем разрядку. */
  .card.len-m { font-size: clamp(7px, 2.2vw, 12px); letter-spacing: -.01em; }
  .card.len-l { font-size: clamp(6px, 1.9vw, 11px); letter-spacing: -.02em; }
  /* Плашка забирала ширину у слова — на телефоне отдаём ей всю карточку. */
  .card .w { padding: 2px 0; border-width: 1px; border-radius: 3px; }

  /* Поле в 145 пикселей показывало восемь символов — отдаём всю ширину. */
  .clue-form { width: 100%; flex-wrap: wrap; }
  .clue-form input { min-width: 0; flex: 1 1 100%; }
  .clue-form select { flex: 0 0 auto; }
  .clue-form .btn { flex: 1; }
}
