:root {
  --bg: #0d0b1a;
  --bg2: #17142b;
  --card: #211d3b;
  --card2: #2b2650;
  --line: #3a3466;
  --text: #f5f3ff;
  --muted: #a49fc8;
  --accent: #ffd23f;
  --good: #3ddc84;
  --bad: #ff5470;
  --warn: #ffb020;
  --a: #ff5470; --b: #3d9bff; --c: #ffc93c; --d: #3ddc84;
  --radius: 18px;
  font-family: 'Fredoka', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { background: radial-gradient(1200px 700px at 10% -10%, #2a1f5c 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #3b1342 0%, transparent 60%), var(--bg); background-attachment: fixed; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 14px; padding: 12px 18px; background: var(--card2); font-weight: 600; min-height: 48px; transition: transform .08s, filter .15s, background .15s; }
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: var(--accent); color: #1b1300; }
button.good { background: var(--good); color: #032611; }
button.bad { background: var(--bad); color: #2b0009; }
button.ghost { background: transparent; border: 2px solid var(--line); }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
input, select, textarea { background: var(--bg2); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.1; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.center { text-align: center; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--card2); font-size: .9rem; font-weight: 600; }
.tag-good { background: color-mix(in srgb, var(--good) 25%, transparent); color: var(--good); }
.tag-bad { background: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.tag-warn { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.accent { color: var(--game, var(--accent)); }
.hidden { display: none !important; }

/* ---------- Landing ---------- */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.landing h1 { font-size: clamp(2.6rem, 8vw, 5rem); }
.landing .big { font-size: 1.4rem; padding: 18px 30px; min-width: 240px; }
.logo { font-size: 4rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }

/* ---------- Host (TV) ---------- */
.host { min-height: 100vh; display: flex; flex-direction: column; font-size: clamp(16px, 1.25vw, 26px); }
.host-bar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line); }
.host-bar .code { font-size: 1.6em; font-weight: 800; letter-spacing: .12em; color: var(--accent); }
.host-main { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.host-strip { display: flex; gap: 10px; padding: 10px 24px; flex-wrap: wrap; border-top: 1px solid var(--line); background: rgba(0,0,0,.2); }
.lobby-grid { display: grid; grid-template-columns: minmax(300px, 26%) 1fr; gap: 24px; align-items: start; }
.join-panel { text-align: center; position: sticky; top: 16px; }
.join-panel .code-big { font-size: 4.2em; font-weight: 800; letter-spacing: .14em; color: var(--accent); line-height: 1; margin: .1em 0 .2em; }
.join-panel img { width: 100%; max-width: 260px; border-radius: 16px; background: #fff; padding: 8px; }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; text-align: left; }
.player-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--card2); border-radius: 14px; font-weight: 600; position: relative; animation: pop .35s; }
.player-chip .av { font-size: 1.5em; }
.player-chip.off { opacity: .45; }
.player-chip .x { margin-left: auto; min-height: 28px; padding: 0 8px; background: transparent; color: var(--muted); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--card2); border-radius: 999px; padding: 6px 14px; min-height: 40px; font-weight: 600; }
.chip.on { background: var(--accent); color: #1b1300; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lib-card { text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-height: 150px; position: relative; overflow: hidden; }
.lib-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--game); }
.lib-card.sel { border-color: var(--game); box-shadow: 0 0 0 3px color-mix(in srgb, var(--game) 35%, transparent); }
.lib-card.na { opacity: .4; }
.lib-card .t { font-weight: 700; font-size: 1.1em; }
.lib-card .b { color: var(--muted); font-size: .9em; flex: 1; }
.keys { letter-spacing: -2px; }
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9em; }
.settings label.tog { flex-direction: row; align-items: center; }
.settings input[type=checkbox] { width: 28px; min-height: 28px; height: 28px; accent-color: var(--accent); }
.game-head { display: flex; align-items: center; gap: 16px; }
.game-head .emoji { font-size: 2.4em; }
.game-head h1 { font-size: 2.2em; margin: 0; color: var(--game); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.timer.big { font-size: 3em; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
.timer.paused::after { content: ' ⏸'; }
@keyframes pulse { 50% { opacity: .55; } }
.bar { height: 14px; background: var(--card2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--game, var(--accent)); transition: width .25s linear; }
.huge { font-size: 4em; font-weight: 800; line-height: 1.05; }
.mega { font-size: 9em; font-weight: 800; line-height: 1; color: var(--game); text-shadow: 0 10px 40px color-mix(in srgb, var(--game) 50%, transparent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.answers4 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ans { border-radius: var(--radius); padding: 22px; font-size: 1.6em; font-weight: 700; display: flex; gap: 16px; align-items: center; color: #10101a; transition: opacity .3s, transform .3s; }
.ans .l { font-size: 1.2em; width: 1.6em; height: 1.6em; display: grid; place-items: center; background: rgba(0,0,0,.18); border-radius: 12px; color: #fff; }
.ans.a, .btn-a { background: var(--a); } .ans.b, .btn-b { background: var(--b); } .ans.c, .btn-c { background: var(--c); } .ans.d, .btn-d { background: var(--d); }
.ans.dim { opacity: .25; transform: scale(.97); }
.ans.win { outline: 6px solid #fff; transform: scale(1.02); }
.board { display: flex; flex-direction: column; gap: 10px; }
.board .r { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--card); border-radius: 14px; font-size: 1.25em; font-weight: 600; animation: slideIn .4s backwards; }
.board .r .pos { width: 2em; color: var(--muted); }
.board .r .av { font-size: 1.4em; }
.board .r .pts { margin-left: auto; font-weight: 800; color: var(--game, var(--accent)); font-variant-numeric: tabular-nums; }
.board .r:nth-child(1) .pos { color: gold; }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }
.table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.table td, .table th { padding: 10px 14px; text-align: left; }
.table td { background: var(--card); }
.table td:first-child { border-radius: 12px 0 0 12px; } .table td:last-child { border-radius: 0 12px 12px 0; }
.suspects { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.suspect { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; border: 2px solid transparent; }
.suspect .e { font-size: 2.6em; }
.suspect.guilty { border-color: var(--bad); box-shadow: 0 0 30px color-mix(in srgb, var(--bad) 40%, transparent); }
.clue { background: #f3ead2; color: #2a2112; border-radius: 10px; padding: 16px 18px; font-family: 'Courier New', monospace; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.clue h3 { font-family: inherit; }
.locks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.lock { background: var(--card); border-radius: var(--radius); padding: 16px; border: 2px solid var(--line); }
.lock.active { border-color: var(--game); }
.lock.solved { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--card)); }
.lock.solved .ic { animation: unlock .6s; }
.lock .ic { font-size: 2em; }
@keyframes unlock { 30% { transform: scale(1.5) rotate(-12deg); } }
.toast-wrap { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--card2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-weight: 600; animation: pop .25s; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.error { background: var(--bad); color: #2b0009; }
.overlay { position: fixed; inset: 0; background: rgba(5,4,15,.8); display: grid; place-items: center; z-index: 40; font-size: 3em; font-weight: 800; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.flip { animation: flip .5s; }
@keyframes flip { from { transform: rotateY(90deg); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ---------- Phone ---------- */
.play { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; gap: 14px; -webkit-tap-highlight-color: transparent; }
.play-top { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.play-top .av { font-size: 1.8rem; }
.play-main { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.play .bigbtn { min-height: 72px; font-size: 1.3rem; width: 100%; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatars button { font-size: 1.6rem; padding: 0; min-height: 48px; background: var(--card); }
.avatars button.on { background: var(--accent); }
.abcd { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; min-height: 60vh; }
.abcd button { font-size: 3rem; font-weight: 800; color: #fff; border-radius: 22px; }
.abcd button.picked { outline: 5px solid #fff; }
.abcd.locked button:not(.picked) { opacity: .3; }
.hold { user-select: none; -webkit-user-select: none; touch-action: none; min-height: 220px; display: grid; place-items: center; text-align: center; border-radius: 24px; background: var(--card2); border: 3px dashed var(--line); font-size: 1.3rem; padding: 18px; }
.hold.on { background: var(--card); border-style: solid; border-color: var(--game); }
.word { font-size: clamp(2.2rem, 11vw, 4rem); font-weight: 800; text-align: center; line-height: 1.05; color: var(--game); word-break: break-word; }
.tabs { display: flex; gap: 8px; }
.tabs button { flex: 1; min-height: 44px; }
.tabs button.on { background: var(--game, var(--accent)); color: #111; }
.fv-field { display: flex; flex-direction: column; gap: 4px; }
.fv-field span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.vip-bar { background: color-mix(in srgb, var(--accent) 15%, var(--card)); border: 1px solid var(--accent); border-radius: 14px; padding: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.vip-bar button { flex: 1; min-height: 40px; padding: 6px 8px; font-size: .9rem; }
.list-btn { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; }
.list-btn.on { background: var(--game, var(--accent)); color: #111; }
.wait { text-align: center; padding: 30px 10px; }
.wait .e { font-size: 4rem; animation: bob 2.4s ease-in-out infinite; }

@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .join-panel { position: static; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}

/* Press-and-hold secret card */
.hold .secret { display: none; }
.hold.on .secret { display: block; }
.hold.on .cover { display: none; }
.list-btn.bigbtn { min-height: 60px; font-size: 1.15rem; }
details summary { cursor: pointer; }
