:root {
  --bg: #0b0618;
  --bg-2: #140b2e;
  --tile: #1c1145;
  --tile-2: #2a1a66;
  --line: #3d2a8a;
  --text: #f5f3ff;
  --muted: #a8a0d0;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --yellow: #facc15;
  --lime: #a3e635;
  --red: #fb4f6a;
  --green: #34d399;
  --radius: 14px;
  --pixel: 'Press Start 2P', 'Courier New', monospace;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(244, 114, 182, .16), transparent 60%),
    radial-gradient(1100px 600px at 90% 110%, rgba(34, 211, 238, .14), transparent 60%),
    var(--bg);
  color: var(--text); font-family: var(--ui); line-height: 1.4; min-height: 100vh;
  -webkit-font-smoothing: antialiased; touch-action: manipulation;
}
a { color: var(--cyan); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.pixel { font-family: var(--pixel); letter-spacing: .02em; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* scanlines for that arcade-cabinet feel */
.scan::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px);
}

/* ---------- logo ---------- */
.logo { font-family: var(--pixel); line-height: 1.1; margin: 0; font-size: clamp(1.6rem, 6vw, 3.2rem); }
.logo .a { color: var(--cyan); text-shadow: 0 0 18px rgba(34, 211, 238, .7); }
.logo .b { color: var(--pink); text-shadow: 0 0 18px rgba(244, 114, 182, .7); }
.logo.sm { font-size: 1rem; }

