:root {
  --bg: #0a0a12;
  --bg-2: #12121f;
  --ink: #f4f4ff;
  --muted: #9a9ab8;
  --accent: #ff2e63;
  --accent-2: #00e5ff;
  --accent-3: #ffd23f;
  --good: #08d9a5;
  --bad: #ff2e63;
  --card: #16162a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255,46,99,0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(0,229,255,0.14), transparent 60%),
    var(--bg);
  position: fixed;
  inset: 0;
}

/* ===== Screens ===== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  text-align: center;
  gap: 20px;
}
.screen.is-active { display: flex; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Phone-only gate ===== */
.gate-msg { font-size: 18px; line-height: 1.5; color: #d8d8ee; max-width: 420px; }
.gate-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.gate-url { color: var(--accent-2); font-weight: 700; font-size: 15px; word-break: break-all; max-width: 90vw; user-select: all; }

/* ===== Start ===== */
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand-logo { font-size: 56px; filter: drop-shadow(0 0 18px rgba(255,210,63,.6)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }
.brand-name {
  font-size: clamp(44px, 14vw, 76px);
  font-weight: 900;
  letter-spacing: -2px;
  line-height: .9;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-name span { background: linear-gradient(90deg, var(--accent-2), #7c5cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag { color: var(--muted); font-weight: 600; letter-spacing: .5px; font-size: 14px; text-transform: uppercase; }
.festive-tag {
  margin-top: 6px; font-size: 13px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(90deg, #ff3b3b 25%, #ffffff 50%, #4a7bff 75%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.rules { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; }
.rule {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07);
  padding: 12px 14px; border-radius: 14px; font-size: 14px; color: #d8d8ee;
}
.rule b { color: var(--ink); }
.rule-ico { font-size: 20px; flex: 0 0 24px; text-align: center; }

.pb { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.pb-value { font-size: 30px; font-weight: 900; color: var(--accent-3); }

.hint { color: var(--muted); font-size: 12px; }
.privacy-note { color: var(--muted); font-size: 11px; text-align: center; max-width: 320px; line-height: 1.4; opacity: .85; }

/* ===== Buttons ===== */
.btn {
  appearance: none; border: 0; cursor: pointer; font-family: inherit;
  font-weight: 800; font-size: 18px; letter-spacing: .5px;
  padding: 16px 28px; border-radius: 999px; color: #fff;
  transition: transform .08s ease, filter .2s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(90deg, var(--accent), #ff6b3d);
  box-shadow: 0 10px 30px rgba(255,46,99,.4), inset 0 1px 0 rgba(255,255,255,.25);
  min-width: 200px;
}
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); }

/* ===== Countdown — drag-race tree ===== */
#screen-countdown { background: radial-gradient(circle at 50% 40%, rgba(0,0,0,.4), transparent 70%); }
.tree {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 22px 26px; border-radius: 28px;
  background: #07070d; border: 2px solid rgba(255,255,255,.08);
  box-shadow: inset 0 0 40px rgba(0,0,0,.7);
}
.bulb {
  width: clamp(64px, 20vw, 96px); aspect-ratio: 1; border-radius: 50%;
  background: #14141f; border: 2px solid rgba(255,255,255,.06);
  transition: background .04s linear, box-shadow .04s linear;
}
.bulb.amber.lit {
  background: radial-gradient(circle at 38% 35%, #ffd98a, #ff9b1e 55%, #b35e00);
  box-shadow: 0 0 28px 6px rgba(255,160,30,.8);
}
.bulb.green.lit {
  background: radial-gradient(circle at 38% 35%, #b6ffd0, #08d96a 55%, #047a3a);
  box-shadow: 0 0 40px 10px rgba(8,217,106,.9);
}
.countdown-label { color: var(--muted); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }

/* ===== Game ===== */
#screen-game { padding: 0; justify-content: flex-start; gap: 0; }
.hud {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 24px; z-index: 5; pointer-events: none;
}
.hud-taps, .hud-timer { display: flex; flex-direction: column; align-items: center; }
.hud span { font-size: 40px; font-weight: 900; line-height: 1; }
.hud-taps span { color: var(--accent-2); }
.hud-timer span { color: var(--accent-3); font-variant-numeric: tabular-nums; }
.hud small { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }

.timebar { position: absolute; top: 0; left: 0; right: 0; height: 6px; background: rgba(255,255,255,.08); z-index: 6; }
.timebar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--accent-3), var(--accent)); transform-origin: left; }

.tap-area {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.tap-prompt {
  font-size: clamp(60px, 22vw, 140px); font-weight: 900; letter-spacing: -3px;
  color: rgba(255,255,255,.06); pointer-events: none; transition: opacity .2s;
}
.tap-area.is-hot { background: radial-gradient(circle at 50% 50%, rgba(0,229,255,.06), transparent 70%); }

/* Firework particle overlay — drawn above taps, below the HUD; ignores input */
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }

.ripple {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; pointer-events: none; z-index: 3;
  background: radial-gradient(circle, var(--accent-2), rgba(0,229,255,0));
  animation: ripple .45s ease-out forwards;
}
@keyframes ripple { from { transform: scale(1); opacity: .9; } to { transform: scale(9); opacity: 0; } }

.flash-bust { animation: flashbust .25s ease; }
@keyframes flashbust { 0%,100% { background-color: transparent; } 50% { background-color: rgba(255,46,99,.5); } }

/* ===== Results ===== */
#screen-results { justify-content: center; gap: 14px; overflow-y: auto; }
.results-card {
  position: relative; overflow: hidden; width: 100%; max-width: 420px;
  background: #0a0a16;
  border: 1px solid rgba(255,255,255,.08); border-radius: 24px;
  padding: 18px 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
/* Heatmap fills the card as a background; a scrim keeps overlaid text readable. */
.results-card::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(8,8,18,.74), rgba(8,8,18,.40) 46%, rgba(8,8,18,.88));
}
.results-head, .dotline { position: relative; z-index: 2; }
/* Busted / no-score verdict card — no stats, no share */
.busted-card {
  width: 100%; max-width: 420px; text-align: center;
  background: linear-gradient(160deg, #2a0f1a, #14060c);
  border: 1px solid rgba(255,46,99,.35); border-radius: 24px;
  padding: 40px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.busted-card.neutral {
  background: linear-gradient(160deg, var(--card), #0e0e1c);
  border-color: rgba(255,255,255,.10);
}
.busted-big {
  font-size: clamp(48px, 16vw, 80px); font-weight: 900; letter-spacing: 2px;
  color: var(--bad); text-shadow: 0 0 24px rgba(255,46,99,.5);
}
.busted-card.neutral .busted-big { color: var(--muted); text-shadow: none; }
.busted-reason { margin-top: 10px; font-size: 17px; font-weight: 700; color: var(--ink); }
.busted-tip { margin-top: 14px; font-size: 13px; color: var(--muted); }
.results-head { text-align: center; margin-bottom: 14px; }
.results-grade {
  display: inline-block; font-size: 13px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; color: var(--bg); background: var(--accent-3);
  padding: 4px 12px; border-radius: 999px;
}
.results-score { font-size: 64px; font-weight: 900; line-height: 1; margin-top: 8px; }
.results-score small { font-size: 18px; color: var(--muted); font-weight: 700; margin-left: 6px; }

/* Click heatmap — fills the whole card as a background layer */
.heatmap-canvas {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Tap-rhythm dot timeline — three timing stats annotate one graph */
.dotline {
  background: rgba(8,8,18,.5); border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px; padding: 14px 16px 12px; backdrop-filter: blur(2px);
}
.dotline-stats { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dl-stat { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.dl-stat.dl-mid { align-items: center; }
.dl-stat.dl-end { align-items: flex-end; }
.dl-key { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.dl-val { font-size: 24px; font-weight: 900; color: #fff; line-height: 1.1; white-space: nowrap; }
.dotline-canvas { width: 100%; height: 56px; display: block; }
.dotline-axis {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}

/* Primary = Share the video (the viral asset); Image + Again are smaller secondaries */
.results-actions { display: flex; width: 100%; max-width: 420px; }
.results-actions .btn { flex: 1 1 0; min-width: 0; }
.btn-share-main { font-size: 19px; padding: 18px; }
.results-actions-sub { display: flex; gap: 9px; width: 100%; max-width: 420px; margin-top: 9px; }
.results-actions-sub .btn { flex: 1 1 0; min-width: 0; padding: 12px 8px; font-size: 14px; }
.btn-gif { background: rgba(0,229,255,.14); border: 1px solid rgba(0,229,255,.42); color: #d6f3ff; }
.btn[disabled] { opacity: .6; }

/* GIF preview modal */
.gif-modal {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,4,10,.9); padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.gif-modal[hidden] { display: none; }
.gif-modal-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gif-preview {
  width: 100%; max-width: 320px; aspect-ratio: 1; object-fit: contain;
  border-radius: 18px; border: 1px solid rgba(255,255,255,.12); background: #0a0a16;
}
.clip-stage {
  width: 100%; max-width: 320px; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px; border: 1px solid rgba(255,255,255,.08); background: #0a0a16;
}
.clip-stage .gif-preview { border: 0; }
.clip-prog {
  position: relative; width: 82%; height: 14px;
  background: rgba(255,255,255,.10); border-radius: 999px;
  box-shadow: inset 0 0 8px rgba(0,0,0,.55);
}
.clip-prog-bar {
  position: relative; height: 100%; width: 0%; min-width: 14px; border-radius: 999px;
  background: linear-gradient(90deg, #ff2e63, #ffd23f, #08d96a, #00e5ff, #7c5cff);
  background-size: 280% 100%;
  animation: progShift 1.1s linear infinite;
  box-shadow: 0 0 12px rgba(0,229,255,.55);
  transition: width .14s linear;
}
@keyframes progShift { from { background-position: 0 0; } to { background-position: 280% 0; } }
.clip-spark {
  position: absolute; right: -3px; top: 50%; width: 18px; height: 18px;
  transform: translateY(-50%); border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255,255,255,.6) 35%, rgba(255,255,255,0) 70%);
  box-shadow: 0 0 16px 5px rgba(255,255,255,.85), 0 0 26px 8px rgba(0,229,255,.5);
  animation: sparkPulse .55s ease-in-out infinite;
}
@keyframes sparkPulse {
  0%, 100% { opacity: .8; transform: translateY(-50%) scale(.8); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.2); }
}
.gif-hint { color: var(--muted); font-size: 13px; text-align: center; }
.gif-modal-actions { display: flex; gap: 10px; width: 100%; }
.gif-modal-actions .btn { flex: 1 1 0; min-width: 0; padding: 14px 8px; font-size: 15px; }
.gif-modal-actions .clip-icon { flex: 0 0 54px; font-size: 20px; padding: 14px 0; }
