:root {
  --bg: #070910;
  --navy: #0c1220;
  --pine: #152033;
  --blood: #8b3a2a;
  --gold: #e8c547;
  --gold-dim: #a6842a;
  --ice: #6eb5ff;
  --glow: #4ecdc4;
  --thunder: #c4b5fd;
  --ink: #e8eef8;
  --muted: #8b97ad;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Rajdhani", sans-serif;
  user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2744 0%, transparent 60%),
    var(--bg);
}

#game {
  display: block;
  position: absolute;
  left: 0;
  top: var(--vv-top, 0px);
  right: 0;
  bottom: var(--vv-bottom, 0px);
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top, 0px) + var(--vv-top, 0px)) 16px 8px;
  pointer-events: none;
  gap: 16px;
  z-index: 4;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  gap: 14px;
  align-items: center;
}

.hud-stat {
  min-width: 72px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(12,18,32,0.88), rgba(7,9,16,0.72));
  border: 1px solid rgba(232, 197, 71, 0.28);
  box-shadow: 0 0 18px rgba(78, 205, 196, 0.08);
}

.hud-stat .label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.hud-stat span:last-child {
  font-family: "Cinzel", serif;
  font-size: 18px;
  color: var(--gold);
}

.growth-wrap { min-width: 220px; }
.growth-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--thunder);
  margin-bottom: 4px;
}
.growth-bar {
  height: 10px;
  background: #121826;
  border: 1px solid rgba(196, 181, 253, 0.4);
  overflow: hidden;
}
#growth-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4338ca, #c4b5fd, #fff);
  box-shadow: 0 0 12px #c4b5fd;
  transition: width 0.25s ease;
}

.valhalla-btn {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  min-width: min(340px, 84vw);
  padding: 20px 28px;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: clamp(17px, 3vw, 26px);
  letter-spacing: 0.08em;
  color: #0b0614;
  background: linear-gradient(180deg, #f5e27a, #d4a017);
  border: 3px solid #fff3a1;
  cursor: pointer;
  box-shadow: 0 0 18px #fff3a1, 0 0 60px rgba(232, 197, 71, 0.75);
  animation: pulse 1.2s ease-in-out infinite;
}
.valhalla-btn small {
  display: block;
  margin-top: 7px;
  font-family: "Rajdhani", sans-serif;
  font-size: 13px;
  letter-spacing: 0.12em;
}
.valhalla-btn:disabled { opacity: 0.35; animation: none; cursor: default; }

.interact-hint {
  position: absolute;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px) + var(--vv-bottom, 0px));
  transform: translateX(-50%);
  z-index: 5;
  padding: 8px 14px;
  background: rgba(8, 12, 22, 0.85);
  border: 1px solid rgba(110, 181, 255, 0.45);
  color: var(--ice);
  letter-spacing: 0.06em;
}
kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--ice);
  color: #fff;
}

.screen {
  position: absolute;
  top: var(--vv-top, 0px);
  right: 0;
  bottom: var(--vv-bottom, 0px);
  left: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(110,181,255,0.08), transparent 35%),
    radial-gradient(circle at 80% 80%, rgba(232,197,71,0.08), transparent 40%),
    rgba(5, 7, 12, 0.55);
}

.title-screen {
  background: #070910;
  place-items: end center;
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--vv-top, 0px));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px) + var(--vv-bottom, 0px));
}
.menu-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
}
.menu-video.hidden {
  display: none !important;
}
.title-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.title-actions .cta {
  min-width: 220px;
  min-height: 52px;
  padding: 16px 36px;
  font-size: 18px;
  color: #0b0614;
  background: linear-gradient(180deg, #f5e27a, #d4a017);
  box-shadow: 0 0 22px rgba(232, 197, 71, 0.55), 0 8px 28px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(245, 226, 122, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.title-actions .speed-cta {
  color: #04120f;
  background: linear-gradient(180deg, #7ee7df, #1f8f86);
  box-shadow: 0 0 18px rgba(78, 205, 196, 0.45), 0 8px 28px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(126, 231, 223, 0.65);
}
.title-actions .fs-cta {
  min-height: 44px;
  padding: 12px 28px;
  font-size: 15px;
}
.fs-cta {
  display: none;
}
.fs-float {
  display: none;
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px) + var(--vv-top, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(232, 197, 71, 0.45);
  background: rgba(12, 18, 32, 0.88);
  color: var(--gold);
  font-size: 20px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.fs-float.active {
  color: #0b0614;
  background: linear-gradient(180deg, #f5e27a, #d4a017);
  border-color: #fff3a1;
}
.fs-hint {
  display: grid;
  place-items: center;
  position: absolute;
  top: var(--vv-top, 0px);
  right: 0;
  bottom: var(--vv-bottom, 0px);
  left: 0;
  z-index: 45;
  pointer-events: none;
}
.fs-hint-card {
  pointer-events: none;
  text-align: center;
  padding: 14px 18px;
  background: rgba(8, 12, 22, 0.88);
  border: 1px solid rgba(232, 197, 71, 0.4);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
}
.fs-hint-card p {
  font-family: "Cinzel", serif;
  font-size: 16px;
  color: var(--gold);
  margin-bottom: 4px;
}
.fs-hint-card small {
  color: var(--muted);
  font-size: 13px;
}
.fs-spacer {
  display: none;
  width: 1px;
  height: 140vh;
  pointer-events: none;
}

@media (pointer: coarse), (max-height: 520px) {
  .fs-cta { display: inline-block; }
  .fs-float { display: flex; }
  .overlay { padding-right: calc(58px + env(safe-area-inset-right, 0px)); }
}
#screen-title:not(.hidden) ~ .fs-float {
  display: none !important;
}
html.is-standalone .fs-cta,
html.is-standalone .fs-float {
  display: none !important;
}

html.is-fs-seek,
html.is-fs-seek body {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
  overscroll-behavior: none;
}
html.is-fs-seek #app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}
html.is-fs-seek .fs-spacer {
  display: block;
}

html.is-fullscreen,
html.is-fullscreen body,
html:fullscreen,
html:fullscreen body,
html:-webkit-full-screen,
html:-webkit-full-screen body {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  overscroll-behavior: none;
}
html.is-fullscreen #app,
html:fullscreen #app,
html:-webkit-full-screen #app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
html.is-fullscreen #game,
html:fullscreen #game,
html:-webkit-full-screen #game {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}
html.is-fullscreen .screen,
html:fullscreen .screen,
html:-webkit-full-screen .screen {
  top: 0;
  bottom: 0;
}
.title-screen.playing .title-actions {
  opacity: 0;
  pointer-events: none;
}

#screen-arena {
  background: transparent;
  place-items: start center;
  padding-top: 10px;
  pointer-events: none;
}
#screen-arena .arena-ui { pointer-events: auto; }

.rune-frame {
  width: min(720px, 92vw);
  padding: 36px 32px;
  background: linear-gradient(180deg, rgba(16, 24, 42, 0.94), rgba(8, 10, 18, 0.96));
  border: 1px solid rgba(232, 197, 71, 0.45);
  box-shadow:
    0 0 0 6px rgba(12, 18, 32, 0.8),
    0 0 40px rgba(78, 205, 196, 0.12),
    inset 0 0 40px rgba(110, 181, 255, 0.05);
  text-align: center;
}

.kicker {
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--glow);
  font-size: 12px;
  margin-bottom: 10px;
}

h1, h2, h3 {
  font-family: "Cinzel", serif;
  font-weight: 800;
  line-height: 1.05;
}

h1 {
  font-size: clamp(40px, 8vw, 72px);
  color: var(--gold);
  text-shadow: 0 0 24px rgba(232, 197, 71, 0.35);
}

h2 { font-size: 34px; color: var(--gold); margin-bottom: 10px; }

.tagline {
  margin: 16px auto 24px;
  max-width: 520px;
  color: var(--muted);
  font-size: 18px;
}

.cta {
  cursor: pointer;
  border: 0;
  padding: 14px 28px;
  font-family: "Cinzel", serif;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: #0a0e18;
  background: linear-gradient(180deg, #7ee7df, #2aa89f);
  box-shadow: 0 0 22px rgba(78, 205, 196, 0.35);
}
.cta.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(232, 197, 71, 0.4);
  box-shadow: none;
}

.controls-blurb {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
/* Nine grades: a tidy 3 × 3 instead of 4 + 4 + 1. */
.grade-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade-btn {
  cursor: pointer;
  padding: 14px 8px;
  background: #121a2c;
  border: 1px solid rgba(110, 181, 255, 0.25);
  color: var(--ink);
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
}
.grade-btn:hover, .grade-btn:focus {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.25);
}
.grade-btn small {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.diff-btn {
  cursor: pointer;
  padding: 18px 14px 16px;
  background: #121a2c;
  border: 1px solid rgba(110, 181, 255, 0.25);
  color: var(--ink);
  font-family: "Rajdhani", sans-serif;
  text-align: left;
}
.diff-btn:hover, .diff-btn:focus {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.25);
}
.diff-btn.recommended {
  border-color: rgba(126, 231, 223, 0.45);
}
.diff-rank {
  display: block;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 8px;
}
.diff-btn small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.35;
}
.hero-select-screen {
  place-items: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: fadeScreenIn 0.5s ease-out both;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(110, 181, 255, 0.12), transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(232, 197, 71, 0.08), transparent 45%),
    #070910;
}
.hero-select-shell {
  width: min(920px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.hero-select-title {
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: clamp(26px, 4vw, 36px);
  color: var(--gold);
  margin: 0;
  text-align: center;
}
.hero-select-tag {
  margin: 0 0 8px;
  color: var(--muted);
  text-align: center;
  max-width: 36rem;
}
.hero-pick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 3vw, 28px);
  width: 100%;
  margin: 4px 0 12px;
}
.hero-pick {
  cursor: pointer;
  appearance: none;
  border: 1px solid rgba(110, 181, 255, 0.28);
  background: linear-gradient(180deg, rgba(18, 26, 44, 0.95), rgba(8, 12, 22, 0.98));
  color: var(--ink);
  border-radius: 10px;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.hero-pick:hover,
.hero-pick:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(232, 197, 71, 0.28);
  outline: none;
  transform: translateY(-2px);
}
.hero-pick.selected {
  border-color: rgba(126, 231, 223, 0.65);
  box-shadow: 0 0 24px rgba(126, 231, 223, 0.22);
}
.hero-pick-stage {
  position: relative;
  width: min(100%, 340px);
  max-height: min(50vh, 340px);
  aspect-ratio: 480 / 560;
  display: grid;
  place-items: end center;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 88%, rgba(0, 0, 0, 0.45), transparent 55%),
    linear-gradient(180deg, rgba(30, 42, 68, 0.55), rgba(10, 14, 24, 0.2));
  overflow: hidden;
}
.hero-preview {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  pointer-events: none;
}
.hero-pick-name {
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: clamp(18px, 2.4vw, 22px);
  color: var(--gold);
}
.hero-pick-hint {
  font-family: "Rajdhani", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-pick:hover .hero-pick-hint,
.hero-pick:focus-visible .hero-pick-hint {
  color: #7ee7df;
}
@media (max-width: 640px), (max-height: 480px) {
  .hero-pick-row {
    gap: 10px;
  }
  .hero-pick {
    padding: 10px 8px 12px;
  }
  .hero-pick-hint {
    font-size: 11px;
  }
  .hero-pick-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .hero-pick {
    padding: 8px 6px 10px;
  }
  .hero-pick-stage {
    max-height: min(26vh, 180px);
    min-height: 100px;
    aspect-ratio: auto;
    width: 100%;
  }
  .hero-preview {
    min-height: 80px;
  }
  .hero-name { font-size: 14px; }
}
#btn-diff-back, #btn-level-back, #btn-grade-back, #btn-hero-back {
  margin-top: 4px;
}

.arena-ui {
  width: min(760px, 94vw);
  margin-top: 8px;
  pointer-events: auto;
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 4px 12px;
  box-sizing: border-box;
}
.timer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-family: "Cinzel", serif;
  color: var(--ice);
}
#arena-timer { font-size: 28px; }
#hint-stage { letter-spacing: 0.16em; font-size: 12px; color: var(--gold); }

.math-card {
  background: linear-gradient(180deg, rgba(10,16,28,0.92), rgba(8,10,16,0.88));
  border: 1px solid rgba(110, 181, 255, 0.35);
  box-shadow: 0 0 30px rgba(78, 205, 196, 0.15);
  padding: 22px 20px 18px;
  overflow: visible;
  box-sizing: border-box;
}
.encounter-label {
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--thunder);
  margin-bottom: 8px;
}
#math-prompt {
  font-size: clamp(26px, 4vw, 40px);
  margin-bottom: 14px;
  color: #fff;
}

