*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #07070a;
  overscroll-behavior: none;
}

body {
  user-select: none;
  -webkit-user-select: none;
}

button, input, a { -webkit-user-select: none; user-select: none; }

/* Ambient */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 70% at 8% 18%, rgba(124, 58, 237, 0.38), transparent 58%),
    radial-gradient(ellipse 80% 60% at 92% 22%, rgba(34, 211, 238, 0.26), transparent 55%),
    radial-gradient(ellipse 70% 45% at 50% 105%, rgba(168, 85, 247, 0.14), transparent 55%),
    radial-gradient(ellipse 50% 40% at 70% 80%, rgba(6, 182, 212, 0.08), transparent 50%),
    #07070a;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}

.orb-a {
  width: 340px; height: 340px;
  background: #7c3aed;
  top: -80px; left: -60px;
  opacity: 0.62;
  animation: driftA 18s ease-in-out infinite alternate;
}

.orb-b {
  width: 280px; height: 280px;
  background: #06b6d4;
  bottom: 8%; right: -70px;
  opacity: 0.5;
  animation: driftB 22s ease-in-out infinite alternate;
}

.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(168, 85, 247, 0.14) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 24px 24px, 48px 48px, 48px 48px;
  background-position: 0 0, 0 0, 0 0;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 28%, black 20%, transparent 75%);
  opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .orb-a, .orb-b { animation: none; }
}

@keyframes driftA {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 60px) scale(1.15); }
}
@keyframes driftB {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-50px, -30px) scale(1.2); }
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.screen.active { display: block; }

.screen-inner {
  position: relative;
  z-index: 2;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* Typography helpers */
.label-caps {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.52);
}

/* Header */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease-out, background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sound-toggle.active {
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.14);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.3);
}

.sound-toggle.muted {
  color: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.06);
}

/* Hero BPI card */
.hero-card {
  position: relative;
  border-radius: 20px;
  padding: 22px 20px;
  background: linear-gradient(145deg, rgba(26,26,36,0.92), rgba(18,18,24,0.96));
  border: 1px solid rgba(168, 85, 247, 0.15);
  overflow: hidden;
  box-shadow:
    0 20px 50px -18px rgba(124, 58, 237, 0.45),
    0 8px 24px -12px rgba(168, 85, 247, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero-card-glow {
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(168,85,247,0.32), transparent 70%);
  pointer-events: none;
}

.ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.12), transparent 68%),
    rgba(255, 255, 255, 0.03);
  box-shadow:
    0 0 20px -4px rgba(168, 85, 247, 0.45),
    inset 0 0 12px rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.22);
}

.bpi-ring {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.55));
}

.ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: url(#none);
  stroke: #c084fc;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.8));
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.72);
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.35);
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
}

.stat-icon { font-size: 18px; line-height: 1; }
.stat-val { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-lbl { font-size: 10px; color: rgba(255,255,255,0.52); margin-top: 2px; letter-spacing: 0.02em; }

/* Modules */
.modules-section { margin-top: 38px; flex: 1; }

.modules-section .label-caps {
  color: rgba(255, 255, 255, 0.52);
}

.module-grid { display: flex; flex-direction: column; gap: 10px; }

.mod-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(168, 85, 247, 0.15);
  box-shadow:
    0 10px 28px -14px rgba(124, 58, 237, 0.4),
    0 4px 14px -8px rgba(168, 85, 247, 0.22);
  transition: transform 0.2s cubic-bezier(0.22,1,0.36,1), border-color 0.2s, box-shadow 0.2s;
}

.mod-card:active { transform: scale(0.98); }

.mod-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(168,85,247,0.28), rgba(34,211,238,0.16));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow:
    0 0 18px -2px rgba(168, 85, 247, 0.55),
    0 0 10px -2px rgba(34, 211, 238, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.22);
  position: relative;
}

.mod-info { flex: 1; min-width: 0; }
.mod-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.mod-desc { font-size: 12px; color: rgba(255,255,255,0.52); margin-top: 2px; }

.mod-stars-badge {
  font-size: 11px;
  font-weight: 600;
  color: #facc15;
  background: rgba(250, 204, 21, 0.1);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(250, 204, 21, 0.2);
}

