/* «Процедурная» — общий экран. Тёмная «процедурная» палитра с бирюзовыми акцентами. */
:root {
  --bg: #0d141b;
  --panel: #16212b;
  --panel2: #1d2b37;
  --line: #2b3d4c;
  --text: #eef3f7;
  --muted: #93a6b6;
  --accent: #2fd1b0;
  --accent-ink: #062a22;
  --good: #3ddc84;
  --gold: #ffd23f;
  --bad: #ff5b5b;
  --warn: #ffb347;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(1200px 700px at 70% -10%, #1b3240 0%, var(--bg) 60%) fixed, var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; display: flex; flex-direction: column; }
button, input { font: inherit; }
[hidden] { display: none !important; }

/* шапка */
.top { display: flex; align-items: center; gap: 18px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: rgba(10, 16, 22, 0.75); flex: none; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 850; font-size: 20px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 22px; font-weight: 900; }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex: 1; }
.steps li { padding: 4px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; border: 1px solid transparent; }
.steps li.on { color: var(--accent-ink); background: var(--accent); font-weight: 750; }
.steps li.done { color: var(--text); border-color: var(--line); }
.top-right { display: flex; align-items: center; gap: 10px; }
.room { color: var(--muted); font-size: 14px; }
.room b { color: var(--text); letter-spacing: 0.12em; font-size: 18px; }
.chip { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--accent); }

main { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; overflow: auto; padding: 24px clamp(16px, 3vw, 40px); }

