/* ==========================================================================
   Math Facts Master — core styles
   Mobile-first, no framework, no external assets.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;

  --bg: #0f1c3f;
  --bg-deep: #071027;
  --bg-soft: #16264f;
  --surface: rgba(24, 42, 82, 0.78);
  --surface-solid: #172a52;
  --surface-raised: rgba(32, 54, 102, 0.92);
  --surface-hover: rgba(44, 72, 134, 0.95);
  --line: rgba(148, 178, 232, 0.2);
  --line-strong: rgba(148, 178, 232, 0.4);

  --text: #f4f7ff;
  --text-muted: #a9b8d8;
  --text-dim: #7f90b5;
  --text-inverse: #0a1428;

  --primary: #4a90e2;
  --primary-strong: #2f76c9;
  --primary-soft: rgba(74, 144, 226, 0.18);
  /* Solid action buttons use a darker shade so white label text passes AA. */
  --btn-primary: #2f76c9;
  --btn-primary-hover: #2563a8;
  --success: #7ed321;
  --success-soft: rgba(126, 211, 33, 0.16);
  --warning: #f5a623;
  --warning-soft: rgba(245, 166, 35, 0.16);
  --danger: #ff5c74;
  --danger-strong: #d0021b;
  --danger-soft: rgba(255, 92, 116, 0.14);
  --gold: #ffd93d;
  --gold-soft: rgba(255, 217, 61, 0.14);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.16);
  --pink: #ff7bac;
  --pink-soft: rgba(255, 123, 172, 0.16);

  --zone-add: #4a90e2;
  --zone-sub: #7ed321;
  --zone-mult: #f5a623;
  --zone-div: #a78bfa;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(2, 8, 22, 0.28);
  --shadow: 0 12px 32px rgba(2, 8, 22, 0.34);
  --shadow-lg: 0 24px 64px rgba(2, 8, 22, 0.46);
  --glow-blue: 0 0 0 1px rgba(74, 144, 226, 0.3), 0 14px 36px rgba(74, 144, 226, 0.22);
  --glow-gold: 0 0 24px rgba(255, 217, 61, 0.35);

  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system,
    sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --app-width: 760px;
  --tap: 48px;
  --ease: cubic-bezier(0.22, 0.9, 0.24, 1);
}

html {
  height: 100%;
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -20%, rgba(74, 144, 226, 0.22), transparent 60%),
    radial-gradient(800px 500px at 100% 115%, rgba(167, 139, 250, 0.16), transparent 65%),
    radial-gradient(600px 400px at 0% 100%, rgba(126, 211, 33, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255, 255, 255, 0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 9%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 84% 36%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 44%, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 72%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 82%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 92% 88%, rgba(255, 255, 255, 0.4) 50%, transparent 51%);
  opacity: 0.8;
  z-index: 0;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.14;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.65rem, 6vw, 2.4rem);
  font-weight: 800;
}

h2 {
  font-size: clamp(1.25rem, 4.5vw, 1.65rem);
  font-weight: 750;
}

h3 {
  font-size: 1.08rem;
  font-weight: 700;
}

a {
  color: var(--primary);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--gold);
  color: var(--text-inverse);
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------ utilities ------------------------------ */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--gold);
  color: var(--text-inverse);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: calc(12px + var(--safe-top));
}

.muted {
  color: var(--text-muted);
}

.center {
  text-align: center;
}

.stack {
  display: grid;
  gap: 12px;
}

.icon {
  display: inline-flex;
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
}

/* -------------------------------- shell -------------------------------- */

.app {
  position: relative;
  z-index: 1;
  width: min(100%, var(--app-width));
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(var(--safe-top) + 12px)
    calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 40px)
    calc(var(--safe-left) + 16px);
  outline: none;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: screen-in 0.32s var(--ease) both;
}

.section-title {
  margin-top: 4px;
  font-size: 1.1rem;
  color: var(--text);
}

.page-header {
  display: grid;
  gap: 8px;
  padding: 4px 2px 2px;
}

.page-header h1 {
  margin-top: 2px;
}

.page-subtitle {
  max-width: 46rem;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ------------------------------- buttons ------------------------------- */

.btn {
  display: inline-flex;
  min-height: var(--tap);
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--btn-primary);
  color: #fff;
  font-weight: 750;
  font-size: 1rem;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(74, 144, 226, 0.3);
  transition:
    transform 0.16s var(--ease),
    background 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    opacity 0.16s var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.btn .icon {
  width: 1.15em;
  height: 1.15em;
}

.btn-secondary {
  background: rgba(148, 178, 232, 0.14);
  border-color: var(--line-strong);
  box-shadow: none;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(148, 178, 232, 0.24);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 178, 232, 0.12);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-strong);
  box-shadow: 0 8px 20px rgba(208, 2, 27, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: #e01634;
}

