@import url('https://fonts.googleapis.com/css2?family=Anton&family=Inter:wght@400;600;800&family=Libre+Baskerville:wght@700&display=swap');
:root {
  --blue: #060ce9; --blue-hi: #1a2bff; --blue-lo: #040891; --night: #02052e;
  --gold: #ffd24a; --ink: #fff; --dim: #a3abeb; --ok: #4ade80; --bad: #ff6b6b;
  --display: Anton, Impact, sans-serif; --serif: 'Libre Baskerville', Georgia, serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse at top, #0a1290 0%, var(--night) 70%);
  color: var(--ink); font-family: Inter, system-ui, sans-serif;
  display: flex; flex-direction: column; align-items: center; padding: 24px 16px; min-height: 100dvh;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
h1, h2, .big { font-family: var(--display); letter-spacing: .03em; text-transform: uppercase; font-weight: 400; }
.logo-big { font: clamp(48px, 9vw, 104px) var(--display); color: var(--gold); text-shadow: 4px 4px 0 #000; letter-spacing: .02em; text-align: center; line-height: 1; }
.sub { color: var(--dim); margin-top: 10px; text-align: center; }
.conn { position: fixed; bottom: 10px; left: 14px; font-size: 12px; color: var(--dim); z-index: 50; pointer-events: none; }
.conn::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; }
.conn.ok::before { background: var(--ok); }
.chip { display: inline-block; background: var(--c); color: #000; padding: 2px 14px; border-radius: 999px; font-family: var(--display); letter-spacing: .03em; text-transform: uppercase; }

/* buttons */
.btn {
  font: 18px var(--display); letter-spacing: .05em; text-transform: uppercase; border: 0; border-radius: 10px;
  padding: 12px 22px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.45); background: #2b34c9; color: #fff;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .05s, filter .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.45); }
.btn:disabled { opacity: .35; cursor: default; transform: none; filter: none; }
.btn.go { background: var(--gold); color: #000; }
.btn.ok { background: var(--ok); color: #000; }
.btn.bad { background: #ef4444; }
.btn.ghost { background: transparent; color: var(--dim); box-shadow: inset 0 0 0 2px rgba(163,171,235,.5); }
.btn.xl { font-size: 26px; padding: 16px 40px; }
kbd { font: 600 11px Inter, sans-serif; background: rgba(0,0,0,.25); border-radius: 4px; padding: 2px 6px; letter-spacing: 0; }
.seg { border: 0; border-radius: 999px; padding: 7px 14px; background: rgba(255,255,255,.08); color: var(--dim); cursor: pointer; font-weight: 600; }
.seg.on { background: var(--gold); color: #000; }
input, textarea {
  font: 600 16px Inter, sans-serif; color: #fff; background: rgba(0,0,0,.35); border: 2px solid rgba(163,171,235,.4);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); }

/* ---------- picker ---------- */
.picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 28px; width: 100%; max-width: 760px; }
.pick {
  background: var(--c); color: #000; border-radius: 14px; padding: 26px 12px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.45);
  transition: transform .08s; display: flex; flex-direction: column; gap: 4px;
}
.pick b { font: 30px var(--display); text-transform: uppercase; letter-spacing: .03em; overflow-wrap: anywhere; }
.pick small { font-weight: 600; opacity: .75; }
.pick:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.45); }
.links { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; justify-content: center; }
.note { margin-top: 18px; background: rgba(0,0,0,.3); border: 1px solid var(--gold); color: var(--gold); padding: 10px 16px; border-radius: 10px; }
.note:empty { display: none; }

/* ---------- host + projector ---------- */
body.game { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; padding: 0; align-items: stretch; height: 100dvh; overflow: hidden; }
.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: rgba(0,0,0,.35); }
.logo { font: 28px var(--display); color: var(--gold); text-shadow: 2px 2px 0 #000; letter-spacing: .03em; }
.top .join { color: var(--dim); font-size: 15px; }
.top .join b { color: #fff; }
.tools { margin-left: auto; display: flex; gap: 8px; }
.tool { background: rgba(255,255,255,.08); border: 0; border-radius: 999px; padding: 7px 14px; color: var(--dim); cursor: pointer; font-size: 13px; font-weight: 600; }
.tool:hover { color: #fff; }
#stage { padding: 14px 18px; min-height: 0; display: flex; }
#stage > * { flex: 1; min-width: 0; }

.board {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: 1.2fr repeat(5, 1fr);
  gap: 6px; background: #000; border: 6px solid #000; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.cat, .cell {
  background: radial-gradient(ellipse at 50% 35%, var(--blue-hi) 0%, var(--blue) 55%, var(--blue-lo) 100%);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; min-height: 0;
}
.cat { margin-bottom: 4px; }
.cat span { font: clamp(13px, 1.75vw, 28px)/1.05 var(--display); text-transform: uppercase; text-shadow: 2px 2px 0 #000; letter-spacing: .03em; }
.cat.halloween span { color: #ff9a3c; }
.cat.puzzles span { color: #7ff0c8; }
.cell { border: 0; font: clamp(22px, 3.6vw, 62px) var(--display); color: var(--gold); text-shadow: 3px 3px 0 #000; transition: filter .12s, transform .12s; }
.cell:not(:disabled) { cursor: pointer; }
.cell:not(:disabled):hover { filter: brightness(1.35); transform: scale(1.03); z-index: 1; }
.cell.used { background: #03066b; color: transparent; text-shadow: none; }

.clue {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 35%, var(--blue-hi), var(--blue) 50%, var(--blue-lo));
  border: 6px solid #000; border-radius: 10px; padding: 64px 5vw 28px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: zoom .4s cubic-bezier(.2,.9,.3,1.15);
}
@keyframes zoom { from { transform: scale(.15); opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes pulse { to { transform: scale(1.08); filter: brightness(1.25); } }
.clue-head { position: absolute; top: 14px; left: 22px; right: 22px; display: flex; justify-content: space-between; gap: 12px; font: clamp(15px, 1.6vw, 24px) var(--display); color: #c9d0ff; letter-spacing: .06em; text-transform: uppercase; }
.clue-head .val { color: var(--gold); }
.clue-q { font: 700 clamp(22px, 3.3vw, 54px)/1.32 var(--serif); text-transform: uppercase; text-shadow: 3px 3px 0 #000; max-width: 1250px; overflow-wrap: anywhere; }
.clue-a { margin-top: 3vh; font: clamp(24px, 3.2vw, 50px) var(--display); color: var(--gold); text-shadow: 3px 3px 0 #000; animation: pop .3s; letter-spacing: .02em; }
.clue-status { margin-top: 3vh; min-height: 96px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.buzzin { font: clamp(30px, 4.4vw, 62px) var(--display); color: var(--gold); text-transform: uppercase; text-shadow: 3px 3px 0 #000; animation: pulse .7s infinite alternate; }
.buzzer { display: flex; align-items: center; gap: 18px; background: var(--c); color: #000; padding: 8px 10px 8px 30px; border-radius: 999px; font: clamp(26px, 3.4vw, 50px) var(--display); text-transform: uppercase; box-shadow: 0 0 60px var(--c); animation: pop .25s; }
.buzzer .count { min-width: 1.6em; background: #000; color: #fff; border-radius: 999px; padding: 0 16px; font-variant-numeric: tabular-nums; }
.bar { width: min(520px, 70%); height: 8px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.res { font: clamp(20px, 2.4vw, 36px) var(--display); text-transform: uppercase; display: flex; align-items: center; gap: 12px; animation: pop .25s; letter-spacing: .03em; }
.res.ok { color: var(--ok); }
.res.bad { color: var(--bad); }
.hint { color: var(--dim); font-size: 15px; }
.clue.dd { background: radial-gradient(circle at 50% 45%, #2b3bff, var(--blue) 40%, #02055c); }
.dd-title { font: clamp(56px, 10vw, 160px)/1 var(--display); color: var(--gold); text-shadow: 6px 6px 0 #000; text-transform: uppercase; transform: rotate(-4deg); animation: whirl .9s cubic-bezier(.2,.9,.3,1.2); }
@keyframes whirl { from { transform: rotate(-740deg) scale(.05); } }
.dd-sub { margin-top: 24px; font-size: clamp(16px, 1.8vw, 24px); color: #c9d0ff; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }

.scores { display: flex; gap: 10px; padding: 0 18px 12px; justify-content: center; }
.pod {
  flex: 1 1 0; max-width: 230px; min-width: 0; background: linear-gradient(#0b16bd, #060c86); border: 3px solid #000;
  border-top: 6px solid var(--c); border-radius: 10px; padding: 8px 10px; text-align: center; transition: transform .2s, box-shadow .2s, opacity .2s;
}
.pod.active { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--c), 0 0 44px var(--c); }
.pod.out { opacity: .4; }
.pod-name { font: 16px var(--display); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; width: 100%; background: none; border: 0; padding: 0; }
button.pod-name { cursor: pointer; }
button.pod-name:hover { text-decoration: underline; }
.pod-score { font: clamp(22px, 2.5vw, 36px) var(--display); font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); }
.pod-meta { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod.control .pod-meta { color: var(--gold); }
.live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 4px; }
.pod-tools { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.pod-tools button { border: 0; border-radius: 6px; padding: 3px 8px; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; }
.pod-tools button:hover { background: rgba(255,255,255,.22); }

.controls { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px 18px 14px; background: rgba(0,0,0,.35); flex-wrap: wrap; min-height: 66px; }
.controls:empty { display: none; }
.peek { margin-right: auto; font-size: 14px; color: var(--dim); max-width: 40%; cursor: help; outline: none; }
.peek span, .secret { color: #fff; font-weight: 700; filter: blur(7px); transition: filter .15s; }
.peek span { margin-left: 6px; }
.peek:hover span, .peek:focus span, .secret:hover { filter: none; }
.wait { color: var(--dim); }
.ddbox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--dim); }
.ddbox input { width: 120px; }

/* lobby */
.lobby { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; overflow: auto; }
.join-big { font-size: clamp(16px, 2vw, 26px); color: var(--dim); text-align: center; }
.join-big b { color: #fff; background: rgba(0,0,0,.35); padding: 2px 12px; border-radius: 8px; }
.setup { background: rgba(0,0,0,.3); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; width: min(640px, 100%); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row label { width: 140px; color: var(--dim); font-weight: 600; }
.segs { display: flex; gap: 6px; flex-wrap: wrap; }
.lteams { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; width: min(900px, 100%); }
.lt { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.25); border-left: 6px solid var(--c); border-radius: 10px; padding: 8px 12px; }
.lt input { flex: 1; min-width: 0; padding: 6px 10px; }
.lt b { flex: 1; font: 22px var(--display); text-transform: uppercase; letter-spacing: .03em; }
.on { font-size: 12px; color: var(--dim); white-space: nowrap; }
.on.yes { color: var(--ok); }
.setup .btn.xl { align-self: center; margin-top: 6px; }

/* final + results */
.final { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; overflow: auto; }
.final-title { font: clamp(40px, 6.5vw, 96px)/1 var(--display); color: var(--gold); text-shadow: 4px 4px 0 #000; text-transform: uppercase; animation: pop .4s; }
.final-cat { font: clamp(28px, 4vw, 60px) var(--display); text-transform: uppercase; text-shadow: 3px 3px 0 #000; letter-spacing: .03em; }
.final .clue-q { font-size: clamp(20px, 2.8vw, 44px); }
.final .count { font: clamp(48px, 6vw, 88px) var(--display); color: var(--gold); text-shadow: 3px 3px 0 #000; font-variant-numeric: tabular-nums; }
.ticks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tick { padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--dim); font-weight: 600; }
.tick.done { background: var(--c); color: #000; }
.fcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; width: min(1200px, 100%); }
.fcard { background: linear-gradient(#0b16bd, #060c86); border: 3px solid #000; border-top: 6px solid var(--c); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.fcard.right { box-shadow: 0 0 0 3px var(--ok); }
.fcard.wrong { box-shadow: 0 0 0 3px var(--bad); }
.fname { font: 20px var(--display); text-transform: uppercase; letter-spacing: .03em; }
.fans { font: 700 18px/1.35 var(--serif); min-height: 2.6em; overflow-wrap: anywhere; }
.fwager { color: var(--dim); font-size: 14px; }
.ftools { display: flex; gap: 6px; justify-content: center; }
.ftools .btn { padding: 8px 14px; font-size: 15px; }
.over { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; overflow: auto; }
.winner { font: clamp(40px, 7vw, 110px)/1.05 var(--display); color: var(--gold); text-shadow: 5px 5px 0 #000; text-transform: uppercase; text-align: center; animation: pop .5s; }
.rank { display: flex; flex-direction: column; gap: 8px; width: min(560px, 100%); }
.rk { display: flex; align-items: center; gap: 14px; background: rgba(0,0,0,.3); border-left: 6px solid var(--c); border-radius: 10px; padding: 10px 16px; font: 24px var(--display); text-transform: uppercase; letter-spacing: .03em; }
.rk b { flex: 1; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk span { color: var(--dim); width: 1.4em; }

/* login */
.login { position: fixed; inset: 0; background: radial-gradient(ellipse at top, #0a1290, var(--night) 70%); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login form { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; }
.login input { width: 260px; text-align: center; font-size: 20px; }
.err { color: var(--bad); min-height: 1.2em; font-weight: 600; }

/* ---------- team (student) screen ---------- */
body.team { padding: 16px; gap: 12px; }
.t-head { display: flex; align-items: center; gap: 12px; width: min(560px, 100%); background: var(--c); color: #000; border-radius: 14px; padding: 12px 16px; box-shadow: 0 5px 0 rgba(0,0,0,.4); }
.t-name { flex: 1; min-width: 0; font: 28px var(--display); text-transform: uppercase; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-score { font: 30px var(--display); font-variant-numeric: tabular-nums; }
.t-score.neg { color: #7a0000; }
.t-edit { border: 0; background: rgba(0,0,0,.15); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 700; }
.mini { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: min(560px, 100%); }
.mini span { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); border-left: 4px solid var(--c); }
.mini span.me { background: rgba(255,255,255,.2); }
#main { width: min(560px, 100%); display: flex; flex-shrink: 0; flex-direction: column; align-items: center; gap: 16px; flex: 1; }
.card { width: 100%; background: rgba(0,0,0,.3); border-radius: 16px; padding: 22px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.card h2 { font-size: 30px; color: var(--gold); }
.card p { color: var(--dim); }
.card form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.card form .btn { align-self: center; }
.card textarea { min-height: 90px; resize: vertical; }
.t-clue { width: 100%; background: radial-gradient(ellipse at 50% 30%, var(--blue-hi), var(--blue) 55%, var(--blue-lo)); border: 4px solid #000; border-radius: 12px; padding: 16px; text-align: center; }
.t-cat { font: 16px var(--display); color: #c9d0ff; text-transform: uppercase; letter-spacing: .05em; }
.t-cat em { color: var(--gold); font-style: normal; }
.t-q { margin-top: 8px; font: 700 clamp(16px, 4.2vw, 21px)/1.4 var(--serif); text-transform: uppercase; text-shadow: 2px 2px 0 #000; }
.t-a { margin-top: 10px; font: 24px var(--display); color: var(--gold); text-shadow: 2px 2px 0 #000; }
.buzz {
  width: min(70vw, 300px); height: min(70vw, 300px); border-radius: 50%; border: 0; font: 58px var(--display); text-transform: uppercase;
  color: #000; background: #4a4f7a; cursor: not-allowed; box-shadow: 0 12px 0 #1d2040, inset 0 -10px 20px rgba(0,0,0,.3);
  flex-shrink: 0; transition: transform .05s; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.buzz.live { background: var(--c); cursor: pointer; animation: pulse .6s infinite alternate; box-shadow: 0 12px 0 rgba(0,0,0,.5), 0 0 70px var(--c); }
.buzz.live:active { transform: translateY(8px); box-shadow: 0 4px 0 rgba(0,0,0,.5); animation: none; }
.buzz.done { background: #2a2d4d; color: #8a8fc0; cursor: default; }
.buzz.won { background: var(--c); color: #000; cursor: default; }
.msg { font-size: clamp(20px, 5vw, 28px); text-align: center; font-weight: 800; }
.msg .count { display: block; font: 110px/1 var(--display); color: var(--gold); text-shadow: 4px 4px 0 #000; font-variant-numeric: tabular-nums; }
.ok-text { color: var(--ok); font-weight: 700; }
.bad-text { color: var(--bad); font-weight: 700; }
.leave { margin-top: 6px; background: transparent; color: var(--dim); border: 1px solid rgba(163,171,235,.5); border-radius: 999px; padding: 8px 18px; font-size: 14px; cursor: pointer; }
body.team.is-up { background: radial-gradient(ellipse at center, color-mix(in srgb, var(--c) 40%, var(--night)) 0%, var(--night) 75%); }

@media (max-width: 760px) {
  .scores { flex-wrap: wrap; }
  .pod { flex-basis: 40%; }
  .top .join { display: none; }
}