.hint-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 16px;
  min-height: 0;
  max-height: min(34vh, 220px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
  box-sizing: border-box;
}
.hint-visual.hidden { display: none; }
.teach-box {
  width: 100%;
  text-align: left;
  background: rgba(15, 28, 22, 0.72);
  border: 1px solid rgba(134, 239, 172, 0.45);
  padding: 12px 14px 10px;
  box-sizing: border-box;
  max-height: min(40vh, 260px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.teach-lead {
  margin: 0 0 6px;
  font-family: "Cinzel", serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: #86efac;
}
.teach-prompt {
  margin: 0 0 10px;
  color: #e2e8f0;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
}
.teach-prompt strong { color: #fff; font-size: 1.05em; }
.teach-steps {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}
.teach-steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 7px;
  color: #f8fafc;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}
.teach-step-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.teach-n {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  background: #e8c547;
  color: #111827;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}
.hint-chip {
  padding: 6px 10px;
  background: rgba(110, 181, 255, 0.1);
  border: 1px solid rgba(110, 181, 255, 0.35);
  color: var(--ice);
  font-size: 14px;
}
.hint-blocks { display: flex; gap: 3px; align-items: flex-end; }
.hint-block {
  width: 10px;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.5);
}

/* ——— Teach diagrams (SVG/HTML visuals in elf plan) ——— */
.teach-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding-top: 6px;
  width: 100%;
}
.teach-visual-hero {
  margin: 4px 0 2px;
  padding: 4px 0 2px;
  min-height: 120px;
}
.teach-body.has-diagram .teach-visual-hero {
  order: 0;
}
.teach-body.has-diagram .teach-plan-step,
.teach-body.has-diagram .teach-why {
  display: flex;
  flex-direction: column;
}
.teach-body.has-diagram .teach-step-body,
.teach-body.has-diagram .teach-why-text {
  margin-bottom: 8px;
}
.teach-body.has-diagram .teach-diagram {
  margin-top: 0;
  padding: 16px 12px 12px;
  border-width: 2px;
  border-color: rgba(232, 197, 71, 0.45);
  box-shadow: 0 0 24px rgba(232, 197, 71, 0.12);
}
.teach-body.has-diagram .dot {
  width: 22px;
  height: 22px;
}
.teach-body.has-diagram .dot-array-row {
  grid-template-columns: repeat(var(--cols, 3), 22px);
  gap: 10px;
}
.teach-body.has-diagram .group-box {
  min-width: 60px;
  min-height: 52px;
}
.teach-no-diagram {
  margin: 8px 0 0;
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
}

/* ——— Concept primers (basics-first vocabulary) ——— */
.concept-primer .teach-step-label {
  color: #93c5fd;
}
.concept-def {
  font-size: clamp(15px, 3.2vw, 18px);
  line-height: 1.45;
  color: #e2e8f0;
}
.concept-why {
  margin: 6px 0 4px;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.35;
}
.concept-compare {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.concept-pair-card {
  flex: 1 1 120px;
  max-width: 180px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  text-align: center;
}
.concept-pair-card.prime {
  border-color: rgba(232, 197, 71, 0.55);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.12);
}
.concept-pair-title {
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 6px;
}
.concept-pairs {
  font-size: 16px;
  color: #e8c547;
  font-weight: 700;
}
.concept-pair-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: #94a3b8;
}
.concept-fallback {
  margin: 0;
  text-align: center;
  color: #cbd5e1;
}
.teach-body.has-primer .teach-diagram {
  border-color: rgba(147, 197, 253, 0.45);
}
.pr-basics {
  margin: 4px 0 10px;
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.4;
}
.teach-diagram {
  margin: 8px 0 4px;
  width: 100%;
  padding: 12px 10px 10px;
  background: rgba(8, 14, 26, 0.85);
  border: 1px solid rgba(232, 197, 71, 0.28);
  border-radius: 8px;
  box-sizing: border-box;
}
.diagram-caption {
  margin: 10px 0 0;
  text-align: center;
  font-size: clamp(14px, 3vw, 17px);
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.35;
}
.diagram-caption strong { color: #86efac; }
.diagram-note {
  margin: 6px 0;
  text-align: center;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.dot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7c2, #e8c547 45%, #b8860b);
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.55);
  flex-shrink: 0;
}
.dot.ghost {
  background: transparent;
  border: 2px dashed rgba(148, 163, 184, 0.45);
  box-shadow: none;
  opacity: 0.5;
}
.share-loose { margin: 4px 0 8px; }
.share-loose .dot-row.loose .dot {
  background: radial-gradient(circle at 35% 30%, #dbeafe, #6eb5ff 50%, #3b82f6);
  box-shadow: 0 0 8px rgba(110, 181, 255, 0.5);
}
.compact-loose {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.big-total {
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 800;
  color: #fff;
  font-family: "Cinzel", serif;
}
.caption-inline { color: #94a3b8; font-size: 14px; }

.group-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}
.group-row.ghost-row { margin-top: 8px; opacity: 0.7; }
.group-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid rgba(134, 239, 172, 0.55);
  background: rgba(22, 101, 52, 0.22);
}
.group-box.empty {
  border-style: dashed;
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(30, 41, 59, 0.45);
}
.group-box.filled {
  border-color: #86efac;
  box-shadow: 0 0 12px rgba(134, 239, 172, 0.25);
}
.group-row.compact .group-box {
  min-width: 40px;
  min-height: 40px;
  padding: 6px;
}
.group-count {
  font-size: 18px;
  font-weight: 800;
  color: #86efac;
}
.group-box.empty .group-count { color: #64748b; }
.group-need {
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dot-array {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.dot-array-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 18px);
  gap: 8px;
  justify-content: center;
}
.dot-array-row.off { opacity: 0.35; }

.blocks-join {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
}
.blocks-op {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  padding-bottom: 18px;
}
.blocks-sum {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  color: #86efac;
  padding-bottom: 14px;
  font-family: "Cinzel", serif;
}
.block-tower {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 3px;
  min-width: 36px;
}
.block-unit {
  width: 28px;
  height: 14px;
  border-radius: 3px;
  background: var(--tower-color, #e8c547);
  box-shadow: 0 0 6px rgba(232, 197, 71, 0.35);
}
.block-unit.removed {
  background: transparent !important;
  border: 2px solid #f87171;
  box-shadow: none;
  position: relative;
  opacity: 0.85;
}
.block-unit.removed::after {
  content: "";
  position: absolute;
  inset: 40% -2px;
  height: 2px;
  background: #f87171;
  transform: rotate(-28deg);
}
.block-label {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #e2e8f0;
}
.block-more { font-size: 11px; color: #94a3b8; }
.block-tower.mystery,
.block-tower.ghost-tower {
  min-height: 48px;
  justify-content: center;
  border: 2px dashed rgba(148, 163, 184, 0.5);
  border-radius: 8px;
  padding: 8px 12px;
}
.block-tower.mystery .block-label { color: var(--gold); font-size: 22px; }

.counting-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  max-width: 500px;
  margin: 0 auto 12px;
}
.counting-counter {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  color: #07111f;
  font-size: 16px;
  font-weight: 900;
  box-sizing: border-box;
}
.counting-counter.gold {
  background: #facc15;
  border-color: #fef08a;
}
.counting-counter.blue {
  background: #60a5fa;
  border-color: #bfdbfe;
}
.counting-counter.waiting {
  background: transparent;
  border-style: dashed;
  border-color: #93c5fd;
  color: #bfdbfe;
}
.counting-counter.crossed {
  position: relative;
  background: rgba(248, 113, 113, 0.28);
  border-color: #f87171;
  color: #fecaca;
}
.counting-counter.crossed::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: #f87171;
  transform: rotate(-38deg);
}
.counting-instruction {
  margin: 4px auto 8px;
  max-width: 520px;
  color: #f8fafc;
  text-align: center;
  font-size: clamp(16px, 3.5vw, 21px);
  font-weight: 800;
  line-height: 1.35;
}

.sub-tower .block-unit {
  background: #6eb5ff;
  box-shadow: 0 0 6px rgba(110, 181, 255, 0.4);
}
.sub-compact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sub-num {
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 800;
  color: #fff;
  font-family: "Cinzel", serif;
}
.sub-num.take { color: #f87171; }
.sub-num.result { color: #86efac; }

.number-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding: 8px 4px 0;
}
.nl-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 36px;
}
.nl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #475569;
  border: 2px solid #94a3b8;
}
.nl-tick.known .nl-dot {
  background: #e8c547;
  border-color: #fde68a;
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.5);
}
.nl-tick.answer .nl-dot {
  background: #86efac;
  border-color: #bbf7d0;
  box-shadow: 0 0 10px rgba(134, 239, 172, 0.55);
}
.nl-tick.mystery .nl-dot {
  background: transparent;
  border-style: dashed;
  border-color: var(--gold);
}
.nl-lab {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}
.nl-tick.answer .nl-lab { color: #86efac; font-size: 15px; }
.nl-hop {
  min-width: 28px;
  text-align: center;
  padding-bottom: 22px;
  color: transparent;
  font-size: 11px;
  font-weight: 700;
}
.nl-hop.on { color: var(--gold); }

.frac-bar {
  display: grid;
  grid-template-columns: repeat(var(--den, 4), 1fr);
  gap: 3px;
  width: min(100%, 320px);
  margin: 0 auto 6px;
  height: 36px;
}
.frac-cell {
  background: rgba(51, 65, 85, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 4px;
}
.frac-cell.shaded {
  background: linear-gradient(180deg, #fde68a, #e8c547);
  border-color: #fbbf24;
}
.frac-cell.shaded-b {
  background: linear-gradient(180deg, #93c5fd, #3b82f6);
  border-color: #60a5fa;
}

.decomp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 6px;
}
.decomp-row .hint-chip.tens { border-color: rgba(232, 197, 71, 0.5); }
.decomp-row .hint-chip.ones { border-color: rgba(110, 181, 255, 0.5); }
.decomp-row .hint-chip.sum {
  border-color: rgba(134, 239, 172, 0.55);
  color: #86efac;
}


/* ——— Ratio fair-share diagram ——— */
.ratio-diagram .ratio-piles,
.ratio-diagram .ratio-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
}
.ratio-pile,
.ratio-result-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
}
.ratio-pile-tag {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
}
.ratio-pile-n {
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
}
.ratio-colon {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  padding: 0 4px;
}
.ratio-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 220px;
}
.ratio-dots.side-a .dot {
  background: radial-gradient(circle at 35% 30%, #fff7c2, #e8c547 45%, #b8860b);
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.55);
}
.ratio-dots.side-b .dot {
  background: radial-gradient(circle at 35% 30%, #dbeafe, #6eb5ff 50%, #3b82f6);
  box-shadow: 0 0 8px rgba(110, 181, 255, 0.5);
}
.ratio-bar {
  position: relative;
  width: min(160px, 40vw);
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(51, 65, 85, 0.85);
}
.ratio-bar.side-a .ratio-bar-fill {
  background: linear-gradient(90deg, #fde68a, #e8c547);
}
.ratio-bar.side-b .ratio-bar-fill {
  background: linear-gradient(90deg, #93c5fd, #3b82f6);
}
.ratio-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
}
.ratio-bar-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #0f172a;
  text-shadow: 0 0 4px rgba(255,255,255,0.5);
}
.ratio-split {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.ratio-chunk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.ratio-side-label {
  font-size: 13px;
  font-weight: 800;
  color: #94a3b8;
  min-width: 18px;
}
.ratio-chunks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: stretch;
}
.ratio-chunk {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 2px dashed rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.4);
  opacity: 0.45;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.ratio-chunk.on {
  opacity: 1;
  border-style: solid;
}
.ratio-chunk.side-a.on {
  border-color: rgba(232, 197, 71, 0.65);
  background: rgba(120, 53, 15, 0.28);
}
.ratio-chunk.side-b.on {
  border-color: rgba(110, 181, 255, 0.65);
  background: rgba(30, 58, 138, 0.28);
}
.ratio-chunk.side-a .dot {
  background: radial-gradient(circle at 35% 30%, #fff7c2, #e8c547 45%, #b8860b);
  box-shadow: 0 0 6px rgba(232, 197, 71, 0.45);
  width: 14px;
  height: 14px;
}
.ratio-chunk.side-b .dot {
  background: radial-gradient(circle at 35% 30%, #dbeafe, #6eb5ff 50%, #3b82f6);
  box-shadow: 0 0 6px rgba(110, 181, 255, 0.45);
  width: 14px;
  height: 14px;
}
.ratio-chunk.bar-chunk {
  min-width: 36px;
  padding: 6px 10px;
}
.ratio-chunk-n {
  font-weight: 800;
  font-size: 14px;
  color: #e2e8f0;
}
.ratio-chunk.side-a .ratio-chunk-n { color: #fde68a; }
.ratio-chunk.side-b .ratio-chunk-n { color: #93c5fd; }
.ratio-chunk-ghost {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}
.ratio-chunk.result {
  min-width: 44px;
  min-height: 36px;
  padding: 8px 10px;
}
.teach-body.has-diagram .ratio-chunk.side-a .dot,
.teach-body.has-diagram .ratio-chunk.side-b .dot {
  width: 16px;
  height: 16px;
}

@media (max-width: 520px), (orientation: landscape) and (max-height: 520px) {
  .dot { width: 14px; height: 14px; }
  .dot-array-row {
    grid-template-columns: repeat(var(--cols, 3), 14px);
    gap: 6px;
  }
  .group-box { min-width: 44px; min-height: 38px; padding: 6px 8px; }
  .block-unit { width: 22px; height: 11px; }
  .teach-diagram { padding: 8px 6px 8px; }
  .frac-bar { height: 28px; }
  .ratio-chunk { min-width: 24px; min-height: 24px; padding: 4px; }
  .ratio-bar { height: 22px; }
}



/* ——— Place / column diagram (multi-digit) ——— */
.place-diagram .place-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: 100%;
}
.place-row {
  display: grid;
  grid-template-columns: 28px repeat(var(--place-cols, 3), minmax(36px, 52px));
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.place-head {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #94a3b8;
  text-transform: uppercase;
}
.place-label {
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  font-size: 18px;
}
.place-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.55);
}
.place-cell.working {
  border-color: rgba(232, 197, 71, 0.7);
  box-shadow: 0 0 12px rgba(232, 197, 71, 0.25);
}
.place-cell.done {
  border-color: rgba(134, 239, 172, 0.55);
  background: rgba(22, 101, 52, 0.25);
}
.place-digit {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
}
.place-rule {
  display: block;
  height: 2px;
  background: rgba(232, 197, 71, 0.45);
  border-radius: 2px;
  margin: 2px 0;
}

/* ——— Decimal place-value ——— */
.decimal-diagram .dec-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.dec-heads,
.dec-row {
  display: grid;
  grid-template-columns: 40px 48px 18px 64px;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.dec-heads {
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.dec-spacer { display: block; }
.dec-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.55);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
}
.dec-cell.lit {
  border-color: rgba(110, 181, 255, 0.7);
  box-shadow: 0 0 10px rgba(110, 181, 255, 0.25);
}
.dec-point {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}
.dec-op, .dec-eq {
  text-align: center;
  font-weight: 800;
  color: var(--gold);
  font-size: 20px;
}
.dec-rule {
  width: min(220px, 70vw);
  height: 2px;
  background: rgba(232, 197, 71, 0.45);
  margin: 2px auto;
}

/* ——— Area / break-apart (long mul) ——— */
.area-break {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.area-factor, .area-chip {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(232, 197, 71, 0.4);
  background: rgba(30, 41, 59, 0.6);
}
.area-chip { color: #fde68a; border-color: rgba(232, 197, 71, 0.55); }
.area-rects {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.area-rect {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 100px;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid rgba(134, 239, 172, 0.45);
  background: rgba(22, 101, 52, 0.22);
}
.area-rect.tens-rect {
  flex: 1.4;
  min-width: 120px;
  border-color: rgba(232, 197, 71, 0.55);
  background: rgba(120, 53, 15, 0.28);
}
.area-rect.ones-rect {
  flex: 0.8;
  border-color: rgba(110, 181, 255, 0.55);
  background: rgba(30, 58, 138, 0.28);
}
.area-dim {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
}
.area-val {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  color: #86efac;
  font-family: "Cinzel", serif;
}
.area-rects.joined .area-rect {
  box-shadow: 0 0 14px rgba(134, 239, 172, 0.2);
}

/* ——— PEMDAS / order ——— */
.pemdas-expr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(24px, 6vw, 36px);
  font-weight: 800;
  font-family: "Cinzel", serif;
}
.pemdas-mul {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px dashed rgba(148, 163, 184, 0.45);
  color: #e2e8f0;
}
.pemdas-mul.lit {
  border-style: solid;
  border-color: rgba(232, 197, 71, 0.75);
  background: rgba(120, 53, 15, 0.35);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.3);
  color: #fde68a;
}
.pemdas-mul.done {
  border-style: solid;
  border-color: rgba(134, 239, 172, 0.6);
  background: rgba(22, 101, 52, 0.3);
  color: #86efac;
}
.pemdas-add { color: #93c5fd; }
.pemdas-op { color: var(--gold); }
.pemdas-result {
  padding: 10px 18px;
  border-radius: 10px;
  border: 2px solid rgba(134, 239, 172, 0.6);
  background: rgba(22, 101, 52, 0.28);
  color: #86efac;
}

/* ——— Percent bar ——— */
.pct-bar {
  position: relative;
  width: min(280px, 85vw);
  height: 36px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(51, 65, 85, 0.85);
}
.pct-bar.small { width: min(120px, 40vw); height: 28px; }
.pct-fill {
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  background: linear-gradient(90deg, #fde68a, #e8c547 60%, #86efac);
  transition: width 0.25s ease;
}
.pct-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #0f172a;
  text-shadow: 0 0 4px rgba(255,255,255,0.45);
}
.pct-scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.pct-whole {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid rgba(134, 239, 172, 0.5);
  background: rgba(22, 101, 52, 0.22);
}
.pct-whole-n {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 700;
}
.pct-whole-n::before { content: "of "; }
.pct-whole-share {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  color: #86efac;
  font-family: "Cinzel", serif;
}

/* ——— Balance / equation ——— */
.bal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.bal-pan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 100px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(110, 181, 255, 0.45);
  background: rgba(30, 58, 138, 0.28);
  box-shadow: 0 6px 0 rgba(15, 23, 42, 0.45);
}
.bal-pan.right {
  border-color: rgba(232, 197, 71, 0.5);
  background: rgba(120, 53, 15, 0.28);
}
.bal-chip {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
}
.bal-chip.right-chip { color: #fde68a; }
.bal-plus { color: var(--gold); font-weight: 800; font-size: 18px; }
.bal-eq {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 800;
  color: #86efac;
  font-family: "Cinzel", serif;
}

/* ——— Negatives number line (also the "negative" word-check picture) ——— */
.numline-diagram .neg-line,
.concept-negative .neg-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  padding: 8px 4px 4px;
  border-bottom: 2px solid rgba(148, 163, 184, 0.35);
}
.numline-diagram .nl-tick,
.concept-negative .nl-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 28px;
}
.numline-diagram .nl-dot,
.concept-negative .nl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
}
.numline-diagram .nl-tick.start .nl-dot,
.concept-negative .nl-tick.start .nl-dot {
  background: #e8c547;
  box-shadow: 0 0 8px rgba(232, 197, 71, 0.55);
  width: 12px;
  height: 12px;
}
.numline-diagram .nl-tick.answer .nl-dot,
.concept-negative .nl-tick.answer .nl-dot {
  background: #86efac;
  box-shadow: 0 0 8px rgba(134, 239, 172, 0.55);
  width: 12px;
  height: 12px;
}
.numline-diagram .nl-tick.mystery .nl-dot,
.concept-negative .nl-tick.mystery .nl-dot {
  background: transparent;
  border: 2px dashed #94a3b8;
}
.numline-diagram .nl-tick.zero .nl-lab,
.concept-negative .nl-tick.zero .nl-lab { color: var(--gold); font-weight: 800; }
.numline-diagram .nl-lab,
.concept-negative .nl-lab {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

/* ——— Sign rule (neg × pos) ——— */
.sign-size, .sign-rule, .sign-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.sign-chip {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(30, 41, 59, 0.6);
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  color: #fff;
}
.sign-chip.size { color: #93c5fd; border-color: rgba(110, 181, 255, 0.5); }
.sign-chip.neg-prod {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.35);
  font-size: clamp(24px, 6vw, 36px);
}
.sign-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.25);
}
.sign-mark {
  font-size: 28px;
  font-weight: 800;
  color: #fca5a5;
}
.sign-desc {
  font-size: 12px;
  font-weight: 700;
  color: #fecaca;
  text-align: center;
}


.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice {
  cursor: pointer;
  padding: 14px 10px;
  font-size: 22px;
  font-weight: 700;
  font-family: "Rajdhani", sans-serif;
  color: var(--ink);
  background: #151d30;
  border: 1px solid rgba(232, 197, 71, 0.25);
}
.choice:hover { border-color: var(--glow); }
.choice.disabled, .choice.eliminated {
  opacity: 0.18;
  pointer-events: none;
  text-decoration: line-through;
}
.choice.wrong {
  border-color: var(--blood);
  animation: shove 0.28s ease;
}
.choice.right {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.45);
}
/* A tapped wrong answer stays out of play (cannot be tapped twice). */
.choice.eliminated-wrong {
  opacity: 0.32;
  pointer-events: none;
  text-decoration: line-through;
  border-color: var(--blood);
}
/* "Prove it on a twin puzzle" banner shown after a lesson. */
.twin-banner {
  margin: 0 0 8px;
  padding: 6px 10px;
  text-align: center;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  border: 1px solid rgba(232, 197, 71, 0.45);
  background: rgba(232, 197, 71, 0.08);
}
/* Concept primers: real-world analogy line + tiny picture. */
.concept-analogy {
  margin: 6px 0 0;
  font-size: 0.95em;
  opacity: 0.92;
}
.mini-svg {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 6px auto;
  color: var(--ink);
}

.summary-card.summary-scroll {
  max-height: min(92vh, 920px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  text-align: center;
}
.speed-card { max-width: 560px; }
.speed-result {
  margin: 8px auto 14px;
  font-family: "Cinzel", serif;
  font-size: 22px;
  color: var(--gold);
}
.speed-stats, .speed-records {
  margin: 0 auto 14px;
  max-width: 420px;
  text-align: left;
  line-height: 1.55;
}
.speed-stats { color: #e2e8f0; }
.speed-records { color: var(--muted); font-size: 15px; }
.speed-line, .speed-rec {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.speed-rec-title {
  margin: 10px 0 4px;
  font-family: "Cinzel", serif;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-size: 14px;
}
#hud-speed-lives { color: #f87171; }
.summary-meta {
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.04em;
}
.summary-verdict {
  margin: 0 auto 14px;
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid transparent;
}
.summary-verdict strong {
  font-family: "Cinzel", serif;
  font-size: 18px;
  letter-spacing: 0.04em;
}
.summary-verdict span {
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.95;
}
.summary-verdict.verdict-good {
  border-color: rgba(74, 222, 128, 0.5);
  background: linear-gradient(180deg, rgba(20, 48, 28, 0.9), rgba(12, 28, 20, 0.85));
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.15);
}
.summary-verdict.verdict-good strong { color: #86efac; }
.summary-verdict.verdict-good span { color: #bbf7d0; }
.summary-verdict.verdict-ok {
  border-color: rgba(251, 191, 36, 0.55);
  background: linear-gradient(180deg, rgba(48, 36, 12, 0.9), rgba(28, 22, 10, 0.85));
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.12);
}
.summary-verdict.verdict-ok strong { color: #fbbf24; }
.summary-verdict.verdict-ok span { color: #fde68a; }
.summary-verdict.verdict-bad {
  border-color: rgba(248, 113, 113, 0.55);
  background: linear-gradient(180deg, rgba(56, 18, 18, 0.92), rgba(28, 12, 14, 0.88));
  box-shadow: 0 0 18px rgba(248, 113, 113, 0.18);
}
.summary-verdict.verdict-bad strong { color: #fca5a5; }
.summary-verdict.verdict-bad span { color: #fecaca; }
.summary-badge.coaching {
  border-color: rgba(248, 113, 113, 0.45);
  background: linear-gradient(180deg, rgba(48, 18, 18, 0.88), rgba(18, 14, 20, 0.9));
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.12);
  max-width: 360px;
}
.summary-badge.coaching strong { color: #fca5a5; }
.goal-chip-warn {
  border-color: rgba(248, 113, 113, 0.55) !important;
  background: rgba(248, 113, 113, 0.12) !important;
  color: #fecaca !important;
}
.practice-nudge {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
}
.practice-nudge-strong {
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(56, 18, 18, 0.75);
  color: #fecaca;
}
.practice-nudge-strong strong { color: #fca5a5; }
.pr-guess-warn {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.55);
  background: rgba(56, 18, 18, 0.8);
  color: #fecaca;
  font-size: 14px;
  line-height: 1.45;
}
.pr-guess-warn strong { color: #fca5a5; display: block; margin-bottom: 4px; }
.pr-guess-do {
  margin-top: 8px;
  color: #fde68a;
  font-size: 13px;
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 14px;
  max-width: 520px;
}
.summary-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(232, 197, 71, 0.45);
  background: linear-gradient(180deg, rgba(40, 32, 12, 0.85), rgba(18, 22, 34, 0.9));
  box-shadow: 0 0 14px rgba(232, 197, 71, 0.12);
  max-width: 240px;
}
.summary-badge strong {
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.summary-badge span {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.3;
}
.summary-badge.empty {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 22, 36, 0.7);
  box-shadow: none;
}
.summary-badge.empty strong { color: #94a3b8; }
.summary-hero {
  list-style: none;
  text-align: left;
  margin: 0 auto 14px;
  max-width: 480px;
  padding: 0;
}
.summary-hero .sh-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 16px;
}
.summary-hero .sh-row strong { color: #f8fafc; }
.summary-hero .sh-frac {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92em;
}
.summary-pb {
  margin: 0 auto 14px;
  max-width: 480px;
  padding: 10px 14px;
  border: 1px solid rgba(110, 181, 255, 0.35);
  background: rgba(12, 28, 48, 0.65);
  text-align: left;
  font-size: 14px;
  color: #e2e8f0;
}
.summary-pb .pb-flash {
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 15px;
  margin-bottom: 4px;
}
.summary-pb .pb-delta { color: #86efac; }
.summary-pb .pb-delta.down { color: #fca5a5; }
.summary-section-title {
  margin: 0 0 8px;
  font-family: "Cinzel", serif;
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
}
.summary-next {
  margin: 0 auto 16px;
  max-width: 480px;
  text-align: left;
  padding: 12px 14px;
  background: rgba(15, 22, 36, 0.72);
  border: 1px solid rgba(78, 205, 196, 0.28);
}
.summary-goal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.goal-chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(232, 197, 71, 0.4);
  background: rgba(232, 197, 71, 0.1);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}
.summary-practice-body {
  font-size: 14px;
  color: #e2e8f0;
  line-height: 1.45;
}
.summary-practice-body h4 {
  margin: 10px 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
}
.summary-practice-body ul {
  margin: 0;
  padding-left: 1.1em;
}
.summary-practice-body li { margin-bottom: 6px; }
.summary-practice-body .tip {
  display: block;
  color: #a5b4fc;
  font-size: 13px;
  margin-top: 2px;
}
.summary-practice-body .miss-ex {
  color: #cbd5e1;
  font-size: 13px;
}
.summary-next-btn {
  margin-top: 12px;
  width: 100%;
}
.summary-footnote {
  margin: 0 auto 14px;
  max-width: 480px;
  font-size: 11px;
  color: #64748b;
  text-align: center;
}
.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, transparent, rgba(8, 10, 18, 0.96) 35%);
}

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--vv-bottom, 0px);
  height: min(52vh, 280px);
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 0 max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left));
  pointer-events: none;
}
.stick-zone, .touch-actions { pointer-events: auto; }
.stick-zone {
  width: min(48vw, 300px);
  height: 100%;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.stick-base {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 1px solid rgba(110,181,255,0.4);
  background: rgba(8,12,22,0.42);
  position: absolute;
  left: 12px;
  bottom: 10px;
  top: auto;
  opacity: 0.78;
}
.stick-base.active { opacity: 1; }
.stick-knob {
  width: 44%;
  height: 44%;
  border-radius: 50%;
  background: rgba(232,197,71,0.9);
  box-shadow: 0 0 12px rgba(232,197,71,0.35);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(calc(-50% + var(--kx, 0px)), calc(-50% + var(--ky, 0px)));
}
.touch-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: 4px;
}
.touch-skills {
  display: flex;
  gap: 8px;
  margin-right: 18px;
}
.touch-main {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.touch-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(232,197,71,0.4);
  background: rgba(12,18,32,0.82);
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 11px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-actions button small {
  font-family: "Rajdhani", sans-serif;
  font-size: 8px;
  letter-spacing: 0.08em;
  margin-top: 3px;
  opacity: 0.9;
}
#btn-attack {
  width: 82px;
  height: 82px;
  font-size: 16px;
  font-weight: 800;
  background: rgba(18, 28, 48, 0.92);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.28);
}
#btn-parry {
  width: 64px;
  height: 64px;
}
#btn-slide, .btn-slide {
  width: 64px;
  height: 64px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(8, 24, 42, 0.92);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.28);
  opacity: 0.55;
}
#btn-slide.ready, .btn-slide.ready {
  opacity: 1;
  color: #e0f2fe;
  border-color: rgba(125, 211, 252, 0.85);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
  background: rgba(6, 28, 48, 0.95);
}
#btn-slide:disabled {
  opacity: 0.35;
}

