/* Игротека — общие стили. Каждая игра может переопределить переменные в своём :root. */
:root {
  --bg: #14161c;
  --card: #1f232d;
  --card2: #272c38;
  --line: #333a4a;
  --text: #f2f3f7;
  --muted: #9aa3b8;
  --accent: #ffb703;
  --accent-text: #1a1400;
  --danger: #ef476f;
  --ok: #2fd6a3;
  --info: #5aa9ff;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4; -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; text-align: center; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }

.wrap {
  width: 100%; max-width: 520px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px; min-height: 100dvh;
}
.wrap.wide { max-width: 1180px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.accent { color: var(--accent); }
.small { font-size: 14px; }
.hint { font-size: 14px; color: var(--muted); }
.label { font-size: 17px; font-weight: 600; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .btn { flex: 1 1 140px; width: auto; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card.accent { border-color: var(--accent); }
.card.danger { border-color: var(--danger); }
.card.ok { border-color: var(--ok); }

/* Кнопки: минимум 44px по высоте — под палец */
.btn {
  display: block; width: 100%; padding: 16px; border-radius: 14px; border: none;
  font-size: 18px; font-weight: 700; text-align: center; text-decoration: none;
  background: var(--accent); color: var(--accent-text); min-height: 52px;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.okb { background: var(--ok); color: #062018; }
.btn.sm { padding: 10px 14px; font-size: 15px; min-height: 44px; border-radius: 12px; width: auto; }
.btn:disabled, .btn.disabled { opacity: .35; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(.985); }
body.busy [data-act] { pointer-events: none; }
body.busy .btn[data-act] { opacity: .7; }
.linkbtn { background: none; border: none; padding: 8px 4px; color: var(--accent); font-size: 15px; text-decoration: underline; min-height: 44px; }

/* Верхняя панель */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.back { color: var(--muted); text-decoration: none; font-size: 15px; padding: 8px 0; }
.chip-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; min-height: 40px;
}
.chip-btn b { color: var(--accent); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.net-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: middle; }
.net-dot.bad { background: var(--danger); }

/* Поля */
.input, textarea.input {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 17px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { min-height: 120px; resize: vertical; font-size: 15px; line-height: 1.35; }

/* Счётчик −/+ */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); font-size: 24px; font-weight: 600;
}
.stepper button:disabled { opacity: .3; }
.stepper span { min-width: 34px; text-align: center; font-size: 22px; font-weight: 700; }

/* Переключатели */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button, .chip {
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  font-size: 15px; font-weight: 600; min-height: 44px;
}
.seg button.on, .chip.on { border-color: var(--accent); color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.mode {
  text-align: left; padding: 14px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg); width: 100%;
}
.mode b { display: block; font-size: 16px; margin-bottom: 4px; }
.mode span { color: var(--muted); font-size: 14px; line-height: 1.35; display: block; }
.mode.on { border-color: var(--accent); }
.mode.on b { color: var(--accent); }
.mode:disabled { opacity: 1; cursor: default; }

/* Списки игроков */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--card2); border: 1px solid transparent; min-height: 48px;
}
.item.me { border-color: var(--ok); }
.item.cur { border-color: var(--accent); }
.item.out { opacity: .5; }
.item.spy, .item.bad { border-color: var(--danger); }
.item .who { font-weight: 600; word-break: break-word; }
.item .what { color: var(--muted); text-align: right; font-size: 15px; }
.item .tools { display: flex; gap: 4px; flex: none; }
.item .tools button {
  background: none; border: 1px solid var(--line); border-radius: 10px; color: var(--muted);
  min-width: 40px; height: 40px; font-size: 15px;
}
.offline .who::after { content: " · не в сети"; color: var(--muted); font-weight: 400; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted); font-weight: 600; vertical-align: middle; }
.badge.accent { color: var(--accent); border-color: var(--accent); }

/* Таймер */
.tm { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tm.small { font-size: 22px; }
.tm.end { color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* Нижняя закреплённая панель действий (на телефоне всегда под пальцем) */
.dock {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -16px -24px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 75%, transparent); display: flex; flex-direction: column; gap: 8px;
}
.dock:empty { display: none; }

/* Модальные окна, тосты, баннер связи */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: #000a; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .backdrop { align-items: center; } }
.modal {
  width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; display: flex; flex-direction: column; gap: 12px; max-height: 90dvh; overflow: auto;
}
.modal .qr { background: #fff; border-radius: 12px; padding: 10px; align-self: center; line-height: 0; }
.modal .qr svg { width: 220px; height: 220px; }
.modal .link { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; background: var(--bg); border-radius: 10px; padding: 10px; user-select: all; }
/* Плашки — сверху, чтобы не закрывать нижнюю панель с кнопками хода */
.toast {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60;
  background: var(--card2); border: 1px solid var(--line); color: var(--text); padding: 12px 16px; border-radius: 12px;
  max-width: min(92vw, 440px); box-shadow: 0 6px 24px #0008; font-weight: 600; text-align: center;
}
.toast.err { border-color: var(--danger); }
.toast.att { border-color: var(--accent); color: var(--accent); }
.netbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: var(--danger); color: #fff;
  text-align: center; font-size: 14px; font-weight: 600; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
}

/* Карточка «скрытого» содержимого */
.secret {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 30px 16px; text-align: center;
}
.secret .cap { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.secret .big { font-size: 38px; font-weight: 800; word-break: break-word; line-height: 1.15; }
.secret.bad { border-color: var(--danger); }
.secret.bad .big { color: var(--danger); }
.pass-name { font-size: 46px; font-weight: 800; text-align: center; color: var(--accent); word-break: break-word; line-height: 1.1; }

details.rules { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
details.rules summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details.rules[open] summary { margin-bottom: 8px; }
details.rules p, details.rules li { color: var(--muted); font-size: 15px; }
details.rules ul { padding-left: 18px; margin: 6px 0; }

.events { font-size: 13px; color: var(--muted); text-align: center; }
.score-table .item { min-height: 40px; padding: 8px 12px; }
.plus { color: var(--ok); font-weight: 700; }
