/* ============================================================
   Colors come from the theme (data-theme on <html>) and the
   light/dark mode (data-mode). Each theme sets the same tokens.
   ============================================================ */
:root {
  --radius: 18px;
  --good: #1f9d55;
  --good-bg: #e3f7eb;
  --bad: #d64545;
  --bad-bg: #fde8e8;
  --hl: #ffd84d;
  --hl2: #9fd3ff;
  /* Math tools (hundred chart, number line) always sit on "paper" so they read like a worksheet. */
  --paper: #ffffff;
  --paper-ink: #1f2544;
  --heading-font: 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  font-family: 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
}
:root[data-mode='dark'] {
  --good: #4ade80;
  --good-bg: #0f3321;
  --bad: #f87171;
  --bad-bg: #3d1717;
  --paper: #fdfdf8;
}

/* ---------- Classic ---------- */
:root, :root[data-theme='classic'] {
  --bg: #f6f8ff; --card: #ffffff; --ink: #1f2544; --muted: #5d6485; --line: #dde2f3;
  --primary: #4f7cff; --primary-ink: #ffffff; --accent: #ffb020; --soft: #eef3ff;
  --topbar: linear-gradient(90deg, #4f7cff, #7b5cff);
  --pattern: radial-gradient(circle at 1px 1px, rgba(79, 124, 255, 0.12) 1.5px, transparent 0) 0 0 / 26px 26px;
}
:root[data-theme='classic'][data-mode='dark'] {
  --bg: #0f1424; --card: #1a2138; --ink: #e8ecff; --muted: #a3abcf; --line: #2c3556;
  --primary: #7c9dff; --primary-ink: #0b1030; --soft: #232d4d;
  --topbar: linear-gradient(90deg, #2c3f99, #4b3aa8);
  --pattern: radial-gradient(circle at 1px 1px, rgba(124, 157, 255, 0.14) 1.5px, transparent 0) 0 0 / 26px 26px;
}

/* ---------- Science Lab: teal + purple, graph paper ---------- */
:root[data-theme='science'] {
  --bg: #eefbfb; --card: #ffffff; --ink: #0f2f3a; --muted: #4b6b75; --line: #c9ecec;
  --primary: #0e9aa7; --primary-ink: #ffffff; --accent: #7c3aed; --soft: #e0f7f7;
  --topbar: linear-gradient(90deg, #0e7490, #7c3aed);
  --pattern:
    linear-gradient(rgba(14, 154, 167, 0.09) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(14, 154, 167, 0.09) 1px, transparent 1px) 0 0 / 28px 28px;
}
:root[data-theme='science'][data-mode='dark'] {
  --bg: #07161c; --card: #0f2530; --ink: #dff7f7; --muted: #8fb3bb; --line: #1d3f4a;
  --primary: #2dd4bf; --primary-ink: #042a26; --accent: #a78bfa; --soft: #123a44;
  --topbar: linear-gradient(90deg, #0b4f63, #4c1d95);
  --pattern:
    radial-gradient(circle at 20% 30%, rgba(167, 139, 250, 0.16), transparent 40%),
    linear-gradient(rgba(45, 212, 191, 0.07) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(45, 212, 191, 0.07) 1px, transparent 1px) 0 0 / 28px 28px;
}

/* ---------- Rainbows & Unicorns: pastels, rainbow bar, sparkles ---------- */
:root[data-theme='unicorns'] {
  --bg: #fff5fd; --card: #ffffff; --ink: #4a1d5c; --muted: #8a5f99; --line: #f5d0fe;
  --primary: #c026d3; --primary-ink: #ffffff; --accent: #38bdf8; --soft: #fae8ff;
  --topbar: linear-gradient(90deg, #f472b6, #c084fc, #60a5fa, #34d399, #facc15, #fb923c);
  --pattern:
    radial-gradient(circle at 10% 20%, rgba(244, 114, 182, 0.18), transparent 30%),
    radial-gradient(circle at 90% 30%, rgba(96, 165, 250, 0.18), transparent 30%),
    radial-gradient(circle at 50% 90%, rgba(250, 204, 21, 0.16), transparent 35%),
    radial-gradient(circle at 2px 2px, rgba(192, 38, 211, 0.14) 1.5px, transparent 0) 0 0 / 34px 34px;
}
:root[data-theme='unicorns'][data-mode='dark'] {
  --bg: #1b1027; --card: #2a1a3d; --ink: #fbe7ff; --muted: #cfa9dd; --line: #45285e;
  --primary: #e879f9; --primary-ink: #2a0530; --accent: #7dd3fc; --soft: #3a2152;
  --topbar: linear-gradient(90deg, #be185d, #7e22ce, #1d4ed8, #047857, #a16207, #c2410c);
  --pattern:
    radial-gradient(circle at 10% 20%, rgba(244, 114, 182, 0.16), transparent 30%),
    radial-gradient(circle at 90% 30%, rgba(96, 165, 250, 0.14), transparent 30%),
    radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.12) 1.2px, transparent 0) 0 0 / 34px 34px;
}

/* ---------- Jungle: greens, leafy blobs ---------- */
:root[data-theme='jungle'] {
  --bg: #eefae6; --card: #fffef7; --ink: #1c3a1f; --muted: #52704f; --line: #d3ecc6;
  --primary: #15803d; --primary-ink: #ffffff; --accent: #f59e0b; --soft: #e2f5d7;
  --topbar: linear-gradient(90deg, #166534, #4d7c0f);
  --pattern:
    radial-gradient(ellipse 60px 30px at 20% 10%, rgba(34, 197, 94, 0.14), transparent 70%),
    radial-gradient(ellipse 80px 40px at 80% 40%, rgba(101, 163, 13, 0.14), transparent 70%),
    radial-gradient(ellipse 70px 35px at 40% 80%, rgba(22, 163, 74, 0.12), transparent 70%) 0 0 / 360px 360px;
}
:root[data-theme='jungle'][data-mode='dark'] {
  --bg: #0b1a10; --card: #13261a; --ink: #e3f7df; --muted: #9dbf99; --line: #24452c;
  --primary: #4ade80; --primary-ink: #052e16; --accent: #fbbf24; --soft: #1b3a24;
  --topbar: linear-gradient(90deg, #14532d, #365314);
  --pattern:
    radial-gradient(ellipse 60px 30px at 20% 10%, rgba(74, 222, 128, 0.09), transparent 70%),
    radial-gradient(ellipse 80px 40px at 80% 40%, rgba(163, 230, 53, 0.08), transparent 70%) 0 0 / 360px 360px;
}

/* ---------- Sports: red + blue, field stripes ---------- */
:root[data-theme='sports'] {
  --bg: #f1f7ff; --card: #ffffff; --ink: #14213d; --muted: #53607a; --line: #d9e3f5;
  --primary: #e11d48; --primary-ink: #ffffff; --accent: #2563eb; --soft: #ffe4ea;
  --topbar: linear-gradient(90deg, #1d4ed8, #e11d48);
  --pattern: repeating-linear-gradient(90deg, rgba(34, 197, 94, 0.07) 0 60px, transparent 60px 120px);
}
:root[data-theme='sports'][data-mode='dark'] {
  --bg: #0c1220; --card: #161f33; --ink: #e6ecff; --muted: #9aa7c2; --line: #27324d;
  --primary: #fb7185; --primary-ink: #3b0612; --accent: #60a5fa; --soft: #33192a;
  --topbar: linear-gradient(90deg, #1e3a8a, #9f1239);
  --pattern: repeating-linear-gradient(90deg, rgba(34, 197, 94, 0.06) 0 60px, transparent 60px 120px);
}

/* ---------- Arts: orange / pink / purple paint splotches ---------- */
:root[data-theme='arts'] {
  --bg: #fffaf2; --card: #ffffff; --ink: #3b2414; --muted: #7a5f4c; --line: #f3e2cf;
  --primary: #ea580c; --primary-ink: #ffffff; --accent: #8b5cf6; --soft: #ffedd5;
  --topbar: linear-gradient(90deg, #f97316, #ec4899, #8b5cf6);
  --pattern:
    radial-gradient(circle at 12% 18%, rgba(249, 115, 22, 0.16) 0 50px, transparent 52px),
    radial-gradient(circle at 85% 25%, rgba(236, 72, 153, 0.14) 0 40px, transparent 42px),
    radial-gradient(circle at 70% 85%, rgba(139, 92, 246, 0.14) 0 60px, transparent 62px),
    radial-gradient(circle at 25% 75%, rgba(250, 204, 21, 0.18) 0 36px, transparent 38px) 0 0 / 520px 520px;
}
:root[data-theme='arts'][data-mode='dark'] {
  --bg: #1a140f; --card: #2a2019; --ink: #fbeee2; --muted: #c9ab94; --line: #43342a;
  --primary: #fb923c; --primary-ink: #2b1203; --accent: #a78bfa; --soft: #3c2a1c;
  --topbar: linear-gradient(90deg, #c2410c, #be185d, #6d28d9);
  --pattern:
    radial-gradient(circle at 12% 18%, rgba(249, 115, 22, 0.12) 0 50px, transparent 52px),
    radial-gradient(circle at 85% 25%, rgba(236, 72, 153, 0.1) 0 40px, transparent 42px),
    radial-gradient(circle at 70% 85%, rgba(139, 92, 246, 0.12) 0 60px, transparent 62px) 0 0 / 520px 520px;
}

:root {
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.07);
}
:root[data-mode='dark'] { --shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35); }

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-size: 18px; line-height: 1.45; color: var(--ink);
  background: var(--pattern), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}
a { color: var(--primary); }
button, input, select { font: inherit; }
h1, h2, h3, .brand, .score-big, .equation { font-family: var(--heading-font); }

/* Floating theme pictures behind everything */
#decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#decor span { position: absolute; opacity: 0.16; animation: drift linear infinite alternate; will-change: transform; }
:root[data-mode='dark'] #decor span { opacity: 0.2; }
@keyframes drift {
  0% { transform: translate(0, 0) rotate(-8deg); }
  50% { transform: translate(18px, -26px) rotate(6deg); }
  100% { transform: translate(-14px, 12px) rotate(-4deg); }
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--topbar); color: #fff;
  position: sticky; top: 0; z-index: 20; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}
.brand { font-weight: 700; font-size: 1.35rem; text-decoration: none; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); display: inline-flex; align-items: center; gap: 6px; }
.brand-icon { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
#nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#nav > a:not(.btn) { color: #fff; text-decoration: none; font-weight: 800; padding: 6px 12px; border-radius: 99px; transition: background 0.2s; }
#nav > a:not(.btn):hover { background: rgba(255, 255, 255, 0.2); }
#nav .btn.small { background: #fff; color: var(--primary); }

main { position: relative; z-index: 1; max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; outline: none; }
main > * { animation: rise 0.35s ease-out both; }
h1 { font-size: 2rem; margin: 8px 0 4px; }
h2 { font-size: 1.4rem; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.crumbs { font-size: 0.95rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { text-decoration: none; font-weight: 700; }

/* ---------- Profile menu ---------- */
.menu { position: relative; }
.menu-button {
  display: inline-flex; align-items: center; gap: 6px; border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 800; border-radius: 99px;
  padding: 4px 12px 4px 6px; cursor: pointer; transition: background 0.2s, transform 0.15s;
}
.menu-button:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.menu-avatar { font-size: 1.4rem; background: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.menu-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(300px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); border: 2px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25); padding: 14px; display: grid; gap: 8px; z-index: 30;
  animation: pop 0.18s ease-out; transform-origin: top right;
}
.menu-panel[hidden] { display: none; }
.menu-panel label, .menu-label { font-weight: 800; font-size: 0.95rem; }
.menu-panel select { width: 100%; }
.menu-panel hr { border: 0; border-top: 2px dashed var(--line); margin: 4px 0; width: 100%; }
.menu-head { display: flex; gap: 10px; align-items: center; padding-bottom: 6px; }
.menu-head-avatar { font-size: 2rem; background: var(--soft); border-radius: 50%; width: 48px; height: 48px; display: grid; place-items: center; }
.menu-link { text-decoration: none; font-weight: 800; color: var(--ink); padding: 8px 10px; border-radius: 10px; }
.menu-link:hover { background: var(--soft); }
.mode-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.mode-btn {
  border: 0; background: transparent; color: var(--ink); font-weight: 800; font-size: 0.9rem; padding: 8px 4px;
  border-radius: 9px; cursor: pointer; transition: background 0.2s, transform 0.15s;
}
.mode-btn[aria-pressed='true'] { background: var(--card); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); color: var(--primary); }
.mode-btn:hover { transform: scale(1.05); }

/* ---------- Cards, buttons, forms ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; border: 2px solid var(--line); display: block; color: inherit; text-decoration: none;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background-color 0.3s;
}
a.card:hover { border-color: var(--primary); transform: translateY(-4px) rotate(-0.5deg); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14); }
a.card:hover .icon { animation: wiggle 0.5s ease-in-out; }
.grid > .card { animation: rise 0.4s ease-out both; }
.grid > .card:nth-child(2) { animation-delay: 0.05s; }
.grid > .card:nth-child(3) { animation-delay: 0.1s; }
.grid > .card:nth-child(4) { animation-delay: 0.15s; }
.grid > .card:nth-child(n + 5) { animation-delay: 0.2s; }
.card .icon { font-size: 2.4rem; display: inline-block; }
.card h3 { margin: 6px 0 4px; font-size: 1.25rem; }
.card.soon { opacity: 0.6; }
.pill { display: inline-block; font-size: 0.8rem; font-weight: 800; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); margin-right: 6px; }
.pill.quiz { background: #fff1c2; color: #7a5a00; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 900; cursor: pointer;
  background: var(--primary); color: var(--primary-ink); text-decoration: none; font-size: 1.05rem;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2); transition: transform 0.12s, box-shadow 0.12s, filter 0.2s;
}
.btn:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2); filter: brightness(1.05); }
.btn:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.btn.secondary { background: var(--card); color: var(--primary); border: 2px solid var(--primary); }
.btn.small { padding: 6px 14px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.pulse { animation: pulse 1.6s ease-in-out infinite; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

form.stack { display: grid; gap: 14px; max-width: 420px; }
label { font-weight: 700; display: grid; gap: 4px; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], select {
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, .btn:focus-visible, .choice:focus-visible, .menu-button:focus-visible, .mode-btn:focus-visible, .theme-tile:focus-visible {
  outline: 3px solid var(--hl); outline-offset: 2px;
}
.error { color: var(--bad); font-weight: 700; }

/* ---------- Theme tiles (account page) ---------- */
.theme-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.theme-tile {
  border: 3px solid var(--line); border-radius: 16px; padding: 0; cursor: pointer; background: var(--card);
  color: var(--ink); font-weight: 800; overflow: hidden; text-align: center; transition: transform 0.15s, border-color 0.2s;
}
.theme-tile:hover { transform: translateY(-3px) scale(1.02); }
.theme-tile[aria-pressed='true'] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--soft); }
.theme-tile .swatch { height: 64px; display: grid; place-items: center; font-size: 2rem; }
.theme-tile .swatch span { display: inline-block; }
.theme-tile:hover .swatch span { animation: wiggle 0.5s ease-in-out; }
.theme-tile .tile-name { display: block; padding: 8px 6px; font-size: 0.95rem; }
.swatch.classic { background: linear-gradient(135deg, #4f7cff, #7b5cff); }
.swatch.science { background: linear-gradient(135deg, #0e7490, #7c3aed); }
.swatch.unicorns { background: linear-gradient(135deg, #f472b6, #c084fc, #60a5fa, #34d399, #facc15); }
.swatch.jungle { background: linear-gradient(135deg, #166534, #84cc16); }
.swatch.sports { background: linear-gradient(135deg, #1d4ed8, #e11d48); }
.swatch.arts { background: linear-gradient(135deg, #f97316, #ec4899, #8b5cf6); }
.account-mode { max-width: 360px; }

/* ============================================================
   Practice
   ============================================================ */
.practice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mascot { font-size: 2.6rem; display: inline-block; animation: bob 2.2s ease-in-out infinite; }
.streak { display: inline-block; margin: 12px 0 0; font-weight: 900; color: var(--accent); background: var(--soft); border-radius: 99px; padding: 4px 12px; animation: pop 0.3s ease-out; }

.track { position: relative; margin: 14px 0 22px; padding-right: 30px; }
.progressbar { height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progressbar > div {
  height: 100%; border-radius: 99px; transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(90deg, var(--primary), var(--accent));
  background-size: 200% 100%; animation: shimmer 3s linear infinite;
}
.track .runner {
  position: absolute; top: -14px; font-size: 1.7rem; transform: translateX(-50%);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); animation: hop 1s ease-in-out infinite;
}
.track .finish { position: absolute; right: 0; top: -8px; font-size: 1.4rem; }

.question-card { animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.question-card.shake { animation: shake 0.45s ease-in-out; }
.question { font-size: 1.4rem; font-weight: 800; margin: 6px 0 14px; }
.equation { font-size: 2.2rem; font-weight: 700; margin: 8px 0 16px; letter-spacing: 1px; color: var(--primary); }
.answer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.answer-row input { width: 140px; font-size: 1.7rem; font-weight: 900; text-align: center; border-width: 3px; transition: border-color 0.2s, transform 0.2s; }
.answer-row input:focus { border-color: var(--primary); transform: scale(1.04); }
.choices { display: grid; gap: 10px; max-width: 460px; margin-top: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); cursor: pointer; font-size: 1.2rem; font-weight: 800; text-align: left; color: var(--ink);
  transition: transform 0.15s, border-color 0.2s, background-color 0.2s;
}
.choice:hover:not([disabled]) { transform: translateX(4px); border-color: var(--primary); }
.choice .box { width: 28px; height: 28px; border: 3px solid var(--muted); border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 1rem; }
.choice.radio .box { border-radius: 50%; }
.choice.selected { border-color: var(--primary); background: var(--soft); animation: pop 0.2s ease-out; }
.choice.selected .box { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.choice.correct { border-color: var(--good); background: var(--good-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice[disabled] { cursor: default; }

.feedback { margin-top: 18px; padding: 16px; border-radius: var(--radius); animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.feedback.good { background: var(--good-bg); border: 3px solid var(--good); }
.feedback.bad { background: var(--bad-bg); border: 3px solid var(--bad); }
.feedback .big { font-size: 1.45rem; font-weight: 900; font-family: var(--heading-font); }
.feedback.good .big { animation: bounce 0.8s ease-out; transform-origin: left center; }
.feedback ol { margin: 8px 0 0; padding-left: 22px; }

/* Hundred chart */
.hundred { display: inline-grid; grid-template-columns: repeat(10, minmax(0, 1fr)); border: 2px solid var(--paper-ink); background: var(--paper); max-width: 100%; user-select: none; border-radius: 6px; overflow: hidden; }
.hundred button {
  border: 1px solid var(--paper-ink); background: var(--paper); width: clamp(28px, 8.5vw, 48px); height: clamp(28px, 8.5vw, 44px);
  font-weight: 700; font-size: clamp(0.8rem, 3vw, 1.1rem); cursor: pointer; color: var(--paper-ink); padding: 0;
  transition: background-color 0.15s;
}
.hundred button:hover { background: #fff7cc; }
.hundred button.start { background: var(--hl2); }
.hundred button.on { background: var(--hl); animation: pop 0.2s ease-out; }
.tool-help { font-size: 0.95rem; color: var(--muted); margin: 6px 0; }

/* Number line */
.numberline { width: 100%; max-width: 760px; background: var(--paper); border-radius: 12px; border: 2px solid var(--line); }
.numberline text { font-family: inherit; font-weight: 700; }

/* Base ten */
.baseten { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-end; background: var(--paper); color: var(--paper-ink); border-radius: 12px; padding: 10px 14px; width: fit-content; max-width: 100%; }
.baseten .group { text-align: center; font-weight: 800; }
.baseten svg { display: block; }

/* ============================================================
   Results & progress
   ============================================================ */
.score-big { font-size: 3.8rem; font-weight: 700; animation: bounce 1s ease-out; }
.trophy { font-size: 3.4rem; display: inline-block; animation: spin-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.review-item { border-left: 6px solid var(--line); padding: 8px 14px; margin: 10px 0; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); }
.review-item.good { border-color: var(--good); }
.review-item.bad { border-color: var(--bad); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border: 2px solid var(--line); }
.stat .num { font-size: 2rem; font-weight: 900; }
.meter { height: 12px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter > div { height: 100%; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
th { background: var(--soft); }
.table-wrap { overflow-x: auto; }
.avatars { display: flex; gap: 6px; flex-wrap: wrap; }
.avatars button { font-size: 1.8rem; border: 2px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; padding: 4px 8px; transition: transform 0.15s; }
.avatars button:hover { transform: scale(1.12) rotate(-6deg); }
.avatars button.selected { border-color: var(--primary); background: var(--soft); }
.loading { color: var(--muted); }

/* ============================================================
   Confetti + animations
   ============================================================ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti span { position: fixed; font-size: 1.6rem; animation: burst 1.2s cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
.confetti span.rain { top: -40px; animation-name: rain; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 80px)) scale(1) rotate(var(--rot)); opacity: 0; }
}
@keyframes rain { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.9); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hop { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes bounce { 0% { transform: scale(0.6); } 50% { transform: scale(1.15); } 70% { transform: scale(0.95); } 100% { transform: scale(1); } }
@keyframes spin-in { from { transform: scale(0) rotate(-180deg); } to { transform: scale(1) rotate(0); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2), 0 0 0 0 var(--soft); } 50% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2), 0 0 0 10px var(--soft); } }
@keyframes shimmer { from { background-position: 0% 0; } to { background-position: 200% 0; } }

@media (max-width: 600px) {
  .menu-name { display: none; }
  /* Full-width dropdown just under the menu button (top: auto keeps it there). */
  .menu-panel { position: fixed; top: auto; left: 16px; right: 16px; width: auto; margin-top: 10px; transform-origin: top center; }
  .menu-button { padding-right: 10px; }
  h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #decor { display: none; }
}

/* ============================================================
   Family: sign-up child blocks, "Who's practicing?"
   ============================================================ */
form.signup { max-width: 520px; }
fieldset.grownup-fields, fieldset.child-fields {
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card);
  padding: 14px 18px 18px; margin: 0; display: grid; gap: 12px; box-shadow: var(--shadow);
}
fieldset legend { font-family: var(--heading-font); font-weight: 700; font-size: 1.15rem; padding: 0 6px; }
.child-list { display: grid; gap: 14px; }
.child-fields { animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.child-fields .remove-child { justify-self: start; }
form.signup h2 { margin: 10px 0 0; }

.who { text-align: center; }
.who .add-child { text-align: left; margin: 20px auto 0; max-width: 460px; }
.profile-tiles { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin: 24px 0; }
.profile-tile {
  display: grid; justify-items: center; gap: 8px; width: 150px; padding: 18px 10px; cursor: pointer;
  background: var(--card); color: var(--ink); border: 3px solid var(--line); border-radius: 24px;
  font-weight: 900; font-size: 1.1rem; text-decoration: none; box-shadow: var(--shadow);
  transition: transform 0.18s, border-color 0.2s;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.profile-tile:nth-child(2) { animation-delay: 0.06s; }
.profile-tile:nth-child(3) { animation-delay: 0.12s; }
.profile-tile:nth-child(n + 4) { animation-delay: 0.18s; }
.profile-tile:hover { transform: translateY(-6px) scale(1.04); border-color: var(--primary); }
.profile-tile:hover .profile-avatar { animation: wiggle 0.5s ease-in-out; }
.profile-tile.current { border-color: var(--primary); }
.profile-tile.add { border-style: dashed; color: var(--muted); }
.profile-avatar { font-size: 3.4rem; width: 96px; height: 96px; display: grid; place-items: center; background: var(--soft); border-radius: 50%; }
.profile-name { overflow-wrap: anywhere; }
.profile-tiles.small { justify-content: flex-start; margin: 0; gap: 10px; }
.profile-tiles.small .profile-tile { width: 110px; padding: 10px 6px; font-size: 0.95rem; }
.profile-tiles.small .profile-avatar { font-size: 2.2rem; width: 60px; height: 60px; }
.profile-tile:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; }

/* Child tiles wear the child's own theme colors */
.profile-tile.themed .profile-avatar { box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.55); }
.profile-tile.themed .profile-avatar > span { display: grid; place-items: center; width: 70%; height: 70%; border-radius: 50%; background: rgba(255, 255, 255, 0.92); }
.profile-tiles.small .profile-tile.themed .profile-avatar > span { font-size: 1.8rem; }
.profile-theme { font-size: 0.8rem; font-weight: 800; color: var(--muted); }

/* Brand: name + slogan in the top bar */
.brand-text { display: grid; line-height: 1.1; }
.brand-slogan { font-family: 'Nunito', system-ui, sans-serif; font-size: 0.72rem; font-weight: 800; opacity: 0.9; letter-spacing: 0.2px; }
@media (max-width: 600px) { .brand-slogan { display: none; } }

/* One-time notices ("Your password was changed") and the "check your email" card */
.flash { background: var(--good-bg); border: 2px solid var(--good); border-radius: 12px; padding: 10px 14px; font-weight: 800; }
.notice { max-width: 520px; }

/* My Progress: clear space between sections, resume cards, empty state */
.progress-page > section, .progress-page > .stats { margin-top: 26px; }
.progress-page > section > h2:first-child { margin-top: 0; }
.resume-card { display: grid; gap: 10px; }
.resume-card h3 { margin: 0; }
.resume-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.empty-state { display: flex; align-items: center; gap: 16px; }
.empty-icon { font-size: 2.6rem; }

/* Reading: the story panel above the questions */
.story { margin: 0 0 16px; border-left: 6px solid var(--accent); }
.story summary { cursor: pointer; font-family: var(--heading-font); font-weight: 700; font-size: 1.25rem; list-style-position: outside; }
.story-hint { font-family: 'Nunito', system-ui, sans-serif; font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.story-text p { font-size: 1.22rem; line-height: 1.75; margin: 12px 0 0; max-width: 62ch; }