/* общие элементы */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; }
.kicker { text-transform: uppercase; letter-spacing: 0.1em; font-size: 12px; color: var(--accent); font-weight: 800; }
h1 { font-size: clamp(28px, 3.4vw, 46px); margin: 4px 0 10px; line-height: 1.1; }
h2 { margin: 0 0 12px; font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; margin-top: 14px; }
.row.left { justify-content: flex-start; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 11px 20px; font-weight: 800; cursor: pointer; text-decoration: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.btn small { font-weight: 600; font-size: 13px; opacity: 0.8; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; cursor: default; filter: none; }
.btn.big { font-size: 19px; padding: 14px 26px; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; margin-top: 16px; }
.msg { min-height: 1.4em; color: var(--warn); margin-top: 8px; }

/* меню */
.menu { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr); gap: 32px; align-items: center; max-width: 1300px; margin: 0 auto; min-height: 100%; }
.menu-art { aspect-ratio: 1.25; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: #0a1016; }
.menu-art canvas { width: 100%; height: 100%; display: block; }
.lead { font-size: 18px; color: #d3dee7; max-width: 560px; }
.menu-btns { display: flex; flex-direction: column; gap: 12px; max-width: 420px; margin-top: 18px; }
.menu-btns .row { justify-content: flex-start; margin: 0; }
.menu-btns .row .btn { flex: 1; }
.warn-note { margin-top: 22px; font-size: 13px; color: var(--muted); max-width: 520px; border-left: 3px solid var(--warn); padding-left: 12px; }

/* лобби */
.lobby-grid { display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr); gap: 22px; max-width: 1250px; margin: 0 auto; }
.join { text-align: center; }
.code { font-size: clamp(54px, 7vw, 92px); font-weight: 900; letter-spacing: 0.14em; color: var(--accent); line-height: 1; margin: 10px 0 14px; }
.qr-wrap { background: #fff; border-radius: 14px; padding: 10px; display: inline-block; }
.qr-wrap canvas { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.link { margin-top: 12px; font-size: 18px; font-weight: 750; word-break: break-all; }
.join-steps { text-align: left; color: #c8d5df; padding-left: 22px; margin: 14px 0 0; }
.join-steps li { margin: 6px 0; }
.join-steps small { display: block; color: var(--muted); }
.mode-chip { background: var(--panel2); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--accent); border: 1px solid var(--line); }
.plist { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; min-height: 60px; }
.pl { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel2); border-radius: 12px; border: 1px solid var(--line); }
.pl i { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.pl b { font-size: 18px; }
.pl .dev { color: var(--muted); flex: 1; font-size: 14px; }
.pl .x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
.pl.off { opacity: 0.55; }
.pl .tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #22313d; color: var(--muted); }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1.5px dashed var(--line); border-radius: 12px; }
.add-local { display: flex; gap: 10px; }
.add-local input { flex: 1; background: #0f1820; border: 1.5px solid var(--line); border-radius: 12px; color: var(--text); padding: 10px 14px; }
.add-local input:focus { outline: none; border-color: var(--accent); }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.levels button { background: var(--panel2); border: 1.5px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 4px; cursor: pointer; font-size: 13px; line-height: 1.2; }
.levels button b { display: block; font-size: 18px; }
.levels button.on { border-color: var(--accent); background: #12332d; }
.solo-level { margin: 14px 0 4px; }

/* проверка ввода */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.tile { background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 8px; transition: border-color 0.2s, background 0.2s, transform 0.1s; }
.tile .nm { font-size: 24px; font-weight: 850; display: flex; align-items: center; gap: 10px; }
.tile .nm i { width: 18px; height: 18px; border-radius: 50%; }
.tile .st { font-size: 18px; color: var(--muted); }
.tile.ok { border-color: var(--good); background: #12301f; }
.tile.ok .st { color: var(--good); font-weight: 800; }
.tile.flash { transform: scale(1.03); }
.tile.off { opacity: 0.55; }

/* правило уровня */
.brief { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr); gap: 22px; max-width: 1300px; margin: 0 auto; }
.rule { font-size: 21px; color: #dbe6ee; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips span { background: #12332d; color: var(--accent); border: 1px solid #1f5a4d; border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 14px; }
.chips span.new { background: var(--accent); color: var(--accent-ink); }
.stages { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.stages li { background: var(--panel2); border-radius: 10px; padding: 7px 12px; font-size: 15px; }
.stages li b { color: var(--accent); margin-right: 8px; }
.goal { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.goal div { background: var(--panel2); border-radius: 12px; padding: 10px 14px; border: 1px solid var(--line); }
.goal div b { display: block; font-size: 24px; }
.goal div span { color: var(--muted); font-size: 13px; }
.ready { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; color: var(--muted); align-items: center; }
.ready span { padding: 4px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.ready span.on { color: var(--good); border-color: var(--good); }
.brief-demo canvas { width: 100%; aspect-ratio: 1.05; display: block; border-radius: 14px; margin-top: 10px; }

/* игра */
.screen.play { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.hud { flex: none; display: flex; align-items: center; gap: 22px; padding: 8px 18px; background: rgba(8, 12, 17, 0.95); border-bottom: 1px solid var(--line); }
.hud-level { display: flex; align-items: baseline; gap: 10px; min-width: 210px; }
.hud-level b { font-size: 30px; color: var(--accent); }
.hud-level span { font-size: 18px; font-weight: 750; }
.hud-time { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 70px; text-align: center; }
.hud-time.low { color: var(--warn); }
.hud-team { flex: 1; min-width: 160px; }
.bar { height: 14px; border-radius: 999px; background: #22313d; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22b866, #7dffa8); transition: width 0.25s; }
.hud-nums { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-top: 3px; }
.hud-nums span:last-child { color: var(--gold); }
.hud-err { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.pips { display: flex; gap: 4px; flex-wrap: wrap; max-width: 220px; }
.pips i { width: 13px; height: 13px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px rgba(255, 91, 91, 0.25); }
.pips i.used { background: #2a3640; box-shadow: none; }
.hud-fx { display: flex; gap: 6px; flex-wrap: wrap; max-width: 330px; }
.hud-fx span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #12332d; color: var(--accent); border: 1px solid #1f5a4d; }
.warn-banner { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 6; background: var(--warn); color: #2b1800; font-weight: 850; font-size: 20px; padding: 10px 22px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
.fields { flex: 1; min-height: 0; display: grid; gap: 4px; background: #05080b; }
.fields.n1 { grid-template-columns: 1fr; }
.fields.n2 { grid-template-columns: 1fr 1fr; }
.fields.n3, .fields.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.field { position: relative; min-width: 0; min-height: 0; }
.field canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.field.team { display: flex; align-items: center; justify-content: center; background: var(--panel); flex-direction: column; gap: 8px; padding: 20px; text-align: center; }
.field.team b { font-size: 40px; color: var(--accent); }
.overlay { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(5, 9, 13, 0.55); }
.count { font-size: clamp(90px, 16vw, 200px); font-weight: 900; color: #fff; text-shadow: 0 6px 40px rgba(0, 0, 0, 0.6); }
.count-sub { font-size: 24px; font-weight: 750; }
.pause-card { max-width: 560px; text-align: center; }

/* итоги */
.result { max-width: 900px; margin: 0 auto; }
.result h1.good { color: var(--good); }
.result h1.bad { color: var(--warn); }
.board { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 18px; }
.board th { text-align: right; color: var(--muted); font-weight: 650; font-size: 14px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.board th:first-child, .board td:first-child { text-align: left; }
.board td { text-align: right; padding: 10px; border-bottom: 1px solid #22313d; font-variant-numeric: tabular-nums; }
.board td i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.board tr.team td { font-weight: 850; color: var(--accent); border-bottom: 0; }

/* модальные окна */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(3, 6, 9, 0.7); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; }
.modal-x { position: absolute; right: 12px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 30px; cursor: pointer; }
.modal-box.bind { text-align: center; max-width: 520px; cursor: crosshair; }
.bind-pulse { font-size: 22px; font-weight: 800; color: var(--accent); margin: 20px 0; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.modal-box h3 { margin: 18px 0 6px; color: var(--accent); }
.modal-box ul { padding-left: 20px; }
.modal-box li { margin: 4px 0; }
.set-row { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.set-row input[type='range'] { flex: 1; accent-color: var(--accent); }
.set-row label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.set-row input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--accent); }
.light-preview { width: 100%; height: 200px; border-radius: 12px; display: block; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: #22313d; color: var(--text); padding: 12px 20px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 40; border: 1px solid var(--line); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .menu, .lobby-grid, .brief { grid-template-columns: 1fr; }
  .steps { display: none; }
  .hud { flex-wrap: wrap; gap: 10px; }
  .hud-fx { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bind-pulse { animation: none; }
}
