:root {
  /* ground */
  --ink: #12142b;
  --ink-panel: #1c2350;
  --ink-panel-2: #262d63;

  /* surfaces */
  --cream: #fdf6e9;
  --navy-text: #232a52;
  --muted: #8992c4;
  --muted-on-cream: #8b8570;

  /* accents — each one does a job, not decoration */
  --gold: #ffb703;      /* marquee / primary / speed-bar mid */
  --gold-ink: #7a4a00;  /* text-safe tone of gold, for on-gold text */
  --coral: #ff6b6b;     /* energy / danger / speed-bar low */
  --green: #22c55e;     /* success / speed-bar high */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Nunito', 'Segoe UI', Verdana, system-ui, sans-serif;
  color: var(--cream);
  background: var(--ink);
  overflow-x: hidden;
}

h1, h2, .question-text, .big-num, .answer-btn, .stat-pill, .mode-name,
.profile-name, .table-chip, .timer-wrap, .streak-wrap, .points-wrap {
  font-family: 'Baloo 2', 'Nunito', system-ui, sans-serif;
}

/* soft marquee glow behind the top of the page, arcade-cabinet style */
.arcade-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(480px 320px at 50% -60px, rgba(255,183,3,.28), transparent 70%),
    radial-gradient(600px 400px at 85% 110%, rgba(34,197,94,.10), transparent 70%),
    radial-gradient(600px 400px at 10% 110%, rgba(255,107,107,.10), transparent 70%);
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 28px 20px 48px;
}
.screen.active { display: flex; }

.title {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  color: var(--gold);
  letter-spacing: .5px;
  text-wrap: balance;
  text-shadow: 0 0 18px rgba(255,183,3,.55), 0 0 4px rgba(255,183,3,.8);
  margin: 6px 0 4px;
  text-align: center;
}
@media (prefers-reduced-motion: no-preference) {
  .title { animation: marquee-glow 3.2s ease-in-out infinite alternate; }
}
@keyframes marquee-glow {
  from { text-shadow: 0 0 18px rgba(255,183,3,.55), 0 0 4px rgba(255,183,3,.8); }
  to   { text-shadow: 0 0 28px rgba(255,183,3,.85), 0 0 8px rgba(255,183,3,1); }
}
.subtitle {
  color: var(--muted);
  font-size: 18px;
  margin-top: 0;
}
.section-heading {
  color: var(--cream);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .75;
  margin: 22px 0 10px;
}

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 14px 26px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  transition: transform .08s ease, box-shadow .08s ease;
  box-shadow: 0 5px 0 rgba(0,0,0,.35);
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn:focus-visible, .answer-btn:focus-visible, .table-chip:focus-visible,
.mode-card:focus-visible, .profile-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.btn-primary { background: var(--green); color: #062e15; }
.btn-secondary { background: var(--gold); color: var(--gold-ink); }
.btn-back {
  align-self: flex-start;
  background: var(--ink-panel-2);
  color: var(--cream);
  padding: 10px 18px;
  font-size: 15px;
  font-family: 'Nunito', sans-serif;
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
}
.btn-back.small { padding: 8px 14px; font-size: 14px; }

/* ---------- profile screen ---------- */
.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  max-width: 640px;
  margin: 18px 0;
}
.profile-card {
  background: var(--cream);
  border-radius: 20px;
  padding: 18px 22px;
  min-width: 120px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
  border: none;
  font-family: inherit;
  position: relative;
}
.profile-card:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.profile-emoji {
  font-size: 34px;
  width: 56px;
  height: 56px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,183,3,.18);
}
.profile-name { font-weight: 700; font-size: 17px; margin-top: 8px; color: var(--navy-text); }
.profile-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.4);
}

.new-profile-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.new-profile-row input {
  border-radius: 14px;
  border: none;
  padding: 12px 16px;
  font-size: 17px;
  font-family: 'Nunito', sans-serif;
  width: 220px;
  background: var(--cream);
  color: var(--navy-text);
  box-shadow: inset 0 0 0 3px var(--ink-panel-2);
}
.new-profile-row input::placeholder { color: var(--muted-on-cream); }