.btn-danger-ghost {
  background: var(--danger-soft);
  border-color: rgba(255, 92, 116, 0.35);
  box-shadow: none;
  color: #ffb3bf;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(255, 92, 116, 0.24);
}

.icon-btn {
  display: inline-flex;
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  transition: background 0.16s var(--ease);
}

.icon-btn:hover {
  background: rgba(148, 178, 232, 0.14);
}

.icon-btn .icon {
  width: 1.35rem;
  height: 1.35rem;
}

/* ------------------------------- top bar ------------------------------- */

.top-bar {
  display: grid;
  grid-template-columns: var(--tap) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 2px 0;
}

.top-bar-title {
  overflow: hidden;
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-bar-actions {
  display: flex;
  min-width: var(--tap);
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* --------------------------- pills, tags, stars ------------------------ */

.pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.1);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill .icon {
  width: 1rem;
  height: 1rem;
}

.pill-gold {
  border-color: rgba(255, 217, 61, 0.35);
  background: var(--gold-soft);
  color: var(--gold);
}

.pill-green {
  border-color: rgba(126, 211, 33, 0.35);
  background: var(--success-soft);
  color: #b6f56a;
}

.pill-blue {
  border-color: rgba(74, 144, 226, 0.4);
  background: var(--primary-soft);
  color: #9dc8ff;
}

.pill-orange {
  border-color: rgba(245, 166, 35, 0.4);
  background: var(--warning-soft);
  color: #ffca72;
}

.pill-muted {
  color: var(--text-dim);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(74, 144, 226, 0.14);
  color: #b7d5ff;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag-muted {
  background: rgba(148, 178, 232, 0.1);
  color: var(--text-muted);
}

.stars {
  display: inline-flex;
  gap: 4px;
  color: rgba(148, 178, 232, 0.25);
}

.star {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
}

.star .icon {
  width: 100%;
  height: 100%;
}

.star-filled {
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 217, 61, 0.45));
}

.stars-small {
  gap: 2px;
}

.stars-small .star {
  width: 1rem;
  height: 1rem;
}

.star-mini {
  display: inline-flex;
  width: 0.95rem;
  height: 0.95rem;
  margin: 0 1px 0 4px;
  vertical-align: -2px;
  color: var(--gold);
}

/* ------------------------------ progress ------------------------------- */

.progress {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.16);
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #78b6ff);
  transition: width 0.5s var(--ease);
}

.progress-gold .progress-fill {
  background: linear-gradient(90deg, #f2b300, var(--gold));
}

.progress-muted .progress-fill {
  background: rgba(148, 178, 232, 0.4);
}

/* -------------------------------- cards -------------------------------- */

.card,
.form-card,
.settings-group,
.resume-card,
.review-card,
.next-phase-card,
.score-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.card,
.form-card {
  padding: 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 22, 48, 0.42);
  text-align: center;
}

