:root {
  --bg: #05070d;
  --bg2: #0a141c;
  --card: rgba(4, 16, 24, 0.85);
  --ink: #d9faff;
  --muted: #7fb8cc;
  --dim: #3d5a6b;
  --line: #16303f;
  --accent: #ff2d95;
  --accent2: #00e5ff;
  --good: #3dff9e;
  --bad: #ff5470;
  --warn: #ffd23d;
  --radius: 6px;
  --pix: 'Press Start 2P', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

body { padding: 16px; }

@keyframes pulseGlow { 0%, 100% { opacity: 0.8; } 50% { opacity: 1; } }

h1, h2, h3 { margin: 0.2em 0; }
h1 {
  font-family: var(--pix);
  font-size: clamp(16px, 4.5vw, 24px);
  line-height: 1.5;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 45, 149, 0.9), 0 0 46px rgba(255, 45, 149, 0.45);
  animation: pulseGlow 1.8s infinite;
}
h2 { font-weight: 700; letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.22), inset 0 0 34px rgba(0, 229, 255, 0.05);
  padding: 18px;
  margin: 12px auto;
  max-width: 720px;
}

.wide { max-width: 1100px; }

button {
  background: var(--accent);
  color: #1a0512;
  border: none;
  border-radius: 4px;
  padding: 12px 20px;
  font-family: var(--pix);
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 0 #8f1052, 0 0 20px rgba(255, 45, 149, 0.55);
}
button:disabled { opacity: 0.45; cursor: default; }
button.secondary {
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent2);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.25);
  font-size: 10px;
}
button.big { font-size: 14px; padding: 16px 28px; width: 100%; }

