:root {
  --bg: #16151a;
  --bg2: #1f1d24;
  --card: #26232c;
  --line: #3a3642;
  --ink: #f3ece2;
  --muted: #a49a8e;
  --orange: #f26a21;
  --orange2: #ff8a45;
  --tape: #f2c230;
  --pink: #ff2d8a;
  --red: #e2554a;
  --green: #5cc27a;
  --display: 'Archivo Black', 'Arial Black', Impact, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a2530 0%, transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 4px),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.kicker { font-size: 11px; letter-spacing: 0.18em; color: var(--muted); font-weight: 700; }

.tape { height: 30px; background: var(--tape); color: #111; overflow: hidden; white-space: nowrap; font-weight: 700; font-size: 13px; letter-spacing: 0.12em; display: flex; align-items: center; border-bottom: 3px solid #111; }
.tape span { display: inline-block; padding-left: 100%; animation: tape 40s linear infinite; }
@keyframes tape { to { transform: translateX(-100%); } }
body.in-game .tape { display: none; }

.screen { display: none; min-height: calc(100vh - 30px); }
.screen.active { display: block; }
body.in-game .screen.active { min-height: 100vh; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }

.btn { background: #34303b; border: 1px solid #4a4553; border-radius: 8px; padding: 10px 16px; cursor: pointer; font-weight: 700; transition: transform .08s, background .15s; }
.btn:hover { background: #403b48; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--orange); border-color: #ff9a5e; color: #1a0d05; }
.btn.primary:hover { background: var(--orange2); }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 20px; font-size: 17px; font-family: var(--display); letter-spacing: .02em; }
.btn.small { padding: 7px 11px; font-size: 13px; }
.link { background: none; border: none; color: var(--orange2); cursor: pointer; text-decoration: underline; padding: 0 4px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
input, select { background: #1a181e; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
input:focus, select:focus { border-color: var(--orange); }
input[type=range] { padding: 0; accent-color: var(--orange); }

/* MENU */
.menu-wrap { max-width: 980px; margin: 0 auto; padding: 48px 20px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
.logo { grid-column: 1 / -1; }
.logo h1 { font-family: var(--display); font-size: clamp(52px, 9vw, 104px); line-height: .9; margin: 8px 0 12px; letter-spacing: -0.02em; }
.logo h1 span { color: var(--orange); -webkit-text-stroke: 0; text-shadow: 6px 6px 0 #000; }
.logo-kicker { display: inline-block; background: #111; border: 2px solid var(--tape); color: var(--tape); padding: 4px 10px; font-weight: 700; font-size: 12px; letter-spacing: .15em; }
.logo-sub { color: var(--muted); max-width: 520px; font-size: 16px; }
.menu-card { display: flex; flex-direction: column; gap: 14px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: .3em; font-weight: 700; }
.how h3 { margin-top: 0; font-family: var(--display); font-weight: 400; }
.how ol { padding-left: 20px; margin: 0; display: grid; gap: 8px; color: #d9d0c4; line-height: 1.45; }
.msg { min-height: 1.2em; margin: 0; color: var(--red); font-size: 13px; }

/* LOBBY */
.lobby-wrap { max-width: 920px; margin: 0 auto; padding: 40px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.lobby-wrap h3 { font-family: var(--display); font-weight: 400; }
.room-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.room-code { font-family: var(--display); font-size: 54px; letter-spacing: .12em; color: var(--tape); }
.players { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.players li { display: flex; justify-content: space-between; align-items: center; background: #1c1a20; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.players .tag { font-size: 11px; padding: 3px 7px; border-radius: 4px; background: #34303b; color: var(--muted); font-weight: 700; }
.players .tag.host { background: var(--tape); color: #111; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lobby-actions { display: flex; gap: 10px; margin: 16px 0 10px; flex-wrap: wrap; }
.lobby-actions .btn.big { flex: 1; }

/* GAME */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 16px; background: #111014; border-bottom: 3px solid var(--tape); }
.tb-left, .tb-right { display: flex; gap: 10px; align-items: center; }
.tb-right { justify-content: flex-end; }
.round-chip { font-family: var(--display); font-size: 15px; letter-spacing: .04em; }
.role-chip { font-weight: 700; font-size: 12px; letter-spacing: .14em; padding: 5px 10px; border-radius: 4px; background: var(--orange); color: #111; }
.role-chip.describer { background: var(--pink); color: #fff; }
.timer { min-width: 190px; text-align: center; }
#timerText { font-family: var(--display); font-size: 26px; }
.timer-bar { height: 5px; background: #2a2730; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--tape); transition: width .25s linear; }
.timer.low #timerText { color: var(--red); animation: blink .6s steps(2) infinite; }
.timer.low .timer-bar i { background: var(--red); }
@keyframes blink { 50% { opacity: .45; } }
.team-score b { font-family: var(--display); font-size: 20px; color: var(--tape); margin-left: 6px; }

.game-body { display: grid; grid-template-columns: 220px minmax(0, 1fr) 260px; gap: 14px; padding: 14px; height: calc(100vh - 66px); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.tools { display: flex; flex-direction: column; gap: 14px; }
.tool-group { display: flex; gap: 6px; }
.tool { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: #1c1a20; border: 2px solid var(--line); border-radius: 8px; padding: 8px 4px; cursor: pointer; font-size: 20px; }
.tool span { font-size: 11px; font-weight: 700; color: var(--muted); }
.tool.active { border-color: var(--orange); background: #2e2219; }
.tool.active span { color: var(--orange2); }
.sizes { display: flex; gap: 6px; }
.size { flex: 1; height: 40px; border-radius: 8px; border: 2px solid var(--line); background: #1c1a20; cursor: pointer; display: grid; place-items: center; }
.size i { display: block; border-radius: 50%; background: var(--ink); }
.size.active { border-color: var(--orange); }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.swatch { aspect-ratio: 1; border-radius: 8px; border: 2px solid rgba(255,255,255,.15); cursor: pointer; }
.swatch.active { outline: 3px solid var(--orange); outline-offset: 1px; }

.stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.board { position: relative; height: 100%; max-height: 100%; aspect-ratio: 600 / 720; max-width: 100%; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 3px #000, 0 18px 50px rgba(0,0,0,.6); }
.board .layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.board .cur { cursor: none; }
.board.readonly .cur { cursor: default; }
.hint-toast { position: absolute; top: 24px; left: 50%; transform: translateX(-50%) scale(.8); background: var(--pink); color: #fff; font-family: var(--display); font-size: 30px; padding: 10px 22px; border-radius: 12px; box-shadow: 0 8px 0 #8a1149; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; white-space: nowrap; }
.hint-toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
.stage-banner { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); background: rgba(17,16,20,.92); border: 2px solid var(--tape); padding: 10px 18px; border-radius: 10px; font-weight: 700; text-align: center; max-width: 90%; }
.stage-banner .btn { margin-top: 8px; }

.dossier { background: #efe3cf; color: #221d18; border-radius: 6px; padding: 12px; box-shadow: inset 0 0 0 2px #cdbb9e; }
.dossier .kicker { color: #8b6f4c; }
.dossier-name { font-family: var(--display); font-size: 17px; margin: 4px 0 8px; line-height: 1.15; }
.dossier-row { display: flex; justify-content: space-between; font-size: 12.5px; border-top: 1px dashed #bda888; padding-top: 5px; margin-top: 5px; gap: 8px; }
.dossier-row b { text-align: right; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.hints { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hints .btn { padding: 8px 6px; font-size: 13px; }

.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding-right: 4px; }
.chat .line { font-size: 13px; line-height: 1.35; word-wrap: break-word; }
.chat .line b { color: var(--orange2); }
.chat .line.me b { color: var(--tape); }
.chat .line.sys { color: var(--muted); font-style: italic; }
.chat .line.hint { color: var(--pink); font-weight: 700; }
.chat-form input { width: 100%; }
.voice-status { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: #1c1a20; border: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.voice-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; transition: box-shadow .08s, background .1s; }
.voice-status .dot.on { background: var(--green); }
.voice-status .dot.muted { background: var(--red); }
.voice-btn.on { background: #1f3a29; border-color: var(--green); }
.voice-btn.muted { background: #3d1d1d; border-color: var(--red); }

/* REVEAL */
.overlay { position: fixed; inset: 0; background: rgba(8,7,10,.82); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.reveal-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; width: min(860px, 100%); max-height: 96vh; overflow: auto; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.reveal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.reveal-head h2 { font-family: var(--display); font-weight: 400; margin: 4px 0; font-size: 26px; }
.score-big { font-family: var(--display); font-size: 64px; color: var(--tape); line-height: 1; }
.score-big small { font-size: 20px; color: var(--muted); }
.verdict { margin: 6px 0 14px; }
.verdict b { color: var(--orange2); font-size: 18px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare figure { margin: 0; }
.compare figcaption { text-align: center; margin-top: 6px; font-weight: 700; font-size: 13px; color: var(--muted); }
.cmp canvas { width: 100%; max-height: 52vh; object-fit: contain; height: auto; display: block; border-radius: 6px; box-shadow: 0 0 0 3px #000; }
.breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 18px; margin: 16px 0; }
.bd-row { font-size: 12.5px; }
.bd-row .bar { height: 7px; background: #1c1a20; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bd-row .bar i { display: block; height: 100%; background: var(--orange); }
.reveal-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* FINAL */
.final-wrap { max-width: 1100px; margin: 0 auto; padding: 40px 20px; text-align: center; }
.final-title { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 7vw, 72px); margin: 8px 0; color: var(--tape); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 28px 0; text-align: left; }
.g-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.g-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.g-pair canvas, .g-pair img { width: 100%; display: block; border-radius: 4px; }
.g-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; gap: 6px; }
.g-meta b { color: var(--tape); font-family: var(--display); font-weight: 400; font-size: 18px; }
.final-actions { display: flex; gap: 12px; justify-content: center; }

.modal-card { max-width: 380px; text-align: center; }

@media (max-width: 1000px) {
  .menu-wrap, .lobby-wrap { grid-template-columns: 1fr; }
  .game-body { grid-template-columns: 1fr; height: auto; }
  .stage { height: 78vh; order: -1; }
  .panel.right { max-height: 340px; }
  .topbar { grid-template-columns: 1fr auto; }
  .tb-right { grid-column: 1 / -1; justify-content: space-between; }
  .breakdown { grid-template-columns: 1fr 1fr; }
}