.touch-use {
  width: 52px;
  height: 52px;
  font-size: 12px;
  opacity: 0.95;
  border-color: rgba(110, 181, 255, 0.55);
  color: var(--ice);
  box-shadow: 0 0 12px rgba(110, 181, 255, 0.35);
}
.touch-skill, .touch-ult {
  width: 54px;
  height: 54px;
  font-size: 18px;
  opacity: 0.38;
}
.touch-skill span, .touch-ult span { font-size: 18px; }
.touch-skill.ready {
  opacity: 1;
  color: #bbf7d0;
  border-color: rgba(74, 222, 128, 0.7);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.45);
  background: rgba(6, 32, 18, 0.9);
  animation: pulse-ult 0.8s ease-in-out infinite;
}
.touch-ult.ready {
  opacity: 1;
  color: #0b0614;
  background: linear-gradient(180deg, #f5e27a, #d4a017);
  border-color: #fff3a1;
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.7);
  animation: pulse-ult 0.75s ease-in-out infinite;
}
@keyframes pulse-ult {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.12); filter: brightness(1.6) drop-shadow(0 0 10px rgba(255, 244, 163, 0.95)); }
}

.wipe {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, #e8eef8 48%, #6eb5ff 50%, #070910 52%, transparent 60%);
  background-size: 240% 100%;
  background-position: 100% 0;
}
.wipe.play {
  animation: slash 0.55s ease-in forwards;
}
.flash {
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}
.flash.go { animation: flash 0.28s ease; }