.stat .icon {
  width: 1.15rem;
  height: 1.15rem;
  margin-bottom: 2px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.stat-gold .icon,
.stat-gold .stat-value {
  color: var(--gold);
}

.stat-green .icon,
.stat-green .stat-value {
  color: #a8ef62;
}

.stat-orange .icon,
.stat-orange .stat-value {
  color: #ffc266;
}

.stat-blue .icon,
.stat-blue .stat-value {
  color: #88bdff;
}

/* -------------------------------- boot -------------------------------- */

.boot-screen,
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.boot-screen {
  background:
    radial-gradient(circle at 50% 38%, rgba(74, 144, 226, 0.25), transparent 55%),
    var(--bg-deep);
  transition: opacity 0.35s var(--ease);
}

.boot-orbit {
  position: relative;
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 1px dashed rgba(148, 178, 232, 0.35);
  border-radius: 50%;
  animation: spin 9s linear infinite;
}

.boot-rocket {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 45% 45%;
  background: linear-gradient(180deg, #fff, var(--primary));
  box-shadow: 0 0 24px rgba(74, 144, 226, 0.7);
  transform: translateY(-46px) rotate(45deg);
}

.boot-title {
  font-size: 1.35rem;
  font-weight: 800;
}

.boot-copy {
  max-width: 32rem;
  color: var(--text-muted);
}

.boot-error h1 {
  font-size: 1.5rem;
}

.boot-error p {
  max-width: 28rem;
  color: var(--text-muted);
}

/* -------------------------------- home -------------------------------- */

.hero {
  position: relative;
  display: grid;
  gap: 8px;
  justify-items: start;
  overflow: hidden;
  padding: clamp(22px, 7vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(500px 280px at 88% -5%, rgba(74, 144, 226, 0.35), transparent 70%),
    linear-gradient(145deg, rgba(31, 55, 104, 0.92), rgba(14, 27, 58, 0.95));
  box-shadow: var(--shadow);
}

.hero h1 {
  position: relative;
  z-index: 1;
  max-width: 12ch;
  font-size: clamp(2rem, 8.5vw, 3rem);
}

.hero h1 span {
  color: var(--gold);
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 30rem;
  color: var(--text-muted);
}

.hero-logo {
  position: absolute;
  top: 18px;
  right: 20px;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 217, 61, 0.08);
  color: var(--gold);
  transform: rotate(8deg);
}

.hero-logo .icon {
  width: 52px;
  height: 52px;
}

.hero-orbit {
  position: absolute;
  border: 1px solid rgba(148, 178, 232, 0.18);
  border-radius: 50%;
  pointer-events: none;
}

.hero-orbit-one {
  top: -80px;
  right: -70px;
  width: 280px;
  height: 280px;
}

.hero-orbit-two {
  top: -40px;
  right: -30px;
  width: 180px;
  height: 180px;
  border-style: dashed;
}

.hero-stars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.resume-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-color: rgba(74, 144, 226, 0.45);
  background:
    linear-gradient(120deg, rgba(74, 144, 226, 0.18), rgba(74, 144, 226, 0.04)),
    var(--surface);
}

.resume-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.resume-copy h2 {
  overflow: hidden;
  font-size: 1.05rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resume-button {
  flex: 0 0 auto;
}

.menu-grid {
  display: grid;
  gap: 10px;
}

.menu-tile {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease),
    background 0.16s var(--ease);
}

.menu-tile:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.menu-tile:active {
  transform: translateY(1px);
}

.menu-tile-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 16px;
  background: var(--primary-soft);
  color: #8ec1ff;
}

.menu-tile-icon .icon {
  width: 1.6rem;
  height: 1.6rem;
}

.menu-tile-green .menu-tile-icon {
  background: var(--success-soft);
  color: #b0ef72;
}

.menu-tile-orange .menu-tile-icon {
  background: var(--warning-soft);
  color: #ffc266;
}

.menu-tile-violet .menu-tile-icon {
  background: var(--violet-soft);
  color: #c4b5fd;
}

.menu-tile-pink .menu-tile-icon {
  background: var(--pink-soft);
  color: #ffb8d2;
}

.menu-tile-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.menu-tile-title {
  font-size: 1.03rem;
  font-weight: 750;
}

.menu-tile-subtitle {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.menu-tile-badge {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
}

.install-button {
  width: 100%;
}

.home-footnote {
  padding: 4px 4px 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

/* ------------------------------- worlds ------------------------------- */

.world-list {
  display: grid;
  gap: 12px;
}

.world-card {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 24px;
  align-items: start;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease),
    background 0.16s var(--ease);
}

.world-card:hover:not(:disabled) {
  border-color: rgba(74, 144, 226, 0.55);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.world-card-locked {
  opacity: 0.62;
  filter: saturate(0.5);
}

.world-badge {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.24), transparent 50%),
    linear-gradient(150deg, rgba(74, 144, 226, 0.75), rgba(20, 40, 80, 0.9));
  color: #fff;
  font-size: 1.55rem;
  font-weight: 800;
}

.world-badge.zone-moon {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.3), transparent 50%),
    linear-gradient(150deg, rgba(167, 139, 250, 0.8), rgba(34, 28, 72, 0.95));
}

.world-badge.zone-mars {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.24), transparent 50%),
    linear-gradient(150deg, rgba(245, 166, 35, 0.85), rgba(80, 34, 20, 0.95));
}

.world-badge.zone-deepspace {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.22), transparent 50%),
    linear-gradient(150deg, rgba(255, 123, 172, 0.75), rgba(30, 20, 60, 0.95));
}

