:root {
  --bg: #120d2b;
  --bg-2: #1b1442;
  --surface: #221a52;
  --surface-2: #2c2266;
  --line: #3b2f80;
  --text: #f6f1ff;
  --muted: #a99fd6;
  --gold: #ffc94a;
  --gold-2: #ff9f1c;
  --coral: #ff5d73;
  --teal: #2ee6c5;
  --radius: 16px;
  --display: 'Bungee', 'Arial Black', system-ui, sans-serif;
  --ui: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #2d1f74 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--ui);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
.display { font-family: var(--display); letter-spacing: .02em; font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 80px; }
.narrow { max-width: 620px; }

.logo { font-family: var(--display); font-size: clamp(2rem, 7vw, 3.6rem); line-height: 1; margin: 0; }
.logo .a { color: var(--gold); text-shadow: 0 0 24px rgba(255, 201, 74, .45); }
.logo .b { color: var(--coral); text-shadow: 0 0 24px rgba(255, 93, 115, .45); }
.tagline { color: var(--muted); margin: .75rem 0 2rem; font-size: 1.1rem; }

.card {
  background: linear-gradient(180deg, var(--surface), 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, .25);
}
.card h2 { font-size: 1.25rem; }

label { display: block; font-weight: 600; margin: 0 0 6px; }
input[type=text], input[type=number], textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 74, .2); }
textarea { min-height: 140px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--ui); color: var(--text); text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 18px; cursor: pointer; transition: transform .08s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a1600; border-color: transparent; }
.btn.danger { background: linear-gradient(180deg, #ff6f82, #e23a55); border-color: transparent; }
.btn.teal { background: linear-gradient(180deg, #4ff0d3, #18bfa2); color: #00221c; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: .875rem; border-radius: 9px; }
.btn.lg { padding: 16px 26px; font-size: 1.15rem; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.pill.gold { background: rgba(255, 201, 74, .15); color: var(--gold); border-color: rgba(255, 201, 74, .4); }
.pill.teal { background: rgba(46, 230, 197, .12); color: var(--teal); border-color: rgba(46, 230, 197, .4); }

.linkbox { display: flex; gap: 8px; }
.linkbox input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--gold); color: #2a1600; font-weight: 700; padding: 10px 18px; border-radius: 999px;
  transition: all .25s; pointer-events: none; z-index: 1000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 2px; }
.tab { white-space: nowrap; }
.tab.active { background: var(--gold); color: #2a1600; border-color: transparent; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.scroll-x { overflow-x: auto; }

/* review groups */
.group {
  display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 12px; border: 1px solid transparent;
}
.group:nth-child(odd) { background: rgba(255, 255, 255, .03); }
.group.cut { opacity: .5; }
.group.cut .rank { background: var(--surface-2); color: var(--muted); }
.group.off { opacity: .35; text-decoration: line-through; }
.group.selected { border-color: var(--gold); background: rgba(255, 201, 74, .08); }
.group .rank { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: var(--gold); color: #2a1600; font-size: .85rem; }
.group input[type=text] { padding: 7px 10px; }
.group .count { font-weight: 700; min-width: 64px; text-align: right; }
.group .variants { grid-column: 3 / -1; font-size: .8rem; color: var(--muted); margin-top: -4px; }
.group input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); }

/* survey */
.q-card { counter-increment: q; }
.q-card label::before { content: counter(q) '. '; color: var(--gold); }
.qlist { counter-reset: q; }

/* ===================== BOARD ===================== */
.board-body { overflow: hidden; height: 100vh; }
.stage {
  height: 100vh; display: grid; grid-template-rows: auto 1fr auto; gap: 2vh;
  padding: 2.5vh 3vw; position: relative;
}
.marquee {
  position: absolute; inset: 1.2vh; border-radius: 28px; pointer-events: none;
  border: 3px solid rgba(255, 201, 74, .25);
  box-shadow: inset 0 0 60px rgba(255, 201, 74, .08), 0 0 60px rgba(255, 93, 115, .08);
}
.bulbs { position: absolute; inset: 1.2vh; pointer-events: none; }
.bulb { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: blink 1.6s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2vw; z-index: 1; }
.team {
  display: flex; flex-direction: column; align-items: center; padding: 1.2vh 1.5vw; border-radius: 20px;
  background: rgba(0, 0, 0, .25); border: 2px solid var(--line); transition: all .3s; min-width: 0;
}
.team .tname { font-weight: 800; font-size: clamp(1rem, 2.2vw, 1.8rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.team .tscore { font-family: var(--display); font-size: clamp(2rem, 5vw, 4.5rem); line-height: 1; }
.team.t0 .tscore { color: var(--teal); }
.team.t1 .tscore { color: var(--coral); }
.team.win { border-color: var(--gold); box-shadow: 0 0 40px rgba(255, 201, 74, .45); transform: scale(1.04); }
.bank { text-align: center; }
.bank .label { color: var(--muted); font-weight: 700; letter-spacing: .2em; font-size: clamp(.7rem, 1.2vw, 1rem); text-transform: uppercase; }
.bank .amount {
  font-family: var(--display); font-size: clamp(2.5rem, 7vw, 6rem); line-height: 1; color: var(--gold);
  text-shadow: 0 0 30px rgba(255, 201, 74, .5); transition: transform .2s;
}
.bank .amount.bump { animation: bump .45s; }
@keyframes bump { 40% { transform: scale(1.18); } }
.mult { display: inline-block; margin-top: .6vh; background: var(--coral); color: #fff; font-weight: 800; border-radius: 999px; padding: .3vh 1vw; font-size: clamp(.8rem, 1.3vw, 1.1rem); }

.center { display: grid; grid-template-rows: auto 1fr; gap: 2.5vh; min-height: 0; z-index: 1; }
.question {
  text-align: center; font-weight: 800; font-size: clamp(1.3rem, 3.2vw, 3rem); line-height: 1.15;
  padding: 0 4vw; text-wrap: balance;
}
.question .rnum { display: block; font-family: var(--display); font-weight: 400; color: var(--gold); font-size: .45em; letter-spacing: .15em; margin-bottom: .6vh; }

.tiles { display: grid; grid-auto-flow: column; grid-template-columns: 1fr 1fr; gap: 1.6vh 1.6vw; min-height: 0; perspective: 1200px; }
.tile { position: relative; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); min-height: 0; cursor: default; }
.tile.revealed { transform: rotateX(-180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px;
  display: flex; align-items: center; padding: 0 2vw; overflow: hidden;
}
.face.front {
  background: linear-gradient(180deg, #2b2170, #1a1347); border: 2px solid #4a3ca6;
  justify-content: center; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .08);
}
.face.front .num {
  width: clamp(36px, 6vh, 72px); height: clamp(36px, 6vh, 72px); border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: clamp(1.2rem, 3.4vh, 2.6rem); color: var(--gold);
  border: 3px solid var(--gold); box-shadow: 0 0 18px rgba(255, 201, 74, .35);
}
.face.back {
  transform: rotateX(180deg); justify-content: space-between; gap: 1vw;
  background: linear-gradient(180deg, #ffd86b, #ffae2e); color: #2a1600; border: 2px solid #ffe7a3;
  box-shadow: 0 0 30px rgba(255, 201, 74, .35);
}
.tile.dud .face.back { background: linear-gradient(180deg, #8c82bd, #6a5fa3); color: #fff; border-color: #a89fe0; box-shadow: none; }
.face.back .alabel { font-weight: 900; font-size: clamp(1rem, 3.6vh, 2.6rem); text-transform: uppercase; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; }
.face.back .apts {
  font-family: var(--display); font-size: clamp(1.2rem, 4.2vh, 3rem); background: #2a1600; color: var(--gold);
  border-radius: 12px; padding: .4vh 1vw; min-width: 2.4em; text-align: center; flex: none;
}
.tile.empty { visibility: hidden; }
.tile.host-peek .face.front::after {
  content: attr(data-peek); position: absolute; left: 1vw; bottom: .6vh; font-size: .8rem; color: var(--muted); font-weight: 600;
}

.strikes { display: flex; justify-content: center; gap: 1.5vw; min-height: 6vh; z-index: 1; }
.strike-pip { font-family: var(--display); font-size: clamp(2rem, 5vh, 3.5rem); color: rgba(255, 93, 115, .18); line-height: 1; }
.strike-pip.on { color: var(--coral); text-shadow: 0 0 20px rgba(255, 93, 115, .7); }

.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; pointer-events: none;
}
.bigx { display: flex; gap: 3vw; }
.bigx span {
  font-family: var(--display); font-size: 38vh; line-height: 1; color: var(--coral);
  text-shadow: 0 0 60px rgba(255, 93, 115, .9), 0 0 4px #fff; animation: slam .9s forwards;
}
@keyframes slam { 0% { transform: scale(2.2); opacity: 0; } 15% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.95); } }
.banner {
  font-family: var(--display); font-size: clamp(2rem, 8vw, 7rem); text-align: center; line-height: 1;
  color: var(--gold); text-shadow: 0 0 40px rgba(255, 201, 74, .8); animation: pop 2s forwards; padding: 0 4vw;
}
.banner small { display: block; font-size: .35em; color: var(--text); margin-top: 1.5vh; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.06); opacity: 1; } 25% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* lobby / collecting / final screens */
.screen { display: grid; place-items: center; text-align: center; z-index: 1; min-height: 0; }
.screen .logo { font-size: clamp(3rem, 9vw, 8rem); }
.join { display: flex; gap: 4vw; align-items: center; justify-content: center; margin-top: 4vh; flex-wrap: wrap; }
.qr { background: #fff; padding: 14px; border-radius: 18px; box-shadow: 0 0 50px rgba(255, 201, 74, .35); }
.qr img, .qr canvas { display: block; }
.join .url { font-family: ui-monospace, Menlo, monospace; font-size: clamp(1rem, 2vw, 1.6rem); color: var(--gold); word-break: break-all; }
.counter { font-family: var(--display); font-size: clamp(4rem, 12vw, 10rem); color: var(--teal); line-height: 1; text-shadow: 0 0 40px rgba(46, 230, 197, .5); }
.versus { display: flex; gap: 4vw; align-items: center; justify-content: center; margin-top: 4vh; font-size: clamp(1.5rem, 4vw, 3.5rem); font-weight: 900; }
.versus .vs { font-family: var(--display); color: var(--gold); }

.sound-gate {
  position: fixed; inset: 0; background: rgba(10, 6, 30, .85); z-index: 100; display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px);
}

/* host dock on board */
.dock {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 60;
  background: rgba(20, 14, 50, .92); border: 1px solid var(--line); border-radius: 16px; padding: 8px;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 96vw; backdrop-filter: blur(8px);
  transition: opacity .2s;
}
.dock.collapsed { opacity: 0; pointer-events: none; }
.kbd { font-family: ui-monospace, monospace; font-size: .72rem; opacity: .7; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }

/* confetti */
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 40; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ===================== REMOTE ===================== */
.remote .tilebtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.remote .tbtn { text-align: left; justify-content: space-between; padding: 14px; min-height: 60px; }
.remote .tbtn .n { color: var(--gold); font-weight: 800; margin-right: 8px; }
.remote .tbtn.on { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #2a1600; border-color: transparent; }
.remote .tbtn.on .n { color: #2a1600; }
.remote .big { font-size: 1.2rem; padding: 18px; flex: 1; }
.remote .scoreline { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; text-align: center; }
.remote .scoreline .s { font-family: var(--display); font-size: 2rem; }
