/* Reflexor — style. Dependency-free. Big-center / small-edges, per-player color flashes. */
:root {
  --bg: #0a0a14;
  --bg2: #12122a;
  --fg: #f3f3ff;
  --dim: #9aa0c0;
  --accent: #6c5cff;
  --accent2: #00e5ff;
  --ok: #34e07b;
  --bad: #ff3b5c;
  --warn: #ffb020;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--fg);
  background:
    radial-gradient(1200px 800px at 20% -10%, #1b1b44 0%, transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, #2a0f4a 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#app, .app-root { height: 100%; }
.app-root { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 28px);
  gap: 16px;
  min-height: 0;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* connection indicator */
.conn-dot {
  position: fixed; top: 10px; right: 12px; width: 10px; height: 10px; border-radius: 50%;
  z-index: 50; box-shadow: 0 0 8px currentColor;
}
.conn-dot.on { background: var(--ok); color: var(--ok); }
.conn-dot.off { background: var(--bad); color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* buttons + inputs */
.btn {
  appearance: none; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06);
  color: var(--fg); font-size: 1rem; font-weight: 600; padding: 12px 18px; border-radius: 12px;
  cursor: pointer; transition: transform .08s, background .15s, box-shadow .15s; font-family: inherit;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: default; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #06061a; box-shadow: 0 6px 24px rgba(108,92,255,.5);
}
.btn.big { font-size: 1.2rem; padding: 16px 26px; width: 100%; max-width: 340px; }
.inp {
  width: 100%; font-size: 1.1rem; padding: 14px 16px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: var(--fg);
  font-family: inherit; outline: none;
}
.inp:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(0,229,255,.2); }
.row { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 340px; }
.row.center { justify-content: center; max-width: none; }
.center { text-align: center; }

/* ---------- Home ---------- */
.home .logo { font-size: clamp(2.6rem, 9vw, 4.5rem); font-weight: 900; letter-spacing: -2px;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); -webkit-background-clip: text;
  background-clip: text; color: transparent; display: flex; align-items: center; gap: 8px; }
.home .bolt { -webkit-text-fill-color: initial; color: var(--warn); filter: drop-shadow(0 0 12px var(--warn)); }
.tagline { color: var(--dim); margin: -8px 0 8px; }
.card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.lbl { font-size: .85rem; color: var(--dim); }
.or { text-align: center; color: var(--dim); font-size: .9rem; margin: 4px 0; }
.code-inp { text-transform: uppercase; letter-spacing: 6px; font-weight: 800; text-align: center; }