.world-symbol {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.world-index {
  position: absolute;
  right: 6px;
  bottom: 2px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.world-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.world-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.world-title-row h2 {
  font-size: 1.08rem;
}

.lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.12);
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lock-pill .icon {
  width: 0.8rem;
  height: 0.8rem;
}

.world-meta {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.world-description {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.world-progress {
  display: grid;
  gap: 5px;
  margin-top: 4px;
}

.world-progress-text {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 650;
}

.world-lock-reason {
  margin-top: 2px;
  color: #ffca72;
  font-size: 0.76rem;
}

.world-chevron {
  display: inline-flex;
  align-self: center;
  color: var(--text-dim);
  transform: rotate(180deg);
}

.world-chevron .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.world-footer {
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.world-footer-split {
  flex-wrap: wrap;
  gap: 10px;
}

/* -------------------------------- levels ------------------------------- */

.level-overview {
  display: grid;
  gap: 6px;
}

.level-list {
  display: grid;
  gap: 10px;
}

.level-node {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease),
    background 0.16s var(--ease);
}

.level-node:hover:not(:disabled) {
  border-color: rgba(74, 144, 226, 0.55);
  background: var(--surface-raised);
  transform: translateY(-1px);
}

.level-node-locked {
  opacity: 0.58;
}

.level-node-complete {
  border-color: rgba(126, 211, 33, 0.28);
}

.level-index {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: rgba(74, 144, 226, 0.14);
  color: #9dc8ff;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.level-index .icon {
  width: 1.3rem;
  height: 1.3rem;
}

.level-index-complete {
  background: var(--success-soft);
  color: #b6f56a;
}

.level-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.level-name {
  font-size: 0.98rem;
  font-weight: 750;
}

.level-description {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.level-reward {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.level-lock-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 0.7rem;
}

.level-lock-text .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.level-go {
  display: inline-flex;
  justify-content: center;
  color: var(--text-dim);
}

.level-go .icon {
  width: 1.15rem;
  height: 1.15rem;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 22, 48, 0.4);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.notice .icon {
  margin-top: 2px;
  color: var(--warning);
}

.notice-locked {
  border-color: rgba(245, 166, 35, 0.32);
  background: rgba(245, 166, 35, 0.07);
}

.notice-locked-inline {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 0.76rem;
}

.review-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-color: rgba(167, 139, 250, 0.35);
  background:
    radial-gradient(360px 160px at 100% 0%, rgba(167, 139, 250, 0.22), transparent 70%),
    var(--surface);
}

.review-copy {
  display: grid;
  flex: 1 1 240px;
  gap: 4px;
}

.review-card .eyebrow {
  color: #c4b5fd;
}

/* ------------------------------- prelevel ------------------------------ */

.mission-hero {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(420px 220px at 92% -10%, rgba(74, 144, 226, 0.3), transparent 70%),
    linear-gradient(150deg, rgba(30, 52, 98, 0.9), rgba(13, 26, 56, 0.95));
  box-shadow: var(--shadow-sm);
}

.mission-orbit {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 1px dashed rgba(148, 178, 232, 0.4);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 144, 226, 0.22), transparent 65%);
  color: #9dc8ff;
}

.mission-orbit.zone-moon {
  color: #c4b5fd;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.24), transparent 65%);
}

.mission-orbit.zone-mars {
  color: #ffca72;
  background: radial-gradient(circle, rgba(245, 166, 35, 0.24), transparent 65%);
}

.mission-orbit.zone-deepspace {
  color: #ff9ec1;
  background: radial-gradient(circle, rgba(255, 123, 172, 0.24), transparent 65%);
}

.mission-symbol {
  font-size: 2rem;
  font-weight: 800;
}

.mission-copy {
  display: grid;
  gap: 8px;
}

.mission-stars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.phase-list {
  display: grid;
  gap: 10px;
}

.phase-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.phase-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: #9dc8ff;
  font-weight: 800;
}

.phase-practice .phase-number {
  background: var(--success-soft);
  color: #b6f56a;
}

.phase-fluency .phase-number {
  background: var(--warning-soft);
  color: #ffca72;
}

.phase-mastery .phase-number {
  background: var(--violet-soft);
  color: #c4b5fd;
}

.phase-copy {
  display: grid;
  gap: 5px;
}

.phase-copy p {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.phase-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.sticky-actions {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* --------------------------- practice / speed -------------------------- */

.form-card {
  display: grid;
  gap: 16px;
}

.form-card.compact {
  padding: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-note {
  margin-top: -6px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 42px 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: rgba(10, 22, 48, 0.5);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% + 2px),
    calc(100% - 15px) calc(50% + 2px);
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  color: var(--text);
  font-size: 1rem;
  appearance: none;
}

.select option {
  background: var(--surface-solid);
  color: var(--text);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px;
  cursor: pointer;
}

.toggle-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.toggle-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.toggle-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.toggle-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.checkbox-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 50px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.16);
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    transform 0.18s var(--ease),
    background 0.18s var(--ease);
}

.checkbox-input:checked + .switch-track {
  border-color: var(--primary);
  background: var(--primary);
}