.hidden { display: none !important; }

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.06); }
}
@keyframes slash {
  from { background-position: 100% 0; opacity: 1; }
  to { background-position: -40% 0; opacity: 0; }
}
@keyframes flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}
@keyframes shove {
  0% { transform: translateX(0); }
  40% { transform: translateX(-10px); }
  100% { transform: translateX(0); }
}

.rotate-hint {
  display: none;
}
.rotate-hint-card {
  text-align: center;
  padding: 28px 24px;
}
.rotate-hint-card p {
  font-family: "Cinzel", serif;
  font-size: 22px;
  color: var(--gold);
  margin: 16px 0 8px;
}
.rotate-hint-card small {
  color: var(--muted);
  font-size: 15px;
}
.rotate-phone {
  width: 54px;
  height: 90px;
  margin: 0 auto;
  border: 3px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.35);
  animation: rotate-device 1.6s ease-in-out infinite;
}
@keyframes rotate-device {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(90deg); }
}

@media (orientation: portrait) and (max-width: 920px) and (pointer: coarse) {
  .rotate-hint {
    display: grid;
    place-items: center;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #070910;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .overlay {
    padding: calc(6px + env(safe-area-inset-top, 0px) + var(--vv-top, 0px)) calc(52px + env(safe-area-inset-right, 0px)) 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .hud-stat {
    min-width: 52px;
    padding: 4px 8px;
  }
  .hud-stat span:last-child { font-size: 14px; }
  .growth-wrap { min-width: 120px; }
  .growth-bar { height: 8px; }
  .rune-frame {
    width: min(860px, 94vw);
    max-height: 94vh;
    overflow-y: auto;
    padding: 16px 20px;
  }
  h2 { font-size: 22px; margin-bottom: 6px; }
  .tagline { margin: 8px auto 12px; font-size: 14px; }
  .diff-btn { padding: 10px 12px; }
  .diff-rank { font-size: 16px; margin-bottom: 4px; }
  .grade-btn { padding: 8px 6px; }
  .title-screen { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--vv-bottom, 0px)); }
  .title-actions { gap: 8px; }
  .title-actions .cta { min-height: 46px; padding: 12px 28px; font-size: 16px; }
  .title-actions .fs-cta { min-height: 38px; padding: 8px 22px; font-size: 13px; }
  .fs-float { width: 38px; height: 38px; font-size: 16px; }
  .arena-ui {
    width: min(720px, 92vw);
    margin-top: 2px;
    /* Leave generous band above touch controls so math/choices never cover Attack/Parry/animations. */
    max-height: calc(100dvh - 112px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--vv-bottom, 0px));
    padding: 0 8px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .math-card {
    padding: 10px 12px 10px;
    max-height: min(58vh, calc(100dvh - 122px - env(safe-area-inset-top, 0px)));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #math-prompt { font-size: clamp(16px, 3.8vw, 20px); margin-bottom: 4px; word-break: break-word; }
  .hint-visual {
    max-height: min(22vh, 120px);
    margin-bottom: 6px;
    gap: 4px;
  }
  .teach-box {
    max-height: min(26vh, 140px);
    padding: 6px 8px 6px;
  }
  .teach-lead { font-size: 12px; margin-bottom: 4px; }
  .teach-prompt { font-size: 13px; margin-bottom: 6px; }
  .teach-steps li { font-size: 14px; margin-bottom: 5px; gap: 8px; line-height: 1.3; }
  .teach-n { flex: 0 0 18px; height: 18px; font-size: 11px; line-height: 18px; }
  .hint-chip { font-size: 12px; padding: 4px 8px; }
  .choice {
    padding: 10px 8px;
    font-size: 17px;
    min-height: 44px;
  }
  .choices {
    gap: 8px;
  }
  .timer-row { margin-bottom: 4px; }
  #arena-timer { font-size: 18px; }
  #hint-stage { font-size: 11px; }
  #hud {
    gap: 4px;
    padding-top: max(4px, env(safe-area-inset-top, 0px));
  }
  .interact-hint {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px) + var(--vv-bottom, 0px));
    z-index: 8;
  }
  .fs-float {
    top: max(6px, env(safe-area-inset-top, 0px));
    right: max(6px, env(safe-area-inset-right, 0px));
    z-index: 12;
  }
  .touch-controls {
    height: min(48vh, 168px);
    z-index: 10;
    padding: 0 max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left));
  }
  .stick-zone { width: min(44vw, 240px); }
  .stick-base { width: 86px; height: 86px; left: 6px; bottom: 4px; }
  .touch-actions { gap: 6px; }
  .touch-skills { margin-right: 12px; gap: 6px; }
  .touch-main { gap: 8px; }
  #btn-attack { width: 70px; height: 70px; font-size: 14px; }
  #btn-parry { width: 56px; height: 56px; font-size: 10px; }
  #btn-slide { width: 56px; height: 56px; font-size: 9px; }
  .touch-use { width: 46px; height: 46px; font-size: 11px; }
  .touch-skill, .touch-ult { width: 46px; height: 46px; font-size: 16px; }
  .touch-skill span, .touch-ult span { font-size: 16px; }
  .touch-actions button small { font-size: 7px; margin-top: 1px; }
  .interact-hint { bottom: calc(78px + env(safe-area-inset-bottom, 0px) + var(--vv-bottom, 0px)); }
}


/* Brain Beam boot loader */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: #000;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.boot-loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-logo {
  width: min(72vw, 340px);
  height: auto;
  filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.35));
  user-select: none;
  -webkit-user-drag: none;
}
.boot-bar-wrap {
  width: min(70vw, 280px);
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(56, 189, 248, 0.35);
  overflow: hidden;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}
.boot-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22d3ee, #a3e635, #f97316);
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.55);
  transition: width 0.12s linear;
}
.boot-status {
  margin: 0;
  font-family: Rajdhani, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}
html.booting .title-actions {
  opacity: 0.35;
  pointer-events: none;
}
html.booting #btn-start {
  pointer-events: none;
}
/* Keep title CTAs clear of Android browser chrome */
.title-screen .title-actions {
  margin-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  padding-bottom: 4px;
}


/* In-game pause menu */
.pause-btn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px) + var(--vv-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 40;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(8, 12, 22, 0.78);
  color: #e2e8f0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.pause-btn:hover { border-color: #38bdf8; color: #fff; }
.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 14, 0.72);
  backdrop-filter: blur(4px);
}
.pause-overlay.hidden { display: none; }
.pause-card {
  width: min(420px, 92vw);
  padding: 28px 26px 24px;
  text-align: center;
}
.pause-card h2 {
  margin: 0 0 18px;
  font-size: 28px;
}
.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 22px;
  color: #cbd5e1;
  font-family: Rajdhani, sans-serif;
  font-weight: 600;
  font-size: 16px;
}
.volume-row input[type="range"] {
  flex: 1;
  accent-color: #38bdf8;
}
#volume-value {
  min-width: 2.2em;
  text-align: right;
  color: #7dd3fc;
}
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pause-actions .cta { width: 100%; }

/* ——— Lesson picker ——— */
.topic-grid .diff-btn small { display: block; margin-top: 4px; opacity: 0.85; }
#hud-lesson {
  font-size: 12px;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— Arena help (opt-in) ——— */
.arena-help-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}
.ask-etheral-btn {
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 16px;
  color: #86efac;
  background: rgba(15, 40, 28, 0.85);
  border: 1px solid rgba(134, 239, 172, 0.5);
  border-radius: 4px;
}
.ask-etheral-btn:hover,
.ask-etheral-btn:focus-visible {
  border-color: #86efac;
  box-shadow: 0 0 14px rgba(134, 239, 172, 0.35);
}

.elf-plan-offer {
  margin-top: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(12, 28, 22, 0.95), rgba(8, 16, 14, 0.92));
  border: 1px solid rgba(134, 239, 172, 0.45);
  box-shadow: 0 0 22px rgba(134, 239, 172, 0.18);
  text-align: center;
}
.elf-offer-speech {
  margin: 0 0 10px;
  font-family: "Cinzel", serif;
  font-size: 16px;
  color: #bbf7d0;
  letter-spacing: 0.04em;
}
.elf-offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.elf-offer-actions .cta {
  min-width: 110px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 15px;
}

/* ——— Teach modal ——— */
.teach-overlay {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(4, 8, 14, 0.72);
  pointer-events: auto;
  box-sizing: border-box;
}
.teach-overlay.hidden { display: none !important; }

/* Hide touch HUD while Etheral teach modal is open so buttons don't stack. */
html.teach-open .touch-controls {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden;
}
html.teach-open .interact-hint {
  opacity: 0 !important;
  pointer-events: none !important;
}
html.teach-open .fs-float {
  z-index: 90;
}