/* ---------- generic UI ---------- */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 80px; }
.narrow { max-width: 520px; }
.card {
  background: linear-gradient(180deg, var(--tile), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.card h2 { font-size: 1.15rem; }
label { display: block; font-weight: 700; margin: 0 0 6px; }
input[type=text], input[type=number], input[type=password], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, .2); }
textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.btn {
  font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  background: var(--tile-2); color: var(--text); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .08s, filter .15s; user-select: none; -webkit-user-select: none; min-height: 46px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #ffe066, var(--yellow)); color: #1a1200; border-color: transparent; }
.btn.cyan { background: var(--cyan); color: #032026; border-color: transparent; }
.btn.pink { background: var(--pink); color: #2a0718; border-color: transparent; }
.btn.good { background: var(--green); color: #032015; border-color: transparent; }
.btn.bad { background: var(--red); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 1.2rem; padding: 16px 24px; min-height: 58px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px 12px; min-height: 40px; }
.seg { display: flex; gap: 8px; }
.seg .btn { flex: 1; flex-direction: column; gap: 2px; padding: 12px; }
.seg .btn.on { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan) inset; }
.seg .btn small { font-weight: 500; color: var(--muted); }

.pill { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--tile-2); border: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 100;
  background: #000; color: #fff; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line);
  transition: .25s; pointer-events: none; font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }

.games-list a { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.code-input { text-transform: uppercase; letter-spacing: .4em; font-family: var(--pixel); text-align: center; font-size: 22px !important; }

/* ================= BOARD (iPad / projector) ================= */
body.board { height: 100vh; height: 100dvh; overflow: hidden; }
.stage { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 1.2vh 1.2vw; gap: 1vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.topbar .round { font-family: var(--pixel); color: var(--yellow); font-size: clamp(.7rem, 1.6vw, 1.1rem); text-shadow: 0 0 12px rgba(250, 204, 21, .6); }
.topbar .tools { display: flex; gap: 6px; }
.topbar .tools .btn { min-height: 36px; padding: 6px 10px; font-size: .85rem; background: rgba(42, 26, 102, .7); }

.grid { flex: 1; display: grid; gap: .8vh .6vw; min-height: 0; }
.cat, .tile {
  border-radius: 10px; display: flex; align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(180deg, var(--tile-2), var(--tile)); border: 2px solid var(--line); min-height: 0; overflow: hidden;
}
.cat {
  font-weight: 900; text-transform: uppercase; padding: .5vh .5vw; line-height: 1.1;
  font-size: clamp(.7rem, 1.7vw, 1.6rem); border-color: var(--pink); color: #fff;
  box-shadow: 0 0 14px rgba(244, 114, 182, .35), inset 0 0 18px rgba(244, 114, 182, .15);
}
.tile {
  font-family: var(--pixel); color: var(--yellow); font-size: clamp(.7rem, min(2.15vw, 4.6vh), 2.3rem);
  text-shadow: 0 0 14px rgba(250, 204, 21, .55); border-color: rgba(34, 211, 238, .55);
  box-shadow: inset 0 0 22px rgba(34, 211, 238, .12); cursor: default; transition: transform .1s, box-shadow .15s;
}
.tile.tap { cursor: pointer; }
.tile.tap:active { transform: scale(.96); }
.tile.used { background: rgba(20, 11, 46, .6); border-color: rgba(61, 42, 138, .4); box-shadow: none; color: transparent; text-shadow: none; }
.tile.pop { animation: tileIn .45s both; }
@keyframes tileIn { from { opacity: 0; transform: scale(.6) rotateX(70deg); } to { opacity: 1; transform: none; } }
.tile.dd-mark::after { content: '★'; position: absolute; font-size: .7em; margin: -2.2em 0 0 3.2em; color: var(--pink); }

.pods { display: flex; gap: 1vw; justify-content: center; }
.pod {
  flex: 1; max-width: 340px; border-radius: 12px; padding: .8vh 1vw; text-align: center; position: relative;
  background: linear-gradient(180deg, var(--tile-2), var(--tile)); border: 2px solid var(--line); transition: .2s;
}
.pod .nm { font-weight: 900; font-size: clamp(.8rem, 1.9vw, 1.5rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .sc { font-family: var(--pixel); font-size: clamp(.8rem, 2vw, 1.6rem); margin-top: .4vh; }
.pod .sc.neg { color: var(--red); }
.pod .bar { position: absolute; left: 0; right: 0; top: 0; height: 5px; border-radius: 12px 12px 0 0; }
.pod.ctrl::before { content: '▶'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--yellow); font-size: clamp(.7rem, 1.4vw, 1.1rem); }
.pod.lit { transform: translateY(-6px) scale(1.04); box-shadow: 0 0 0 3px currentColor, 0 0 30px currentColor; }
.pod.out { opacity: .4; }
.pod.empty { opacity: .35; border-style: dashed; }
.pod .delta { position: absolute; right: 8px; top: -14px; font-family: var(--pixel); font-size: .8rem; padding: 4px 6px; border-radius: 6px; animation: floatUp 2s both; }
.pod .delta.up { background: var(--green); color: #032015; }
.pod .delta.down { background: var(--red); color: #fff; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(10px); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

/* clue overlay */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; padding: 3vh 4vw 2vh;
  background: radial-gradient(900px 500px at 50% 40%, #2a1a66, #120a2c 70%); border: 4px solid var(--cyan);
}
.overlay.zoom { animation: zoomIn .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes zoomIn { from { transform: scale(.15); opacity: 0; } to { transform: none; opacity: 1; } }
.overlay .meta { display: flex; justify-content: space-between; font-family: var(--pixel); font-size: clamp(.7rem, 1.6vw, 1.2rem); color: var(--muted); }
.overlay .meta .val { color: var(--yellow); }
.overlay .q {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 900; text-transform: uppercase; line-height: 1.18; padding: 2vh 2vw; letter-spacing: .01em;
  font-size: clamp(1.4rem, 4.2vw, 4.4rem); text-shadow: 0 3px 0 rgba(0, 0, 0, .5);
}
.overlay .q.long { font-size: clamp(1.2rem, 3.4vw, 3.4rem); }
.overlay .ans { text-align: center; font-size: clamp(1.1rem, 3vw, 2.8rem); font-weight: 900; color: var(--lime); text-shadow: 0 0 20px rgba(163, 230, 53, .5); margin-bottom: 1vh; animation: tileIn .4s both; }
.overlay .ans small { display: block; font-family: var(--pixel); font-size: .4em; color: var(--muted); text-shadow: none; margin-bottom: .6em; }
.status { text-align: center; font-weight: 900; font-size: clamp(1rem, 2.4vw, 2rem); min-height: 1.5em; }
.status.go { color: var(--cyan); text-shadow: 0 0 18px rgba(34, 211, 238, .7); }
.timebar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 1vh 0; }
.timebar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--pink), var(--cyan)); transform-origin: left; }

.buzzer-name { font-size: clamp(1.6rem, 5vw, 4.6rem); font-weight: 900; text-align: center; animation: tileIn .35s both; }

.powerup { font-family: var(--pixel); font-size: clamp(2rem, 8vw, 7rem); text-align: center; background: linear-gradient(90deg, var(--cyan), var(--pink), var(--yellow), var(--cyan)); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.4s linear infinite, pulse 1s ease-in-out infinite alternate; filter: drop-shadow(0 0 18px rgba(244, 114, 182, .6)); }
@keyframes shimmer { to { background-position: 300% 0; } }
@keyframes pulse { from { transform: scale(.96); } to { transform: scale(1.04); } }

.dock {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 1vh 0 0;
}
.dock .btn { font-size: clamp(.85rem, 1.5vw, 1.1rem); }
.dock.mini .btn { min-height: 38px; padding: 6px 12px; font-size: .85rem; }

/* lobby */
.lobby { flex: 1; display: grid; grid-template-columns: 1.1fr .9fr; gap: 3vw; align-items: center; padding: 1vh 3vw; min-height: 0; }
.lobby .qr { background: #fff; padding: 14px; border-radius: 18px; display: inline-block; box-shadow: 0 0 40px rgba(34, 211, 238, .35); }
.lobby .qr img { display: block; width: min(30vh, 26vw); height: auto; }
.joincode { font-family: var(--pixel); font-size: clamp(2rem, 6vw, 5rem); color: var(--yellow); letter-spacing: .15em; text-shadow: 0 0 22px rgba(250, 204, 21, .6); }
.slots { display: grid; gap: 1.4vh; }
.slot { display: flex; align-items: center; gap: 14px; padding: 1.6vh 1.4vw; border-radius: 14px; border: 2px dashed var(--line); font-size: clamp(1rem, 2.4vw, 2rem); font-weight: 900; min-height: 7vh; }
.slot.on { border-style: solid; animation: tileIn .4s both; }
.slot .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; background: currentColor; }
.slot .x { margin-left: auto; font-size: .9rem; }

/* intermission / over */
.center-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vh; text-align: center; min-height: 0; }
.standings { display: grid; gap: 1.2vh; width: min(720px, 90vw); }
.standings .st { display: flex; align-items: center; gap: 16px; padding: 1.4vh 1.6vw; border-radius: 14px; background: var(--tile); border: 2px solid var(--line); font-size: clamp(1rem, 2.4vw, 2rem); font-weight: 900; animation: tileIn .45s both; }
.standings .st .rk { font-family: var(--pixel); color: var(--muted); font-size: .7em; width: 2.4em; }
.standings .st .sc { margin-left: auto; font-family: var(--pixel); font-size: .8em; }
.standings .st.first { border-color: var(--yellow); box-shadow: 0 0 30px rgba(250, 204, 21, .35); }
.big-title { font-family: var(--pixel); font-size: clamp(1.4rem, 4.6vw, 4rem); color: var(--yellow); text-shadow: 0 0 22px rgba(250, 204, 21, .6); }

/* final reveal cards */
.reveal-row { display: flex; gap: 1.4vw; justify-content: center; flex-wrap: wrap; }
.rcard { min-width: 22vw; max-width: 30vw; padding: 2vh 1.4vw; border-radius: 14px; background: var(--tile); border: 2px solid var(--line); text-align: center; }
.rcard.cur { border-color: var(--cyan); box-shadow: 0 0 28px rgba(34, 211, 238, .4); }
.rcard .nm { font-weight: 900; font-size: clamp(1rem, 2vw, 1.6rem); }
.rcard .an { font-size: clamp(1rem, 2.4vw, 2rem); font-weight: 800; margin: 1vh 0; min-height: 1.3em; }
.rcard .wg { font-family: var(--pixel); font-size: clamp(.7rem, 1.4vw, 1rem); color: var(--muted); }
.rcard.ok { border-color: var(--green); } .rcard.no { border-color: var(--red); }

/* modal (host menu) */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(5, 2, 14, .8); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; }

/* numpad */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad .btn { font-size: 1.4rem; min-height: 56px; }
.wager-display { font-family: var(--pixel); font-size: 1.8rem; text-align: center; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); color: var(--yellow); }

/* ================= PHONE ================= */
body.phone { min-height: 100vh; min-height: 100dvh; }
.phone-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 10px; }
.phone-top .who { display: flex; align-items: center; gap: 8px; font-weight: 900; min-width: 0; }
.phone-top .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-top .money { font-family: var(--pixel); font-size: 1rem; }
.phone-main { padding: 16px; max-width: 520px; margin: 0 auto; }
.phone-msg { text-align: center; padding: 6vh 8px 2vh; }
.phone-msg .h { font-size: 1.6rem; font-weight: 900; margin-bottom: 8px; }
.phone-clue { background: var(--tile); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.phone-clue .m { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; display: flex; justify-content: space-between; }
.phone-clue .t { font-weight: 700; margin-top: 4px; }

.buzzer {
  display: block; width: min(78vw, 360px); aspect-ratio: 1; margin: 2vh auto; border-radius: 50%;
  border: 0; font-family: var(--pixel); font-size: clamp(1.4rem, 8vw, 2.4rem); color: rgba(255, 255, 255, .35);
  background: radial-gradient(circle at 35% 30%, #4a3a8a, #241860 60%, #160e3a);
  box-shadow: 0 14px 0 #0c0726, 0 20px 40px rgba(0, 0, 0, .5); transition: transform .05s, box-shadow .05s;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.buzzer.live {
  color: #fff; background: radial-gradient(circle at 35% 30%, #ff9ccc, var(--pink) 55%, #a3175d);
  box-shadow: 0 14px 0 #6b0f3c, 0 0 60px rgba(244, 114, 182, .8); animation: pulse .6s ease-in-out infinite alternate;
}
.buzzer.down { transform: translateY(10px); box-shadow: 0 4px 0 #6b0f3c, 0 0 30px rgba(244, 114, 182, .6); animation: none; }
.buzzer.early { background: radial-gradient(circle at 35% 30%, #777, #444 60%, #222); color: #ffb4b4; animation: shake .25s; }
.buzzer.won { font-size: clamp(1.1rem, 6vw, 1.8rem); color: #032015; background: radial-gradient(circle at 35% 30%, #b6ffd9, var(--green) 55%, #0f7a54); box-shadow: 0 14px 0 #0b4d36, 0 0 60px rgba(52, 211, 153, .8); animation: none; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.buzz-note { text-align: center; font-weight: 800; min-height: 1.5em; font-size: 1.1rem; }

.mini-board { display: grid; gap: 5px; }
.mini-board .mc { font-size: .62rem; font-weight: 900; text-transform: uppercase; text-align: center; line-height: 1.1; padding: 4px 2px; color: #fff; border-bottom: 2px solid var(--pink); display: flex; align-items: center; justify-content: center; min-height: 40px; }
.mini-board .mv { font-family: var(--pixel); font-size: .62rem; color: var(--yellow); background: var(--tile-2); border: 1px solid rgba(34, 211, 238, .5); border-radius: 8px; min-height: 46px; display: flex; align-items: center; justify-content: center; padding: 0; }
.mini-board .mv.used { visibility: hidden; }
.mini-board .mv.dd { box-shadow: inset 0 0 0 2px var(--pink); }

/* host remote */
.host-ans { background: #0f2a12; border: 1px solid #1f6b2a; color: var(--lime); border-radius: 12px; padding: 12px 14px; font-weight: 900; font-size: 1.3rem; }
.host-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-row .nm { flex: 1; font-weight: 800; }

@media (max-width: 820px) {
  .lobby { grid-template-columns: 1fr; text-align: center; overflow: auto; }
  .lobby .qr img { width: 40vw; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
