/* =========================================================================
   Игротека — дизайн-система.
   Принципы (почему так, а не иначе):
   1. Один экран = одно действие. Телефон держат одной рукой в шумной комнате,
      поэтому на экране максимум один главный акцент и одна кнопка действия.
   2. Ограниченный набор компонентов (идея Jackbox «The Jack Principles»):
      текст, выбор, кнопка, ожидание. Игрок, освоивший одну игру, знает все.
   3. Тёмная база + один акцент на игру. Свет из экрана в тёмной комнате
      не должен слепить, а акцент задаёт «настроение» конкретной игры.
   4. Тач-цели не меньше 56px по высоте (WCAG 2.5.5 просит 44px, Android 48dp —
      берём с запасом: играют на ходу, часто пьяными пальцами).
   5. Цвет никогда не единственный идентификатор: у игрока всегда есть имя и буква.
   ========================================================================= */

:root {
  --ink: #08080c;
  --ink-2: #0e0e15;
  --surface: #15151f;
  --surface-2: #1c1c28;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f6f3ea;
  --muted: #a09bb2;
  --dim: #6f6b80;

  --accent: #c8ff3b;
  --accent-ink: #0a0a0f;
  --danger: #ff5470;
  --ok: #3be08b;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-full: 999px;

  --tap: 56px;
  --pad: 20px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);

  --ease: cubic-bezier(0.22, 0.8, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Акценты игр. Один и тот же набор — в карточках каталога и внутри комнаты. */
[data-accent="lime"] { --accent: #c8ff3b; --accent-ink: #0a0a0f; }
[data-accent="orange"] { --accent: #ff7a3d; --accent-ink: #1a0a02; }
[data-accent="cyan"] { --accent: #46e0ff; --accent-ink: #001217; }
[data-accent="violet"] { --accent: #a97bff; --accent-ink: #0f0420; }
[data-accent="magenta"] { --accent: #ff4d8d; --accent-ink: #1a0009; }
[data-accent="amber"] { --accent: #ffc24b; --accent-ink: #1a1200; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Мягкое свечение акцента сверху: комната «подсвечена», но не светит в глаза. */
.glow {
  position: fixed;
  inset: -20vh -20vw auto -20vw;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 70%),
    radial-gradient(35% 40% at 15% 10%, rgba(90, 70, 255, 0.16) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.9;
}

a { color: inherit; text-decoration: none; }

/* ---------- Типографика ---------- */

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.03em; line-height: 1.02; }
h1 { font-size: clamp(34px, 9vw, 64px); }
h2 { font-size: clamp(22px, 5.4vw, 30px); }
h3 { font-size: 18px; letter-spacing: -0.01em; }
p { margin: 0; line-height: 1.5; color: var(--muted); }
strong { color: var(--text); font-weight: 700; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.lead { font-size: 16px; color: var(--muted); max-width: 46ch; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Каркас ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) var(--pad) 8px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; }

.topnav { display: flex; align-items: center; gap: 8px; flex: none; }
.topnav .btn { padding: 0 12px; }

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--pad) calc(40px + env(safe-area-inset-bottom));
  flex: 1;
}

.section { margin-top: 44px; }

/* ---------- Кнопки и поля ---------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  min-height: var(--tap);
  padding: 0 20px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 120ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), opacity 160ms;
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 12px 30px -14px color-mix(in srgb, var(--accent) 70%, transparent);
}

.btn--ghost { background: transparent; }
.btn--small { min-height: 42px; font-size: 14px; padding: 0 14px; width: auto; border-radius: var(--r-sm); }

.field { display: grid; gap: 8px; }

.field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.input, .textarea {
  appearance: none;
  width: 100%;
  min-height: var(--tap);
  padding: 15px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text);
  /* 16px обязателен: при меньшем iOS зумит страницу при фокусе. */
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  transition: border-color 160ms, background 160ms;
}

.textarea { min-height: 118px; resize: none; }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.pill--hot { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Сегментированный переключатель уровня пошлости. */
.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.segment button {
  appearance: none;
  min-height: 48px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.segment button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, var(--ink-2));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}

/* ---------- Карточки ---------- */

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--ink-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ---------- Главная ---------- */

.hero { padding-top: 26px; display: grid; gap: 14px; }
.hero h1 span { color: var(--accent); }

.playgrid { display: grid; gap: 14px; margin-top: 26px; }
@media (min-width: 760px) { .playgrid { grid-template-columns: 1.15fr 0.85fr; } }

.panel { display: grid; gap: 14px; align-content: start; }
.panel h3 { display: flex; align-items: center; gap: 8px; }

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.42em;
  font-weight: 800;
  font-size: 22px;
  text-align: center;
  padding-left: calc(16px + 0.42em);
}

.catalog { display: grid; gap: 12px; }
@media (min-width: 700px) { .catalog { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1020px) { .catalog { grid-template-columns: repeat(3, 1fr); } }

.game-card {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(170deg, var(--surface) 0%, var(--ink-2) 100%);
  overflow: hidden;
  transition: border-color 180ms var(--ease), transform 180ms var(--ease);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.game-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.game-card__num {
  position: absolute;
  top: -8px;
  right: 10px;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 255, 255, 0.045);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.game-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.game-card h3 { font-size: 19px; }
.game-card p { font-size: 13.5px; line-height: 1.45; min-height: 3.9em; }

/* ---------- Комната ---------- */

.room {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.hud {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) var(--pad) 12px;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.hud__code {
  font-weight: 900;
  letter-spacing: 0.24em;
  font-size: 15px;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--ink-2);
}

.hud__clock {
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.hud__clock:empty { display: none; }
.hud__round { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-left: 8px; }

.timer {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 92%);
  width: 100%;
  transform-origin: left center;
  transition: transform 250ms linear;
}

.stack {
  display: grid;
  gap: 16px;
  /* Запас снизу, чтобы панель ведущего не накрывала последний элемент. */
  padding: 18px var(--pad) 132px;
  flex: 1;
  align-content: start;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.screen { display: grid; gap: 16px; animation: screen-in 260ms var(--ease); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.screen__title { font-size: clamp(26px, 7vw, 34px); }
.screen__prompt { font-size: clamp(22px, 6.4vw, 28px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.screen__note { font-size: 13.5px; color: var(--dim); }

/* Строка игроков: кто ответил, кто ведущий, у кого сколько очков. */
.pile { display: flex; flex-wrap: wrap; gap: 8px; }

.player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 5px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  max-width: 100%;
}

.player--me { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--text); }
.player--off { opacity: 0.42; }

.player__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 10ch; }
.player__score { color: var(--dim); font-variant-numeric: tabular-nums; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex: none;
  color: #0a0a0f;
}

.avatar--lg { width: 44px; height: 44px; font-size: 17px; }

/* Выбор: крупные строки, вся строка — тач-цель. */
.options { display: grid; gap: 10px; }

.option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  min-height: var(--tap);
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, transform 120ms;
  -webkit-tap-highlight-color: transparent;
}

.option:hover { border-color: var(--line-strong); }
.option:active { transform: scale(0.99); }
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.option[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.option--duel { min-height: 92px; font-size: 17px; }

/* Два взаимоисключающих ответа («делал / не делал») — крупные кнопки в полширины. */
.options--two { grid-template-columns: 1fr 1fr; }
.option--center { justify-content: center; text-align: center; font-size: 17px; min-height: 64px; }

/* Вскрытие: строка «что / сколько». */
.reveal { display: grid; gap: 8px; }

.reveal__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  animation: screen-in 300ms var(--ease) backwards;
}

.reveal__row--hot { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.reveal__label { flex: 1; font-size: 15.5px; line-height: 1.35; }
.reveal__value { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); font-size: 15px; white-space: nowrap; }
.reveal__sub { display: block; font-size: 12px; color: var(--dim); font-weight: 600; margin-top: 3px; }

/* Таблица очков. */
.board { display: grid; gap: 8px; }

.board__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

.board__row--first { border-color: color-mix(in srgb, var(--accent) 65%, transparent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.board__place { width: 26px; font-weight: 900; color: var(--dim); font-variant-numeric: tabular-nums; }
.board__name { flex: 1; font-weight: 700; }
.board__score { font-weight: 900; font-variant-numeric: tabular-nums; }

/* Секретная карточка (шпион / локация). */
.secret {
  border-radius: var(--r-lg);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: radial-gradient(120% 140% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 60%), var(--surface);
  padding: 26px 20px;
  text-align: center;
  display: grid;
  gap: 10px;
}
.secret__role { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.secret__value { font-size: clamp(24px, 7vw, 32px); font-weight: 900; letter-spacing: -0.02em; }
.secret__body { font-size: 14.5px; color: var(--muted); white-space: pre-line; }

/* Нижняя панель ведущего. */
.hostbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px var(--pad) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8, 8, 12, 0) 0%, var(--ink) 26%, var(--ink) 100%);
  backdrop-filter: blur(6px);
}

.hostbar__hint { font-size: 12px; color: var(--dim); text-align: center; }

/* Тост для ошибок. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 220ms var(--ease);
  box-shadow: var(--shadow);
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

/* Оверлей входа в комнату. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(8px);
}

.overlay__box { width: 100%; max-width: 420px; display: grid; gap: 14px; }

.empty { padding: 28px 16px; text-align: center; color: var(--dim); font-size: 14px; }

/* ---------- Страница правил ---------- */

.rules { max-width: 720px; display: grid; gap: 18px; }
.rules__list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; counter-reset: r; }
.rules__list li { counter-increment: r; display: grid; grid-template-columns: 30px 1fr; gap: 10px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.rules__list li::before {
  content: counter(r);
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.example { border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); padding: 2px 0 2px 14px; display: grid; gap: 4px; }
.example__title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-weight: 800; }
.example__body { font-size: 14.5px; color: var(--muted); line-height: 1.5; }

.footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 12.5px; color: var(--dim); }

/* ---------- Служебное ---------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