.mod-progress-wrap {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mod-progress-bar {
  height: 4px;
  width: 100%;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.mod-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #a855f7, #22d3ee);
  transition: width 0.4s ease;
}

.mod-pts-txt {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.mod-lvl {
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(168, 85, 247, 0.18), rgba(34, 211, 238, 0.08)),
    rgba(12, 12, 16, 0.55);
  border: 1px solid rgba(192, 132, 252, 0.45);
  color: #e9d5ff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 0 14px -2px rgba(168, 85, 247, 0.5),
    inset 0 0 10px rgba(168, 85, 247, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}

/* Level Hub / Tabs & Cards */
.level-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.tab-btn {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(168,85,247,0.3), rgba(34,211,238,0.2));
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25);
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
  padding-bottom: 24px;
}

.level-card {
  position: relative;
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 124px;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.level-card.unlocked {
  background: linear-gradient(145deg, rgba(26,26,36,0.8), rgba(18,18,24,0.9));
  border-color: rgba(168, 85, 247, 0.25);
}

.level-card.unlocked:hover {
  border-color: rgba(168, 85, 247, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -6px rgba(168, 85, 247, 0.35);
}

.level-card.locked {
  opacity: 0.65;
  background: rgba(10, 10, 14, 0.6);
  border-color: rgba(255, 255, 255, 0.04);
}

.lvl-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lvl-card-badge {
  font-size: 13px;
  font-weight: 800;
  color: #c084fc;
  font-variant-numeric: tabular-nums;
}

.lvl-card-stars {
  font-size: 12px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.star-icon {
  font-size: 12px;
  color: #facc15;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
  display: inline-block;
  line-height: 1;
}

.star-icon.dim {
  opacity: 0.22;
  color: rgba(255, 255, 255, 0.3);
  text-shadow: none;
}

.star-icon.active {
  opacity: 1;
  color: #facc15;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
}

.summary-core {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.summary-core svg {
  filter: drop-shadow(0 0 18px rgba(168, 85, 247, 0.55));
}

.lvl-req-pill {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lvl-lock-icon {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.4);
}

.btn-play-lvl {
  margin-top: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, filter 0.2s;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
.btn-play-lvl:active { transform: scale(0.96); }

/* CTA */
.dash-cta {
  margin-top: 24px;
  padding-top: 8px;
}

.cta-hint {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  margin-top: 12px;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 14px 24px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 28%, #7c3aed 58%, #06b6d4 160%);
  background-size: 140% 140%;
  box-shadow:
    0 0 0 1px rgba(192, 132, 252, 0.25),
    0 0 32px -2px rgba(168, 85, 247, 0.65),
    0 10px 28px -6px rgba(124, 58, 237, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.2s, filter 0.2s, background 0.2s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.btn-primary:hover {
  box-shadow:
    0 0 0 1px rgba(192, 132, 252, 0.35),
    0 0 40px 0 rgba(168, 85, 247, 0.75),
    0 12px 32px -6px rgba(124, 58, 237, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  filter: brightness(1.05);
}
.btn-primary:active {
  transform: scale(0.97);
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 45%, #0891b2 160%);
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.35),
    0 0 16px -4px rgba(124, 58, 237, 0.45),
    0 4px 14px -4px rgba(76, 29, 149, 0.55),
    inset 0 2px 6px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  filter: brightness(0.92);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.3);
  box-shadow: none;
}

.btn-ghost {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s ease-out, background 0.2s;
}
.btn-ghost:active { transform: scale(0.97); }

.btn-danger {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(251,113,133,0.3);
  background: rgba(251,113,133,0.15);
  color: #fb7185;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease-out;
}
.btn-danger:active { transform: scale(0.97); }

/* Workout shell */
.workout-shell {
  max-width: 520px;
}

.workout-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.progress-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.12);
  transition: width 0.35s cubic-bezier(0.22,1,0.36,1), background 0.3s;
}

.progress-dots .dot.active {
  width: 24px;
  background: linear-gradient(90deg, #a855f7, #22d3ee);
}

.progress-dots .dot.done {
  background: #34d399;
}

.latency-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 99px;
  background: rgba(34,211,238,0.08);
  border: 1px solid rgba(34,211,238,0.18);
  color: #67e8f9;
  min-width: 78px;
  justify-content: center;
}

.lat-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 8px #22d3ee;
  animation: pulseDot 1.4s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Stage panels */
.stage-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 20px;
}

.stage-panel.hidden { display: none !important; }

.stage-badge {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(168,85,247,0.25), rgba(34,211,238,0.15));
  border: 1px solid rgba(168,85,247,0.3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #c084fc;
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}

.stage-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}

.stage-desc {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(255,255,255,0.5);
  max-width: 300px;
}

.stage-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 24px;
}

.tip-chip {
  padding: 8px 14px;
  border-radius: 99px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

/* Exercise HUD */
.ex-hud {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.hud-item {
  padding: 10px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}

.hud-lbl {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 4px;
}

.hud-val {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Stroop */
.stroop-arena, .spatial-arena, .math-arena {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.instruction-chip {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 20px;
}

.stroop-word {
  font-size: clamp(36px, 12vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  min-height: 1.2em;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s;
}

.timer-bar {
  width: min(260px, 70vw);
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  margin-top: 28px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #a855f7, #22d3ee);
  transform-origin: left center;
  transform: scaleX(1);
}

/* Choice buttons */
.choice-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.choice-btn {
  min-height: 64px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.12s ease-out, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.choice-btn:active:not(:disabled) { transform: scale(0.96); }
.choice-btn:disabled { opacity: 0.55; cursor: default; }

.choice-btn.correct {
  background: rgba(52,211,153,0.18);
  border-color: rgba(52,211,153,0.5);
  color: #34d399;
  box-shadow: 0 0 24px -4px rgba(52,211,153,0.4);
}

.choice-btn.wrong {
  background: rgba(251,113,133,0.15);
  border-color: rgba(251,113,133,0.45);
  color: #fb7185;
}

.choice-btn.color-swatch {
  font-size: 0;
  min-height: 72px;
}

.choice-btn.color-swatch::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 10px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

/* Spatial grid */
.spatial-grid {
  display: grid;
  gap: 10px;
  width: min(300px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
}

.spatial-cell {
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.2s;
  position: relative;
  touch-action: manipulation;
}

.spatial-cell:active:not(.locked) { transform: scale(0.94); }

.spatial-cell.lit {
  background: linear-gradient(135deg, rgba(168,85,247,0.7), rgba(34,211,238,0.55));
  border-color: rgba(255,255,255,0.35);
  box-shadow: 0 0 28px -4px rgba(168,85,247,0.65);
}

.spatial-cell.picked {
  background: rgba(34,211,238,0.35);
  border-color: rgba(34,211,238,0.55);
  box-shadow: 0 0 16px -4px rgba(34,211,238,0.45);
}

.spatial-cell.good {
  background: rgba(52,211,153,0.35);
  border-color: rgba(52,211,153,0.6);
  box-shadow: 0 0 16px -4px rgba(52,211,153,0.5);
}

.spatial-cell.bad {
  background: rgba(251,113,133,0.3);
  border-color: rgba(251,113,133,0.55);
}

.spatial-cell.missed {
  background: rgba(168,85,247,0.2);
  border-color: rgba(168,85,247,0.4);
  outline: 2px dashed rgba(168,85,247,0.5);
  outline-offset: -4px;
}

.spatial-cell.locked { cursor: default; pointer-events: none; }

/* Math / Rule switch */
.rule-banner {
  padding: 10px 20px;
  border-radius: 99px;
  background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(34,211,238,0.12));
  border: 1px solid rgba(168,85,247,0.3);
  margin-bottom: 28px;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), background 0.3s;
}

.rule-banner.switch-pulse {
  background: linear-gradient(135deg, rgba(251,113,133,0.25), rgba(168,85,247,0.2));
  border-color: rgba(251,113,133,0.4);
  transform: scale(1.06);
}

#rule-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c084fc;
}

.math-prompt {
  font-size: clamp(40px, 14vw, 64px);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  min-height: 1.2em;
  line-height: 1.1;
}

.math-choices {
  grid-template-columns: 1fr 1fr;
}

.math-choices.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Feedback flash */
.feedback-flash {
  position: absolute;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.22,1,0.36,1);
  white-space: nowrap;
  z-index: 5;
}

.feedback-flash.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.feedback-flash.ok {
  background: rgba(52,211,153,0.18);
  border: 1px solid rgba(52,211,153,0.35);
  color: #34d399;
}

.feedback-flash.bad {
  background: rgba(251,113,133,0.15);
  border: 1px solid rgba(251,113,133,0.3);
  color: #fb7185;
}

.workout-shell { position: relative; }

/* Summary */
.summary-shell { gap: 0; }

.summary-hero {
  text-align: center;
  padding: 12px 0 24px;
}

.summary-emoji {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 8px 20px rgba(168,85,247,0.4));
}

.summary-bpi {
  border-radius: 18px;
  padding: 18px 20px;
  background: linear-gradient(145deg, rgba(26,26,36,0.92), rgba(18,18,24,0.96));
  border: 1px solid rgba(168, 85, 247, 0.15);
  margin-bottom: 14px;
  box-shadow:
    0 16px 40px -18px rgba(124, 58, 237, 0.4),
    0 6px 18px -10px rgba(168, 85, 247, 0.22);
}

.sum-ring-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.12), transparent 68%),
    rgba(255, 255, 255, 0.03);
  box-shadow:
    0 0 16px -3px rgba(34, 211, 238, 0.45),
    inset 0 0 10px rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.28);
}
.sum-ring {
  width: 56px; height: 56px;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.55));
}
.sum-ring .ring-track { stroke-width: 5; }
.sum-ring .ring-progress { stroke-width: 5; stroke-dasharray: 188.5; stroke-dashoffset: 188.5; stroke: #22d3ee; }

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.metric-card {
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.metric-lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.52);
}

