:root {
  --bg: #15102a; --bg2: #221a42; --card: #2c2357; --line: #3d3270; --text: #f4f1ff; --dim: #a79fd0;
  --accent: #ff5ea8; --accent2: #7c5cff; --good: #3ddc97; --bad: #ff6b6b; --gold: #ffd43b;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 20% -10%, #3a2470 0%, transparent 55%), radial-gradient(circle at 110% 110%, #4a1d5e 0%, transparent 50%), var(--bg);
  color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: 14px 18px; background: var(--card); font-weight: 650; transition: transform .08s, background .15s; }
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button:disabled { opacity: .45; cursor: default; }
input, textarea { width: 100%; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); outline: none; }
input:focus, textarea:focus { border-color: var(--accent2); }
.muted { color: var(--dim); }
.err { color: var(--bad); min-height: 1.4em; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

/* ---------- phone ---------- */
.phone { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 14px 16px 24px; }
.phone header { display: flex; align-items: center; gap: 10px; padding: 4px 2px 12px; }
.phone header .who { font-weight: 700; }
.phone header .score { margin-left: auto; background: var(--card); padding: 6px 12px; border-radius: 999px; font-weight: 700; }
.brand { font-size: 40px; font-weight: 900; letter-spacing: -1px; text-align: center; margin: 28px 0 4px; background: linear-gradient(135deg, var(--accent), #ffb86b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel { background: rgba(44, 35, 87, .75); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 6px; background: var(--bg2); padding: 5px; border-radius: 14px; }
.tabs button { flex: 1; background: transparent; padding: 10px; }
.tabs button.on { background: var(--card); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px 6px 12px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.chip b { cursor: pointer; color: var(--dim); font-weight: 400; }
.code-input { text-transform: uppercase; letter-spacing: 10px; text-align: center; font-size: 34px; font-weight: 800; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.screen h2 { margin: 6px 0 0; font-size: 15px; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.prompt { font-size: 22px; font-weight: 700; line-height: 1.3; }
.sub { color: var(--dim); font-size: 15px; }
.big-wait { flex: 1; display: grid; place-items: center; text-align: center; font-size: 22px; font-weight: 650; padding: 20px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choices button { text-align: left; padding: 16px; font-size: 18px; border: 2px solid var(--line); }
.feedback { background: rgba(255, 107, 107, .15); border: 1px solid var(--bad); padding: 10px 14px; border-radius: 12px; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.timer { height: 6px; background: var(--bg2); border-radius: 3px; overflow: hidden; }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--gold), var(--bad)); background-size: 300% 100%; transition: width .25s linear; }
.tier-row { background: var(--bg2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.tier-row .item { font-weight: 650; }
.tier-row .tiers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tier-row .tiers button { padding: 10px 0; font-weight: 800; }
.tier-S { --t: #ff6b6b; } .tier-A { --t: #ffa94d; } .tier-B { --t: #ffd43b; } .tier-C { --t: #69db7c; } .tier-D { --t: #4dabf7; }
.tiers button.on { background: var(--t); color: #1a1530; }
.badge { display: inline-block; min-width: 32px; text-align: center; padding: 3px 8px; border-radius: 8px; font-weight: 800; background: var(--t, var(--card)); color: #1a1530; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-list .p { display: flex; align-items: center; gap: 10px; background: var(--bg2); padding: 10px 12px; border-radius: 12px; }
.toggle { display: flex; align-items: center; gap: 10px; background: var(--bg2); padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; }
.vipbar { margin-top: auto; display: flex; justify-content: flex-end; padding-top: 16px; }
.vipbar button { font-size: 13px; padding: 8px 12px; }

/* ---------- TV ---------- */
.tv { height: 100vh; display: flex; flex-direction: column; padding: 3vh 4vw; overflow: hidden; }
.tv .top { display: flex; align-items: center; gap: 2vw; font-size: 2.2vh; color: var(--dim); }
.tv .top .code { margin-left: auto; font-weight: 800; color: var(--text); background: var(--card); padding: .6vh 1.2vw; border-radius: 1vh; letter-spacing: .3vw; }
.tv .stage { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 3vh; min-height: 0; }
.tv h1 { font-size: 9vh; margin: 0; font-weight: 900; letter-spacing: -.2vh; background: linear-gradient(135deg, var(--accent), #ffb86b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tv .kicker { font-size: 2.4vh; letter-spacing: .5vh; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.tv .q { font-size: 5vh; font-weight: 800; max-width: 80vw; line-height: 1.2; }
.tv .how { font-size: 3vh; max-width: 65vw; color: var(--dim); }
.tv .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 2vh 2vw; width: 80vw; }
.tv .opt { background: var(--card); border: .3vh solid var(--line); border-radius: 2vh; padding: 2.4vh 2vw; font-size: 3.2vh; font-weight: 700; text-align: left; display: flex; flex-direction: column; gap: 1vh; }
.tv .opt.correct { border-color: var(--good); background: rgba(61, 220, 151, .18); }
.tv .opt.dim { opacity: .5; }
.tv .opt .by { font-size: 2vh; color: var(--dim); font-weight: 600; }
.tv .who-row { display: flex; flex-wrap: wrap; gap: .8vh; }
.tv .pchip { display: inline-flex; align-items: center; gap: .6vw; padding: .6vh 1vw; border-radius: 999px; font-size: 2.1vh; font-weight: 700; background: var(--bg2); border: .25vh solid var(--c, var(--line)); }
.tv .pchip.off { opacity: .35; }
.tv .pchip.done { background: var(--c); color: #160f2c; }
.tv .bottom { display: flex; align-items: center; gap: 1vw; min-height: 6vh; }
.tv .timer { width: 30vw; height: 1.2vh; margin-left: auto; }
.tv .join { font-size: 3.4vh; }
.tv .join b { color: var(--gold); }
.tv .bigcode { font-size: 16vh; font-weight: 900; letter-spacing: 3vw; line-height: 1; }
.tv .players { display: flex; flex-wrap: wrap; gap: 1.5vh; justify-content: center; max-width: 80vw; }
.tv .players .pchip { font-size: 3vh; padding: 1vh 2vw; }
.tv .cards { display: flex; flex-wrap: wrap; gap: 2vh; justify-content: center; max-width: 90vw; }
.tv .card { background: var(--card); border: .3vh solid var(--line); border-radius: 2vh; padding: 2vh 2vw; min-width: 18vw; display: flex; flex-direction: column; gap: 1vh; font-size: 2.4vh; }
.tv .card.good { border-color: var(--good); }
.tv .card .t { font-size: 3.4vh; font-weight: 800; }
.tv .card .pts { color: var(--gold); font-weight: 800; }
.tv .board { display: flex; flex-direction: column; gap: 1.2vh; width: 60vw; }
.tv .board .r { display: flex; align-items: center; gap: 1.5vw; background: var(--card); border-radius: 1.6vh; padding: 1.4vh 2vw; font-size: 3.2vh; font-weight: 750; }
.tv .board .r .s { margin-left: auto; }
.tv .board .r .g { color: var(--good); font-size: 2.4vh; }
.tv .board .r.first { background: linear-gradient(135deg, rgba(255, 212, 59, .3), rgba(255, 94, 168, .25)); }
.tv .tiertable { display: grid; grid-template-columns: auto 8vw 8vw 4vw; gap: 1vh 2vw; font-size: 3vh; align-items: center; background: var(--card); padding: 2.5vh 3vw; border-radius: 2vh; }
.tv .tiertable .h { color: var(--dim); font-size: 2vh; text-transform: uppercase; }
.tv .tiertable .badge { font-size: 2.8vh; }
.tv .eq { display: flex; gap: .8vw; height: 14vh; align-items: flex-end; }
.tv .eq i { width: 1.6vw; background: linear-gradient(var(--accent), var(--accent2)); border-radius: .6vh; animation: eq 1s ease-in-out infinite; }
@keyframes eq { 0%, 100% { height: 20%; } 50% { height: 100%; } }
.tv .eq.paused i { animation-play-state: paused; }
.tv .answer { font-size: 8vh; font-weight: 900; }
.tv .skip { position: fixed; right: 1.5vw; bottom: 1.5vh; font-size: 1.8vh; padding: .8vh 1.2vw; opacity: .5; }
.tv .skip:hover { opacity: 1; }
.tv .settings { display: flex; flex-wrap: wrap; gap: 1vh; justify-content: center; max-width: 70vw; }
.tv .settings button { font-size: 2vh; padding: 1vh 1.5vw; border: .25vh solid var(--line); }
.tv .settings button.on { border-color: var(--accent); background: rgba(255, 94, 168, .2); }
.sound-gate { position: fixed; inset: 0; background: rgba(10, 6, 25, .85); display: grid; place-items: center; z-index: 10; }
.sound-gate button { font-size: 3vh; padding: 2vh 3vw; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Who Would Win */
.tv .vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 2vw; width: 85vw; align-items: stretch; }
.tv .vs-side { background: var(--card); border: .3vh solid var(--line); border-radius: 2vh; padding: 2.5vh 2vw; display: flex; flex-direction: column; gap: 1.2vh; align-items: center; font-size: 2.4vh; transition: opacity .3s; }
.tv .vs-side.win { border-color: var(--gold); box-shadow: 0 0 4vh rgba(255, 212, 59, .35); }
.tv .vs-side.lose { opacity: .5; }
.tv .vs-name { font-size: 5vh; font-weight: 900; }
.tv .vs-pitch { font-size: 2.8vh; font-style: italic; max-width: 36vw; }
.tv .vs-votes { font-size: 4vh; font-weight: 900; color: var(--gold); }
.tv .vs-mid { align-self: center; font-size: 6vh; font-weight: 900; color: var(--accent); }
/* Master of One */
.tv .expert { display: grid; grid-template-columns: 1fr 1fr; gap: 2vw; width: 85vw; text-align: left; }
.tv .expert > div { background: var(--card); border-radius: 2vh; padding: 2vh 2vw; }
.tv .expert .h { font-size: 1.9vh; text-transform: uppercase; color: var(--dim); letter-spacing: .3vh; margin-bottom: .8vh; }
.tv .expert .a { font-size: 2.8vh; font-weight: 600; }
.tv .score10 { font-size: 7vh; font-weight: 900; }
.phone textarea { resize: vertical; min-height: 110px; }
.phone .chip[data-s] { cursor: pointer; }

/* ---------- drag-and-drop tier list ---------- */
.tierlist { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.trow { display: flex; min-height: 78px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.trow:last-child { border-bottom: 0; }
.tlabel { width: 54px; flex: none; display: grid; place-items: center; font-size: 24px; font-weight: 900; color: #1a1530; background: var(--t); }
.tzone { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; align-content: flex-start; }
.tpool { min-height: 90px; background: rgba(44, 35, 87, .5); border: 2px dashed var(--line); border-radius: 12px; }
.dcard { width: 70px; background: var(--card); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; align-items: center;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.dcard img { width: 100%; height: 56px; object-fit: cover; pointer-events: none; background: #000; }
.dcard span { font-size: 10.5px; line-height: 1.15; padding: 3px 4px; text-align: center; font-weight: 650; overflow-wrap: anywhere; }
.dcard.noimg { min-height: 64px; justify-content: center; }
.dcard.noimg span { font-size: 12.5px; }
.dcard.dragging { opacity: .3; }
.dcard.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 94, 168, .35); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.hint { font-size: 13px; text-align: center; }

/* ---------- drag-to-rank ---------- */
.ranklist { display: flex; flex-direction: column; gap: 8px; counter-reset: rank; }
.rcard { width: auto; flex-direction: row; gap: 12px; padding: 14px 12px; align-items: center; }
.rcard span { font-size: 16px; text-align: left; flex: 1; padding: 0; }
.rcard .num { counter-increment: rank; width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--bg2); font-size: 15px; }
.rcard .num::before { content: counter(rank); }
.rcard .grip { color: var(--dim); font-style: normal; font-size: 20px; }
.rank-end { text-align: center; font-weight: 800; color: var(--dim); font-size: 14px; }

/* ---------- ready / settings ---------- */
.ready { display: flex; flex-direction: column; gap: 8px; align-items: stretch; text-align: center; }
.ready-done { padding: 12px; border-radius: 12px; background: rgba(61, 220, 151, .15); border: 1px solid var(--good); font-weight: 700; }
.toggle.small { font-size: 14px; padding: 8px 12px; }
.topic-count { margin-top: 8px; font-weight: 700; color: var(--gold); }
.topic-count.ok { color: var(--good); }
details summary { cursor: pointer; padding: 10px 12px; background: var(--bg2); border-radius: 12px; font-weight: 650; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.settings-body { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.select { margin-left: auto; padding: 8px; border-radius: 8px; background: var(--bg2); color: inherit; border: 1px solid var(--line); }

/* ---------- TV: reveals with pictures and rankings ---------- */
.tv .tiertable img { width: 4.5vh; height: 4.5vh; object-fit: cover; border-radius: .8vh; vertical-align: middle; margin-right: .8vw; }
.tv .ranktable { display: grid; grid-template-columns: 4vw 1fr 1fr 4vw; gap: 1vh 1.5vw; font-size: 2.6vh; align-items: center; background: var(--card); padding: 2.5vh 3vw; border-radius: 2vh; width: 80vw; text-align: left; }
.tv .ranktable .h { color: var(--dim); font-size: 2vh; text-transform: uppercase; }
.tv .ranktable .n { font-weight: 900; font-size: 3vh; color: var(--accent); }
.tv .ready-note { font-size: 2.2vh; color: var(--dim); }
/* long reveals: never clip off the top, shrink the expert screen a bit */
.tv .stage { justify-content: safe center; overflow-y: auto; }
.tv .expert-q { font-size: 3.6vh; }
.tv .expert .a { font-size: 2.3vh; max-height: 30vh; overflow-y: auto; }
