:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-2: #06060a;
  --panel: #14141a;
  --panel-2: #1a1a22;
  --border: #25252f;
  --text: #ececf1;
  --muted: #9ba1a6;
  --ai: #ff3d71;             /* punchy magenta-red */
  --real: #2c97ff;           /* punchy cyan-blue */
  --good: #00e680;           /* neon green */
  --bad: #ff3d71;
  --accent-1: #e040fb;       /* magenta */
  --accent-2: #00e5ff;       /* cyan */
  --accent-3: #ffdd00;       /* yellow */
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(224, 64, 251, 0.10), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(0, 229, 255, 0.08), transparent 60%),
    var(--bg);
}

* { box-sizing: border-box; }
/* Make sure the [hidden] HTML attribute always wins over our flex / grid
   display rules — without this, the cheat overlay (display: flex) would
   show on first paint regardless of its hidden attribute. */
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

button {
  font: inherit; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 8px;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
button:hover { background: #24242f; border-color: #34344a; }
button:active { transform: translateY(1px); }
@keyframes gradient-flow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes btn-glow {
  0%, 100% {
    box-shadow:
      0 6px 22px rgba(224, 64, 251, 0.40),
      0 0 24px rgba(224, 64, 251, 0.30),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0, 229, 255, 0.55),
      0 0 36px rgba(0, 229, 255, 0.40),
      inset 0 1px 0 rgba(255, 255, 255, 0.26);
  }
}
button.primary {
  background: linear-gradient(
    115deg,
    var(--accent-1) 0%,
    var(--real) 30%,
    var(--accent-2) 55%,
    var(--accent-1) 80%,
    var(--real) 100%
  );
  background-size: 240% 240%;
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: gradient-flow 5s ease-in-out infinite, btn-glow 3.2s ease-in-out infinite;
}
button.primary:hover {
  filter: brightness(1.10);
  animation-duration: 2.5s, 1.6s;
}

/* Submit-button states tied to the player's progress: brighter & bigger
   when partially marked, even bigger plus a green blink when every tile
   is marked. updateSubmitState() toggles these classes. */
button.primary.primed {
  transform: scale(1.06);
  filter: brightness(1.14) saturate(1.18);
}
button.primary.primed-full {
  transform: scale(1.13);
  filter: brightness(1.26) saturate(1.30);
  animation:
    gradient-flow 4s ease-in-out infinite,
    primed-blink 0.7s ease-in-out infinite;
}
@keyframes primed-blink {
  0%, 100% {
    box-shadow:
      0 14px 42px rgba(0, 230, 128, 0.72),
      0 0 38px rgba(0, 230, 128, 0.55),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
  50% {
    box-shadow:
      0 6px 20px rgba(0, 230, 128, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.18);
  }
}
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.big { padding: 14px 28px; font-size: 17px; }
button.huge {
  padding: 20px 44px;
  font-size: 22px;
  letter-spacing: 0.04em;
  font-weight: 800;
  border-radius: 14px;
}

/* Full neon-rainbow variant: cycles magenta -> green -> cyan -> yellow ->
   magenta in both the gradient fill and the surrounding glow. Used on the
   end-of-game 'Play again' button. */
@keyframes neon-rainbow-flow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
@keyframes neon-rainbow-glow {
  0%, 100% {
    box-shadow:
      0 10px 30px rgba(224, 64, 251, 0.60),
      0 0 36px rgba(224, 64, 251, 0.45),
      0 0 72px rgba(224, 64, 251, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
  25% {
    box-shadow:
      0 10px 30px rgba(0, 230, 128, 0.55),
      0 0 36px rgba(0, 230, 128, 0.42),
      0 0 72px rgba(0, 230, 128, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
  50% {
    box-shadow:
      0 10px 30px rgba(0, 229, 255, 0.62),
      0 0 36px rgba(0, 229, 255, 0.48),
      0 0 72px rgba(0, 229, 255, 0.30),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
  75% {
    box-shadow:
      0 10px 30px rgba(255, 221, 0, 0.55),
      0 0 36px rgba(255, 221, 0, 0.42),
      0 0 72px rgba(255, 221, 0, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
}
button.primary.neon {
  background: linear-gradient(
    115deg,
    var(--accent-1) 0%,
    var(--good) 25%,
    var(--accent-2) 50%,
    var(--accent-3) 75%,
    var(--accent-1) 100%
  );
  background-size: 300% 300%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  animation: neon-rainbow-flow 6s linear infinite, neon-rainbow-glow 3.6s ease-in-out infinite;
  position: relative;
}
button.primary.neon:hover {
  filter: brightness(1.12) saturate(1.15);
  animation-duration: 3s, 1.8s;
}
/* Outer ring glow that pulses with the gradient. */
button.primary.neon::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: inherit;
  background-size: inherit;
  filter: blur(14px);
  opacity: 0.45;
  z-index: -1;
  animation: neon-rainbow-flow 6s linear infinite;
}

input[type="text"], input:not([type]) {
  font: inherit;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px;
  width: 80px; text-transform: uppercase; letter-spacing: 0.1em;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  background: rgba(12, 12, 17, 0.92); backdrop-filter: blur(10px);
}
.topbar > .brand { justify-self: start; }
.topbar > .hud { justify-self: center; }
.topbar > .home-btn { justify-self: end; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.brand .dot.ai { background: var(--ai); }
.brand .dot.real { background: var(--real); }

.home-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.home-btn:hover { color: var(--text); border-color: var(--accent-1); }

.hud { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.hud .lbl { color: #5f5f6a; margin-right: 4px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.hud span span { color: var(--text); font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; font-family: "SF Mono", ui-monospace, Menlo, monospace; }
#hud-time.urgent { color: #f0a73b; }
#hud-time.over { color: var(--bad); animation: pulseRed 0.8s infinite; }
@keyframes pulseRed {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

main { max-width: 1280px; margin: 0 auto; padding: 24px 24px 64px; }

h1 { font-size: 30px; letter-spacing: -0.01em; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 32px 0 12px; }

.lede { font-size: 16px; color: var(--text); max-width: 720px; }
.lede .chip { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 700; vertical-align: 1px; letter-spacing: 0.04em; }
.chip.ai { background: var(--ai); color: #fff; }
.chip.real { background: var(--real); color: #fff; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.actions { margin-top: 18px; display: flex; gap: 12px; align-items: center; }
.actions.center { justify-content: center; }

.legend { color: var(--muted); display: flex; gap: 24px; font-size: 13px; }
.legend .chip { vertical-align: 0; }

.play-header { margin-bottom: 12px; }
#level-title { margin-top: 0; margin-bottom: 4px; }
#level-blurb { margin: 0 0 6px; }
.legend { margin: 6px 0 0; }

/* Play screen layout — center everything horizontally so the round
   header doesn't read as left-shifted relative to the grid. */
.play-screen { display: flex; flex-direction: column; align-items: center; }
.play-screen .grid { width: 100%; max-width: 960px; }
.play-screen .actions.center { justify-content: center; width: 100%; }

/* Round hero: banner image + gradient overlay + round title. */
.round-hero {
  position: relative;
  width: 100%;
  max-width: 960px;
  height: clamp(180px, 26vh, 320px);
  border-radius: 18px;
  overflow: hidden;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.round-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.04);  /* subtle ken-burns offset, gives shadow room */
  transition: transform 0.6s ease;
}
.round-hero:hover img { transform: scale(1.06); }
.round-hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px 28px 20px;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 11, 0.0) 0%,
    rgba(10, 10, 11, 0.55) 55%,
    rgba(10, 10, 11, 0.92) 100%
  );
}
.round-title {
  margin: 0 0 4px;
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: -0.01em;
  background: linear-gradient(
    90deg,
    var(--accent-3) 0%,
    var(--accent-1) 35%,
    var(--accent-2) 70%,
    var(--accent-3) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradient-flow 7s ease-in-out infinite, text-glow-pulse 3.6s ease-in-out infinite;
}
.round-hero-overlay p { margin: 0; max-width: 760px; }

/* Per-round accent — subtle tinted glow on the hero. */
.round-hero[data-round="1"] { box-shadow: 0 14px 40px rgba(255, 221, 0, 0.18), 0 14px 40px rgba(0, 0, 0, 0.55); }
.round-hero[data-round="2"] { box-shadow: 0 14px 40px rgba(44, 151, 255, 0.22), 0 14px 40px rgba(0, 0, 0, 0.55); }
.round-hero[data-round="3"] { box-shadow: 0 14px 40px rgba(0, 230, 128, 0.20), 0 14px 40px rgba(0, 0, 0, 0.55); }
.round-hero[data-round="4"] { box-shadow: 0 14px 40px rgba(224, 64, 251, 0.28), 0 14px 40px rgba(0, 0, 0, 0.55); }

.grid {
  display: grid;
  /* Always exactly 5 columns. minmax(0, 1fr) lets tiles shrink to fit narrow
     screens instead of overflowing. */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

/* Keyboard-selected tile gets a bright neon outline + glow so users
   always know which one R/F will mark. */
.tile.selected {
  outline: 3px solid var(--accent-2);
  outline-offset: -3px;
  z-index: 1;
  box-shadow: 0 0 0 6px rgba(0, 229, 255, 0.18), 0 8px 24px rgba(0, 229, 255, 0.18);
}

/* Inline keyboard-key hint chips. */
kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--text);
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  margin: 0 2px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
/* Lights up green when at least one tile is marked, telling the player
   Enter is now an option. */
@keyframes kbd-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(0, 230, 128, 0.55); }
  50%      { box-shadow: 0 0 22px rgba(0, 230, 128, 0.85); }
}
kbd.hot {
  background: var(--good);
  color: #07140d;
  border-color: rgba(0, 230, 128, 0.6);
  font-weight: 700;
  animation: kbd-pulse 1.6s ease-in-out infinite;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--panel);
  border-radius: 10px;
  border: 3px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
  user-select: none;
}
.tile:hover { transform: scale(1.015); border-color: #45455a; }
.tile.mark-real { border-color: var(--real); }
.tile.mark-ai { border-color: var(--ai); }

.tile.locked-correct { cursor: default; }
.tile.locked-correct:hover { transform: none; }
.tile.flash-wrong { animation: flashWrong 0.6s ease-out; }
@keyframes flashWrong {
  0%, 100% { border-color: var(--border); }
  20%, 60% { border-color: var(--bad); }
}

.tile img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  pointer-events: none;
}

.tile .badge {
  position: absolute; right: 6px; bottom: 6px;
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: #fff; pointer-events: none;
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.tile.mark-real .badge.real { display: block; }
.tile.mark-ai .badge.ai { display: block; }
.tile .badge { display: none; }
.badge.real { background: var(--real); }
.badge.ai { background: var(--ai); }
.badge.locked { background: var(--good); }

.tile .lock-tick {
  position: absolute; left: 6px; top: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--good);
  display: none;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.tile.locked-correct .lock-tick { display: flex; }

.status { color: var(--muted); font-size: 13px; }

.records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 8px auto 28px;
}
.record {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.record::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 14px;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0.45;
  pointer-events: none;
}
.record-icon { font-size: 28px; line-height: 1; margin-bottom: 4px; }
.record-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.record-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.record-by { margin-top: 4px; }

.leaderboards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}
.lb h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.04em; }
.lb-empty { padding: 8px 12px; }
@media (max-width: 720px) {
  .records { grid-template-columns: 1fr; }
  .leaderboards { grid-template-columns: 1fr; }
}

.scores {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.scores th, .scores td { padding: 8px 12px; text-align: left; }
.scores thead th {
  background: var(--panel-2); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.scores tbody tr { border-top: 1px solid var(--border); }
.scores tbody tr.you { background: rgba(46, 201, 139, 0.08); }
.scores td.score { font-variant-numeric: tabular-nums; font-weight: 600; }

.big-score { font-size: 36px; font-variant-numeric: tabular-nums; }
.save-row { margin: 16px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
#start .scores { margin: 0 auto; }

/* Swipe-mode play screen. */
.swipe-screen { display: flex; flex-direction: column; align-items: center; }
.swipe-screen .round-hero { width: 100%; max-width: 720px; }
.card-stack {
  position: relative;
  width: min(360px, 92vw);
  aspect-ratio: 1 / 1;
  margin: 16px auto 8px;
  perspective: 1200px;
}
.card {
  position: absolute;
  inset: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  will-change: transform;
}
.card:nth-child(1) { z-index: 3; }
.card:nth-child(2) { z-index: 2; transform: translateY(10px) scale(0.96); opacity: 0.85; }
.card:nth-child(3) { z-index: 1; transform: translateY(20px) scale(0.92); opacity: 0.65; }
.card.dragging { transition: none; cursor: grabbing; }
.card.swiped-real {
  transform: translateX(-130vw) rotate(-26deg) !important;
  opacity: 0;
}
.card.swiped-ai {
  transform: translateX(130vw) rotate(26deg) !important;
  opacity: 0;
}
/* Per-swipe right/wrong feedback so the player can pin a +1 on a swipe. */
.card.swiped-correct {
  box-shadow:
    0 0 0 6px var(--good),
    0 0 60px rgba(0, 230, 128, 0.85);
}
.card.swiped-wrong {
  box-shadow:
    0 0 0 6px var(--bad),
    0 0 60px rgba(255, 61, 113, 0.85);
}
/* A floating verdict badge on the card itself, in case the glow is missed. */
.card.swiped-correct::before, .card.swiped-wrong::before {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  color: #fff;
  z-index: 10;
  pointer-events: none;
}
.card.swiped-correct::before {
  content: "✓ RIGHT";
  background: rgba(0, 230, 128, 0.85);
}
.card.swiped-wrong::before {
  content: "✗ WRONG";
  background: rgba(255, 61, 113, 0.85);
}
.card img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  pointer-events: none;
}
.card-overlay {
  position: absolute;
  top: 28px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.08em;
  border: 4px solid;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 14px rgba(0, 0, 0, 0.55);
  transition: opacity 0.10s;
}
.card-overlay-real {
  left: 22px;
  color: #fff;
  border-color: var(--real);
  background: rgba(44, 151, 255, 0.22);
  transform: rotate(-14deg);
  box-shadow: 0 0 24px rgba(44, 151, 255, 0.55);
}
.card-overlay-ai {
  right: 22px;
  color: #fff;
  border-color: var(--ai);
  background: rgba(255, 61, 113, 0.22);
  transform: rotate(14deg);
  box-shadow: 0 0 24px rgba(255, 61, 113, 0.55);
}

.swipe-actions {
  display: flex; gap: 18px;
  margin: 14px 0 6px;
}
.swipe-btn {
  font-size: 15px;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 2px solid;
  background: transparent;
}
.swipe-btn.swipe-real-btn {
  border-color: var(--real);
  color: var(--real);
}
.swipe-btn.swipe-real-btn:hover {
  background: rgba(44, 151, 255, 0.15);
  box-shadow: 0 0 18px rgba(44, 151, 255, 0.4);
}
.swipe-btn.swipe-ai-btn {
  border-color: var(--ai);
  color: var(--ai);
}
.swipe-btn.swipe-ai-btn:hover {
  background: rgba(255, 61, 113, 0.15);
  box-shadow: 0 0 18px rgba(255, 61, 113, 0.4);
}

/* Cheat-lockout overlay. */
.cheat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.cheat-card {
  background: var(--panel);
  border: 1px solid var(--ai);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(255, 61, 113, 0.45);
}
.cheat-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  background: linear-gradient(90deg, var(--ai), var(--accent-1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cheat-card p { margin: 0 0 8px; }
.cheat-emoji {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 12px rgba(255, 61, 113, 0.5));
}
.cheat-card button { margin-top: 16px; }

/* Per-level done + final screens — center everything horizontally. */
#level-done, #finish, #start, #rules { display: flex; flex-direction: column; align-items: center; text-align: center; }
#rules { max-width: 720px; margin: 0 auto; }
#rules h1 { margin: 8px 0 16px; }
#rules h2 { margin: 28px 0 8px; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; }
.rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rules-list li {
  padding: 12px 16px 12px 38px;
  position: relative;
  border-top: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}
.rules-list li:first-child { border-top: 0; }
.rules-list li::before {
  content: "▸";
  position: absolute;
  left: 14px;
  top: 12px;
  color: var(--accent-2);
  font-weight: 700;
}
.rules-rounds .round-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent-1);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.check input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-color: transparent;
}
.check input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}
#level-done .stat-list, #finish .stat-list { margin-left: auto; margin-right: auto; }
#level-done .actions, #finish .actions { width: 100%; justify-content: center; }
#start .lede, #finish .lede, #level-done .lede { max-width: 720px; }

/* Start screen splash hero — wide REAL/AI banner that fades out when the
   player clicks Start. */
.start-hero {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto 24px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow:
    0 24px 60px rgba(224, 64, 251, 0.22),
    0 24px 60px rgba(0, 229, 255, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: opacity 0.55s ease, max-height 0.55s ease,
              margin 0.55s ease, transform 0.55s ease;
  max-height: 600px;
  transform: scale(1);
}
.start-hero img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.25s;
}
.start-hero.swapping img { opacity: 0; }

/* Glowing purple mode-cycle arrows pinned to the splash banner edges. */
@keyframes mode-arrow-pulse {
  0%, 100% {
    box-shadow:
      0 0 22px rgba(224, 64, 251, 0.55),
      inset 0 0 14px rgba(224, 64, 251, 0.30);
  }
  50% {
    box-shadow:
      0 0 38px rgba(224, 64, 251, 1.00),
      inset 0 0 22px rgba(224, 64, 251, 0.45);
  }
}
.mode-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: rgba(20, 16, 32, 0.65);
  border: 2px solid var(--accent-1);
  color: var(--accent-1);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  z-index: 5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mode-arrow-pulse 2.4s ease-in-out infinite;
  transition: background 0.18s, transform 0.12s, color 0.18s;
  text-shadow: 0 0 12px rgba(224, 64, 251, 0.85);
}
.mode-arrow:hover {
  background: rgba(50, 30, 80, 0.85);
  color: #fff;
  transform: translateY(-50%) scale(1.08);
}
.mode-arrow-left { left: 16px; }
.mode-arrow-right { right: 16px; }

.mode-hint {
  text-align: center;
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.mode-hint kbd { background: rgba(224, 64, 251, 0.12); border-color: rgba(224, 64, 251, 0.4); color: var(--accent-1); }
.start-hero.fade-out {
  opacity: 0;
  transform: scale(0.985);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-width: 0;
  pointer-events: none;
}

@keyframes text-glow-pulse {
  0%, 100% { filter: drop-shadow(0 2px 14px rgba(224, 64, 251, 0.35)); }
  50%      { filter: drop-shadow(0 2px 22px rgba(0, 229, 255, 0.55)); }
}
.cheer {
  font-size: 38px;
  margin: 0 0 18px;
  background: linear-gradient(
    90deg,
    var(--good) 0%,
    var(--accent-2) 30%,
    var(--accent-1) 60%,
    var(--good) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradient-flow 6s ease-in-out infinite, text-glow-pulse 3.2s ease-in-out infinite;
}
.stat-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 24px;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.stat-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.stat-list li:first-child { border-top: 0; }
.stat-list li.divider { padding: 0; height: 4px; background: var(--panel-2); }
.stat-list .stat-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-list strong { font-variant-numeric: tabular-nums; font-size: 17px; }

/* Round 5: twin-pair round. We reuse #grid as the container and switch
   from the 5-column tile grid to 2 columns of bigger tiles. The DOM is
   flat (tiles directly), so keyboard navigation flows naturally. */
.grid.twin-pair {
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 720px;
}
.grid.twin-pair .tile {
  aspect-ratio: 1;
}
@media (max-width: 540px) {
  .grid.twin-pair { max-width: 100%; gap: 10px; }
}

/* ---------- mobile fit ----------------------------------------------------
   Phones can't read 5-wide thumbnails of nature photos at ~50px each — drop
   to 3 columns so each tile is large enough to spot AI tells. Also shrink
   page chrome (padding, hero, HUD) so the play surface dominates. */
@media (max-width: 720px) {
  main { padding: 12px 12px 48px; }
  .topbar { padding: 10px 14px; }
  .brand strong { font-size: 14px; }
  .hud { gap: 10px; font-size: 11px; flex-wrap: wrap; }
  .hud .lbl { font-size: 10px; }
  .round-hero { height: clamp(120px, 18vh, 200px); margin-bottom: 12px; }
  .round-hero-overlay { padding: 12px 14px; }
  .round-title { font-size: clamp(18px, 5vw, 24px); }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .tile { border-width: 2px; }
  .tile .badge { font-size: 9px; padding: 1px 4px; }
  .tile .lock-tick { width: 18px; height: 18px; font-size: 12px; }
  /* Hide the lower-priority HUD entries to keep the topbar on one line. */
  .hud span:nth-child(3), .hud span:nth-child(4) { display: none; }
}

/* Show the mobile hint only on coarse-pointer devices, swap with the
   keyboard-centric desktop legend. */
.mobile-only { display: none; }
@media (pointer: coarse), (max-width: 720px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
}

/* ---------- gradient polish ---------------------------------------------
   Pour the same magenta/cyan/yellow neon palette into the numerals that
   carry the most weight on the screen: round-done stat values, world-record
   numbers, the running HUD score, and the final score. */
.stat-list strong,
.record-value,
#hud-total-score,
.big-score {
  background: linear-gradient(
    115deg,
    var(--accent-3) 0%,
    var(--accent-1) 35%,
    var(--accent-2) 70%,
    var(--accent-3) 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: gradient-flow 6s ease-in-out infinite;
}
.big-score {
  filter: drop-shadow(0 2px 18px rgba(0, 229, 255, 0.45));
}
#hud-total-score {
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Tile borders: when a tile is marked, ramp the border into a tinted gradient
   instead of a solid color so the play surface stays lively. */
.tile.mark-real {
  border-image: linear-gradient(135deg, var(--real), var(--accent-2)) 1;
}
.tile.mark-ai {
  border-image: linear-gradient(135deg, var(--ai), var(--accent-1)) 1;
}
.tile.locked-correct {
  box-shadow: 0 0 0 2px rgba(0, 230, 128, 0.18), 0 6px 18px rgba(0, 230, 128, 0.18);
}

/* Subtle topbar gradient — barely-there magenta→cyan wash so the brand row
   doesn't feel flat against the gradient body. */
.topbar {
  background: linear-gradient(
    90deg,
    rgba(224, 64, 251, 0.06) 0%,
    rgba(12, 12, 17, 0.92) 25%,
    rgba(12, 12, 17, 0.92) 75%,
    rgba(0, 229, 255, 0.06) 100%
  );
}
