/* ============================================================
   Mathe-Trainer — Stylesheet (refined / tween)
   ============================================================ */

:root {
  /* Surface */
  --bg-1: #F5F2FF;
  --bg-2: #FFF4F0;
  --bg-3: #EFFAF6;
  --surface: #FFFFFF;
  --surface-soft: #F8F7FB;

  /* Accents */
  --purple: #6E47D8;
  --purple-d:#4E2FAE;
  --purple-l:#EBE3FF;
  --coral:  #FF6B6B;
  --coral-l:#FFE3E3;
  --teal:   #1FB89A;
  --teal-l: #DCF6EF;
  --gold:   #FFB547;
  --gold-l: #FFEFD4;
  --pink:   #FF4D8D;
  --blue:   #4F88FF;

  /* Text */
  --ink:        #1A1A2E;
  --ink-soft:   #5C5F7C;
  --ink-mute:   #8A8DA8;

  --on-color: white;

  /* Shape */
  --r-card: 20px;
  --r-btn:  14px;
  --r-pill: 999px;

  /* Shadows */
  --sh-card:  0 12px 32px -16px rgba(78, 47, 174, .25),
              0 2px 6px -3px rgba(0, 0, 0, .05);
  --sh-btn:   0 6px 14px -6px rgba(110, 71, 216, .5);
  --sh-press: 0 2px 4px -2px rgba(110, 71, 216, .4);

  /* Gradients (used sparingly) */
  --grad-rainbow:
    linear-gradient(90deg, #FF6B6B 0%, #FFB547 25%, #1FB89A 55%, #4F88FF 80%, #6E47D8 100%);
  --grad-primary:
    linear-gradient(135deg, #6E47D8 0%, #4F88FF 100%);
  --grad-success:
    linear-gradient(135deg, #1FB89A 0%, #4F88FF 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, var(--bg-1) 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 90% 100%, var(--bg-2) 0%, transparent 60%),
    var(--bg-3);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Full-screen theme background (used during session) */
#app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
#app-bg.show { opacity: 1; }
#app-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 12, 40, .15) 0%, rgba(20, 12, 40, .35) 100%);
}
body.themed .card {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, .6);
}
body.themed .card::before {
  background: var(--theme-accent, var(--grad-rainbow));
}

/* App shell ---------------------------------------------------- */
.app {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.loader { color: var(--ink-mute); font-weight: 500; }

/* Card --------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
  padding: 28px 24px;
  width: 100%;
  max-width: 560px;
  position: relative;
}
/* The question screen uses a much wider playing field so the avatars,
   joy meter and progress lane can breathe — without making the actual
   numbers any bigger. */
.card.card--play {
  max-width: min(1100px, calc(100vw - 24px));
  padding: 40px 44px;
}
@media (max-width: 600px) {
  .card.card--play { padding: 24px 18px; }
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 16px; right: 16px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--grad-rainbow);
}

/* Typography --------------------------------------------------- */
h1, h2, h3 {
  font-family: 'Bricolage Grotesque', sans-serif;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-weight: 600;
}
h1 { font-size: clamp(24px, 5vw, 30px); }
h2 { font-size: clamp(20px, 4.5vw, 24px); }
h3 { font-size: 16px; font-weight: 600; }
p  { margin: 0 0 12px; line-height: 1.55; color: var(--ink-soft); }
.muted { color: var(--ink-mute); }
.small { font-size: 13px; }
.center { text-align: center; }

/* Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--on-color);
  background: var(--grad-primary);
  border: none;
  border-radius: var(--r-btn);
  padding: 14px 22px;
  cursor: pointer;
  box-shadow: var(--sh-btn);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover  { filter: brightness(1.07); }
.btn:active {
  transform: translateY(1px) scale(.99);
  box-shadow: var(--sh-press);
}
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--big {
  font-size: 18px;
  padding: 18px 28px;
  border-radius: 18px;
  width: 100%;
}
.btn--soft {
  background: var(--purple-l);
  color: var(--purple-d);
  box-shadow: none;
}
.btn--ghost {
  background: transparent;
  color: var(--purple);
  box-shadow: none;
  border: 1.5px solid var(--purple-l);
}
.btn--success { background: var(--grad-success); }
.btn--warn    {
  background: var(--coral);
  color: white;
  box-shadow: 0 6px 14px -6px rgba(255, 107, 107, .5);
}

/* Home --------------------------------------------------------- */
.home-greeting {
  margin-bottom: 22px;
}
.home-greeting .tag {
  display: inline-block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-l);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.home-greeting h1 { font-size: clamp(28px, 6vw, 36px); }
.home-actions { display: flex; flex-direction: column; gap: 10px; }
.home-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--surface-soft);
  font-size: 13px;
  color: var(--ink-mute);
}
.home-foot a {
  color: var(--purple); text-decoration: none; font-weight: 700;
  padding: 4px 8px; border-radius: 8px;
}
.home-foot a:hover { background: var(--purple-l); }

/* Mission intro card ----------------------------------------- */
.intro-card { text-align: center; padding: 32px 24px 28px; }
.intro-avatars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}
.intro-avatars .char {
  width: 96px;
  height: 96px;
  border-width: 4px;
  box-shadow: 0 8px 22px rgba(45, 27, 78, .28), 0 2px 4px rgba(45, 27, 78, .15);
}
.intro-traveler {
  animation: intro-bob 2.4s ease-in-out infinite;
}
@keyframes intro-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.intro-arrow {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 32px;
  color: var(--theme-accent, var(--purple));
  opacity: .7;
}
.intro-mission {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--theme-accent, var(--purple));
  margin-bottom: 4px;
}
.intro-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 6vw, 36px);
  color: var(--ink);
  margin: 0 0 10px;
}
.intro-story {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 380px;
  margin: 0 auto 22px;
}
.intro-funfact {
  display: block;
  max-width: 420px;
  margin: 4px auto 16px;
  padding: 12px 16px 14px;
  background: linear-gradient(135deg, #FFF6D6, #FFE3F1);
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(110, 71, 216, .15);
  text-align: left;
}
.intro-funfact-label {
  display: block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--theme-accent, var(--purple));
  margin-bottom: 4px;
}
.intro-funfact-text {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}
.intro-go {
  background: var(--theme-accent, var(--purple));
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--coral-l);
  color: var(--coral);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
}