.checkbox-input:checked + .switch-track::after {
  background: #fff;
  transform: translateX(20px);
}

.checkbox-input:focus-visible + .switch-track {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.practice-facts,
.speed-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-panel {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 18px;
  border-color: rgba(255, 217, 61, 0.3);
  background:
    radial-gradient(320px 160px at 50% -20%, rgba(255, 217, 61, 0.18), transparent 70%),
    var(--surface);
  text-align: center;
}

.score-label {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score-value {
  font-size: 2.6rem;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ------------------------------- settings ------------------------------ */

.settings-group {
  display: grid;
  gap: 4px;
  padding: 8px 16px;
}

.settings-group .toggle-row + .toggle-row {
  border-top: 1px solid var(--line);
}

.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}

.data-row + .data-row {
  border-top: 1px solid var(--line);
}

.data-row-stack {
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
}

.inline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-controls .select {
  flex: 1 1 180px;
  min-width: 0;
}

.inline-file {
  display: inline-flex;
  flex: 0 0 auto;
}

/* ------------------------------- gameplay ------------------------------ */

.game-screen {
  gap: 12px;
}

.game-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.game-pause {
  border: 1px solid var(--line);
  background: rgba(10, 22, 48, 0.4);
}

.game-hud-copy {
  display: grid;
  flex: 1 1 auto;
  gap: 0;
  min-width: 0;
}

.game-phase {
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-level {
  overflow: hidden;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lives {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--danger);
  font-size: 0.9rem;
}

.lives-unlimited {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
}

.lives-unlimited .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.life-empty {
  color: rgba(255, 92, 116, 0.24);
}

.hud-streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.1);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-streak .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.hud-streak-active {
  background: var(--warning-soft);
  color: #ffca72;
}

.game-body {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.game-play {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(460px 220px at 50% -30%, rgba(74, 144, 226, 0.2), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow);
}

.game-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.game-progress {
  height: 7px;
}

.game-progress-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.game-progress-copy strong {
  color: var(--gold);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.timer-label {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.timer-bar {
  height: 7px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.14);
  transition: opacity 0.2s var(--ease);
}

.timer-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition:
    width 0.14s linear,
    background 0.3s var(--ease);
}

.timer-warning .timer-fill {
  background: var(--warning);
}

.timer-danger .timer-fill {
  background: var(--danger);
}

.timer-hidden {
  opacity: 0.35;
}

.equation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 16px);
  padding: clamp(16px, 5vw, 30px) 12px;
  border-radius: var(--radius);
  background: rgba(7, 16, 39, 0.45);
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 12vw, 4rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.equation-op,
.equation-equals {
  color: var(--text-muted);
}

.equation-equals {
  color: var(--gold);
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.answer-btn {
  position: relative;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(148, 178, 232, 0.08);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition:
    transform 0.13s var(--ease),
    background 0.13s var(--ease),
    border-color 0.13s var(--ease);
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(74, 144, 226, 0.18);
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-key {
  position: absolute;
  top: 6px;
  left: 8px;
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
}

.answer-correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #d6ffad;
  animation: answer-pop 0.3s var(--ease);
}

.answer-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #ffc7cf;
  animation: shake 0.3s var(--ease);
}

.keyboard-hint {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-align: center;
}

.feedback {
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: feedback-in 0.22s var(--ease);
}

.feedback-correct {
  border-color: rgba(126, 211, 33, 0.4);
  background: rgba(126, 211, 33, 0.08);
}

.feedback-incorrect {
  border-color: rgba(255, 92, 116, 0.4);
  background: rgba(255, 92, 116, 0.07);
}

.feedback-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
}

.feedback-correct .feedback-heading .icon {
  color: #a8ef62;
}

.feedback-incorrect .feedback-heading .icon {
  color: #ff9dad;
}

.feedback-heading .icon {
  width: 1.15rem;
  height: 1.15rem;
}

.feedback-answer,
.feedback-explain,
.feedback-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.feedback-answer strong,
.feedback-hint strong {
  color: var(--text);
}

.feedback-hint {
  padding-top: 5px;
  border-top: 1px dashed var(--line);
}

.hint-visual {
  display: grid;
  justify-items: center;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* visual aids */

.visual-aid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(7, 16, 39, 0.35);
}

.visual-plus {
  color: var(--text-muted);
  font-size: 1.2rem;
  font-weight: 800;
}

.dot-group,
.divide-groups {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 4px;
  justify-content: center;
}

.dot-group {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.divide-groups {
  gap: 8px;
}

.divide-groups .dot-group {
  max-width: 76px;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.25);
}

.dot-removed {
  position: relative;
  background: rgba(148, 178, 232, 0.24);
}

.dot-removed::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -1px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--danger);
  transform: rotate(-45deg);
}