.teach-modal {
  width: min(560px, 96vw);
  max-height: min(88vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 16px;
  text-align: left;
}
.teach-modal h2 {
  margin: 0 0 10px;
  font-size: clamp(20px, 4vw, 26px);
  color: #86efac;
}
.teach-body { margin-bottom: 14px; }
.teach-plan-q {
  margin: 0 0 12px;
  font-size: clamp(16px, 3.2vw, 20px);
  color: #e2e8f0;
  line-height: 1.35;
  word-break: break-word;
}
.teach-plan-q strong { color: #fff; }
.teach-step-label,
.teach-why-label {
  margin: 0 0 6px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-transform: uppercase;
}
.teach-step-body,
.teach-why-text {
  margin: 0 0 10px;
  font-size: clamp(17px, 3.5vw, 22px);
  font-weight: 700;
  line-height: 1.4;
  color: #f8fafc;
}
.teach-answer-chip {
  margin: 12px auto 0;
  padding: 12px 18px;
  display: block;
  width: fit-content;
  max-width: 100%;
  text-align: center;
  background: rgba(232, 197, 71, 0.18);
  border: 2px solid rgba(232, 197, 71, 0.55);
  color: var(--gold);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  font-family: "Cinzel", serif;
  letter-spacing: 0.04em;
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.2);
}
.teach-answer-chip strong { color: #fff; font-size: 1.15em; }
.teach-try-note,
.teach-turn-note {
  margin: 8px 0 0;
  padding: 9px 11px;
  border-left: 3px solid #86efac;
  background: rgba(134, 239, 172, 0.08);
  color: #d1fae5;
  font-size: clamp(14px, 2.8vw, 17px);
  font-weight: 700;
  line-height: 1.35;
}
.teach-question-focus {
  margin: 8px 0;
  padding: 14px;
  border: 2px dashed rgba(232, 197, 71, 0.5);
  border-radius: 8px;
  color: #fde68a;
  text-align: center;
  font-size: clamp(15px, 3vw, 18px);
  font-weight: 800;
}
.teach-participate .teach-diagram {
  border-color: rgba(134, 239, 172, 0.48);
}
.teach-reveal .teach-diagram {
  border-color: rgba(110, 181, 255, 0.48);
}
.teach-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.teach-nav .cta {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px;
}
.teach-nav .cta:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ——— Parent report ——— */
.parent-report {
  margin: 8px auto 16px;
  max-width: 480px;
  text-align: left;
  padding: 12px 14px;
  background: rgba(15, 22, 36, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.28);
}
.parent-report-body .pr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 8px;
}
.parent-report-body .pr-grid .pr-row {
  border-bottom: none;
  padding: 4px 0;
  font-size: 13px;
}
.parent-report-title {
  margin: 0 0 10px;
  font-family: "Cinzel", serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #94a3b8;
  text-transform: uppercase;
}
.parent-report-body {
  font-size: 15px;
  color: #e2e8f0;
  line-height: 1.45;
}
.parent-report-body .pr-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.parent-report-body h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-family: "Cinzel", serif;
}
.parent-report-body ul {
  margin: 0;
  padding-left: 1.1em;
}
.parent-report-body li { margin-bottom: 4px; }
.parent-report-body .pr-miss {
  font-size: 13px;
  color: #cbd5e1;
  opacity: 0.9;
}
.parent-report-empty {
  color: #94a3b8;
  font-style: italic;
}