input[type="text"], input[type="number"] {
  background: #060b12;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  font-size: 18px;
  width: 100%;
  font-family: inherit;
  outline: none;
  box-shadow: inset 0 0 12px rgba(0, 229, 255, 0.08);
}
input[type="text"]:focus, input[type="number"]:focus { border-color: var(--accent2); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---- host screen ---- */
.host-code {
  font-family: var(--pix);
  font-size: clamp(40px, 9vw, 96px);
  letter-spacing: 0.12em;
  color: var(--accent2);
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.9), 0 0 60px rgba(0, 229, 255, 0.4);
}
.qr { background: white; padding: 10px; border-radius: 6px; width: 200px; height: 200px; }
.joinlist { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 14px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip.eliminated { opacity: 0.4; text-decoration: line-through; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.good { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.ok { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.dot.poor { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
.dot.off { background: var(--dim); }

.ladder { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 18px; }
.ladder .step {
  background: var(--bg2);
  border-radius: 4px;
  padding: 6px 12px;
  border: 1px solid var(--line);
}
.ladder .step.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0512;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(255, 45, 149, 0.55);
}
.ladder .arrow { color: var(--dim); }

.progress-count {
  font-family: var(--pix);
  font-size: clamp(30px, 6vw, 64px);
  color: var(--accent2);
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.8);
}

table.board { width: 100%; border-collapse: collapse; font-size: 17px; }
table.board th {
  font-family: var(--pix);
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
table.board th, table.board td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
table.board td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.cutline td { border-bottom: 3px dashed var(--bad); }
tr.saved { background: rgba(61, 255, 158, 0.1); }
tr.eliminated { opacity: 0.55; }
tr.reveal-row { opacity: 0; transform: translateY(8px); transition: all 0.35s ease; }
tr.reveal-row.shown { opacity: 1; transform: none; }
tr.eliminated.shown { opacity: 0.55; }

/* ---- redemption ---- */
.light {
  width: min(70vw, 420px);
  height: min(70vw, 420px);
  border-radius: 50%;
  margin: 30px auto;
  background: #58121f;
  border: 10px solid var(--line);
  transition: background 0.05s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
}
.light.green { background: var(--good); box-shadow: 0 0 80px var(--good); color: #042a18; }

.tapzone {
  position: fixed;
  inset: 0;
  background: #58121f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  user-select: none;
  -webkit-user-select: none;
}
.tapzone.green { background: var(--good); color: #042a18; }
.tapzone h1 {
  font-size: clamp(24px, 7vw, 64px);
  color: inherit;
  text-shadow: none;
  animation: none;
}

/* ---- games ---- */
#game-root { min-height: 300px; }
.countdown {
  height: 10px;
  background: #0a1620;
  border: 1px solid #123040;
  border-radius: 2px;
  overflow: hidden;
  margin: 10px 0;
}
.countdown > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
  width: 100%;
}
canvas.game {
  width: 100%;
  border-radius: 4px;
  background: #060b12;
  border: 1px solid var(--accent2);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.25), inset 0 0 30px rgba(0, 229, 255, 0.04);
  display: block;
  touch-action: none;
}
.swatch { width: 100%; height: 90px; border-radius: 4px; border: 1px solid var(--line); box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3); }
.bigbtn {
  font-size: 20px;
  padding: 40px;
  width: 100%;
  border-radius: 8px;
  background: var(--bg2);
  color: var(--dim);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--line);
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
}
.mash-count {
  font-family: var(--pix);
  font-size: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.8), 0 0 46px rgba(0, 229, 255, 0.35);
  margin: 14px 0;
}
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.grid5 .cell {
  aspect-ratio: 1;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
  transition: box-shadow 0.15s, background 0.15s;
}
.grid5 .cell.lit {
  background: var(--accent2);
  border-color: #7ff3ff;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.9), inset 0 0 8px rgba(255, 255, 255, 0.5);
}
.grid5 .cell.picked {
  background: var(--accent);
  border-color: #ff8ec4;
  box-shadow: 0 0 16px rgba(255, 45, 149, 0.9), inset 0 0 8px rgba(255, 255, 255, 0.4);
}
.oddgrid { display: grid; gap: 5px; }
.oddgrid .tile {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0;
  box-shadow: none;
}

.vote-option {
  display: block;
  width: 100%;
  text-align: left;
  margin: 8px 0;
  background: var(--bg2);
  border: 2px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  text-transform: none;
  box-shadow: none;
}
.vote-option.chosen { border-color: var(--good); box-shadow: 0 0 14px rgba(61, 255, 158, 0.35); }

/* ---- live leaderboard strip ---- */
.liveboard {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  padding: 8px 2px;
  max-width: 720px;
  margin: 6px auto 0;
  white-space: nowrap;
  scrollbar-width: none;
}
.liveboard::-webkit-scrollbar { display: none; }
.lb-title { flex: 0 0 auto; font-size: 15px; }
.lb-chip {
  flex: 0 0 auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 10px;
  font-family: var(--pix);
  font-size: 9px;
  color: #3d6a7d;
  font-variant-numeric: tabular-nums;
}
.lb-chip.me {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--accent2);
  color: var(--accent2);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

/* ---- pre-game tutorial ---- */
.tut { margin: 10px auto 0; max-width: 460px; }
.tut-badge {
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tut-badge.do { background: rgba(61, 255, 158, 0.1); color: var(--good); border: 1px solid var(--good); box-shadow: 0 0 12px rgba(61, 255, 158, 0.2); }
.tut-badge.avoid { background: rgba(255, 84, 112, 0.1); color: var(--bad); border: 1px solid var(--bad); box-shadow: 0 0 12px rgba(255, 84, 112, 0.2); }
.tut-canvas { display: block; margin: 0 auto; border-radius: 4px; max-width: 100%; border: 1px solid var(--line); }

.status-banner {
  font-family: var(--pix);
  font-size: clamp(16px, 4vw, 34px);
  line-height: 1.5;
  text-align: center;
  margin: 24px 0;
}
.status-banner.safe { color: var(--good); text-shadow: 0 0 18px rgba(61, 255, 158, 0.8); }
.status-banner.risk { color: var(--bad); text-shadow: 0 0 18px rgba(255, 84, 112, 0.8); }

.music-viz { display: flex; gap: 8px; height: 160px; align-items: flex-end; justify-content: center; }
.music-viz .bar {
  width: 26px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
  border-radius: 3px 3px 0 0;
  animation: bounce 0.5s infinite alternate;
}
@keyframes bounce { from { height: 20%; } to { height: 100%; } }
.music-viz.stopped .bar { animation: none; height: 8% !important; background: var(--bad); box-shadow: 0 0 12px rgba(255, 84, 112, 0.5); }

.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; text-align: left; }
.config-grid label { font-size: 14px; color: var(--muted); }
.game-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.game-toggles label {
  background: var(--bg2);
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.game-toggles input { margin-right: 4px; }
.game-toggles button { font-size: 9px; padding: 8px 12px; }

.winner-name {
  font-family: var(--pix);
  font-size: clamp(28px, 7vw, 72px);
  line-height: 1.4;
  color: var(--warn);
  text-shadow: 0 0 18px rgba(255, 210, 61, 0.9), 0 0 60px rgba(255, 210, 61, 0.4);
}
.trial-note { font-size: 15px; color: var(--muted); margin-top: 6px; }
.price-item { font-size: 20px; margin: 10px 0; }
.price-item .emoji { font-size: 44px; }
.answer-clusters { columns: 2; font-size: 15px; }