.base-ten {
  display: flex;
  flex-wrap: wrap;
  max-width: 150px;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.base-ten-removed {
  opacity: 0.5;
}

.rod {
  display: inline-block;
  width: 8px;
  height: 35px;
  border-radius: 2px;
  background: linear-gradient(180deg, #7ab8ff, var(--primary));
}

.cube {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #b6f56a;
}

/* rocket track */

.rocket-track {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120px 180px at 50% 0%, rgba(74, 144, 226, 0.24), transparent 70%),
    linear-gradient(180deg, #0b1935, #060e20 70%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.track-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(255, 217, 61, 0.12), transparent 45%);
  pointer-events: none;
}

.track-star {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.6;
  animation: twinkle 3s ease-in-out infinite;
  animation-delay: var(--d);
}

.track-label {
  position: absolute;
  left: 50%;
  color: rgba(148, 178, 232, 0.5);
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: translateX(-50%);
}

.track-label-top {
  top: 8px;
}

.track-label-bottom {
  bottom: 8px;
}

.rocket-mover {
  position: absolute;
  bottom: calc(var(--altitude) * 0.74 + 10%);
  left: 50%;
  display: grid;
  justify-items: center;
  transform: translate(-50%, 50%);
  transition: bottom 0.55s var(--ease);
}

.rocket-body {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #fff;
  transform: rotate(180deg);
  filter: drop-shadow(0 0 8px rgba(74, 144, 226, 0.8));
}

.rocket-body .icon {
  width: 26px;
  height: 26px;
}

.rocket-flame {
  width: 8px;
  height: 12px;
  margin-bottom: -3px;
  border-radius: 0 0 50% 50%;
  background: linear-gradient(180deg, var(--gold), #ff7a00 70%, transparent);
  animation: flame 0.45s ease-in-out infinite alternate;
}

/* paused / loading */

.paused-screen,
.loading-screen {
  min-height: 70dvh;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.paused-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: 100%;
  max-width: 420px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.paused-card .stack {
  width: 100%;
  margin-top: 6px;
}

.paused-icon {
  color: var(--gold);
}

.paused-icon .icon {
  width: 2rem;
  height: 2rem;
}

.loading-screen p {
  color: var(--text-muted);
}

.orbit-loader {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(148, 178, 232, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* -------------------------------- results ------------------------------ */

.result-hero {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: clamp(22px, 6vw, 34px) 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(420px 220px at 50% -20%, rgba(74, 144, 226, 0.3), transparent 70%),
    linear-gradient(160deg, rgba(31, 55, 104, 0.9), rgba(13, 26, 56, 0.95));
  text-align: center;
  box-shadow: var(--shadow);
}

.result-hero h1 {
  margin-top: 2px;
}

.result-badge {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 50%;
}

.result-badge .icon {
  width: 2rem;
  height: 2rem;
}

.result-badge-green {
  background: var(--success-soft);
  color: #b6f56a;
  box-shadow: 0 0 0 8px rgba(126, 211, 33, 0.06);
}

.result-badge-orange {
  background: var(--warning-soft);
  color: #ffca72;
  box-shadow: 0 0 0 8px rgba(245, 166, 35, 0.06);
}

.result-rocket {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  transform: rotate(8deg);
}

.result-rocket .icon {
  width: 3rem;
  height: 3rem;
}

.big-stars .star {
  width: clamp(2rem, 9vw, 2.8rem);
  height: clamp(2rem, 9vw, 2.8rem);
}

.star-caption {
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.phase-rail {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 22, 48, 0.4);
}

.rail-step {
  display: grid;
  flex: 1 1 0;
  gap: 5px;
  justify-items: center;
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 700;
}

.rail-dot {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(148, 178, 232, 0.4);
  border-radius: 50%;
}

.rail-done {
  color: #b6f56a;
}

.rail-done .rail-dot {
  border-color: var(--success);
  background: var(--success);
}

.rail-current {
  color: var(--gold);
}

.rail-current .rail-dot {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(255, 217, 61, 0.16);
}

.rail-failed {
  color: #ff9dad;
}

.rail-failed .rail-dot {
  border-color: var(--danger);
  background: var(--danger);
}

.next-phase-card {
  display: grid;
  gap: 4px;
  padding: 15px 18px;
}

.fact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.fact-chip {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 232, 0.08);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 650;
}

.speed-hero {
  padding-top: 26px;
}

.speed-score {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 3px solid rgba(255, 217, 61, 0.5);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 217, 61, 0.22), transparent 65%),
    rgba(10, 22, 48, 0.5);
  box-shadow: var(--glow-gold);
}

.speed-score strong {
  color: var(--gold);
  font-size: 3rem;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 40px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.empty-state p {
  max-width: 34ch;
  color: var(--text-muted);
}

/* ------------------------------- feedback UI --------------------------- */

.toast-root {
  position: fixed;
  z-index: 120;
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 14px);
  left: calc(var(--safe-left) + 12px);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  width: min(100%, 460px);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  animation: toast-in 0.24s var(--ease);
  pointer-events: auto;
}

.toast-message {
  flex: 1 1 auto;
  font-size: 0.86rem;
}

.toast-action {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.toast-danger {
  border-color: rgba(255, 92, 116, 0.55);
}

.toast-warning {
  border-color: rgba(245, 166, 35, 0.55);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 8, 20, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s var(--ease);
}

.modal {
  display: grid;
  gap: 12px;
  width: min(100%, 430px);
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.24s var(--ease);
}

.modal-body {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.modal-danger {
  border-color: rgba(255, 92, 116, 0.35);
}

.confetti-piece {
  position: absolute;
  top: -10px;
  left: var(--x);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--color);
  pointer-events: none;
  animation: confetti-fall var(--duration) ease-in var(--delay) forwards;
}

.result-screen,
.home-screen {
  position: relative;
}

/* ------------------------------ responsive ----------------------------- */

@media (min-width: 560px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-tile {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .menu-tile-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .sticky-actions {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .answers {
    gap: 12px;
  }

  .answer-btn {
    min-height: 74px;
    font-size: 1.55rem;
  }

  .mission-hero {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }
}

@media (min-width: 760px) {
  .app {
    padding-top: calc(var(--safe-top) + 24px);
  }

  .stat-row {
    gap: 14px;
  }

  .stat {
    padding: 18px 10px;
  }

  .stat-value {
    font-size: 1.7rem;
  }

  .game-body {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 16px;
  }

  .game-play {
    padding: 20px;
  }
}

@media (max-width: 420px) {
  .world-card {
    grid-template-columns: 52px minmax(0, 1fr) 18px;
    gap: 11px;
    padding: 13px;
  }

  .world-badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 1.3rem;
  }

  .stat-row {
    gap: 7px;
  }

  .stat {
    padding: 12px 5px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.64rem;
  }

  .game-body {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 8px;
  }

  .game-play {
    padding: 11px;
    gap: 10px;
  }

  .equation {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  .answer-btn {
    min-height: 60px;
    font-size: 1.25rem;
  }

  .resume-card {
    align-items: stretch;
    flex-direction: column;
  }

  .resume-button {
    width: 100%;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app {
    padding-top: calc(var(--safe-top) + 8px);
  }

  .game-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .rocket-track {
    display: none;
  }

  .equation {
    padding: 10px;
    font-size: 2.1rem;
  }

  .answer-btn {
    min-height: 52px;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(220, 232, 255, 0.55);
    --line-strong: rgba(220, 232, 255, 0.8);
    --text-muted: #d4def5;
    --text-dim: #b8c6e2;
  }

  .btn,
  .menu-tile,
  .world-card,
  .level-node,
  .answer-btn {
    border-width: 2px;
  }
}

.hero-number-knight {
  border-color: rgba(74, 144, 226, 0.5);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.3), transparent 55%),
    linear-gradient(150deg, rgba(74, 144, 226, 0.62), rgba(15, 40, 78, 0.94));
}

.hero-star-ranger {
  border-color: rgba(255, 217, 61, 0.42);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.3), transparent 55%),
    linear-gradient(150deg, rgba(245, 166, 35, 0.55), rgba(70, 38, 22, 0.92));
}

.rune-answers {
  gap: 9px;
}

.rune-btn {
  border-color: rgba(167, 139, 250, 0.34);
  background:
    radial-gradient(circle at 50% -20%, rgba(167, 139, 250, 0.22), transparent 70%),
    rgba(148, 178, 232, 0.07);
}

.rune-btn:hover:not(:disabled) {
  border-color: var(--violet);
  background: var(--violet-soft);
}

.rune-glyph {
  color: var(--violet);
  font-size: 0.72rem;
}

/* ------------------------------ bubble blitz ---------------------------- */

.bubble-screen,
.bubble-play-screen {
  gap: 12px;
}

.bubble-best-panel {
  border-color: rgba(255, 123, 172, 0.32);
  background:
    radial-gradient(320px 160px at 50% -20%, rgba(255, 123, 172, 0.18), transparent 70%),
    var(--surface);
}

.bubble-best-panel .score-label {
  color: var(--pink);
}

.bubble-hud {
  gap: 10px;
}

.bubble-scoreboard {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 4px;
}

.bubble-score {
  color: var(--gold);
  font-size: 1.45rem;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bubble-score-label {
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 750;
}

.bubble-status-row,
.bubble-time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.bubble-answered {
  color: var(--text-dim);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bubble-timer {
  height: 8px;
}

.bubble-timer .timer-fill,
.progress-blue .progress-fill {
  background: linear-gradient(90deg, var(--pink), #ffb6d1);
}

.bubble-prompt {
  padding: clamp(12px, 4vw, 22px) 12px;
  font-size: clamp(2.1rem, 10vw, 3.2rem);
}

.bubble-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.bubble {
  display: grid;
  width: 100%;
  max-width: 170px;
  min-width: 0;
  aspect-ratio: 1;
  min-height: 48px;
  place-items: center;
  justify-self: center;
  padding: 10px;
  border: 1px solid rgba(255, 123, 172, 0.4);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.34), transparent 34%),
    radial-gradient(circle at 50% 70%, rgba(255, 123, 172, 0.35), transparent 62%),
    linear-gradient(160deg, rgba(74, 144, 226, 0.38), rgba(36, 28, 72, 0.94));
  color: #fff;
  font-size: clamp(1.35rem, 6vw, 2rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  box-shadow:
    inset 0 -10px 20px rgba(4, 8, 24, 0.32),
    0 8px 20px rgba(2, 8, 22, 0.3);
  animation: bubble-bob 4.4s ease-in-out infinite;
  transition:
    transform 0.13s var(--ease),
    border-color 0.13s var(--ease),
    background 0.13s var(--ease);
}

.bubble:nth-child(2) {
  animation-delay: -1.1s;
}

.bubble:nth-child(3) {
  animation-delay: -2.2s;
}

.bubble:nth-child(4) {
  animation-delay: -3.3s;
}

.bubble:nth-child(5) {
  animation-delay: -0.6s;
}

.bubble:nth-child(6) {
  animation-delay: -1.7s;
}

.bubble:hover:not(:disabled) {
  border-color: #ffd0e0;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.4), transparent 34%),
    radial-gradient(circle at 50% 70%, rgba(255, 123, 172, 0.45), transparent 62%),
    linear-gradient(160deg, rgba(74, 144, 226, 0.5), rgba(50, 32, 90, 0.96));
  transform: scale(1.025);
}

.bubble:active:not(:disabled) {
  transform: scale(0.97);
}

.bubble-value {
  line-height: 1;
}

.bubble-key {
  position: absolute;
  right: 14%;
  bottom: 8%;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.6rem;
  font-weight: 750;
}

.bubble-correct {
  border-color: var(--success);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.4), transparent 34%),
    linear-gradient(160deg, rgba(126, 211, 33, 0.55), rgba(26, 62, 18, 0.95));
  color: #efffdc;
}

.bubble-fizzle {
  border-color: var(--danger);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.3), transparent 34%),
    linear-gradient(160deg, rgba(255, 92, 116, 0.5), rgba(68, 20, 34, 0.95));
}

.bubble-feedback-copy {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.bubble-round-progress,
.bubble-zen-progress {
  height: 8px;
}

.bubble-result-hero {
  padding-top: 24px;
}

.bubble-result-score {
  display: grid;
  width: 132px;
  height: 132px;
  place-items: center;
  align-content: center;
  border: 3px solid rgba(255, 123, 172, 0.5);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 123, 172, 0.26), transparent 65%),
    rgba(10, 22, 48, 0.5);
  box-shadow: 0 0 24px rgba(255, 123, 172, 0.28);
}

.bubble-result-score strong {
  color: var(--gold);
  font-size: 3rem;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bubble-result-score span {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (orientation: landscape) {
  .bubble-field {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 560px;
  }
}

@media (max-width: 420px) {
  
  
  
  
  
  
  
  
  .bubble-field {
    gap: 8px;
  }

  .bubble {
    padding: 8px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .bubble-play-screen {
    gap: 8px;
  }

  .bubble-prompt {
    padding: 8px;
    font-size: 1.9rem;
  }

  .bubble {
    max-width: 108px;
  }

  }

html[data-motion="reduce"] .bubble,
html[data-motion="reduce"] .bubble:hover:not(:disabled) {
  animation: none;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="allow"]) .bubble,
  html:not([data-motion="allow"]) .bubble:hover:not(:disabled) {
    animation: none;
    transform: none;
  }
}