/* Rank card on home — math-hero progression */
.rank-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #FFE3F1 0%, #E1D7FF 60%, #DCEEFD 100%);
  padding: 16px 18px;
  border-radius: 18px;
  margin: 4px 0 16px;
  box-shadow: 0 4px 14px rgba(110, 71, 216, .15);
  position: relative;
  overflow: hidden;
}
.rank-card::after {
  content: '✨';
  position: absolute;
  top: 8px; right: 12px;
  font-size: 18px;
  opacity: .55;
}
.rank-emoji {
  font-size: 44px;
  line-height: 1;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(110, 71, 216, .18);
  flex: 0 0 64px;
}
.rank-meta { flex: 1; min-width: 0; }
.rank-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  line-height: 1.1;
}
.rank-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin: 4px 0 8px;
  font-weight: 500;
}
.rank-bar {
  height: 6px;
  background: var(--surface);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--coral));
  border-radius: var(--r-pill);
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
}

/* Quick-stat row on home */
.qs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 20px;
}
.qs-cell {
  background: var(--surface-soft);
  padding: 12px 8px;
  border-radius: 14px;
  text-align: center;
}
.qs-cell .v {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}
.qs-cell .l {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Question screen --------------------------------------------- */
.q-top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.q-progress {
  flex: 1;
  position: relative;
  height: 200px;
  border-radius: 26px;
  padding: 0 8px;
  overflow: visible;
  background: linear-gradient(180deg, var(--surface-soft), var(--surface));
  transition: background .4s ease;
}
.q-progress::before {
  content: '';
  position: absolute;
  left: 6px; right: 6px; top: 0; bottom: 0;
  border-radius: 14px;
  background: var(--theme-bg, transparent);
  pointer-events: none;
  z-index: 0;
}
.q-progress-track {
  position: absolute;
  left: 90px; right: 90px; top: 50%;
  height: 6px;
  margin-top: -3px;
  border-radius: var(--r-pill);
  background-image: var(--theme-track, repeating-linear-gradient(
    90deg, var(--ink-mute) 0 6px, transparent 6px 12px));
  opacity: .45;
  z-index: 1;
}
.q-progress-bunny,
.q-progress-carrot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  z-index: 2;
}
.q-progress-bunny { transition: left .55s cubic-bezier(.34,1.56,.64,1); }
.q-progress-carrot {
  right: 18px;
  transform: translate(0, -50%);
}
.char {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  background: #FFFFFF;
  border: 5px solid #FFFFFF;
  box-shadow: 0 8px 22px rgba(45, 27, 78, .3), 0 2px 4px rgba(45, 27, 78, .15);
}
.q-progress-bunny .char {
  animation: char-breath 3.2s ease-in-out infinite;
}
.q-progress-carrot .char {
  animation: char-breath 3.6s ease-in-out infinite;
  animation-delay: .6s;
}
@keyframes char-breath {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.025); }
}
.q-progress-bunny.super .char {
  border-color: #FFD24E;
  box-shadow: 0 0 0 2px rgba(255, 210, 78, .6),
              0 4px 14px rgba(255, 181, 71, .6),
              0 1px 3px rgba(45, 27, 78, .2);
}
.bunny-spark {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  opacity: .95;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.2));
  z-index: 3;
}
.bunny-spark.s1 { top: -6px;  left: -10px; }
.bunny-spark.s2 { top: -6px;  right: -10px; }
.bunny-spark.s3 { bottom: -6px; left: 50%; transform: translateX(-50%); }

