/* ───────── Theme: swap these to reskin everything ───────── */
:root {
  --bg: #0B1430;
  --bg-2: #13204A;
  --panel: #18295C;
  --panel-2: #213572;
  --line: rgba(255, 255, 255, 0.12);
  --text: #F7F3E8;
  --muted: #A9B4D6;
  --gold: #FFB703;
  --gold-2: #FFD166;
  --coral: #FF6B6B;
  --teal: #2EC4B6;
  --violet: #A78BFA;
  --good: #2EC4B6;
  --bad: #FF6B6B;
  --font-display: "Fredoka", "Avenir Next Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 15% -10%, #22357a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #3a1f5c 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: .01em; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.85) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.anim { animation: rise .5s var(--ease) both; }
.pop { animation: pop .45s var(--ease) both; }

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 999px; padding: 16px 28px;
  font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: .02em;
  background: var(--gold); color: #1b1300; box-shadow: 0 6px 0 #b98200, var(--shadow);
  transition: transform .12s var(--ease), box-shadow .12s, opacity .2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b98200; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.coral { background: var(--coral); color: #2a0606; box-shadow: 0 6px 0 #b54141, var(--shadow); }
.btn.teal { background: var(--teal); color: #032422; box-shadow: 0 6px 0 #1b8c82, var(--shadow); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn.block { width: 100%; }
.btn.small { padding: 10px 18px; font-size: .95rem; }

/* toast + connection */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0;
  background: var(--coral); color: #2a0606; font-weight: 800; padding: 14px 22px; border-radius: 16px; max-width: 92vw; text-align: center;
  transition: all .3s var(--ease); z-index: 50; box-shadow: var(--shadow); pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.ok { background: var(--teal); color: #032422; }
.conn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: #000a; padding: 8px 16px; border-radius: 999px; font-weight: 800; z-index: 60; font-size: .9rem; }

/* avatars */
.avatar { --c: var(--gold); width: 56px; height: 56px; border-radius: 50%; background: var(--c); color: #111; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; flex: none; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18); }
.avatar.sm { width: 34px; height: 34px; font-size: .95rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2.6rem; }
.avatar.off { opacity: .35; filter: grayscale(.6); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--panel); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ───────── Landing ───────── */
.landing { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 20px 40px; gap: 26px; }
.logo { text-align: center; }
.logo h1 { font-size: clamp(2.4rem, 8vw, 4.6rem); line-height: .95; }
.logo h1 span { color: var(--gold); }
.logo p { color: var(--muted); font-weight: 700; margin: 10px 0 0; }
.card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); width: min(440px, 100%); }
.card h2 { font-size: 1.5rem; margin-bottom: 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 800; color: var(--muted); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.input { width: 100%; padding: 16px 18px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: #0a1229; font-size: 1.3rem; font-weight: 800; outline: none; transition: border-color .2s; }
.input:focus { border-color: var(--gold); }
.input.code { text-transform: uppercase; letter-spacing: .4em; font-family: var(--font-display); font-size: 2rem; text-align: center; }
textarea.input { resize: none; min-height: 110px; font-size: 1.25rem; line-height: 1.35; }
.or { color: var(--muted); font-weight: 800; letter-spacing: .1em; }
.rejoin { margin-bottom: 14px; }

/* ───────── TV ───────── */
.tv { min-height: 100vh; padding: clamp(18px, 3vw, 44px) clamp(20px, 4vw, 64px) 110px; display: flex; flex-direction: column; }
.tv-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 2vh; }
.tag { display: inline-block; font-family: var(--font-display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: clamp(.9rem, 1.5vw, 1.3rem);
  padding: 8px 18px; border-radius: 999px; background: var(--panel-2); color: var(--gold-2); }
.tag.warm { background: rgba(46,196,182,.18); color: var(--teal); }
.tag.final { background: rgba(255,107,107,.18); color: var(--coral); }
.roomcode-mini { font-family: var(--font-display); color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.4rem); }
.roomcode-mini b { color: var(--text); letter-spacing: .15em; }
.tv-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4vh; }
.prompt { font-family: var(--font-display); font-weight: 600; font-size: clamp(2rem, 4.6vw, 4.4rem); line-height: 1.1; max-width: 22ch; text-wrap: balance; }
.prompt.long { font-size: clamp(1.8rem, 3.8vw, 3.6rem); max-width: 26ch; }
.sub { font-size: clamp(1.1rem, 2vw, 1.7rem); color: var(--muted); font-weight: 700; }
.counter { font-family: var(--font-display); color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.4rem); }

.lobby { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(20px, 3vw, 48px); flex: 1; align-items: start; }
.lobby-left { display: flex; flex-direction: column; gap: 3vh; align-items: center; text-align: center; padding-top: 2vh; }
.join-at { font-size: clamp(1.2rem, 2.2vw, 2rem); font-weight: 800; color: var(--muted); }
.join-at b { color: var(--text); }
.bigcode { font-family: var(--font-display); font-weight: 700; font-size: clamp(5rem, 14vw, 12rem); letter-spacing: .12em; line-height: 1; color: var(--gold);
  text-shadow: 0 8px 0 rgba(0,0,0,.25); padding-left: .12em; }
.players-grid { display: flex; flex-wrap: wrap; gap: 18px 22px; justify-content: center; max-width: 900px; }
.pcard { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 110px; animation: pop .45s var(--ease) both; }
.pcard .nm { font-weight: 800; font-size: 1.15rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; }
.empty-seat { width: 96px; height: 96px; border-radius: 50%; border: 3px dashed var(--line); }
.host-panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.host-panel h3 { font-size: 1.3rem; margin-bottom: 12px; }
.toggle { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); margin-bottom: 8px; cursor: pointer; }
.toggle input { width: 24px; height: 24px; accent-color: var(--gold); }
.toggle .t1 { font-weight: 800; font-size: 1.1rem; }
.toggle .t2 { color: var(--muted); font-size: .85rem; font-weight: 700; }
.seg { display: flex; gap: 8px; margin: 8px 0 16px; }
.seg label { flex: 1; text-align: center; padding: 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); cursor: pointer; font-weight: 800; border: 2px solid transparent; }
.seg input { display: none; }
.seg label.on { border-color: var(--gold); color: var(--gold-2); }
details.custom { margin: 10px 0 18px; background: rgba(255,255,255,.04); border-radius: var(--radius-sm); padding: 12px 14px; }
details.custom summary { cursor: pointer; font-weight: 800; }
.custom-row { display: flex; gap: 8px; margin-top: 10px; }
.custom-row .input { font-size: 1rem; padding: 10px 12px; }
.custom-row select { background: #0a1229; border: 2px solid var(--line); border-radius: 10px; color: var(--text); padding: 0 8px; font-weight: 800; }
.custom-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 160px; overflow: auto; }
.custom-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.custom-list button { background: none; border: 0; color: var(--coral); cursor: pointer; font-weight: 800; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 700; margin-top: 10px; text-align: center; }

.hostbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(20px, 4vw, 64px); background: linear-gradient(0deg, rgba(5,10,28,.95), rgba(5,10,28,.6)); backdrop-filter: blur(6px); z-index: 20; }
.hostbar .left { display: flex; align-items: center; gap: 14px; color: var(--muted); font-weight: 800; }
.timer { --p: 1; width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.8rem;
  background: conic-gradient(var(--gold) calc(var(--p) * 360deg), rgba(255,255,255,.1) 0); position: relative; }
.timer::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg); }
.timer span { position: relative; }
.timer.low { background: conic-gradient(var(--coral) calc(var(--p) * 360deg), rgba(255,255,255,.1) 0); animation: pulse 1s infinite; }
.waiting-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.waiting-row .w { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 800; font-size: .95rem; transition: all .3s; }
.waiting-row .w.done .avatar { box-shadow: 0 0 0 4px var(--teal); }
.waiting-row .w.done::after { content: "✓"; color: var(--teal); font-weight: 900; }
.waiting-row .w.todo { opacity: .45; }

.choices-tv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; width: min(1300px, 100%); }
.choice-tv { background: var(--panel); border-radius: var(--radius); padding: 26px; font-family: var(--font-display); font-size: clamp(1.4rem, 2.6vw, 2.4rem); font-weight: 600;
  border: 3px solid transparent; position: relative; overflow: hidden; animation: pop .45s var(--ease) both; }