/* ---------- Lobby ---------- */
.lobby { justify-content: flex-start; gap: 20px; overflow-y: auto; }
.lobby-code { text-align: center; }
.lobby-code__label { color: var(--dim); letter-spacing: 4px; font-size: .8rem; }
.lobby-code__big { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.codechar {
  font-size: clamp(2.6rem, 13vw, 5.5rem); font-weight: 900; line-height: 1;
  background: linear-gradient(160deg, #fff, var(--accent2)); -webkit-background-clip: text;
  background-clip: text; color: transparent; padding: 6px 14px; border-radius: 14px;
  border: 2px solid rgba(255,255,255,.12); box-shadow: inset 0 0 24px rgba(108,92,255,.25);
}
.joinurl { color: var(--dim); font-size: .85rem; margin-top: 8px; word-break: break-all; }
.section-title { color: var(--dim); font-size: .85rem; letter-spacing: 2px; text-transform: uppercase; align-self: center; }
.lobby-players { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.waiting { color: var(--dim); font-style: italic; }
.start-btn { margin-top: 4px; }

/* ---------- Player grid (signature) ---------- */
.grid {
  display: grid; gap: 6px; width: 100%; max-width: 900px;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
}
.grid--compact { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-width: 760px; }
.cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px; display: flex; align-items: flex-end;
  justify-content: center; overflow: hidden; transition: transform .15s, box-shadow .2s, filter .25s;
  box-shadow: inset 0 -8px 18px rgba(0,0,0,.35); filter: saturate(1.05);
}
.cell__name {
  font-size: .55rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8);
  padding: 2px 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid--compact .cell__name { display: none; }
.cell--off { filter: grayscale(.9) brightness(.5); }
.cell--me { outline: 3px solid #fff; outline-offset: -3px; z-index: 2; }
/* per-player flash feedback */
.fx-tap { animation: fxtap .55s ease; }
.fx-ok { animation: fxok .65s ease; box-shadow: 0 0 0 3px var(--ok), 0 0 22px var(--ok); }
.fx-bad { animation: fxbad .65s ease; box-shadow: 0 0 0 3px var(--bad), 0 0 22px var(--bad); }
.fx-early { animation: fxearly .65s ease; box-shadow: 0 0 0 3px var(--warn), 0 0 22px var(--warn); }
@keyframes fxtap { 0% { transform: scale(1.25); filter: brightness(1.8); } 100% { transform: none; } }
@keyframes fxok { 0% { transform: scale(1.3); filter: brightness(2) saturate(2); } 100% { transform: none; } }
@keyframes fxbad { 0%,100% { transform: none; } 20% { transform: translateX(-4px) scale(1.1); } 60% { transform: translateX(4px); } }
@keyframes fxearly { 0% { transform: scale(1.2); } 50% { filter: brightness(1.6); } 100% { transform: none; } }

/* ---------- Announce ---------- */
.announce { gap: 10px; }
.announce__idx { color: var(--dim); letter-spacing: 3px; }
.announce__icon { font-size: clamp(4rem, 20vw, 9rem); filter: drop-shadow(0 0 24px rgba(108,92,255,.6)); animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.announce__name { font-size: clamp(2rem, 8vw, 3.5rem); font-weight: 900; }
.announce__rules { color: var(--dim); max-width: 600px; text-align: center; font-size: 1.05rem; }
.announce__go { margin-top: 8px; color: var(--accent2); font-weight: 700; letter-spacing: 2px; animation: blink 1.2s infinite; }

/* ---------- Game shell ---------- */
.game { justify-content: space-between; gap: 10px; }
.game-head { display: flex; gap: 12px; align-items: center; color: var(--dim); font-size: .9rem; }
.game-head__name { color: var(--fg); font-weight: 700; }
.game-stage { flex: 1 1 auto; width: 100%; display: flex; align-items: center; justify-content: center; min-height: 0; }
.game-peers { width: 100%; display: flex; justify-content: center; flex: 0 0 auto; }

/* big tap surface */
.tap-surface {
  width: 100%; height: 100%; min-height: 40vh; border-radius: 24px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; cursor: pointer; user-select: none;
  border: 1px solid rgba(255,255,255,.08); transition: background .12s, box-shadow .12s;
  background: rgba(255,255,255,.03);
}
.screen-game { width: 100%; flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 0; }
.huge-num { font-size: clamp(4rem, 26vw, 16rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -4px; }
.huge-num.blanked { letter-spacing: 6px; color: var(--dim); }
.huge-word { font-size: clamp(3rem, 18vw, 11rem); font-weight: 900; line-height: 1; letter-spacing: -2px; }
.hint { color: var(--dim); font-size: 1rem; }

/* 1. zero */
.zero .huge-num { text-shadow: 0 0 40px rgba(0,229,255,.4); }

/* 2. reaction */
.reaction--red { background: linear-gradient(160deg, #c01c34, #7a0f22); box-shadow: inset 0 0 120px rgba(0,0,0,.4); }
.reaction--green { background: linear-gradient(160deg, #1fcf5c, #0a8a3a); box-shadow: 0 0 80px rgba(52,224,123,.6); }
.reaction--early { background: linear-gradient(160deg, #ff9d2e, #b85f00); }
.reaction--done { background: linear-gradient(160deg, #2a2a55, #16163a); }

/* 3. go_no_go */
.gng--idle { background: #16163a; }
.gng--green { background: linear-gradient(160deg, #1fcf5c, #0a8a3a); box-shadow: 0 0 80px rgba(52,224,123,.6); }
.gng--red { background: linear-gradient(160deg, #c01c34, #7a0f22); }
.gng.tapped--good { box-shadow: 0 0 0 6px var(--ok) inset; }
.gng.tapped--bad { box-shadow: 0 0 0 6px var(--bad) inset; }

/* 4. target */
.target-goal { font-size: clamp(1.4rem, 6vw, 2.6rem); font-weight: 800; color: var(--accent2); letter-spacing: 2px; }
.target .huge-num { color: var(--warn); text-shadow: 0 0 40px rgba(255,176,32,.5); }

/* 5. stroop / 6. math / 9. odd — option grids */
.stroop-word { font-size: clamp(3rem, 16vw, 9rem); font-weight: 900; text-shadow: 0 2px 20px rgba(0,0,0,.5); }
.math-q { font-size: clamp(2.6rem, 12vw, 6rem); font-weight: 900; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 520px; }
.opt-btn {
  appearance: none; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07);
  color: var(--fg); font-size: clamp(1.6rem, 7vw, 3rem); font-weight: 800; border-radius: 18px;
  padding: 28px 10px; cursor: pointer; font-family: inherit; transition: transform .08s, box-shadow .15s;
}
.opt-btn:active { transform: scale(.95); }
.opt-color { min-height: 88px; }
.opt--picked { outline: 4px solid #fff; box-shadow: 0 0 24px rgba(255,255,255,.5); }
.opt-btn:disabled { opacity: .55; }

/* 7. simon */
.simon-status { font-size: 1.2rem; font-weight: 700; color: var(--dim); }
.simon-pads { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; max-width: 460px; }
.simon-pad { aspect-ratio: 1/1; border: none; border-radius: 22px; cursor: pointer; filter: brightness(.55) saturate(1.1);
  transition: filter .12s, transform .08s, box-shadow .12s; }
.simon-pad:active { transform: scale(.96); }
.simon-pad.lit { filter: brightness(1.5) saturate(1.4); box-shadow: 0 0 50px currentColor, 0 0 0 4px #fff inset; }
.simon-pad:disabled { cursor: default; }

/* 8. sweep */
.sweep { gap: 30px; }
.sweep-track { position: relative; width: 92%; max-width: 720px; height: 56px; border-radius: 28px;
  background: linear-gradient(90deg, #2a2a55, #16163a, #2a2a55); border: 1px solid rgba(255,255,255,.12);
  overflow: visible; }
.sweep-center { position: absolute; left: 50%; top: -12px; bottom: -12px; width: 4px; transform: translateX(-50%);
  background: var(--accent2); box-shadow: 0 0 16px var(--accent2); border-radius: 4px; }
.sweep-needle { position: absolute; top: -16px; bottom: -16px; width: 8px; transform: translateX(-50%);
  background: #fff; border-radius: 6px; box-shadow: 0 0 18px #fff; }

/* 9. odd */
.odd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 460px; }
.odd-tile { aspect-ratio: 1/1; border: none; border-radius: 18px; cursor: pointer; transition: transform .08s; }
.odd-tile:active { transform: scale(.96); }
.odd--picked { outline: 4px solid #fff; }

/* 10. final tap race */
.finaltap { gap: 10px; }
.finaltap-count { font-size: clamp(3rem, 16vw, 8rem); font-weight: 900; color: var(--warn); line-height: 1; }
.mash { min-height: 26vh; background: linear-gradient(160deg, #ff5e3a, #b8002e); box-shadow: 0 0 60px rgba(255,94,58,.5); }
.mash:active { filter: brightness(1.3); }
.race { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; max-height: 30vh; }
.race-row { display: grid; grid-template-columns: 80px 1fr 44px; gap: 8px; align-items: center; font-size: .85rem; }
.race-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.race-bar-wrap { background: rgba(255,255,255,.06); border-radius: 8px; height: 18px; overflow: hidden; }
.race-bar { height: 100%; border-radius: 8px; transition: width .2s ease; }
.race-n { text-align: right; font-weight: 700; }

/* ---------- Scoreboard / Final ---------- */
.result { gap: 14px; }
.result-headline { font-size: clamp(1.6rem, 6vw, 3rem); font-weight: 900; text-align: center; max-width: 720px;
  background: linear-gradient(135deg, #fff, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-you { display: flex; gap: 10px; align-items: baseline; }
.you-pts { font-size: 1.6rem; font-weight: 900; color: var(--ok); }
.you-pts.dim { color: var(--dim); }
.you-note { color: var(--dim); }
.next-hint { color: var(--dim); font-style: italic; animation: blink 1.4s infinite; }

.lb { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto; max-height: 50vh; }
.lb-row { display: grid; grid-template-columns: 44px 16px 1fr auto auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.04); }
.lb-row--me { background: rgba(108,92,255,.22); outline: 1px solid var(--accent); }
.lb-rank { color: var(--dim); font-weight: 700; }
.lb-dot { width: 14px; height: 14px; border-radius: 50%; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-delta { color: var(--ok); font-weight: 700; }
.lb-score { font-weight: 900; font-variant-numeric: tabular-nums; }

/* podium */
.final { justify-content: flex-start; gap: 16px; overflow-y: auto; }
.final-title { font-size: clamp(2rem, 8vw, 3.4rem); font-weight: 900; }
.podium { display: flex; align-items: flex-end; gap: 12px; justify-content: center; width: 100%; max-width: 560px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 0; }
.pod-medal { font-size: 2.4rem; }
.pod-dot { width: 20px; height: 20px; border-radius: 50%; }
.pod-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { font-weight: 900; font-size: 1.3rem; }
.pod-stand { width: 100%; border-radius: 12px 12px 0 0; background: linear-gradient(180deg, var(--accent), rgba(108,92,255,.2)); }
.pod--p1 .pod-stand { height: 130px; background: linear-gradient(180deg, var(--warn), rgba(255,176,32,.2)); }
.pod--p2 .pod-stand { height: 92px; }
.pod--p3 .pod-stand { height: 64px; background: linear-gradient(180deg, #c0763a, rgba(192,118,58,.2)); }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.conf { position: absolute; top: -20px; border-radius: 2px; animation-name: fall; animation-timing-function: linear;
  animation-iteration-count: infinite; opacity: .9; }
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .8; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100;
  background: var(--bad); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: toastin .25s ease; max-width: 90vw;
}
@keyframes toastin { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