/* ---------- setup screen ---------- */
.stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 6px;
}
.stat-pill {
  background: var(--ink-panel);
  border: 1px solid rgba(255,183,3,.35);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.table-picker {
  display: grid;
  grid-template-columns: repeat(6, 56px);
  gap: 10px;
  justify-content: center;
  max-width: 500px;
}
.table-chip {
  border: 2px solid var(--ink-panel-2);
  border-radius: 14px;
  padding: 10px 0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
}
.table-chip.selected {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--gold-ink);
}

.mode-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.mode-card {
  background: var(--cream);
  border: none;
  border-radius: 20px;
  padding: 18px 24px;
  width: 190px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
  font-family: inherit;
}
.mode-card:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.mode-emoji {
  font-size: 30px;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.mode-emoji--calm  { background: rgba(34,197,94,.16); }
.mode-emoji--brisk { background: rgba(255,107,107,.16); }
.mode-emoji--prize { background: rgba(255,183,3,.22); }
.mode-name { font-weight: 800; font-size: 18px; margin-top: 8px; color: var(--navy-text); }
.mode-desc { font-size: 13px; font-family: 'Nunito', sans-serif; color: var(--muted-on-cream); margin-top: 4px; }

.visual-toggle {
  margin-top: 22px;
  color: var(--muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- game screen ---------- */
.game-topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 10px;
  flex-wrap: wrap;
}
.timer-wrap, .streak-wrap, .points-wrap {
  background: var(--ink-panel);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  color: var(--cream);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.points-wrap { display: none; }

.question-area { text-align: center; margin-bottom: 22px; }
.question-text {
  font-size: clamp(42px, 10vw, 66px);
  font-weight: 800;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}
.speed-bar-wrap {
  display: none;
  width: 220px;
  height: 12px;
  border-radius: 999px;
  background: var(--ink-panel);
  margin: 12px auto 0;
  overflow: hidden;
}
.speed-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .1s linear, background .2s linear;
}
.visual-array {
  display: flex;
  flex-wrap: wrap;
  max-width: 320px;
  gap: 4px;
  justify-content: center;
  margin: 12px auto 0;
  font-size: 20px;
}

.type-answer-wrap {
  display: none;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}
.type-answer-wrap input {
  border: 2px solid var(--ink-panel-2);
  border-radius: 16px;
  padding: 18px 20px;
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  width: 140px;
  background: var(--cream);
  color: var(--navy-text);
  font-family: 'Baloo 2', sans-serif;
}
.type-answer-wrap input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.type-answer-wrap .btn { padding: 18px 26px; font-size: 20px; }

.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 420px;
}
.answer-btn {
  background: var(--cream);
  border: none;
  border-radius: 18px;
  padding: 22px 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--navy-text);
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
}
.answer-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.answer-btn.correct { background: var(--green); color: #062e15; }
.answer-btn.wrong { background: var(--coral); color: #3d0d0d; }

.feedback {
  margin-top: 18px;
  font-size: 20px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--gold);
  min-height: 32px;
  text-align: center;
}

/* ---------- results screen ---------- */
.results-box {
  background: var(--cream);
  border: 2px dashed rgba(35,42,82,.25);
  border-radius: 22px;
  padding: 26px 34px;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0,0,0,.35);
  font-size: 18px;
  font-family: 'Nunito', sans-serif;
  color: var(--navy-text);
  line-height: 1.9;
  min-width: 260px;
}
.results-box .big-num {
  font-size: 42px;
  font-weight: 800;
  color: var(--navy-text);
  font-variant-numeric: tabular-nums;
}
.new-best { color: var(--coral); font-weight: 800; }

.results-buttons {
  display: flex;
  gap: 14px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 420px) {
  .table-picker { grid-template-columns: repeat(4, 56px); }
}