.metric-val {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.metric-val.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 18px;
}

.metric-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
}

.metric-bar {
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  margin-top: 10px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.22,1,0.36,1);
}

.metric-fill.acc {
  background: linear-gradient(90deg, #a855f7, #22d3ee);
}

.module-breakdown { margin-bottom: 18px; }

.break-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.break-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(168,85,247,0.28), rgba(34,211,238,0.14));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow:
    0 0 14px -2px rgba(168, 85, 247, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(192, 132, 252, 0.2);
}

.break-info { flex: 1; min-width: 0; }
.break-name { font-size: 14px; font-weight: 600; }
.break-meta { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.break-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #c084fc;
  font-size: 15px;
}

.lvl-change {
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}
.lvl-change.up { color: #34d399; }
.lvl-change.same { color: rgba(255,255,255,0.3); }

.chart-card {
  border-radius: 16px;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 20px;
}

.chart-wrap {
  position: relative;
  height: 120px;
}

.summary-actions { margin-top: auto; padding-top: 8px; }

/* Sheets & modals — CRITICAL: hidden = display none */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet.hidden { display: none !important; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(78dvh, 640px);
  background: #121218;
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.15);
  margin: 6px auto 14px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-list {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.hist-empty {
  text-align: center;
  padding: 48px 20px;
  color: rgba(255,255,255,0.4);
}

.hist-empty .emoji { font-size: 36px; margin-bottom: 12px; }
.hist-empty p { font-size: 14px; line-height: 1.5; }

.hist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.hist-date {
  font-size: 13px;
  font-weight: 600;
  min-width: 72px;
}

.hist-stats {
  flex: 1;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
}

.hist-bpi {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #c084fc;
  font-size: 14px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.hidden { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 24px;
  border-radius: 20px;
  background: #1a1a24;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  text-align: center;
}

/* Utility */
.tabular-nums { font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }

/* Desktop polish */
@media (min-width: 768px) {
  .screen-inner {
    max-width: 440px;
    padding-top: calc(32px + env(safe-area-inset-top));
  }
  .hero-card { padding: 26px 24px; }
  .choice-btn { min-height: 72px; }
}