:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #dde1e7;
  --accent: #c8841a;
  --accent-ink: #fff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }

.app { display: grid; grid-template-columns: 330px 1fr; height: 100vh; }
.panel { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 18px 24px; overflow-y: auto; }
.panel h1 { font-size: 19px; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0 0 12px; }
section { border-top: 1px solid var(--line); padding: 12px 0; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #f7f8fa; color: var(--text); border-radius: 8px; padding: 7px 10px; }
button:hover { border-color: #b9c0ca; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.big { width: 100%; padding: 11px; font-size: 15px; margin: 8px 0; }

.seg { display: flex; gap: 0; margin-bottom: 8px; }
.seg button { flex: 1; border-radius: 0; margin-left: -1px; padding: 7px 4px; white-space: nowrap; }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: #1d2330; border-color: #1d2330; color: #fff; position: relative; z-index: 1; }
.seg.levels button { font-size: 12.5px; padding: 7px 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seg.small { margin: 0; }
.seg.small button { padding: 4px 10px; }

label.range { display: block; margin: 10px 0 2px; }
label.range output { font-weight: 600; }
label.range input { display: block; width: 100%; margin-top: 2px; accent-color: var(--accent); }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 8px; }
label.check { display: flex; align-items: center; gap: 6px; margin: 8px 0; cursor: pointer; }
select, .text { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.text { width: 100%; }
.seedrow { display: flex; gap: 8px; }
.seedrow .text { flex: 1; }
.two { display: flex; gap: 8px; }
.two button { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.stage { display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.toolbar label.check { margin: 0; }
#stats { color: var(--muted); font-size: 12.5px; margin-left: auto; }
#stats.warn { color: #b4471f; }
.preview { flex: 1; overflow: auto; padding: 20px; display: flex; }
.preview svg { margin: auto; background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.15); flex: none; }
.preview svg.fit { height: calc(100vh - 100px); width: auto; max-width: 100%; }
.error { margin: auto; padding: 20px 24px; background: #fff3f0; border: 1px solid #f3c2b8; border-radius: 10px; max-width: 420px; }

#printArea { display: none; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; }
  .preview svg.fit { height: auto; width: 100%; }
}

@media print {
  html, body { background: #fff; height: auto; }
  .app { display: none; }
  #printArea { display: block; }
  .print-page { overflow: hidden; page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .print-page svg { display: block; width: 100%; height: 100%; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- 3D-режим ---------- */
.play3d { width: 100%; padding: 11px; font-size: 15px; background: #1d2330; border-color: #1d2330; color: #fff; font-weight: 600; }
.g3d { position: fixed; inset: 0; z-index: 100; background: #000; user-select: none; -webkit-user-select: none; font-family: system-ui, -apple-system, sans-serif; }
.g3d-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.g3d-hud { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; }
.g3d-hud span:not(:empty) { background: rgba(0,0,0,.55); color: #fff; padding: 6px 12px; border-radius: 20px; font-size: 16px; font-variant-numeric: tabular-nums; }
.g3d-map { position: absolute; top: 12px; right: 12px; width: 220px; height: 220px; }
.g3d-cross { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,.7); pointer-events: none; }
.g3d-toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(0,0,0,.7); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 16px; opacity: 0; transition: opacity .3s; pointer-events: none; text-align: center; max-width: 90vw; }
.g3d-toast.show { opacity: 1; }
.g3d-bar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.g3d-bar button { background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 20px; padding: 7px 12px; font-size: 14px; }
.g3d-bar button.on { background: rgba(200,132,26,.85); border-color: rgba(255,255,255,.5); }
.g3d-bar kbd, .g3d-card kbd { font: 11px/1 monospace; border: 1px solid currentColor; border-radius: 4px; padding: 2px 4px; opacity: .75; }
.g3d-close { position: absolute; top: 12px; right: 244px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 50%; width: 36px; height: 36px; font-size: 16px; }
.g3d-stick { display: none; position: absolute; width: 100px; height: 100px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); pointer-events: none; }
.g3d-stick div { position: absolute; left: 30px; top: 30px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.5); }
.g3d-overlay { display: none; position: absolute; inset: 0; background: rgba(10,12,18,.55); align-items: center; justify-content: center; }
.g3d-overlay.show { display: flex; }
.g3d-card { background: #fff; color: #1d2330; border-radius: 16px; padding: 24px 28px; max-width: 440px; width: calc(100% - 32px); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.g3d-card h2 { margin: 0 0 10px; font-size: 22px; text-transform: none; letter-spacing: 0; color: inherit; }
.g3d-card p { margin: 8px 0; }
.g3d-card .small { color: #6b7280; font-size: 13px; }
.g3d-card .big-stat { font-size: 34px; font-weight: 700; margin: 6px 0; }
.g3d-card button { margin: 6px 4px 0; }
.g3d-card button.big { display: block; width: 100%; margin: 14px 0 6px; padding: 12px; font-size: 16px; }
@media (max-width: 700px) {
  .g3d-map { width: 130px; height: 130px; }
  .g3d-close { right: 150px; }
  .g3d-bar kbd { display: none; }
}

/* ---------- сетевая игра ---------- */
button.wide { width: 100%; margin-top: 8px; }
#mpOff .text { margin-bottom: 8px; }
#mpOff .seedrow { margin-top: 8px; }
.text.code { text-transform: uppercase; letter-spacing: .2em; font-weight: 600; }
.mp-room { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.mp-room b { font-size: 20px; letter-spacing: .15em; }
.mp-room button { margin-left: auto; padding: 4px 8px; font-size: 12.5px; }
.mp-players { list-style: none; padding: 0; margin: 10px 0; }
.mp-players li { padding: 4px 0; display: flex; align-items: center; gap: 6px; }
.mp-players em { color: var(--muted); font-style: normal; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; flex: none; }
.g3d-count { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 5; font-size: 120px; font-weight: 800; color: #fff; text-shadow: 0 4px 24px rgba(0,0,0,.6); pointer-events: none; }
.g3d-name { position: absolute; left: 0; top: 0; padding: 3px 9px; border-radius: 12px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; white-space: nowrap; pointer-events: none; border: 2px solid; }
.g3d-results { width: 100%; border-collapse: collapse; margin: 10px 0 4px; text-align: left; }
.g3d-results td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.g3d-results td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.g3d-results tr.me td { background: #fff6e0; font-weight: 600; }

/* ---------- страница печати ---------- */
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 8px; }
.back:hover { color: var(--accent); }
#dailyBtn { margin: 0 0 12px; }

/* ---------- главная: мега-лабиринт дня ---------- */
body.landing {
  --ink: #f4ead6; --ink-dim: #b9ad95; --gold: #f2b632; --card: rgba(255, 248, 230, .06); --line-d: rgba(255, 240, 210, .14);
  min-height: 100%; height: auto; color: var(--ink);
  background: radial-gradient(1200px 700px at 75% 10%, #3a3122 0%, transparent 60%),
              radial-gradient(900px 600px at 0% 100%, #1f2a1c 0%, transparent 60%), #15130f;
}
.landing .hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; max-width: 1180px; margin: 0 auto; padding: 64px 32px 32px; align-items: start; }
.landing .kicker { color: var(--gold); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; margin: 0 0 14px; }
.landing h1 { font-size: clamp(36px, 5.2vw, 64px); line-height: 1.04; margin: 0 0 18px; letter-spacing: -.02em; }
.landing h1 span { color: var(--gold); }
.landing .sub { color: var(--ink-dim); font-size: 17px; line-height: 1.55; max-width: 34em; margin: 0 0 26px; }
.landing .join { display: flex; gap: 10px; flex-wrap: wrap; }
.landing .join input { flex: 1 1 200px; font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-d); background: rgba(0,0,0,.35); color: var(--ink); }
.landing .join input::placeholder { color: #8d826c; }
.landing .cta { flex: 0 0 auto; font-size: 18px; font-weight: 700; padding: 14px 26px; border-radius: 12px; border: 0; color: #2a1d05; background: linear-gradient(180deg, #ffd164, #e9a520); box-shadow: 0 6px 24px rgba(242, 182, 50, .3); }
.landing .cta:hover { filter: brightness(1.06); }
.landing .cta:disabled { opacity: .6; cursor: wait; }
.landing .status { color: var(--ink-dim); font-size: 14px; min-height: 1.4em; margin: 12px 0 0; }
.landing .status code { background: rgba(0,0,0,.4); padding: 2px 6px; border-radius: 6px; color: var(--ink); }
.landing .facts { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.landing .facts li { background: var(--card); border: 1px solid var(--line-d); border-radius: 20px; padding: 6px 12px; font-size: 14px; }
.landing .hero-side { display: grid; gap: 20px; }
.landing .maze-card { margin: 0; background: #f6eedb; border-radius: 16px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); transform: rotate(-1.2deg); }
.landing .maze-card svg { display: block; width: 100%; height: auto; max-height: 46vh; }
.landing .maze-card figcaption { color: #6d5f45; font-size: 12.5px; text-align: center; margin-top: 10px; }
.landing .board-card { background: var(--card); border: 1px solid var(--line-d); border-radius: 16px; padding: 18px 20px; }
.landing .board-card h2 { color: var(--gold); margin: 0 0 10px; }
.landing .board { list-style: none; padding: 0; margin: 0; }
.landing .board li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-d); }
.landing .board li:last-child { border-bottom: 0; }
.landing .board .pl { width: 26px; text-align: center; }
.landing .board .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.landing .board .tm { font-variant-numeric: tabular-nums; font-weight: 600; }
.landing .board .empty { color: var(--ink-dim); border: 0; }
.landing .small { color: var(--ink-dim); font-size: 13px; margin: 10px 0 0; }
.landing .how { max-width: 1180px; margin: 0 auto; padding: 8px 32px 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.landing .how div { background: var(--card); border: 1px solid var(--line-d); border-radius: 14px; padding: 16px 18px; display: grid; gap: 6px; }
.landing .how span { color: var(--ink-dim); font-size: 14px; }
.landing .foot { max-width: 1180px; margin: 0 auto; padding: 16px 32px 40px; display: flex; gap: 24px; flex-wrap: wrap; }
.landing .foot a { color: var(--gold); text-decoration: none; }
.landing .foot a:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .landing .hero { grid-template-columns: 1fr; gap: 28px; padding: 32px 16px 16px; }
  .landing .how { grid-template-columns: 1fr; padding: 8px 16px 16px; }
  .landing .foot { padding: 8px 16px 32px; }
  .landing .maze-card { transform: none; }
}

/* ---------- голосовой чат ---------- */
.g3d-name.speaking { box-shadow: 0 0 0 3px rgba(120, 255, 140, .85), 0 0 16px rgba(120, 255, 140, .7); }
.g3d-hud span[data-k=mic].speaking { box-shadow: 0 0 0 3px rgba(120, 255, 140, .85); }
.g3d-vol { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 20px; padding: 4px 12px; font-size: 14px; }
.g3d-vol[hidden] { display: none; }
.g3d-vol input { width: 90px; accent-color: #f2b632; }
.g3d-vol span { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.g3d-name.sleeping { background: rgba(20, 24, 40, .7); color: #cdd3ff; font-style: italic; }

/* ---------- монстры: вспышка испуга ---------- */
.g3d-scare { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(120, 0, 0, 0) 25%, rgba(170, 0, 0, .55) 60%, rgba(60, 0, 0, .95) 100%); }
.g3d-scare.show { animation: g3d-scare .9s ease-out; }
@keyframes g3d-scare { 0% { opacity: 1; } 15% { opacity: .85; } 100% { opacity: 0; } }