.choice-tv .bar { position: absolute; left: 0; bottom: 0; height: 8px; background: var(--muted); transition: width 1s var(--ease); }
.choice-tv.win { border-color: var(--gold); background: linear-gradient(180deg, #3a3210, var(--panel)); }
.choice-tv.win .bar { background: var(--gold); }
.choice-tv .cnt { display: block; font-size: .7em; color: var(--muted); margin-top: 8px; }
.choice-tv .who { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.badge { display: inline-block; background: var(--gold); color: #1b1300; border-radius: 999px; padding: 4px 14px; font-size: .55em; font-weight: 700; margin-top: 10px; }
.badge.teal { background: var(--teal); color: #032422; }
.badge.coral { background: var(--coral); color: #2a0606; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(14px, 2.5vw, 36px); width: min(1100px, 100%); }
.step { flex: 1 1 0; min-width: min-content; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: rise .7s var(--ease) both; }
.step .names { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 10px 18px; }
.step .names .pn { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.step .names.tie .n { font-size: clamp(1.1rem, 1.8vw, 1.6rem); }
.step .names .n { font-family: var(--font-display); font-size: clamp(1.3rem, 2.3vw, 2.1rem); font-weight: 600; }
.step .block { width: 100%; border-radius: 18px 18px 6px 6px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 14px;
  font-family: var(--font-display); font-weight: 700; color: #111; }
.step .block .pl { font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1; }
.step .block .vc { font-size: clamp(.9rem, 1.4vw, 1.2rem); opacity: .8; }
.step.p1 .block { height: 26vh; background: var(--gold); }
.step.p2 .block { height: 19vh; background: #CFD8EA; }
.step.p3 .block { height: 13vh; background: #E3A26F; }
.step.p1 { animation-delay: .9s; } .step.p2 { animation-delay: .45s; } .step.p3 { animation-delay: 0s; }

.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: clamp(16px, 3vw, 40px); align-items: stretch; width: min(1300px, 100%); }
.vs .mid { align-self: center; font-family: var(--font-display); font-size: clamp(2rem, 4vw, 3.4rem); color: var(--coral); font-weight: 700; }
.quip { background: #F7F3E8; color: #13204A; border-radius: var(--radius); padding: clamp(20px, 3vw, 40px); font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.6rem, 3.2vw, 3rem); display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 26vh; animation: pop .5s var(--ease) both; box-shadow: var(--shadow); }
.quip:nth-child(3) { animation-delay: .25s; }
.quip.none { background: var(--panel); color: var(--muted); font-style: italic; }
.quip.win { box-shadow: 0 0 0 6px var(--gold), var(--shadow); }
.quip .meta { font-family: var(--font-body); font-size: clamp(1rem, 1.5vw, 1.3rem); display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; color: #13204A; }
.quip .pts { font-size: clamp(1.4rem, 2.4vw, 2.2rem); color: #b46d00; }
.quip .who { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

.bluff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; width: min(1400px, 100%); }
.bopt { background: var(--panel); border-radius: var(--radius-sm); padding: 20px; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.3rem, 2.2vw, 2rem);
  animation: pop .45s var(--ease) both; text-transform: uppercase; letter-spacing: .02em; }
.bopt.truth { background: linear-gradient(180deg, #0f4c47, var(--panel)); box-shadow: 0 0 0 5px var(--teal); }
.bopt .by { font-family: var(--font-body); text-transform: none; font-size: .6em; color: var(--muted); margin-top: 8px; font-weight: 800; }
.bopt .by b { color: var(--text); }
.bopt .who { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; justify-content: center; }

.board { width: min(900px, 100%); display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 56px 64px 1fr auto; align-items: center; gap: 16px; background: var(--panel); border-radius: var(--radius-sm); padding: 12px 20px;
  font-family: var(--font-display); font-size: clamp(1.2rem, 2vw, 1.8rem); font-weight: 600; animation: rise .5s var(--ease) both; text-align: left; }
.row .rk { color: var(--muted); }
.row .sc { color: var(--gold-2); }
.row .dl { color: var(--teal); font-size: .7em; margin-left: 10px; }
.row.first { background: linear-gradient(90deg, #4a3a08, var(--panel)); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ───────── Phone ───────── */
.phone { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.ph-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 14px; }
.ph-top .me { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; }
.ph-top .score { font-family: var(--font-display); color: var(--gold-2); font-size: 1.2rem; }
.banner { text-align: center; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--panel); font-weight: 800; margin-bottom: 14px; }
.banner.ok { background: rgba(46,196,182,.16); color: var(--teal); }
.banner.tv { background: rgba(255,183,3,.14); color: var(--gold-2); }
.ph-main { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.ph-prompt { font-family: var(--font-display); font-size: 1.55rem; line-height: 1.2; font-weight: 600; text-align: center; padding: 8px 4px; }
.ph-label { text-align: center; }
.tap { appearance: none; border: 2px solid var(--line); background: var(--panel); border-radius: var(--radius-sm); padding: 18px; min-height: 64px; width: 100%;
  font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: transform .1s, border-color .2s, background .2s; text-align: left; }
.tap:active { transform: scale(.98); }
.tap.sel { border-color: var(--gold); background: #3a3210; }
.tap .dot { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.tap.caps { text-transform: uppercase; letter-spacing: .02em; }
.tap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tap-grid .tap { flex-direction: column; justify-content: center; text-align: center; gap: 8px; }
.charcount { text-align: right; color: var(--muted); font-size: .85rem; font-weight: 700; margin-top: -8px; }
.big-emoji { font-size: 4rem; text-align: center; }
.ph-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.ph-center h2 { font-size: 1.8rem; }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; }
  .vs { grid-template-columns: 1fr; }
  .vs .mid { justify-self: center; }
}