@media (orientation: landscape) and (max-height: 520px) {
  .arena-help-row { margin-top: 6px; }
  .ask-etheral-btn { padding: 6px 12px; font-size: 12px; min-height: 40px; }
  .elf-plan-offer {
    padding: 6px 10px;
    margin-top: 4px;
    max-height: min(22vh, 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .elf-offer-speech { font-size: 12px; margin-bottom: 4px; }
  .elf-offer-actions { gap: 8px; }
  .elf-offer-actions .cta {
    min-height: 44px;
    min-width: 96px;
    padding: 8px 14px;
    font-size: 13px;
  }
  .teach-overlay {
    align-items: stretch;
    padding: max(4px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(4px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .teach-modal {
    width: min(640px, 96vw);
    max-height: calc(100dvh - 8px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 8px 12px 8px;
    display: flex;
    flex-direction: column;
  }
  .teach-modal h2 { font-size: 16px; margin-bottom: 4px; flex: 0 0 auto; }
  .teach-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 8px;
  }
  .teach-nav {
    flex: 0 0 auto;
    gap: 10px;
    justify-content: space-between;
  }
  .teach-nav .cta {
    min-height: 44px;
    min-width: 88px;
    padding: 10px 14px;
    font-size: 14px;
  }
  .teach-step-body, .teach-why-text { font-size: 15px; margin-bottom: 6px; }
  .teach-plan-q { font-size: 14px; margin-bottom: 6px; }
  .teach-body.has-diagram .teach-diagram { padding: 8px 6px 6px; }
  .teach-body.has-diagram .dot { width: 16px; height: 16px; }
  .teach-visual-hero { min-height: 72px; }
  .teach-answer-chip { padding: 8px 14px; font-size: 16px; margin-top: 6px; }
  /* Phone on its side: the answer choices stay pinned to the bottom of the lesson page, in one
     row, so they are always on screen while the step and picture scroll behind them. */
  .teach-body .teach-attempt {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(10, 20, 34, 0.97);
  }
  /* (.teach-body prefix: the base .teach-attempt rules come later in this file.) */
  .teach-body .teach-attempt-label { margin-bottom: 4px; font-size: 13px; }
  .teach-body .teach-attempt-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .teach-body .teach-attempt-choice { padding: 6px 4px; font-size: 15px; line-height: 1.15; min-height: 44px; overflow-wrap: anywhere; }
  .teach-body .teach-attempt-feedback { margin-top: 4px; min-height: 0; font-size: 13px; }
  .teach-body .teach-attempt-feedback:empty { display: none; }
  .parent-report { padding: 10px 12px; margin-bottom: 12px; }
  .parent-report-body { font-size: 13px; }
  .summary-card.summary-scroll {
    max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 12px 14px 10px;
  }
  .summary-hero .sh-row { font-size: 14px; padding: 6px 0; }
  .summary-badge { padding: 6px 10px; max-width: 200px; }
  .summary-badge strong { font-size: 12px; }
  .summary-badge span { font-size: 11px; }
  .summary-next, .summary-pb { padding: 10px 12px; }
  .summary-actions { gap: 8px; }
  .summary-actions .cta { min-height: 42px; padding: 10px 18px; font-size: 14px; }
  .parent-report-body .pr-grid { grid-template-columns: 1fr; }
  #hud-lesson { max-width: 64px; font-size: 11px; }
}

/* ——— Title Settings panel ——— */
.settings-card {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 28px 22px;
}
.settings-card h2 { margin-bottom: 14px; }
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border: 1px solid rgba(232, 197, 71, 0.22);
  background: rgba(8, 12, 22, 0.55);
}
.settings-row.volume-row {
  margin: 0;
  min-height: 40px;
}
.settings-row .settings-label {
  min-width: 7.5em;
  text-align: left;
}
.settings-row input[type="range"] {
  flex: 1;
  min-height: 32px;
  accent-color: #38bdf8;
  touch-action: pan-y;
  cursor: pointer;
}
.settings-value {
  min-width: 2.4em;
  text-align: right;
  color: #7dd3fc;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
}
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  color: #cbd5e1;
  font-family: Rajdhani, sans-serif;
  font-weight: 600;
  font-size: 16px;
  text-align: left;
}
.settings-toggle-row .settings-label small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.settings-toggle {
  flex: 0 0 auto;
  min-width: 78px;
  min-height: 38px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.45);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.settings-toggle[aria-checked="true"] {
  color: #0a0e18;
  background: linear-gradient(180deg, #7ee7df, #2aa89f);
  border-color: #7ee7df;
  box-shadow: 0 0 14px rgba(78, 205, 196, 0.35);
}
.settings-toggle:focus-visible,
.settings-row input[type="range"]:focus-visible,
#screen-settings .cta:focus-visible,
.title-actions .cta:focus-visible {
  outline: 2px solid #fde68a;
  outline-offset: 2px;
}
#btn-settings-back { min-width: 160px; }
@media (max-height: 520px) {
  .settings-card { padding: 12px 16px; max-height: 96vh; }
  .settings-card h2 { margin-bottom: 6px; }
  .settings-group { padding: 4px 10px; margin-bottom: 8px; gap: 0; }
  .settings-row.volume-row { min-height: 32px; font-size: 14px; }
  .settings-toggle-row { min-height: 36px; font-size: 14px; }
  .settings-toggle-row .settings-label small { font-size: 11px; }
  .settings-toggle { min-height: 32px; min-width: 64px; font-size: 12px; }
}

/* Reduce flashing effects (Settings → Reduce Shake & Flashes). */
html.reduce-fx .flash.go { animation: none; }

/* Elf Helper off: no Ask Etheral button in the arena (forced lesson still opens). */
html.elf-helper-off #btn-ask-etheral { display: none; }

/* Forced 2-wrong lesson: no skipping out, step through to the end. */
.teach-forced-lead {
  margin: 0 0 8px;
  color: #fde68a;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  font-size: 15px;
}

/* ——— Grades 7–9 teaching pictures (js/mathSenior.js, .sx-*) ——— */
.sx-diagram { text-align: center; }
.sx-svg { display: block; max-width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.sx-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 6px 0; }
.sx-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; padding: 4px 9px; border-radius: 6px;
  background: rgba(30, 41, 59, 0.92); border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e2e8f0; font: 700 16px "Rajdhani", sans-serif; line-height: 1.2;
}
.sx-chip.sx-good { border-color: #86efac; color: #86efac; box-shadow: 0 0 10px rgba(134, 239, 172, 0.25); }
.sx-chip.sx-dim { color: #94a3b8; opacity: 0.85; }
.sx-chip.sx-block { background: rgba(232, 197, 71, 0.22); border-color: rgba(232, 197, 71, 0.7); color: #fde68a; }
.sx-chip.sx-block.b { background: rgba(110, 181, 255, 0.22); border-color: rgba(110, 181, 255, 0.7); color: #bfdbfe; }
.sx-chip.sx-coef { background: rgba(196, 181, 253, 0.2); border-color: rgba(196, 181, 253, 0.6); }
.sx-chip.sx-tag.gold { border-color: rgba(232, 197, 71, 0.6); color: #fde68a; font-size: 14px; }
.sx-chip.sx-tag.blue { border-color: rgba(110, 181, 255, 0.6); color: #bfdbfe; font-size: 14px; }
.sx-cross { text-decoration: line-through; text-decoration-color: #f87171; text-decoration-thickness: 3px; opacity: 0.55; }
.sx-op { color: #e8c547; font: 800 20px "Rajdhani", sans-serif; padding: 0 2px; }
.sx-group { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; border: 1px dashed rgba(232, 197, 71, 0.45); border-radius: 8px; }
.sx-group.b { border-color: rgba(110, 181, 255, 0.5); }
.sx-big { font-size: 28px; }
.sx-pow { font: 800 42px "Rajdhani", sans-serif; line-height: 1; }
.sx-pow-base { color: #e8c547; }
.sx-pow-exp { color: #6eb5ff; font-size: 0.55em; vertical-align: super; margin-left: 2px; }
.sx-run .sx-chip { font-size: 14px; }
.sx-fraction { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.sx-fbar { width: 100%; min-width: 60px; height: 3px; background: #e2e8f0; border-radius: 2px; }
.sx-ladder { display: inline-flex; flex-direction: column; align-items: center; }
.sx-ladder-row {
  display: grid; grid-template-columns: 70px 76px; gap: 6px; align-items: center;
  padding: 3px 8px; border-radius: 6px; background: rgba(30, 41, 59, 0.85); border: 1px solid rgba(148, 163, 184, 0.3);
  font: 700 17px "Rajdhani", sans-serif;
}
.sx-ladder-p { color: #e8c547; text-align: right; }
.sx-ladder-v { color: #e2e8f0; text-align: left; }
.sx-ladder-row.sx-zero { border-color: rgba(110, 181, 255, 0.6); }
.sx-ladder-row.sx-hot { border-color: #86efac; box-shadow: 0 0 12px rgba(134, 239, 172, 0.3); }
.sx-ladder-row.sx-hot .sx-ladder-v { color: #86efac; }
.sx-ladder-row.sx-ghost { opacity: 0.35; }
.sx-ladder-step { font-size: 12px; color: #94a3b8; line-height: 1.3; }
.sx-ladder-h { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.sx-rung {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 52px; padding: 4px 6px;
  border-radius: 6px; border: 1px solid rgba(148, 163, 184, 0.35); color: #94a3b8; font: 800 16px "Rajdhani", sans-serif;
}
.sx-rung small { font-size: 10px; font-weight: 600; }
.sx-rung.on { color: #fde68a; border-color: #e8c547; box-shadow: 0 0 12px rgba(232, 197, 71, 0.3); }
.sx-exprs { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sx-expr { font: 700 21px "Rajdhani", sans-serif; color: #e2e8f0; }
.sx-expr.old { opacity: 0.5; font-size: 17px; }
.sx-expr-part.hot { background: rgba(232, 197, 71, 0.25); border-radius: 5px; padding: 0 3px; color: #fde68a; }
.sx-expr-part.done { color: #86efac; }
.sx-sign { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; font: 800 22px "Rajdhani", sans-serif; }
.sx-sign.neg { background: rgba(248, 113, 113, 0.3); border: 2px solid #f87171; color: #fecaca; }
.sx-sign.pos { background: rgba(134, 239, 172, 0.25); border: 2px solid #86efac; color: #bbf7d0; }
.sx-tilerow { gap: 10px; }
.sx-tilegroup { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; font: 800 20px "Rajdhani", sans-serif; color: #e8c547; max-width: 260px; }
.sx-tile {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 4px;
  border-radius: 5px; font: 700 14px "Rajdhani", sans-serif; color: #0b1220;
  background: #e8c547; border: 1px solid rgba(0, 0, 0, 0.35);
}
.sx-tile.y { background: #6eb5ff; }
.sx-tile.one { min-width: 18px; height: 18px; font-size: 11px; background: #cbd5e1; }
.sx-tile.sq { min-width: 34px; height: 34px; }
.sx-tile.neg { background: #f87171; }
.sx-tile.wide { padding: 0 8px; }
.sx-tile.gone { opacity: 0.12; }
.sx-tilerow.piles { gap: 14px; align-items: flex-start; }
.sx-pile { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 220px; padding: 6px; border: 1px dashed rgba(148, 163, 184, 0.45); border-radius: 8px; justify-content: center; }
.sx-pile-lab { width: 100%; font-size: 12px; color: #94a3b8; }
.sx-pile-sum { width: 100%; font: 800 18px "Rajdhani", sans-serif; color: #86efac; min-height: 4px; }
.sx-abox {
  display: grid; grid-template-columns: 58px repeat(var(--abox-cols, 2), minmax(64px, 1fr));
  gap: 4px; max-width: 360px; margin: 4px auto;
}
.sx-abox-corner { color: #94a3b8; font-weight: 800; align-self: center; }
.sx-abox-head { font: 800 19px "Rajdhani", sans-serif; color: #e8c547; align-self: center; text-align: center; }
.sx-abox-head.left { color: #6eb5ff; }
.sx-abox-head.ask { color: #94a3b8; }
.sx-abox-cell {
  min-height: 48px; display: flex; align-items: center; justify-content: center;
  background: rgba(78, 205, 196, 0.14); border: 1px solid rgba(78, 205, 196, 0.55); border-radius: 6px;
  font: 800 19px "Rajdhani", sans-serif; color: #e2e8f0;
}
.sx-abox-cell.sq { background: rgba(232, 197, 71, 0.2); border-color: rgba(232, 197, 71, 0.6); }
.sx-abox-cell.mid { background: rgba(110, 181, 255, 0.2); border-color: rgba(110, 181, 255, 0.6); }
.sx-abox-cell.num { background: rgba(196, 181, 253, 0.2); border-color: rgba(196, 181, 253, 0.6); }
.sx-pairs .sx-chip { font-size: 14px; }
.sx-balrow { margin: 4px 0; }
/* Algebra needs real lowercase letters (Cinzel shows n as N), so use the body font here. */
.sx-balchain .bal-chip { font-family: "Rajdhani", sans-serif; letter-spacing: 0.5px; }
.sx-balrow.old { opacity: 0.45; }
.sx-balmove { display: inline-block; margin-bottom: 4px; padding: 2px 8px; border-radius: 10px; background: rgba(232, 197, 71, 0.18); color: #fde68a; font-size: 13px; font-weight: 700; }
.sx-ptable {
  display: grid; grid-template-columns: 56px repeat(var(--pcols, 4), minmax(34px, 1fr));
  gap: 3px; max-width: 440px; margin: 4px auto; font: 700 17px "Rajdhani", sans-serif;
}
.sx-pl { color: #94a3b8; font-size: 13px; align-self: center; text-align: right; padding-right: 4px; }
.sx-pn { color: #94a3b8; }
.sx-pt { background: rgba(30, 41, 59, 0.9); border: 1px solid rgba(148, 163, 184, 0.35); border-radius: 5px; color: #e2e8f0; }
.sx-pm { color: #6eb5ff; }
.sx-pn.hot, .sx-pt.hot { color: #86efac; border-color: #86efac; }
.sx-pn.dots, .sx-pt.dots, .sx-pm.dots { color: #64748b; border: none; background: none; }
.sx-digits { gap: 2px; }
.sx-digit { display: inline-block; min-width: 22px; font: 800 28px "Rajdhani", sans-serif; color: #e2e8f0; }
.sx-digit.zero { color: #94a3b8; }
.sx-point { font: 900 30px "Rajdhani", sans-serif; color: #e8c547; margin: 0 -2px; }
.sx-hops .sx-hop { display: inline-block; padding: 1px 6px; border-radius: 10px; background: rgba(134, 239, 172, 0.2); color: #86efac; font-size: 12px; font-weight: 700; }
.sx-hops .sx-hop.ghost { background: none; color: #94a3b8; font-size: 15px; }
.sx-ogrid {
  display: grid; grid-template-columns: 58px repeat(var(--ocols, 2), minmax(34px, 1fr));
  gap: 3px; max-width: 430px; margin: 4px auto;
}
.sx-ohead { font: 800 16px "Rajdhani", sans-serif; color: #e8c547; align-self: center; }
.sx-ohead.corner { color: #94a3b8; font-size: 11px; }
.sx-ocell {
  min-height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.25); border-radius: 4px;
  font: 700 15px "Rajdhani", sans-serif; color: #e2e8f0;
}
.sx-ocell.fav { background: rgba(134, 239, 172, 0.35); border-color: #86efac; color: #f0fdf4; }
.sx-ogrid.dense .sx-ocell { min-height: 24px; font-size: 13px; }
@media (max-width: 600px), (max-height: 520px) {
  .sx-abox-cell { min-height: 36px; font-size: 16px; }
  .sx-pow { font-size: 32px; }
  .sx-expr { font-size: 18px; }
  .sx-digit { font-size: 22px; min-width: 17px; }
  .sx-tile { min-width: 22px; height: 22px; }
  .sx-ogrid.dense .sx-ocell { min-height: 20px; font-size: 11px; }
}
/* Short landscape phones: shrink tall pictures so the whole diagram fits above Back / Next. */
@media (max-height: 520px) {
  .teach-modal .sx-svg { width: auto; height: auto; max-width: 100%; max-height: 32vh; }
}

/* ---- Valhalla ready indicator (Oct 9 2026): key chip on the bar + gentle gold pulse ---- */
.growth-label { white-space: nowrap; }
.growth-label .hud-key {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  min-width: 16px;
  line-height: 15px;
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  color: #1a1204;
  background: linear-gradient(180deg, #fff3a1, #e8c547);
  border: 1px solid #fff7d6;
  border-radius: 3px;
  box-shadow: 0 1px 0 #8a6a12, 0 0 8px rgba(253, 224, 71, 0.55);
  vertical-align: 1px;
}
.growth-label .hud-key-touch { font-size: 10px; letter-spacing: 0.06em; }
.growth-wrap.upgrade-track .growth-label {
  color: #fde68a;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(6, 8, 16, 0.95), 0 0 5px rgba(6, 8, 16, 0.7);
}
.growth-wrap.upgrade-track .growth-bar { border-color: rgba(251, 191, 36, 0.75); }
.growth-wrap.upgrade-track #growth-fill {
  background: linear-gradient(90deg, #b45309, #fbbf24, #fef3c7);
  box-shadow: 0 0 12px #fbbf24;
}
.growth-wrap.valhalla-armed .growth-label { color: #fde68a; }
.growth-wrap.valhalla-armed #growth-fill {
  background: linear-gradient(90deg, #b45309, #fde68a, #fffbeb);
  box-shadow: 0 0 12px #fde68a;
}
.growth-wrap.valhalla-hot .growth-bar {
  border-color: rgba(253, 224, 71, 0.9);
  animation: valhalla-ready-pulse 1.4s ease-in-out infinite;
}
.growth-wrap.valhalla-hot .hud-key { animation: valhalla-key-pulse 1.4s ease-in-out infinite; }
@keyframes valhalla-ready-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(253, 224, 71, 0.35); }
  50% { box-shadow: 0 0 14px rgba(253, 224, 71, 0.85); }
}
@keyframes valhalla-key-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
html.reduce-fx .growth-wrap.valhalla-hot .growth-bar,
html.reduce-fx .growth-wrap.valhalla-hot .hud-key { animation: none; }
@media (max-width: 900px), (max-height: 500px) {
  .growth-label .hud-key { font-size: 10px; line-height: 12px; padding: 0 4px; margin-left: 4px; }
}
/* Readable over snow / sand too (the bar label has no panel behind it). */
.growth-wrap.valhalla-armed .growth-label {
  text-shadow: 0 1px 2px rgba(6, 8, 16, 0.95), 0 0 5px rgba(6, 8, 16, 0.7);
  font-weight: 700;
}

/* Oct 21: keep the top-right HUD stats (Seals) clear of the ☰ pause / ⛶ full-screen buttons. */
#hud .hud-right { margin-right: 46px; }
@media (orientation: landscape) and (max-height: 520px) {
  #hud .hud-right { margin-right: 42px; }
}

/* Oct 21: summary buttons live in a footer below the scrolling stats, so they never sit on
   top of (and hide) the records. */
.summary-card.summary-scroll {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.summary-card.summary-scroll > .summary-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.summary-card.summary-scroll > .summary-actions {
  position: static;
  flex: 0 0 auto;
  background: none;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(232, 197, 71, 0.18);
}

/* ---- Manual rotate ("↻ Rotate & Play") — phones stuck in portrait (js/forceLandscape.js) ---- */
.rotate-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 26px auto 0;
  min-width: 240px;
  min-height: 64px;
  padding: 14px 30px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: #0a0e18;
  background: linear-gradient(180deg, #f5dc7a, var(--gold) 55%, var(--gold-dim));
  border: 2px solid #fff3c2;
  border-radius: 16px;
  box-shadow: 0 0 26px rgba(232, 197, 71, 0.55), 0 6px 0 #6b5418;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: rotate-play-pulse 1.8s ease-in-out infinite;
}
.rotate-play-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.45), 0 2px 0 #6b5418;
}
.rotate-play-icon {
  font-size: 30px;
  line-height: 1;
  font-family: system-ui, sans-serif;
}
.rotate-hint-card small.rotate-play-note {
  display: block;
  margin-top: 14px;
  font-size: 14px;
}
@keyframes rotate-play-pulse {
  0%, 100% { box-shadow: 0 0 22px rgba(232, 197, 71, 0.45), 0 6px 0 #6b5418; }
  50% { box-shadow: 0 0 36px rgba(232, 197, 71, 0.85), 0 6px 0 #6b5418; }
}
html.reduce-fx .rotate-play-btn { animation: none; }

/* "Rotate screen manually" row only shows while the game is manually rotated (the way to turn it
   off); normal landscape phones / desktop keep their Settings card exactly as before. */
.settings-toggle-row.settings-rotate-row { display: none; }
html.force-landscape .settings-toggle-row.settings-rotate-row { display: flex; }

/* Forced landscape: #app is the whole game (canvas, HUD, touch pad, every screen/popup/homework
   root), turned 90° clockwise and sized to the swapped viewport. --fl-* set by forceLandscape.js. */
html.force-landscape,
html.force-landscape body {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.force-landscape #app {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  width: var(--fl-w) !important;
  height: var(--fl-h) !important;
  transform-origin: 0 0;
  transform: translateX(var(--fl-tx)) rotate(90deg);
}
html.force-landscape #game {
  top: 0 !important;
  bottom: auto !important;
}
html.force-landscape .rotate-hint { display: none !important; }
html.force-landscape .fs-spacer { display: none !important; }

@keyframes fadeScreenIn { from { opacity: 0; } to { opacity: 1; } }

/* Level-select preview thumbnails rendered by the game into each .level-thumb canvas. */
.level-thumb {
  display: block;
  width: 100%;
  height: 80px;
  border-radius: 6px;
  margin-bottom: 6px;
  overflow: hidden;
  background: #0a0e1a;
}
.level-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}
@media (max-width: 640px), (max-height: 480px) {
  .level-thumb { height: 56px; }
}

/* Blurred level background behind menu screens */
.screen-bg-blur {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  filter: blur(8px) brightness(0.35);
  -webkit-filter: blur(8px) brightness(0.35);
  transform: scale(1.1);
  pointer-events: none;
}
.rune-frame, .grade-card, .hero-select-shell {
  position: relative;
  z-index: 1;
}

/* Tier-up flash: brighter and longer than normal combat flash */
#flash.tier-flash {
  animation: tierFlash 0.8s ease-out both !important;
}
@keyframes tierFlash {
  0% { opacity: 1; background: rgba(253, 224, 71, 0.85); }
  15% { opacity: 0.9; background: rgba(255, 255, 255, 0.7); }
  40% { opacity: 0.5; background: rgba(249, 115, 22, 0.3); }
  100% { opacity: 0; background: transparent; }
}


/* ── Title menu (13 Nov): one dark panel, two clear tiers, nothing see-through ── */
.title-screen .title-actions {
  width: min(430px, 92vw);
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  background: rgba(7, 9, 16, 0.86);
  border: 1px solid rgba(232, 197, 71, 0.5);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.title-primary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.title-actions .title-primary .cta {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
}
.title-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.title-actions .title-secondary .cta,
.title-actions .title-secondary .cta.ghost {
  flex: 1 1 0;
  min-width: 96px;
  min-height: 42px;
  padding: 9px 10px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #f6ecc8;
  background: #16203a;
  border: 1.5px solid rgba(232, 197, 71, 0.75);
  border-radius: 8px;
  box-shadow: none;
  text-shadow: none;
}
.title-actions .title-secondary .cta:hover,
.title-actions .title-secondary .cta:focus-visible {
  background: #22305a;
  border-color: #f5e27a;
}
/* "Close Game" only makes sense in the desktop app window. */
#btn-quit { display: none; }
html.is-desktop-app #btn-quit { display: inline-block; }
@media (orientation: landscape) and (max-height: 520px) {
  /* Phones held sideways: a short, wide panel so the title art above stays visible. */
  .title-screen .title-actions {
    width: min(560px, 94vw);
    gap: 8px;
    padding: 10px 12px;
  }
  .title-primary { flex-direction: row; }
  .title-actions .title-primary .cta { flex: 1 1 0; width: auto; min-height: 46px; padding: 10px 12px; font-size: 16px; }
  .title-actions .title-secondary .cta,
  .title-actions .title-secondary .cta.ghost { min-height: 36px; padding: 6px 8px; font-size: 12px; }
}

/* Full-screen recovery bar: shows after the browser drops out of full screen mid-game. */
.fs-recover {
  position: fixed;
  top: calc(6px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  gap: 6px;
  align-items: center;
}
.fs-recover.hidden { display: none; }
.fs-recover-btn, .fs-recover-x {
  cursor: pointer;
  min-height: 40px;
  padding: 8px 16px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #0b0614;
  background: linear-gradient(180deg, #f5e27a, #d4a017);
  border: 2px solid rgba(245, 226, 122, 0.8);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}
.fs-recover-x { padding: 8px 12px; background: #16203a; color: #f6ecc8; }


/* WARP offer: the button and hint pulse while Etheral is offering to pull the hero out. */
@keyframes warpFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.0); transform: scale(1); filter: brightness(1); }
  50% { box-shadow: 0 0 22px 6px rgba(56, 189, 248, 0.85); transform: scale(1.12); filter: brightness(1.5); }
}
.touch-use.warp-flash {
  animation: warpFlash 0.7s ease-in-out infinite;
  border-color: #7dd3fc !important;
  color: #e0f2fe !important;
}
.interact-hint.warp-flash {
  animation: warpFlash 0.7s ease-in-out infinite;
  border-color: #7dd3fc;
}


/* Arena help row: both helps are buttons the player chooses to press. */
.arena-help-row { gap: 10px; flex-wrap: wrap; }
.fifty-btn { color: #fde68a; background: rgba(46, 34, 10, 0.85); border-color: rgba(253, 230, 138, 0.5); }
.fifty-btn:disabled, .fifty-btn.used { opacity: 0.35; pointer-events: none; }
html.elf-helper-off #btn-fifty { display: none; }

/* Lesson: "your turn first" answer choices under each step. */
.teach-attempt {
  margin-top: 10px;
  padding: 10px 10px 8px;
  border: 1px solid rgba(126, 231, 223, 0.4);
  border-radius: 8px;
  background: rgba(10, 20, 34, 0.7);
}
.teach-attempt-label { margin: 0 0 8px; font-weight: 700; color: #7ee7df; font-size: 15px; }
.teach-attempt-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.teach-attempt-choice { padding: 10px 8px; font-size: 18px; min-height: 44px; }
.teach-attempt-feedback { margin: 8px 0 0; min-height: 1.2em; color: #fde68a; font-size: 14px; }
.teach-solved-note { margin: 0 0 8px; font-weight: 700; color: #86efac; }
.teach-solved-note.is-back { margin: 10px 0 0; }

/* --- Hearts (extra lives) --- */
.hearts-row { display: flex; gap: 3px; align-items: center; min-height: 22px; }
.hearts-row.hero-none { font-family: "Cinzel", serif; font-size: 13px; color: #fca5a5; letter-spacing: 0.08em; text-transform: uppercase; }
.hud-stat .heart {
  font-family: Arial, sans-serif;
  font-size: 22px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}
.hud-stat .heart.full { color: #ef4444; text-shadow: 0 0 8px rgba(239, 68, 68, 0.65); }
.hud-stat .heart.empty { color: rgba(148, 163, 184, 0.35); text-shadow: none; }
.hud-stat .heart.gain { animation: heartGain 0.7s ease-out; }
.hud-stat .heart.lose { animation: heartLose 0.7s ease-out; }
@keyframes heartGain { 0% { transform: scale(2.2); filter: brightness(2); } 60% { transform: scale(0.9); } 100% { transform: scale(1); filter: none; } }
@keyframes heartLose { 0% { transform: scale(1.7); color: #fff; } 100% { transform: scale(1); } }
.diff-btn .diff-hearts { display: block; margin-top: 8px; font-family: "Cinzel", serif; font-size: 15px; letter-spacing: 0.06em; color: #fca5a5; }
.diff-btn .diff-hearts.none { color: #94a3b8; }
@media (max-width: 760px) { .hud-stat .heart { font-size: 17px; } }
.rank-grid { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
.rank-grid .diff-btn { height: 100%; }
@media (max-width: 520px) { .rank-grid { grid-template-columns: 1fr; } }


/* ───────── Learn Maths (js/learn.js): Etheral's study + "Let's learn" in a duel ───────── */
.learn-overlay { z-index: 86; background: rgba(4, 8, 14, 0.93); }
.learn-modal { width: min(660px, 96vw); max-height: min(92vh, 660px); }
.learn-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.learn-head h2 { flex: 1 1 auto; }
.learn-close {
  flex: 0 0 auto;
  cursor: pointer;
  width: 36px;
  height: 36px;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(232, 197, 71, 0.4);
  border-radius: 4px;
}
.learn-close:hover, .learn-close:focus-visible { border-color: var(--gold); }
.learn-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  counter-reset: learnstep;
}
.learn-steps.hidden { display: none; }
.learn-steps li {
  counter-increment: learnstep;
  padding: 3px 9px;
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}
.learn-steps li::before { content: counter(learnstep) " · "; }
.learn-steps li.active { color: #0a0e18; background: #86efac; border-color: #86efac; }
.learn-steps li.done { color: #86efac; border-color: rgba(134, 239, 172, 0.5); }
.learn-steps li.done::before { content: "✓ "; }
.learn-elf {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: rgba(15, 40, 28, 0.85);
  border: 1px solid rgba(134, 239, 172, 0.5);
  border-radius: 6px;
}
.learn-elf-name {
  flex: 0 0 auto;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #86efac;
  text-transform: uppercase;
}
.learn-elf p { margin: 0; min-height: 1.35em; font-size: clamp(15px, 2.8vw, 18px); line-height: 1.35; color: #e2e8f0; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.learn-pick {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  text-align: left;
  color: var(--ink);
  background: #151d30;
  border: 1px solid rgba(232, 197, 71, 0.25);
  border-radius: 4px;
}
.learn-pick:hover, .learn-pick:focus-visible { border-color: var(--glow); }
.learn-pick-name { font-family: "Cinzel", serif; font-size: 16px; }
.learn-pick small { color: #94a3b8; font-size: 12px; }
.learn-pick.has-star { border-color: rgba(232, 197, 71, 0.7); }
.learn-pick.has-star small { color: var(--gold); }
.learn-idea-card { padding: 4px 0; }
.learn-idea-text { margin: 0 0 12px; font-size: clamp(18px, 3.6vw, 24px); line-height: 1.35; color: #fff; }
.learn-idea-eg { margin: 0; font-size: clamp(17px, 3.4vw, 22px); line-height: 1.4; color: #cbd5e1; }
.learn-idea-eg strong { display: block; margin-top: 6px; font-size: 1.25em; color: #fff; }
.learn-q { margin: 6px 0 14px; font-size: clamp(22px, 4.6vw, 30px); color: #fff; }
.learn-choices { margin-top: 12px; }
.learn-done { text-align: center; padding: 8px 0; }
.learn-done h3 { margin: 4px 0 6px; font-size: clamp(20px, 4vw, 26px); color: var(--gold); }
.learn-done p { margin: 0; color: #cbd5e1; }
.learn-star { font-size: 64px; line-height: 1; color: var(--gold); text-shadow: 0 0 24px rgba(232, 197, 71, 0.6); animation: learn-star-pop 0.6s ease-out; }
@keyframes learn-star-pop { 0% { transform: scale(0.2) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.25) rotate(6deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.learn-nav { flex-wrap: wrap; }
.learn-btn { color: #c4b5fd; background: rgba(30, 20, 56, 0.85); border-color: rgba(196, 181, 253, 0.5); }
.learn-btn.hidden, #btn-teach-learn.hidden { display: none; }
@media (max-height: 520px) {
  .learn-modal { max-height: 96vh; padding: 10px 14px; }
  .learn-elf { margin-bottom: 6px; padding: 6px 10px; }
  .learn-steps { display: none; }
  .learn-elf p { font-size: 14px; }
  .learn-modal h2 { font-size: 15px; }
  .learn-close { width: 30px; height: 30px; font-size: 13px; }
  .learn-pick { padding: 8px 10px; }
  .learn-star { font-size: 40px; }
}


/* Hearts row jolts when a hit lands, so damage is visible even before a heart is lost. */
@keyframes heartsHurt {
  0% { transform: translateX(0); filter: brightness(1); }
  25% { transform: translateX(-3px); filter: brightness(1.8); }
  75% { transform: translateX(3px); filter: brightness(1.8); }
  100% { transform: translateX(0); filter: brightness(1); }
}
#hud-hearts-wrap.hurt { animation: heartsHurt 0.2s linear 2; }

/* long-division chunks (16 Nov) */
.group-row.chunk-row { gap: 10px; flex-wrap: wrap; justify-content: center; }
.group-row.chunk-row .group-box.chunk-box { min-width: 150px; width: auto; height: auto; padding: 10px 14px; }
.group-row.chunk-row .chunk-box .group-count { font-size: 15px; white-space: nowrap; }

/* Guides & hints off (16 Nov): contextual "Press E" tags go; WARP offers stay. */
html.guides-off #interact-hint:not(.warp-flash) { display: none !important; }

/* Parent guide */
.pg-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pg-name { font-size: 12px; opacity: 0.85; display: flex; gap: 6px; align-items: center; }
.pg-name input { width: 130px; padding: 4px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.3); color: inherit; font: inherit; }
.pg-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pg-btns .cta { padding: 6px 12px; font-size: 13px; min-height: 0; }
.pg-meta { font-size: 12px; opacity: 0.7; margin: 0 0 8px; }
.pg-att { border: 1px solid rgba(196,181,253,0.55); background: rgba(124,58,237,0.14); border-radius: 12px; padding: 10px 14px; margin-bottom: 6px; }
.pg-att strong { display: block; font-size: 1.15em; }
.pg-att-tag { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.pg-att p { margin: 4px 0; }
.pg-att ul, .pg-list { margin: 4px 0 0; padding-left: 18px; }
.pg-ex, .pg-tip, .pg-flag { font-size: 0.9em; opacity: 0.85; }
.pg-flag { color: #fcd34d; opacity: 1; }
.pr-more { margin-top: 12px; }
.pr-more > summary { cursor: pointer; font-size: 13px; opacity: 0.8; padding: 6px 0; }

/* Learn: formula sheet button + sheet (Grades 6–9) */
.learn-sheet-btn { display: flex; flex-direction: column; gap: 2px; width: 100%; margin: 0 0 12px; padding: 12px 14px; text-align: left; cursor: pointer;
  font-family: "Cinzel", serif; font-size: 16px; color: #fde68a; background: linear-gradient(180deg, #241a3d, #1a1430); border: 1px solid rgba(232, 197, 71, 0.55); border-radius: 6px; }
.learn-sheet-btn small { font-family: inherit; font-size: 12px; color: #cbd5e1; letter-spacing: 0; }
.learn-sheet-btn:hover, .learn-sheet-btn:focus-visible { border-color: var(--glow); }
.fs-sheet { columns: 2 300px; column-gap: 12px; }
.fs-card { break-inside: avoid; margin: 0 0 12px; padding: 10px 12px; background: #151d30; border: 1px solid rgba(196, 181, 253, 0.3); border-radius: 6px; color: #e2e8f0; }
.fs-card h4 { margin: 0 0 6px; font-family: "Cinzel", serif; font-size: 15px; color: #fde68a; }
.fs-formula { margin: 4px 0; font-size: 18px; font-weight: 700; color: #fff; }
.fs-rows { width: 100%; border-collapse: collapse; font-size: 14px; }
.fs-rows th { text-align: left; white-space: nowrap; vertical-align: top; padding: 3px 10px 3px 0; color: #c4b5fd; font-weight: 700; }
.fs-rows td { padding: 3px 0; }
.fs-ex { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(148, 163, 184, 0.35); font-size: 14px; }
.fs-ex span { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; }
.fs-ex p { margin: 2px 0; }
.fs-ex b, .fs-rows b, .fs-formula b { color: #86efac; }
.fs-f { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 0.82em; line-height: 1.1; margin: 0 2px; }
.fs-f > span:first-child { border-bottom: 1px solid currentColor; padding: 0 2px; }
/* Learn: fill-in-the-step "Do it with me" */
.learn-gsteps { margin: 0 0 10px; padding-left: 22px; font-size: clamp(15px, 2.8vw, 18px); line-height: 1.45; color: #cbd5e1; }
.learn-gsteps li { margin: 0 0 6px; }
.learn-gsteps li.is-current { color: #fff; }
.learn-gap { display: inline-block; min-width: 2.4em; margin: 0 2px; padding: 0 6px; text-align: center; border-bottom: 2px solid #fde68a; color: #fde68a; font-weight: 700; }
.learn-gap.is-filled { border-bottom-color: #86efac; color: #86efac; }
.fs-card sup { font-size: 0.7em; vertical-align: 0.55em; line-height: 0; }
.fs-card sub { font-size: 0.7em; line-height: 0; }

/* How many sums (difficulty screen) */
.sums-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; margin: 4px 0 14px; }
.sums-label { font-family: "Cinzel", serif; font-size: 15px; color: #fde68a; }
.sums-pills { display: flex; gap: 8px; }
.sums-pill { min-width: 54px; padding: 8px 12px; font: 800 18px "Cinzel", serif; color: var(--ink, #e2e8f0); background: #151d30;
  border: 1px solid rgba(232, 197, 71, 0.35); border-radius: 999px; cursor: pointer; }
.sums-pill:hover, .sums-pill:focus-visible { border-color: var(--glow, #fde68a); }
.sums-pill.active { color: #1a1206; background: linear-gradient(180deg, #fde68a, #e8c547); border-color: #fff3a1; box-shadow: 0 0 14px rgba(232, 197, 71, 0.45); }
.sums-note { flex-basis: 100%; text-align: center; color: #94a3b8; font-size: 12px; }
.sums-row.is-fixed .sums-pills { display: none; }
/* Typed answers (desktop) */
.type-answer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; margin: 10px 0 2px; font-size: 14px; color: #cbd5e1; }
.type-answer.hidden { display: none; }
.ta-buf { min-width: 92px; padding: 4px 12px; font: 800 22px "Rajdhani", sans-serif; letter-spacing: 0.04em; color: #fff; text-align: center;
  background: rgba(8, 12, 24, 0.85); border: 1px solid rgba(232, 197, 71, 0.55); border-radius: 6px; }
.ta-hint { font-size: 12px; color: #94a3b8; }
.ta-msg { flex-basis: 100%; text-align: center; color: #fcd34d; font-size: 13px; min-height: 1em; }


/* Phone on its side: the lesson buttons sit in one short row so the working and its pad stay on
   screen without scrolling. */
@media (orientation: landscape) and (max-height: 520px) {
  .teach-modal h2 { font-size: 14px; margin-bottom: 2px; }
  .teach-body { margin-bottom: 4px; }
  .teach-nav, .learn-nav { flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }
  .teach-nav .cta {
    min-height: 38px;
    min-width: 0;
    padding: 6px 12px;
    font-size: 12px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* ——— My Records ——— */
.records-card h2 { margin-bottom: 2px; }
.records-tag { margin: 0 0 10px; color: #94a3b8; font-size: 13px; text-align: center; }
.rec-filter { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
.rec-chip { cursor: pointer; padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(232, 197, 71, 0.4); background: transparent; color: #f6ecc8; font: 600 13px "Rajdhani", sans-serif; }
.rec-chip.on { background: #e8c547; color: #0a0e18; border-color: #e8c547; }
.rec-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.rec-card { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid rgba(110, 181, 255, 0.25); border-radius: 10px; background: rgba(15, 22, 36, 0.75); text-align: center; }
.rec-card-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; }
.rec-card strong { font: 800 22px "Rajdhani", sans-serif; color: #fde68a; }
.rec-card-sub { font-size: 11px; color: #cbd5e1; line-height: 1.25; }
.rec-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 10px; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 13px; color: #e2e8f0; white-space: nowrap; }
.rec-table th { position: sticky; top: 0; text-align: left; font-weight: 600; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #94a3b8; padding: 6px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.3); background: rgba(10, 14, 24, 0.95); }
.rec-table td { padding: 6px 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.12); font-variant-numeric: tabular-nums; }
.rec-table td.rec-hi { color: #86efac; font-weight: 700; }
.rec-table td.rec-lesson { white-space: normal; min-width: 120px; }
.rec-sub { margin: 6px 0 6px; font-size: 14px; color: #e8c547; }
.rec-empty { text-align: center; color: #cbd5e1; margin: 20px auto; max-width: 420px; }
@media (max-width: 640px), (orientation: landscape) and (max-height: 520px) {
  .rec-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .rec-card { padding: 6px 8px; }
  .rec-card strong { font-size: 18px; }
  .records-tag { margin-bottom: 6px; font-size: 12px; }
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 700px) {
  .rec-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.rune-frame.records-card { width: min(960px, 96vw); }


/* ——— Free web version: locked lands + unlock card ——— */
.level-pick.locked { position: relative; opacity: 0.78; }
.level-pick.locked .level-thumb { filter: grayscale(0.55) brightness(0.7); }
.lock-chip { position: absolute; top: 8px; right: 8px; padding: 3px 8px; border-radius: 999px; background: rgba(10, 14, 24, 0.85); border: 1px solid rgba(232, 197, 71, 0.6); color: #fde68a; font: 700 11px "Rajdhani", sans-serif; letter-spacing: 0.04em; }
.unlock-overlay { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 6, 12, 0.72); }
.unlock-overlay.hidden { display: none; }
.unlock-card { max-width: 520px; text-align: center; }
.unlock-card h2 { margin-bottom: 6px; }
.unlock-card p { color: #cbd5e1; }
.unlock-list { text-align: left; margin: 10px auto 12px; padding-left: 20px; color: #e2e8f0; line-height: 1.5; max-width: 420px; }
.unlock-price { margin: 6px 0 14px; }
.unlock-price strong { color: #fde68a; }
.unlock-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.unlock-actions a.cta { text-decoration: none; display: inline-block; }
@media (orientation: landscape) and (max-height: 520px) {
  .unlock-card { padding: 14px 18px; }
  .unlock-list { margin: 6px auto 8px; font-size: 13px; line-height: 1.35; }
  .unlock-price { margin: 4px 0 8px; }
}

/* Paid app: who is signed in on this device */
.app-member { margin: 8px 0 0; text-align: center; color: #cbd5e1; font: 600 13px "Rajdhani", sans-serif; letter-spacing: 0.03em; }


/* USE button: pops in and shines while there is something to use (chest, door, fire, ladder). */
@keyframes usePop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes useGlow {
  0%, 100% { box-shadow: 0 0 10px 2px rgba(250, 204, 21, 0.45); transform: scale(1); }
  50% { box-shadow: 0 0 24px 8px rgba(250, 204, 21, 0.9); transform: scale(1.1); }
}
@keyframes useShine {
  0% { left: -80%; }
  55%, 100% { left: 130%; }
}
.touch-use.use-ready {
  position: relative;
  overflow: hidden;
  color: #fff8db !important;
  border-color: #facc15 !important;
  background: radial-gradient(circle at 50% 35%, rgba(250, 204, 21, 0.55), rgba(120, 70, 10, 0.9)) !important;
  text-shadow: 0 0 6px rgba(255, 230, 120, 0.9);
  animation: usePop 0.35s ease-out, useGlow 1.2s ease-in-out 0.35s infinite;
}
.touch-use.use-ready::after {
  content: "";
  position: absolute;
  top: -20%;
  left: -80%;
  width: 45%;
  height: 140%;
  transform: skewX(-20deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
  animation: useShine 1.8s ease-in-out infinite;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .touch-use.use-ready, .touch-use.use-ready::after { animation: none; }
}

/* Learn (Grades 1–4): a speaker on buttons and topic cards says the words out loud. */
.has-say { position: relative; }
.learn-say {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 8px; width: 30px; height: 30px; border-radius: 50%;
  font-size: 15px; line-height: 1; vertical-align: middle; cursor: pointer;
  background: rgba(250, 204, 21, 0.18); border: 1px solid rgba(250, 204, 21, 0.6);
}
.learn-pick .learn-say { position: absolute; top: 6px; right: 6px; margin: 0; }
.learn-say:active { transform: scale(0.9); }

/* itch.io copy: the "Get the full game" button on the title screen. */
.itch-full-cta { background: linear-gradient(180deg, #fde68a, #f59e0b) !important; color: #1c1005 !important; border-color: #fbbf24 !important; }
.is-itch .unlock-actions a.cta { text-decoration: none; }
.itch-note { font-size: 0.9em; opacity: 0.9; }

/* How to play: picture cards with arrows. */
.howto-card { position: relative; width: min(760px, 96vw); max-height: 96vh; overflow: auto; text-align: center; padding: 16px 20px 14px; }
.howto-step { margin: 0; color: #94a3b8; font: 600 12px "Rajdhani", sans-serif; letter-spacing: 0.12em; text-transform: uppercase; }
.howto-card h2 { margin: 2px 0 8px; }
.howto-pic { border: 2px solid rgba(253, 224, 71, 0.55); border-radius: 10px; overflow: hidden; background: #0b1220; line-height: 0; }
.howto-pic img { width: 100%; height: auto; display: block; }
.howto-text { margin: 10px auto 6px; max-width: 620px; color: #f1f5f9; font-size: 17px; line-height: 1.4; }
.howto-dots { display: flex; gap: 8px; justify-content: center; margin: 6px 0 10px; }
.howto-dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(148, 163, 184, 0.45); }
.howto-dots span.on { background: #fde047; box-shadow: 0 0 8px rgba(253, 224, 71, 0.8); }
.howto-actions { display: flex; gap: 10px; justify-content: center; }
.howto-actions .cta { min-width: 130px; }
.howto-skip { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: #94a3b8; font: 600 14px "Rajdhani", sans-serif; letter-spacing: 0.06em; cursor: pointer; padding: 6px 8px; }
.howto-skip:hover { color: #fff; }
@media (orientation: landscape) and (max-height: 520px) {
  .howto-card { width: min(640px, 92vw); padding: 10px 14px 10px; }
  .howto-card h2 { font-size: 18px; margin-bottom: 4px; }
  .howto-pic img { max-height: 52vh; width: auto; margin: 0 auto; }
  .howto-text { font-size: 14px; margin: 6px auto 2px; }
  .howto-dots { margin: 4px 0 6px; }
}

/* Learn Maths: grade course card, catch-up link and free video links. */
.learn-lead { margin: 4px 0 10px; color: #cbd5e1; font-size: 15px; }
.learn-course { margin: 0 0 10px; padding: 16px 18px 14px; border: 2px solid rgba(232, 197, 71, 0.75); border-radius: 14px;
  background: radial-gradient(420px 160px at 10% 0%, rgba(126, 226, 176, 0.18), transparent 70%), linear-gradient(160deg, rgba(58, 42, 23, 0.85), rgba(12, 20, 38, 0.92)); }
.learn-course h3 { margin: 0 0 4px; font-family: "Cinzel", serif; font-size: 21px; color: #fff7d6; }
.learn-course > p { margin: 0 0 10px; color: #f1e6c8; font-size: 15px; line-height: 1.45; }
.learn-trail { list-style: none; margin: 6px 0 12px; padding: 0; display: flex; gap: 6px; overflow-x: auto; position: relative; }
.learn-stone { flex: 1 1 0; min-width: 74px; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; position: relative; }
.learn-stone:not(:last-child)::after { content: ""; position: absolute; top: 22px; left: calc(50% + 26px); right: calc(-50% + 26px); border-top: 3px dashed rgba(232, 197, 71, 0.45); }
.learn-stone-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: #f6ecd2; border: 3px solid rgba(232, 197, 71, 0.6); color: #2b2112; }
.learn-stone-name { font-size: 11px; line-height: 1.2; color: #cbd5e1; max-width: 96px; }
.learn-stone.is-done .learn-stone-ico { background: #7ee2b0; border-color: #7ee2b0; font-weight: 800; color: #062417; }
.learn-stone.is-next .learn-stone-ico { border-color: #fde047; box-shadow: 0 0 0 4px rgba(253, 224, 71, 0.25), 0 0 18px rgba(253, 224, 71, 0.7); animation: stonePulse 1.6s ease-in-out infinite; }
.learn-stone.is-next .learn-stone-name { color: #fde68a; font-weight: 700; }
@keyframes stonePulse { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .learn-stone.is-next .learn-stone-ico { animation: none; } }
.learn-course-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.learn-course-count { margin: 8px 0 0; color: #fde68a; font-weight: 600; }
.learn-pick-age { color: #7ee2b0; font-size: 12px; font-weight: 700; }
.learn-catchup { margin: 0 0 12px; color: #94a3b8; font-size: 14px; }
.learn-linkbtn { background: none; border: 0; padding: 0; color: #7dd3fc; text-decoration: underline; font: inherit; cursor: pointer; }
.learn-video { margin: 12px 0 4px; padding: 10px 12px; border: 1px dashed rgba(125, 211, 252, 0.55); border-radius: 10px; background: rgba(8, 24, 44, 0.6); text-align: left; }
.learn-video-lead { margin: 0 0 6px; color: #e0f2fe; font-weight: 600; }
.learn-video-links { display: flex; flex-wrap: wrap; gap: 8px; }
.learn-video-link { display: inline-block; padding: 6px 12px; border-radius: 99px; border: 1px solid rgba(125, 211, 252, 0.7); color: #e0f2fe; text-decoration: none; font-size: 14px; background: rgba(14, 116, 144, 0.25); }
.learn-video-link:hover { background: rgba(14, 116, 144, 0.5); }
.learn-video-note { margin: 6px 0 0; color: #94a3b8; font-size: 12px; }
@media (orientation: landscape) and (max-height: 520px) {
  .learn-course { padding: 10px 12px; gap: 10px; }
  .learn-course h3 { font-size: 16px; }
  .learn-course p { font-size: 13px; }
}

/* Black Friday on the "Get the full game" card */
.unlock-sale { display: inline-block; margin-bottom: 6px; padding: 2px 10px; border-radius: 999px; background: #fde68a; color: #1a1406; font-weight: 800; font-size: 0.85em; }
.unlock-price s { opacity: 0.6; }