/* Thematic gradients + track stripes per theme */
.q-progress.theme-meadow {
  --theme-bg: linear-gradient(180deg, #DFF4D8 0%, #B7E7C2 100%);
  --theme-track: repeating-linear-gradient(90deg, #6FB873 0 6px, transparent 6px 14px);
}
.q-progress.theme-space {
  --theme-bg: linear-gradient(180deg, #2A2257 0%, #4B3A8A 100%);
}
.q-progress.theme-space .q-progress-track {
  background-image:
    radial-gradient(circle at 4px center, #FFFFFF 1.5px, transparent 2px),
    radial-gradient(circle at 14px center, #FFD24E 1.5px, transparent 2px);
  background-size: 22px 5px;
  background-repeat: repeat-x;
  opacity: .95;
}
.q-progress.theme-lava {
  --theme-bg: linear-gradient(180deg, #FFD9B0 0%, #FF9A6B 100%);
  --theme-track: repeating-linear-gradient(90deg, #C2410C 0 6px, transparent 6px 14px);
}
.q-progress.theme-pastel {
  --theme-bg: linear-gradient(180deg, #FFE3F1 0%, #E1D7FF 100%);
  --theme-track: repeating-linear-gradient(90deg,
    #FF6B6B 0 6px, #FFB547 6px 12px, #FFE17A 12px 18px,
    #5BD17A 18px 24px, #7B5CFF 24px 30px);
  opacity: .8;
}
.q-progress.theme-ice {
  --theme-bg: linear-gradient(180deg, #DCEEFD 0%, #A7D2F2 100%);
  --theme-track: repeating-linear-gradient(90deg, #2D6FA8 0 6px, transparent 6px 14px);
}
.q-counter {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 14px;
  min-width: 46px;
  text-align: right;
}

.q-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.q-op-label {
  font-size: 12px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.q-timer {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  padding: 4px 10px;
  border-radius: var(--r-pill);
}
.q-streak-badge {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--coral);
  background: var(--coral-l);
  padding: 4px 10px;
  border-radius: var(--r-pill);
}

/* Joy meter — reactive mascot in the question header */
.joy-meter {
  position: relative;
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 50%;
  overflow: visible;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.joy-face {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #FFFFFF;
  border: 3px solid #FFFFFF;
  box-shadow: 0 3px 10px rgba(45, 27, 78, .25);
  display: block;
}
.joy-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease, box-shadow .3s ease;
}
.joy-1 { transform: scale(1.05); }
.joy-1 .joy-ring { opacity: 1; box-shadow: 0 0 0 3px rgba(255, 210, 78, .45); }
.joy-2 { transform: scale(1.12); }
.joy-2 .joy-ring { opacity: 1; box-shadow: 0 0 0 4px rgba(255, 181, 71, .65), 0 0 18px rgba(255, 181, 71, .5); }
.joy-3 { transform: scale(1.2); }
.joy-3 .joy-ring {
  opacity: 1;
  box-shadow: 0 0 0 5px rgba(255, 107, 107, .75), 0 0 26px rgba(255, 181, 71, .85);
  animation: joy-pulse 1.4s ease-in-out infinite;
}
@keyframes joy-pulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(255, 107, 107, .75), 0 0 26px rgba(255, 181, 71, .85); }
  50%      { box-shadow: 0 0 0 7px rgba(255, 107, 107, .9),  0 0 36px rgba(255, 181, 71, 1); }
}

.q-equation {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: clamp(44px, 11vw, 64px);
  text-align: center;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 18px 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  line-height: 1;
}
.q-equation > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.q-equation .op {
  color: var(--purple);
  font-weight: 500;
}
.q-equation .eq {
  color: var(--ink-mute);
  font-weight: 500;
}
.q-equation.wrong { animation: q-shake .35s ease; }
@keyframes q-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Free-entry input */
.q-input-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.q-input {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(56px, 14vw, 84px);
  width: 360px;
  max-width: 100%;
  text-align: center;
  border: 3px solid var(--purple-l);
  background: var(--surface);
  border-radius: 22px;
  padding: 14px 24px;
  color: var(--purple);
  outline: none;
  caret-color: var(--purple);
  -moz-appearance: textfield;
  transition: border-color .15s, background .15s;
  box-shadow: 0 4px 14px rgba(110, 71, 216, .15);
}
.q-input::-webkit-outer-spin-button,
.q-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.q-input:focus { border-color: var(--purple); }
.q-input.correct {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-l);
}
.q-input.wrong {
  border-color: var(--coral);
  color: var(--coral);
  background: var(--coral-l);
}

/* On-screen number pad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 460px;
  margin: 0 auto;
}
.numpad button {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 24px;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--surface-soft);
  border-radius: 14px;
  padding: 14px 0;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.numpad button:active {
  transform: translateY(1px) scale(.97);
  background: var(--surface-soft);
}
.numpad button.utility {
  background: var(--surface-soft);
  color: var(--purple);
}
.numpad button.submit {
  background: var(--grad-primary);
  color: white;
  border: none;
  box-shadow: var(--sh-btn);
}

/* Multiple-choice grid */
.mc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.mc-btn {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 7vw, 36px);
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--purple-l);
  border-radius: 16px;
  padding: 22px 12px;
  cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
  text-align: center;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.mc-btn:hover { border-color: var(--purple); }
.mc-btn:active { transform: translateY(1px) scale(.99); }
.mc-btn.correct {
  background: var(--teal-l);
  border-color: var(--teal);
  color: var(--teal);
}
.mc-btn.wrong {
  background: var(--coral-l);
  border-color: var(--coral);
  color: var(--coral);
}
.mc-btn.dim { opacity: .4; }

/* Feedback banner: shown at the top of the screen, well above the answer
   buttons so a stray tap on the message can't trigger the next answer. */
.feedback {
  position: fixed;
  left: 0; right: 0; top: 0;
  display: flex; justify-content: center;
  padding: 14px 12px 0;
  z-index: 100;
  pointer-events: none;
}
.feedback-card {
  pointer-events: auto;
  background: var(--surface);
  padding: 14px 22px;
  border-radius: 16px;
  box-shadow: var(--sh-card);
  text-align: center;
  transform: translateY(-12px);
  opacity: 0;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
  min-width: 220px;
  max-width: min(420px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
}
.feedback.show .feedback-card {
  transform: translateY(0);
  opacity: 1;
}
.feedback-icon {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 24px;
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.feedback-icon.correct { background: var(--teal-l); color: var(--teal); }
.feedback-icon.wrong   { background: var(--coral-l); color: var(--coral); }
.feedback-body { flex: 1; text-align: left; min-width: 0; }
.feedback-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
}
.feedback-text.correct { color: var(--teal); }
.feedback-text.wrong   { color: var(--coral); }
.feedback-sub {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 2px;
  font-weight: 500;
}

/* Self-explanation step shown under a wrong answer ("Aus Fehlern lernen"). */
.reflect { margin-top: 10px; }
.reflect-solve {
  background: var(--surface-soft); border-radius: 10px; padding: 7px 11px;
  font-size: 14px; color: var(--ink); margin-bottom: 9px; font-weight: 600;
}
.reflect-solve-lbl { color: var(--ink-mute); font-weight: 700; margin-right: 4px; }
.reflect-title { font-size: 13px; color: var(--ink-mute); font-weight: 700; margin-bottom: 6px; }
.reflect-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reflect-chip {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--surface-soft);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: all .15s ease;
}
.reflect-chip:hover { border-color: var(--coral, #FF6B6B); }
.reflect-chip.picked { background: var(--coral-l); border-color: var(--coral); color: var(--coral); }
.reflect-good { font-size: 13px; color: var(--teal); font-weight: 600; margin-top: 8px; }
.reflect-go { margin-top: 10px; width: 100%; padding: 9px; font-size: 15px; }

/* Brief tap-guard right after a fresh question is rendered so a trailing
   tap from the previous question can't trigger an answer. */
.tap-guard { pointer-events: none !important; }

.auth-hint { font-size: 12.5px; color: var(--ink-mute); text-align: center; margin: 2px 0 4px; }

/* Daily learning-time goal ring */
.study-ring-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-soft); border-radius: 16px; padding: 12px 16px; margin-bottom: 12px;
}
.study-ring-wrap { position: relative; width: 64px; height: 64px; flex: 0 0 64px; }
.study-ring { width: 64px; height: 64px; display: block; }
.study-ring-bg { fill: none; stroke: var(--surface); stroke-width: 8; }
.study-ring-fg { fill: none; stroke: var(--teal, #1FB89A); stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.34,1.2,.64,1); }
.study-ring-card.done .study-ring-fg { stroke: var(--amber, #E8B948); }
.study-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.study-ring-center span { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 20px; color: var(--ink); line-height: 1; }
.study-ring-center small { font-size: 10px; color: var(--ink-mute); }
.study-ring-meta { display: flex; flex-direction: column; }
.study-ring-label { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 15px; color: var(--ink); }
.study-ring-sub { font-size: 13px; color: var(--ink-mute); margin-top: 2px; }

/* Tipp-Knopf (staged scaffolding hint before answering) */
.q-tip-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 10px; }
.q-tip-btn {
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--amber, #B8860B);
  background: var(--amber-l, #FFF4D6); border: 1.5px solid var(--amber, #E8B948);
  border-radius: 999px; padding: 7px 16px; cursor: pointer; transition: all .15s ease;
}
.q-tip-btn:hover { filter: brightness(0.97); }
.q-tip-btn.done { opacity: 0.5; cursor: default; }
.q-tip-box { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 340px; }
.q-tip-line {
  background: var(--amber-l, #FFF4D6); border-radius: 12px; padding: 9px 13px;
  font-size: 14.5px; color: var(--ink); font-weight: 600; line-height: 1.35;
  animation: tip-pop .2s ease;
}
@keyframes tip-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Sparkle particles on correct */
.sparkle {
  position: fixed;
  pointer-events: none;
  font-size: 22px;
  z-index: 110;
  animation: sparkle-fly .85s ease-out forwards;
}
@keyframes sparkle-fly {
  0%   { transform: translate(0,0) scale(.4); opacity: 1; }
  100% { transform: var(--end) scale(1) rotate(180deg); opacity: 0; }
}

/* Summary ----------------------------------------------------- */
.summary-hero {
  text-align: center;
  margin: 0 0 18px;
}
.summary-hero .badge-icon {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 36px;
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.summary-hero .badge-icon.gold { background: var(--gold-l); color: var(--gold); }
.summary-hero .badge-icon.teal { background: var(--teal-l); color: var(--teal); }
.summary-hero .badge-icon.purple { background: var(--purple-l); color: var(--purple); }
.summary-goal {
  width: 140px;
  height: 140px;
  margin: 0 auto 14px;
  border: 5px solid #FFFFFF;
  box-shadow: 0 10px 30px rgba(45, 27, 78, .35), 0 2px 6px rgba(45, 27, 78, .2);
  animation: summary-pop .55s cubic-bezier(.34,1.56,.64,1);
}
@keyframes summary-pop {
  0% { transform: scale(.4) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.summary-outcome {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--theme-accent, var(--purple));
  margin: 4px 0 0;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.summary-stat {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.summary-stat .v {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}
.summary-stat .l {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.badge {
  background: var(--surface);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  animation: badge-pop .5s cubic-bezier(.34,1.56,.64,1);
}
.badge::before {
  content: '★';
  display: block;
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 2px;
}
@keyframes badge-pop {
  0%   { transform: scale(.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Confetti ---------------------------------------------------- */
.confetti {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 90; overflow: hidden;
}
.confetti span {
  position: absolute; top: -20px;
  width: 8px; height: 12px;
  animation: confetti-fall 2.5s linear forwards;
  border-radius: 2px;
}
@keyframes confetti-fall {
  0%   { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* Parents area ------------------------------------------------ */
.parents .card { max-width: 720px; }
.tabs {
  display: flex; gap: 4px;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: var(--r-pill);
  margin-bottom: 18px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.tab {
  background: transparent;
  color: var(--ink-soft);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: none;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(0,0,0,.1); }

.op-mastery { margin-bottom: 12px; }
.op-mastery-label {
  display: flex; justify-content: space-between;
  font-weight: 700; margin-bottom: 4px;
  font-size: 14px;
}
.op-mastery-bar {
  height: 8px;
  background: var(--surface-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.op-mastery-fill {
  height: 100%;
  background: var(--grad-success);
  border-radius: var(--r-pill);
}

.calendar-strip {
  display: flex; gap: 3px; flex-wrap: wrap; margin: 8px 0 16px;
}
.cal-day {
  width: 16px; height: 16px;
  border-radius: 4px;
  background: var(--surface-soft);
}
.cal-day.active { background: var(--purple); }

.trouble-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.trouble-item {
  background: var(--coral-l);
  border: 1.5px solid var(--coral);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}
.trouble-item .eq {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
.trouble-item .stats {
  font-size: 11px;
  color: var(--coral);
  margin-top: 2px;
  font-weight: 700;
}

.diff-items {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 6px;
  max-height: 320px; overflow-y: auto;
  padding: 4px;
}
.diff-item {
  background: var(--surface);
  border: 1.5px solid var(--surface-soft);
  border-radius: 10px;
  padding: 6px 4px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-align: center;
}
.diff-item .eq {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.diff-item .m  { font-size: 10px; color: var(--ink-mute); margin-top: 2px; font-weight: 600; }
.diff-item.hot   { border-color: var(--coral); }
.diff-item.warm  { border-color: var(--gold); }
.diff-item.cool  { border-color: var(--teal); }

.form-row { margin-bottom: 14px; }
.form-row > label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--ink);
}
.ops-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle-pill {
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.toggle-pill.active {
  background: var(--purple);
  color: white;
}
input[type="number"], input[type="password"], input[type="text"], select {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid var(--surface-soft);
  border-radius: 10px;
  background: var(--surface);
  width: 100%;
  outline: none;
  color: var(--ink);
}
input:focus, select:focus { border-color: var(--purple); }

.danger-zone {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1.5px dashed var(--surface-soft);
}

/* Auth screen ------------------------------------------------- */
.auth-card { max-width: 380px; }
.auth-row { display: flex; gap: 8px; margin-top: 14px; }
.auth-row input { flex: 1; }
.auth-mark {
  width: 56px; height: 56px;
  background: var(--purple);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 32px;
  margin-bottom: 14px;
}

/* Toast ------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  z-index: 200;
  transition: transform .25s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* Responsive helpers ----------------------------------------- */
@media (max-width: 380px) {
  .card { padding: 22px 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .numpad button { font-size: 22px; padding: 12px 0; }
}
/* Hide numpad on devices with hardware keyboard */
@media (hover: hover) and (pointer: fine) {
  .numpad.auto { display: none; }
}

/* Utility ----------------------------------------------------- */
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }

/* Gap-question placeholder */
.q-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  width: 2.4em;
  height: 1.35em;
  border-radius: 18px;
  background: var(--purple-l);
  color: var(--purple);
  text-align: center;
  font-weight: 800;
  vertical-align: middle;
  line-height: 1;
  box-sizing: border-box;
}

/* Wrong-answer feedback layout (bigger card, sad mascot, correct equation) */
.feedback-wrong-card {
  flex-direction: column;
  text-align: center;
  padding: 20px 24px 22px;
  max-width: min(480px, calc(100% - 24px));
}
.feedback-mascot {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid #FFFFFF;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(45, 27, 78, .3);
  margin: 0 auto 8px;
}
.feedback-correct-eq {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.feedback-correct-eq .op { color: var(--purple); }
.feedback-correct-eq .eq { color: var(--ink-mute); }
.feedback-correct-eq strong { color: var(--teal); }

/* Story snippet (mid-session narration) */
.story-snippet {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: 22px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(45, 27, 78, .2);
  z-index: 90;
  opacity: 0;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  pointer-events: none;
  max-width: min(420px, calc(100% - 24px));
  text-align: center;
}
.story-snippet.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Retry hint (mini banner after first wrong attempt) */
.retry-hint {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(255, 255, 255, .96);
  padding: 8px 14px 8px 8px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--coral);
  box-shadow: 0 6px 18px rgba(45, 27, 78, .22);
  z-index: 95;
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}
.retry-hint.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.retry-hint-mascot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #FFFFFF;
}

/* Daily mission banner on home */
.daily-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #FFF5E1, #FFE7C2);
  padding: 12px 14px;
  border-radius: 14px;
  margin: 0 0 14px;
  box-shadow: 0 2px 8px rgba(45, 27, 78, .1);
}
.daily-banner.daily-done {
  background: linear-gradient(135deg, #DDF6E5, #B9EAC5);
}
.daily-icon { font-size: 28px; flex: 0 0 auto; }
.daily-body { flex: 1; min-width: 0; }
.daily-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.daily-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  margin-top: 2px;
}
.daily-status {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--teal);
}

/* Home extras: album + map buttons */
.home-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* Album */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.sticker {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  transition: transform .2s ease;
}
.sticker img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 4px 10px rgba(45, 27, 78, .18);
}
.sticker.locked img {
  filter: grayscale(1) brightness(0.85) opacity(0.45);
}
.sticker-name {
  margin-top: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}
.sticker-when {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
}

/* Universe map */
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.map-tile {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16/9;
  box-shadow: 0 4px 12px rgba(45, 27, 78, .18);
}
.map-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.map-tile.unexplored img { filter: grayscale(1) brightness(0.45); }
.map-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 12px;
  background: linear-gradient(0deg, rgba(0,0,0,.55), transparent 60%);
  color: #FFFFFF;
}
.map-tile-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.map-tile-plays { font-size: 12px; opacity: .85; }

/* Summary finale image (traveler + goal together) */
.summary-finale {
  width: 220px;
  height: 220px;
  border-radius: 24px;
  object-fit: cover;
  border: 5px solid #FFFFFF;
  box-shadow: 0 12px 32px rgba(45, 27, 78, .35), 0 2px 6px rgba(45, 27, 78, .2);
  margin: 0 auto 14px;
  display: block;
  animation: summary-pop .55s cubic-bezier(.34,1.56,.64,1);
}

/* New sticker callout in summary */
.new-sticker {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #FFF1B5, #FFD24E);
  padding: 12px 14px;
  border-radius: 14px;
  margin: 16px 0 0;
  box-shadow: 0 4px 14px rgba(255, 181, 71, .35);
}
.new-sticker img {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  object-fit: cover;
}
.new-sticker-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.new-sticker-sub { font-size: 12px; color: var(--ink-mute); }

/* Boss-level intro variant */
.intro-boss {
  background: linear-gradient(135deg, #FFF1F0, #FFE3D6);
  border: 2px solid #FF6B6B;
}
.boss-flag {
  display: inline-block;
  background: linear-gradient(90deg, #FF6B6B, #FFB547);
  color: #FFFFFF;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  letter-spacing: .14em;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(255, 107, 107, .35);
}
.boss-banner {
  background: linear-gradient(90deg, #FFB547, #FF6B6B);
  color: #FFFFFF;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  text-align: center;
  padding: 12px 16px;
  border-radius: 14px;
  letter-spacing: .04em;
  margin: 12px 0 0;
}
.boss-trophy {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #FFE17A, #FFB547);
  padding: 12px 14px;
  border-radius: 14px;
  margin: 12px 0 0;
  box-shadow: 0 4px 14px rgba(255, 181, 71, .35);
}
.boss-trophy-icon { font-size: 40px; }
.boss-trophy-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}
.boss-trophy-sub { font-size: 12px; color: var(--ink-mute); }

/* Power-up banner (5er and mega streaks) */
.power-up {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-14px) scale(.9);
  background: linear-gradient(90deg, #FFB547, #FF6B6B);
  color: #FFFFFF;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(255, 107, 107, .45);
  opacity: 0;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  z-index: 105;
  pointer-events: none;
  letter-spacing: .04em;
}
.power-up.show { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
.power-up-mega {
  background: linear-gradient(90deg, #7B5CFF, #FF6BD9, #FFB547);
  background-size: 200% 100%;
  animation: pu-shift 1.2s linear infinite;
  font-size: 18px;
}
@keyframes pu-shift {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
.power-up-icon { font-size: 22px; }

/* Star rain (after mega streak) */
.star-rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 80;
}
.star-rain span {
  position: absolute;
  top: -40px;
  animation-name: star-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  filter: drop-shadow(0 2px 6px rgba(255, 215, 0, .6));
}
@keyframes star-fall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

/* Question help tip (when item is wrong-streak frustrating) */
.q-help {
  background: linear-gradient(135deg, #E1D7FF, #FFE3F1);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 8px rgba(110, 71, 216, .15);
}

/* Inline q-input (now embedded inside the equation) */
.q-input-inline {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: inherit;
  width: 2.4em;
  min-width: 1.6em;
  height: 1.35em;
  box-sizing: border-box;
  text-align: center;
  border: 3px solid var(--purple-l);
  background: rgba(255, 255, 255, .85);
  border-radius: 18px;
  padding: 0;
  color: var(--purple);
  outline: none;
  caret-color: var(--purple);
  -moz-appearance: textfield;
  vertical-align: middle;
  line-height: 1.35em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s, transform .15s;
  box-shadow: 0 2px 10px rgba(110, 71, 216, .15);
}
.q-input-inline::-webkit-outer-spin-button,
.q-input-inline::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.q-input-inline:focus { border-color: var(--purple); transform: scale(1.04); }
.q-input-inline.correct { border-color: var(--teal); color: var(--teal); background: var(--teal-l); }
.q-input-inline.wrong   { border-color: var(--coral); color: var(--coral); background: var(--coral-l); animation: q-shake .35s ease; }

/* Companion card on home */
.companion-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-soft);
  padding: 12px 14px;
  border-radius: 14px;
  margin: 12px 0 0;
}
.companion-face {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 3px 10px rgba(45, 27, 78, .2);
  object-fit: cover;
}
.companion-meta { flex: 1; min-width: 0; }
.companion-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.companion-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}
.companion-level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-mute);
}
.companion-level-bar {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.companion-level-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--purple));
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
}

/* Companion picker (first-time selection) */
.companion-pick {
  background: var(--surface-soft);
  padding: 14px;
  border-radius: 14px;
  margin: 12px 0 0;
  text-align: center;
}
.companion-pick-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 10px;
}
.companion-pick-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.companion-option {
  background: #FFFFFF;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.companion-option img {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #FFFFFF;
  box-shadow: 0 2px 8px rgba(45, 27, 78, .2);
}
.companion-option span {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.companion-option:hover {
  transform: translateY(-2px);
  border-color: var(--purple);
  box-shadow: 0 6px 14px rgba(110, 71, 216, .2);
}

/* Sound toggle */
.sound-toggle {
  background: transparent;
  border: 1.5px solid var(--surface-soft);
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
  margin: 0 8px;
  transition: background .15s, border-color .15s;
}
.sound-toggle:hover { border-color: var(--purple); background: var(--surface-soft); }

/* ============================================================
   THEMEN-TRAINER (Lernkarten) — topic-organised flashcard mode
   ============================================================ */

/* Home entry button */
.btn--topics {
  background: linear-gradient(135deg, #1FB89A, #4F88FF);
  margin-top: 10px;
}

/* --- Topic picker --- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.topic-tile {
  --tile-accent: var(--purple);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  background: var(--surface);
  border: 2px solid var(--surface-soft);
  border-top: 4px solid var(--tile-accent);
  border-radius: 16px;
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: var(--sh-card);
}
.topic-tile:hover  { transform: translateY(-2px); }
.topic-tile:active { transform: translateY(1px) scale(.99); }
.topic-icon { font-size: 30px; line-height: 1; }
.topic-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
}
.topic-blurb {
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.3;
  min-height: 2.5em;
}
.topic-prog { width: 100%; margin-top: 6px; }
.topic-prog-bar {
  height: 7px;
  background: var(--surface-soft);
  border-radius: 999px;
  overflow: hidden;
}
.topic-prog-fill {
  height: 100%;
  background: var(--tile-accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.topic-prog-text { font-size: 11px; color: var(--ink-mute); }

/* --- Teaching card --- */
.teach-card { text-align: center; }
.teach-top { margin-bottom: 10px; }
.teach-chip {
  display: inline-block;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--theme-accent, var(--purple));
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 5px 14px;
}
.teach-title {
  font-size: 24px;
  margin: 4px 0 16px;
}
.teach-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.teach-line {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(20px, 5.5vw, 26px);
  color: var(--ink);
  background: linear-gradient(135deg, var(--theme-accent, var(--purple)) 0%, var(--theme-accent, var(--purple)) 100%);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 10px;
}
.teach-example {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 0 6px;
}
.teach-note {
  font-size: 14px;
  color: var(--ink);
  background: var(--gold-l);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  text-align: left;
  line-height: 1.45;
}
.teach-go { margin-top: 4px; }

/* --- Card question --- */
.cq-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.cq-chip {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: white;
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}
.cq-level { display: inline-flex; gap: 4px; }
.lvl-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface-soft);
  border: 1.5px solid var(--purple-l);
}
.lvl-dot.on { background: var(--theme-accent, var(--purple)); border-color: var(--theme-accent, var(--purple)); }
.cq-counter {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 15px;
}
.cq-progress {
  height: 6px;
  background: var(--surface-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.cq-progress-fill {
  height: 100%;
  background: var(--theme-accent, var(--purple));
  border-radius: 999px;
  transition: width .4s ease;
}

.cq-prompt {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--ink);
  text-align: center;
  line-height: 1.4;
  margin: 8px 0 18px;
}
.cq-prompt-word {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(17px, 4.5vw, 21px);
  line-height: 1.5;
  margin-bottom: 12px;
}
.cq-prompt-mc {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(17px, 4.5vw, 21px);
  line-height: 1.5;
}
.cq-answer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 6vw, 30px);
  margin-bottom: 18px;
}
.cq-unit { color: var(--ink-soft); }

/* The inline answer blank — looks like a small boxed input, driven by numpad */
.cq-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  height: 1.4em;
  padding: 0 .3em;
  margin: 0 .12em;
  vertical-align: middle;
  background: var(--surface-soft);
  border: 2px dashed var(--purple-l);
  border-radius: 12px;
  color: var(--ink);
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.cq-blank.active {
  border-style: solid;
  border-color: var(--theme-accent, var(--purple));
  background: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent, var(--purple)) 20%, transparent);
}
.cq-blank.filled { border-style: solid; }
.cq-blank.correct { border-color: var(--teal); color: var(--teal); background: var(--teal-l); }
.cq-blank.wrong   { border-color: var(--coral); color: var(--coral); background: var(--coral-l); }
.cq-blank.shake   { animation: q-shake .35s ease; }

/* Card numpad reuses .numpad; the OK button sits below full-width */
.cardpad { margin-bottom: 12px; }
.cq-ok { margin-top: 4px; }

/* Multiple-choice for text answers (orderings, rounding) */
.mc-grid.cardmc { grid-template-columns: 1fr; }
.cardmc-btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(16px, 4.2vw, 19px);
  font-weight: 700;
  padding: 16px 16px;
  text-align: center;
}

/* Explanation panel (revealed after answering) */
.cq-explain {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}
.cq-explain.show { opacity: 1; transform: none; }
.cq-explain-head {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 8px;
}
.cq-explain-head.ok { color: var(--teal); }
.cq-explain-head.no { color: var(--ink); }
.cq-explain-head.no strong { color: var(--coral); }
.cq-explain-head.copied { color: var(--amber, #B8860B); }
.cq-explain-body {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 14px;
}
.cq-next { margin-top: 4px; }

/* Card summary icon */
.cardsum-icon {
  width: 76px; height: 76px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  border-radius: 24px;
  margin: 0 auto 4px;
  box-shadow: var(--sh-card);
}

@media (max-width: 380px) {
  .topic-grid { grid-template-columns: 1fr; }
}

/* Card mode: journey layer reused from the arithmetic trainer ------------- */
.card--play .q-progress { margin-bottom: 14px; }
.cq-top { flex-wrap: wrap; }
/* A slightly smaller joy meter fits the card header row better */
.cq-top .joy-meter { width: 56px; height: 56px; flex: 0 0 56px; }
.cq-top .cq-chip { margin-right: auto; }

/* ---------- Name picker (entry screen, replaces the password prompt) ---------- */
.pick-card { text-align: center; }
.pick-title { margin-bottom: 22px; }
.pick-row { display: flex; gap: 16px; }
.pick-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 14px; border: 2px solid var(--purple-l); border-radius: var(--r-card);
  background: var(--surface); color: var(--ink); cursor: pointer;
  box-shadow: var(--sh-card); transition: transform .1s ease, border-color .15s ease;
}
.pick-btn:hover { border-color: var(--purple); }
.pick-btn:active { transform: scale(0.97); }
.pick-emoji { font-size: 46px; line-height: 1; }
.pick-name { font-size: 22px; font-weight: 800; }
.pick-sub { font-size: 13px; color: var(--ink-mute); }
@media (max-width: 380px) { .pick-row { flex-direction: column; } }

/* ============================================================
   ALTES ÄGYPTEN — Wissens-Thema (Theorie + Quiz + Lernpfad)
   ============================================================ */
.btn--egypt { background: linear-gradient(135deg, #C9A227, #C8853C); margin-top: 10px; }
body.egypt-theme #app-bg::after { content: ''; position: absolute; inset: 0; background: rgba(40,28,8,.28); }
.egypt-card { position: relative; }

.egypt-hero { display: flex; align-items: center; gap: 14px; margin: 8px 0 14px; }
.egypt-guide { width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 3px solid #fff; box-shadow: var(--sh-card); flex-shrink: 0; }
.egypt-lead { font-size: 14px; color: var(--ink-soft); line-height: 1.4; }

/* Lernpfad-Stepper (Ägypten) */
.path { display: flex; flex-direction: column; margin-top: 14px; }
.path-station { --accent: var(--purple); position: relative; display: flex; align-items: center; gap: 12px;
  text-align: left; width: 100%; background: var(--surface); border: 2px solid var(--surface-soft);
  border-radius: 16px; padding: 10px 12px; margin-bottom: 14px; cursor: pointer;
  transition: transform .1s, box-shadow .15s, border-color .15s; box-shadow: var(--sh-card); }
.path-station::before { content: ''; position: absolute; left: 41px; top: -14px; height: 14px; width: 2px; background: var(--surface-soft); }
.path-station:first-child::before { display: none; }
.path-station:hover { transform: translateY(-1px); }
.path-hero { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.path-dot { position: absolute; left: 30px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque'; font-weight: 800; font-size: 13px;
  background: #fff; color: var(--ink-mute); border: 2px solid var(--surface-soft); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.path-body { flex: 1; min-width: 0; }
.path-title { font-family: 'Bricolage Grotesque'; font-weight: 700; font-size: 16px; color: var(--ink); }
.path-goal { color: var(--ink-mute); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.path-meta { font-size: 11px; color: var(--ink-mute); margin-top: 4px; }
.path-chev { color: var(--ink-mute); font-weight: 700; flex-shrink: 0; font-size: 13px; }
.st-done { border-color: var(--teal); }
.st-done .path-dot { background: var(--teal); color: #fff; border-color: var(--teal); }
.st-active { border-color: var(--theme-accent, var(--gold)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent, var(--gold)) 28%, transparent); }
.st-active .path-dot { background: var(--theme-accent, var(--gold)); color: #fff; border-color: var(--theme-accent, var(--gold)); }
.st-active .path-chev { color: var(--theme-accent, var(--gold)); }
.st-open { opacity: .9; }

/* Theorie-Reader (Ägypten) */
.eg-reader-hero { width: 100%; max-height: 200px; object-fit: cover; border-radius: 16px; margin-bottom: 12px; }
.eg-reader-title { font-size: 24px; margin: 0 0 10px; }
.eg-reader-body { margin-bottom: 18px; }
.rd-h { font-family: 'Bricolage Grotesque'; font-weight: 700; font-size: 18px; margin: 16px 0 6px; color: var(--ink); }
.rd-p { font-size: 15px; line-height: 1.55; color: var(--ink-soft); margin: 0 0 8px; }
.rd-ul { margin: 0 0 8px; padding-left: 20px; }
.rd-ul li { font-size: 15px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 5px; }
.rd-note { background: var(--gold-l); border-radius: 12px; padding: 12px 14px; font-size: 14px;
  line-height: 1.45; color: var(--ink); margin: 10px 0; }
.rd-goal { background: color-mix(in srgb, var(--theme-accent, var(--gold)) 16%, transparent);
  border-left: 3px solid var(--theme-accent, var(--gold)); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; line-height: 1.4; margin-bottom: 14px; }
.rd-goal-lbl { font-weight: 700; }

/* Quiz (Ägypten) */
.eg-q { font-family: 'Plus Jakarta Sans'; font-weight: 700; font-size: clamp(18px, 4.8vw, 22px);
  line-height: 1.45; color: var(--ink); text-align: center; margin: 10px 0 18px; }
.eg-input { width: 100%; box-sizing: border-box; padding: 14px 16px; margin-bottom: 12px;
  border-radius: 12px; border: 2px solid var(--purple-l); background: var(--surface);
  color: var(--ink); font-size: 18px; font-weight: 700; text-align: center; }
.eg-input:focus { outline: none; border-color: var(--theme-accent, var(--purple)); }
.eg-textarea { width: 100%; box-sizing: border-box; padding: 13px 15px; margin-bottom: 12px;
  border-radius: 12px; border: 2px solid var(--purple-l); background: var(--surface); color: var(--ink);
  font-size: 16px; line-height: 1.45; resize: vertical; min-height: 96px; font-family: inherit; }
.eg-textarea:focus { outline: none; border-color: var(--theme-accent, var(--purple)); }
.eg-hint { font-size: 13px; color: var(--ink-mute); text-align: center; margin: 0 0 10px; }
.reveal-answer { background: var(--surface-soft); border-radius: 12px; padding: 14px 16px;
  font-size: 16px; line-height: 1.45; color: var(--ink); margin-bottom: 12px; text-align: center; }
.self-btns { display: flex; gap: 10px; }
.self-btns .btn { flex: 1; }

/* ---------- Benutzerverwaltung: Login / Registrieren / Admin ---------- */
.auth-card .auth-row input {
  width: 100%; box-sizing: border-box; padding: 13px 15px;
  border: 1.5px solid var(--surface-soft); border-radius: 14px;
  background: var(--surface); color: var(--ink); font-size: 16px;
}
.auth-card .auth-row input:focus { outline: none; border-color: var(--purple); }
.auth-tabs { display: flex; gap: 8px; margin: 6px 0 6px; }
.auth-tab {
  flex: 1; padding: 9px 8px; border-radius: 12px; cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 14px;
  background: var(--surface-soft); color: var(--ink-soft); border: 1.5px solid transparent;
}
.auth-tab.active { background: var(--purple-l); color: var(--purple-d); border-color: var(--purple-l); }
.auth-age { margin-top: 14px; }
.auth-age-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.auth-age-row { display: flex; gap: 10px; }
.age-opt {
  flex: 1; padding: 14px 8px; border-radius: 14px; cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 16px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--surface-soft);
}
.age-opt.active { border-color: var(--purple); background: var(--purple-l); color: var(--purple-d); }
.auth-err { color: var(--coral); min-height: 20px; font-size: 14px; margin: 12px 0 4px; text-align: center; }
.auth-card .btn--big { margin-top: 6px; }

.admin-users { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.admin-user {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--surface-soft); border-radius: 14px; padding: 12px 14px;
}
.admin-user-info { display: flex; flex-direction: column; }
.admin-user-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.admin-user-meta { font-size: 12px; color: var(--ink-mute); }
.admin-user-actions { display: flex; gap: 8px; flex-shrink: 0; }
.admin-reset, .admin-delete { font-size: 13px; padding: 8px 12px; white-space: nowrap; }
.admin-delete { color: var(--bad, #c2410c); }

/* Fehlerheft (error book) */
.fh-area { margin-top: 18px; }
.fh-area-h { font-family: 'Bricolage Grotesque', sans-serif; font-size: 18px; margin: 0 0 8px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.fh-area-n { font-size: 13px; font-weight: 700; color: var(--ink-mute); background: var(--surface-soft); border-radius: 999px; padding: 1px 9px; }
.fh-entry { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1.5px solid var(--surface-soft); border-radius: 14px; padding: 10px 13px; margin-bottom: 8px; }
.fh-entry--review { opacity: 0.85; border-style: dashed; }
.fh-entry-ico { font-size: 22px; flex-shrink: 0; }
.fh-entry-body { flex: 1; min-width: 0; }
.fh-entry-q { font-weight: 600; color: var(--ink); font-size: 15px; }
.fh-entry-grp { font-size: 12px; color: var(--ink-mute); margin-top: 1px; }
.fh-entry-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.fh-wrong { font-size: 12px; font-weight: 700; color: var(--bad, #c2410c); white-space: nowrap; }
.fh-review { font-size: 10.5px; color: var(--ink-mute); white-space: nowrap; }
.fh-empty { text-align: center; padding: 30px 16px; font-size: 17px; color: var(--ink); background: var(--surface-soft); border-radius: 16px; margin-top: 14px; }
.k-group { font-size: 13px; color: var(--ink-mute); font-weight: 600; margin-bottom: 4px; }
.k-suffix, .k-unit { color: var(--ink-mute); }

/* ---------- Language toggle (DE | EN), fixed top-right, always reachable ---------- */
.lang-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(6px);
}
.lang-toggle button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-mute, #667);
  padding: 5px 10px;
  border-radius: 999px;
  line-height: 1;
}
.lang-toggle button.active {
  background: var(--purple, #6E47D8);
  color: #fff;
}

/* Reward mini-game (Snake) ------------------------------------- */
.reward-launch {
  background: linear-gradient(135deg, #FF9F43, #FF6B6B);
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(255, 107, 107, .6);
  margin-bottom: 12px;
  animation: reward-pulse 1.4s ease-in-out infinite;
}
@keyframes reward-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}
.reward-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(8, 16, 28, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.reward-box {
  width: 100%;
  max-width: min(96vw, 600px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.reward-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}
.reward-title {
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}
.reward-top .reward-quit {
  flex-shrink: 0;
  width: auto;
  color: #fff;
  border-color: rgba(255, 255, 255, .4);
}
.reward-hud {
  display: flex;
  gap: 14px;
  color: #cfe3ff;
  font-size: 14px;
  font-weight: 600;
  flex-wrap: wrap;
  justify-content: center;
}
.reward-hud b { color: #fff; }
#rw-canvas {
  /* Concrete pixel size is set inline at play time (fills available space);
     these are just fallbacks + visual styling. */
  max-width: 100%;
  border-radius: 14px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .6);
  touch-action: none;
}
.reward-msg {
  min-height: 22px;
  color: #FFD36B;
  font-weight: 800;
  font-size: 16px;
}
.reward-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.reward-dpad-mid { display: flex; gap: 8px; }
.reward-dpad button {
  width: 58px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.reward-dpad button:active { background: rgba(255, 255, 255, .3); }
.reward-hint {
  color: #8fa6c4;
  font-size: 12px;
}

/* Reward: game chooser + lives + game-over -------------------- */
.reward-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}
.reward-game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border: none;
  border-radius: 16px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.reward-game-card:active { transform: scale(.96); }
.reward-game-card:hover { background: rgba(255, 255, 255, .2); }
.reward-game-emoji { font-size: 38px; line-height: 1; }
.reward-game-name { font-weight: 800; font-size: 15px; }
.reward-lives { font-size: 16px; letter-spacing: 1px; }
.reward-dpad-lr { display: flex; gap: 12px; }
.reward-dpad-lr button {
  width: 88px;
  height: 52px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  touch-action: none;
}
.reward-dpad-lr button:active { background: rgba(255, 255, 255, .3); }
.reward-over {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}
.reward-over-score {
  color: #FFD36B;
  font-weight: 800;
  font-size: 28px;
}

/* Admin: per-student statistics ------------------------------- */
.student-card {
  background: var(--surface);
  border: 1px solid var(--surface-soft);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.student-card.legacy { background: var(--surface-soft); }
.student-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.student-name { font-weight: 800; font-size: 16px; color: var(--ink); }
.student-detail-btn { width: auto; flex-shrink: 0; padding: 8px 14px; font-size: 13px; }
.student-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.student-split {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.stat-split {
  background: var(--surface-soft);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-soft);
}
.student-detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--surface-soft); }
.stat-sec { margin: 12px 0 8px; font-size: 14px; color: var(--ink-soft); }
.stat-sec:first-child { margin-top: 0; }

/* Admin: online status + per-day learning time --------------- */
.online-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-mute);
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.online-dot.on {
  background: #2ECC71;
  box-shadow: 0 0 0 3px rgba(46, 204, 113, .22);
  animation: online-pulse 1.8s ease-in-out infinite;
}
@keyframes online-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(46, 204, 113, .22); }
  50%      { box-shadow: 0 0 0 5px rgba(46, 204, 113, .10); }
}
.student-name { display: flex; align-items: center; }
.study-days {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}
.study-day {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 3px 0;
  border-bottom: 1px dashed var(--surface-soft);
}
.study-day b { color: var(--ink); }

/* Admin: create-user form ------------------------------------ */
.admin-create {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 14px;
}
.admin-create input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--surface-soft);
  border-radius: 12px;
  background: var(--surface);
  font: inherit;
  color: var(--ink);
}
.admin-create .auth-age-row { display: flex; gap: 8px; }
.admin-create .age-opt { flex: 1; }
.admin-create .auth-err { color: var(--coral); font-size: 13px; min-height: 16px; margin: 0; }

/* Admin: leaderboard ----------------------------------------- */
.lb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.lb-cat {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px 14px;
}
.lb-cat-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; color: var(--ink); }
.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
}
.lb-rank { width: 24px; text-align: center; flex-shrink: 0; }
.lb-name { flex: 1; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-val { font-weight: 800; color: var(--purple, #6E47D8); }
