/* ==========================================================================
   MiniCoder, one stylesheet, no build step, no CDN.
   Bright, rounded and chunky: everything is meant to look tappable and fun.
   ========================================================================== */

:root {
  --purple: #7c5cff;
  --purple-dark: #5b3fd6;
  --pink: #ff5c9d;
  --orange: #ff9f43;
  --green: #23c483;
  --green-dark: #16a06a;
  --blue: #3ba7ff;
  --yellow: #ffd23f;
  --red: #ff5a5a;

  --ink: #211d43;
  --ink-soft: #6b6590;
  --ink-faint: #6d6692; /* WCAG AA (4.5:1) on both --bg and --card */
  --focus-ring: var(--purple-dark);

  --bg: #f4f1ff;
  --bg-2: #ece6ff;
  --card: #ffffff;
  --line: #e7e1f7;
  --shadow: 0 6px 0 rgba(33, 29, 67, .07), 0 14px 30px rgba(33, 29, 67, .09);
  --shadow-sm: 0 3px 0 rgba(33, 29, 67, .06), 0 6px 16px rgba(33, 29, 67, .07);

  --radius: 20px;
  --radius-sm: 12px;
  --font: "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "SF Mono", monospace;
}

[data-theme="dark"] {
  --ink: #f0edff;
  --ink-soft: #b6afd8;
  --ink-faint: #9a93c2; /* WCAG AA (4.5:1) on the dark card colour */
  --focus-ring: var(--yellow);
  --bg: #16132b;
  --bg-2: #1e1a3a;
  --card: #221e42;
  --line: #332d5c;
  --shadow: 0 6px 0 rgba(0, 0, 0, .25), 0 14px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 3px 0 rgba(0, 0, 0, .22), 0 6px 16px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 12% -8%, rgba(124, 92, 255, .18), transparent 60%),
    radial-gradient(900px 420px at 92% 0%, rgba(255, 92, 157, .14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .9em; }
a { color: var(--purple); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .08em .38em;
  color: var(--purple-dark);
  word-break: break-word;
}
[data-theme="dark"] code { color: #c9b8ff; }

/* ---------------------------------------------------------------- layout */
.page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 0 rgba(91, 63, 214, .35);
}
.brand .logo-text span { color: var(--purple); }

.topnav { display: flex; gap: 4px; margin-left: 6px; flex-wrap: wrap; }
.topnav a {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: .92rem;
  white-space: nowrap;
}
.topnav a:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.topnav a.active { background: var(--purple); color: #fff; }

.topbar .spacer { flex: 1; }

.main { flex: 1; width: 100%; }
.container {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 3vw, 28px) 60px;
}
.container.wide { width: min(1500px, 100%); }

.footer {
  padding: 18px;
  text-align: center;
  color: var(--ink-faint);
  font-size: .85rem;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  --btn-bg: var(--purple);
  --btn-shadow: var(--purple-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: 14px;
  background: var(--btn-bg);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: .98rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-shadow);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--btn-shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--btn-shadow); }
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }

/* Keyboard users always get a visible ring, links, buttons, inputs, everything. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* FocusOnNavigate lands focus on the page's h1 so screen readers announce the new
   page, but sighted users shouldn't see a ring around a heading they can't interact with. */
h1:focus, h2:focus, h3:focus, h4:focus { outline: none; }

/* Screen-reader-only text (e.g. labelling icon-only table headers). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.btn.green { --btn-bg: var(--green); --btn-shadow: var(--green-dark); }
.btn.pink { --btn-bg: var(--pink); --btn-shadow: #d63c7c; }
.btn.orange { --btn-bg: var(--orange); --btn-shadow: #d97e26; }
.btn.blue { --btn-bg: var(--blue); --btn-shadow: #2482cc; }
.btn.ghost {
  --btn-bg: var(--card); --btn-shadow: var(--line);
  color: var(--ink); border: 2px solid var(--line);
}
.btn.ghost:hover { color: var(--ink); background: var(--bg-2); }
.btn.big { padding: 15px 28px; font-size: 1.1rem; border-radius: 17px; }
.btn.small { padding: 7px 13px; font-size: .85rem; border-radius: 11px; box-shadow: 0 3px 0 var(--btn-shadow); }
.btn.block { width: 100%; }

.icon-btn {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform .1s ease;
}
.icon-btn:hover { background: var(--bg-2); transform: translateY(-1px); }

/* The message bell: an icon button with a little unread counter pinned to its corner. */
a.icon-btn.bell { position: relative; text-decoration: none; }
.bell-count {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1;
}

/* ------------------------------------------------------------ inbox (messages) */
.inbox-item { padding: 0; overflow: hidden; }
.inbox-item.unread { border-color: var(--purple); }
.inbox-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.inbox-row:hover { background: var(--bg-2); }
.inbox-dot { color: var(--purple); width: 12px; flex: 0 0 auto; }
.inbox-from { font-weight: 800; flex: 0 0 auto; }
.inbox-email { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-preview {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.inbox-when { flex: 0 0 auto; }
.inbox-body { padding: 4px 16px 16px 38px; }
@media (max-width: 640px) {
  .inbox-row { flex-wrap: wrap; }
  .inbox-preview { flex-basis: 100%; order: 10; }
}

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 24px);
  box-shadow: var(--shadow-sm);
}
.card.flat { box-shadow: none; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.tight { gap: 7px; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.row.middle { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); }
.tiny { font-size: .82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Spacing utilities, enough to keep the markup free of one-off inline styles. */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 22px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.narrow { width: min(560px, 100%); margin-inline: auto; }
.narrower { width: min(460px, 100%); margin-inline: auto; }

/* ---------------------------------------------------------------- page header */
.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head .ico {
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1;
  flex: none;
}
.page-head h1 { margin: 0 0 2px; }
.page-head p { margin: 0; color: var(--ink-soft); font-weight: 600; }

/* A plain section title with breathing room above it. */
.section-title {
  margin: 34px 0 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.section-title h2 { margin: 0; }
.section-title a { font-size: .85rem; }

/* ---------------------------------------------------------------- pills & chips */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-soft);
  font-weight: 800;
  font-size: .8rem;
  white-space: nowrap;
}
.pill.xp { background: rgba(255, 210, 63, .25); color: #97701a; }
.pill.coins { background: rgba(255, 159, 67, .2); color: #a75f10; }
.pill.streak { background: rgba(255, 92, 92, .16); color: #c33; }
.pill.done { background: rgba(35, 196, 131, .18); color: var(--green-dark); }
.pill.challenge { background: rgba(59, 167, 255, .18); color: #1f6fb0; }
.pill.boss { background: rgba(124, 92, 255, .18); color: var(--purple-dark); }
.pill.quiz { background: rgba(255, 92, 157, .16); color: #c23a6f; }
[data-theme="dark"] .pill.xp { color: var(--yellow); }
[data-theme="dark"] .pill.coins { color: var(--orange); }
[data-theme="dark"] .pill.done { color: #6ee7b0; }
[data-theme="dark"] .pill.streak { color: #ff9a9a; }
[data-theme="dark"] .pill.challenge { color: #7cc5ff; }
[data-theme="dark"] .pill.boss { color: #c9b8ff; }
[data-theme="dark"] .pill.quiz { color: #ff8cc3; }

/* ---------------------------------------------------------------- xp bar */
.xpbar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.xpbar > i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  background-size: 26px 26px;
  transition: width .6s cubic-bezier(.2, .9, .3, 1.2);
}
.xpbar.green > i { background: linear-gradient(90deg, var(--green), #7ee8b0); }
.xpbar.purple > i { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.xpbar.thick { height: 18px; }

/* ---------------------------------------------------------------- avatar */
.avatar {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bg-2), var(--card));
  border: 2px solid var(--line);
  font-size: 1.35rem;
  flex: none;
}
.avatar.lg { width: 76px; height: 76px; font-size: 2.4rem; border-radius: 22px; }
.avatar.xl { width: 108px; height: 108px; font-size: 3.6rem; border-radius: 28px; }
.avatar.sm { width: 34px; height: 34px; font-size: 1.05rem; border-radius: 11px; }

/* ---------------------------------------------------------------- mascot */
.mascot {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.mascot .face {
  font-size: 2.2rem;
  line-height: 1;
  animation: bob 2.6s ease-in-out infinite;
  flex: none;
}
.mascot .bubble {
  position: relative;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.mascot .bubble::before {
  content: "";
  position: absolute;
  left: -9px; top: 16px;
  width: 14px; height: 14px;
  background: var(--card);
  border-left: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  transform: rotate(45deg);
  border-radius: 0 0 0 4px;
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }

/* ---------------------------------------------------------------- hero */
.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 30px;
  align-items: center;
  padding: clamp(20px, 4vw, 44px);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .14), rgba(255, 92, 157, .12));
  border: 2px solid var(--line);
}
.hero h1 { font-size: clamp(2rem, 5.2vw, 3.3rem); }
.hero .lead { font-size: clamp(1rem, 1.6vw, 1.2rem); color: var(--ink-soft); font-weight: 600; }
.hero-art {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.hero-art div {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  animation: float 5s ease-in-out infinite;
}
.hero-art div:nth-child(2n) { animation-delay: .7s; }
.hero-art div:nth-child(3n) { animation-delay: 1.4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- module cards */
.module-card {
  position: relative;
  display: block;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: transform .14s ease, box-shadow .14s ease;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); text-decoration: none; }
.module-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  background: var(--accent, var(--purple));
}
.module-card .emoji { font-size: 2.6rem; line-height: 1; }
.module-card.locked { opacity: .72; }
.module-card.locked:hover { transform: none; }

/* A big, obvious "carry on where you left off" card. */
.next-up {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: clamp(22px, 3vw, 32px);
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent, var(--purple)) 40%, var(--line));
  transition: transform .14s ease, box-shadow .14s ease;
}
.next-up:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.next-up h2 { margin: 2px 0; }
@media (max-width: 620px) {
  .next-up { flex-direction: column; align-items: flex-start; }
  .next-up .btn { width: 100%; }
}

/* Foxy's riddle gates: a friendly AI check-in that pops up mid-lesson. */
.pop-quiz {
  border-color: color-mix(in srgb, var(--yellow) 55%, var(--line));
  animation: pop-quiz-in .25s ease;
}
@keyframes pop-quiz-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Riddle on the left, the mini-game on the right (stacked on phones). */
.pop-quiz-body { display: flex; gap: 20px; align-items: flex-start; }
.pop-quiz-main { flex: 1; min-width: 0; }

/* Inside the side-by-side layout the question needs its own breathing room,
   .stage-question is margin-less by default and ends up glued to the options. */
.pop-quiz-main .stage-question { margin: 6px 0 18px; }
.pop-quiz-main .stage-options { margin-inline: 0; }
.quiz-trail { flex: 0 0 185px; }
.quiz-trail svg { width: 100%; height: auto; display: block; }
@media (max-width: 640px) {
  .pop-quiz-body { flex-direction: column; align-items: stretch; }
  .quiz-trail { flex-basis: auto; width: min(240px, 100%); margin: 0 auto; }
}

/* The picture box: tappable thumbnails of every image a kid may use. */
.picture-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  /* Fifty pictures shouldn't swallow the page, the box scrolls instead. */
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.picture-box-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 6px;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s ease, border-color .1s ease;
}
.picture-box-item:hover { transform: translateY(-2px); border-color: var(--purple); }
.picture-box-item img { width: 40px; height: 40px; }

/* "The AI is working", a screen waiting on the model must never look frozen. */
.ai-thinking { text-align: center; padding: 4px 0; }
.ai-thinking-fox {
  font-size: 1.5rem;
  line-height: 1;
  display: inline-block;
  animation: ai-bob 1.1s ease-in-out infinite;
}
.ai-thinking.big .ai-thinking-fox { font-size: 2.3rem; }
@keyframes ai-bob {
  0%, 100% { transform: translateY(0) rotate(-7deg); }
  50% { transform: translateY(-6px) rotate(7deg); }
}
.ai-thinking-dots { display: inline-flex; gap: 5px; align-items: center; }
.ai-thinking-dots i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--purple);
  animation: ai-dot 1.2s ease-in-out infinite;
}
.ai-thinking-dots i:nth-child(2) { animation-delay: .2s; }
.ai-thinking-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-dot {
  0%, 100% { opacity: .25; transform: scale(.7); }
  40% { opacity: 1; transform: scale(1); }
}
.ai-thinking-bar {
  position: relative;
  height: 8px;
  width: min(320px, 90%);
  margin: 12px auto 2px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
}
.ai-thinking-bar i {
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  animation: ai-slide 1.4s ease-in-out infinite;
}
@keyframes ai-slide {
  from { left: -40%; }
  to { left: 100%; }
}

/* The Arena countdown clock: calm until the last five seconds, then it POUNDS. */
.pill.clock { background: var(--bg-2); font-variant-numeric: tabular-nums; }
.pill.clock.urgent {
  background: var(--red);
  color: #fff;
  animation: clock-pound .5s ease-in-out infinite;
}
@keyframes clock-pound {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* The Rewind Spell: a kind but unskippable "go back and read" moment. */
.rewind-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 8, 30, .72);
  backdrop-filter: blur(3px);
  animation: pop-quiz-in .2s ease;
}
.rewind-card {
  width: min(440px, 100%);
  text-align: center;
  background: var(--card);
  border: 2px solid var(--purple);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: var(--shadow);
}
.rewind-card h2 { margin: 8px 0 6px; }
.rewind-swirl {
  font-size: 3rem;
  line-height: 1;
  display: inline-block;
  animation: rewind-spin 2.4s linear infinite;
}
@keyframes rewind-spin { to { transform: rotate(-360deg); } }

/* Detective mode: the study trail back to the quiz that caught the guessing. */
.hunt-strip {
  border: 2px dashed var(--purple);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 10px;
  font-size: .92rem;
  animation: hunt-pulse 2s ease infinite;
}
@keyframes hunt-pulse {
  0%, 100% { border-color: var(--purple); }
  50% { border-color: color-mix(in srgb, var(--purple) 40%, var(--line)); }
}

/* Foxy (or the rocket, bubble, balloon...) springs to its next spot on each solve. */
.trail-fox { transition: transform .9s cubic-bezier(.34, 1.56, .64, 1); }
.trail-win { animation: trail-pop .6s ease; }
@keyframes trail-pop {
  0% { transform: scale(.4); }
  60% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* On phones the next-up card sits below the fold, surface its button at the
   very top of the dashboard card so "carry on" is the first thing you can tap. */
.mobile-continue { display: none; }
@media (max-width: 760px) {
  .mobile-continue { display: block; width: 100%; text-align: center; margin-bottom: 16px; }
}

/* ---------------------------------------------------------------- first visit welcome */
.welcome {
  width: min(640px, 100%);
  margin: clamp(16px, 6vh, 60px) auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.welcome-fox {
  font-size: 5rem;
  line-height: 1;
  animation: bob 2.6s ease-in-out infinite;
}
.welcome h1 { font-size: clamp(1.7rem, 4.4vw, 2.5rem); }
.welcome .lead {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 1.08rem;
  max-width: 480px;
}
.welcome-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0 20px;
}
.welcome-steps div {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: var(--shadow-sm);
}
.welcome-cta { font-size: 1.15rem; padding: 17px 34px; }

/* ---------------------------------------------------------------- the lesson player
   One screen, one idea. Everything is big, and the Next button never moves. */
.player {
  width: min(720px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.player.wide { width: min(1240px, 100%); }

.player-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player-top .back {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 1.2rem;
  flex: none;
}
.player-top .back:hover { background: var(--bg-2); text-decoration: none; }
.player-title { font-weight: 900; font-size: 1.05rem; }

.step-dots { display: flex; gap: 5px; }
.step-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  transition: background .2s ease, transform .2s ease;
}
.step-dots i.on { background: var(--purple); }
.step-dots i.now { transform: scale(1.4); }
.step-dots.big { justify-content: center; padding: 2px 0; }
.step-dots.big i { width: 11px; height: 11px; }

/* Visited dots are real buttons: a 28px touch/keyboard target drawn as an 11px dot. */
.step-dots button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  margin: -8px 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.step-dots button::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--line);
  transition: background .2s ease, transform .2s ease;
}
.step-dots button.on::before { background: var(--purple); }
.step-dots button.now::before { transform: scale(1.4); }
.step-dots button:hover::before { transform: scale(1.4); }

.stage {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding: clamp(18px, 4vw, 34px);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  animation: stagein .28s cubic-bezier(.2, 1.1, .4, 1);
}
@keyframes stagein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* say, Foxy front and centre, one short thing */
.stage-say { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.stage-face { font-size: 4rem; line-height: 1; animation: bob 2.6s ease-in-out infinite; }
.stage-bubble {
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  font-weight: 700;
  line-height: 1.5;
  max-width: 520px;
}
.stage-bubble p { margin: 0 0 .5em; }
.stage-bubble p:last-child { margin-bottom: 0; }
.stage-say.tip .stage-bubble, .stage-say.warn .stage-bubble, .stage-say.fact .stage-bubble {
  border-radius: 18px;
  padding: 14px 20px;
  border: 2px dashed var(--line);
}
.stage-say.tip .stage-bubble { background: rgba(255, 210, 63, .14); border-color: rgba(255, 159, 67, .5); }
.stage-say.warn .stage-bubble { background: rgba(255, 92, 92, .1); border-color: rgba(255, 92, 92, .45); }
.stage-say.fact .stage-bubble { background: rgba(59, 167, 255, .11); border-color: rgba(59, 167, 255, .45); }
.stage-say.tip .stage-face, .stage-say.warn .stage-face, .stage-say.fact .stage-face { animation: none; }
.stage-list { text-align: left; margin: 10px 0 0; padding-left: 24px; font-size: 1.05rem; }
.stage-list li { margin-bottom: 6px; }

/* show / type shared bits */
.stage-note { font-size: 1.12rem; font-weight: 700; text-align: center; }
.stage-note p { margin: 0; }
.stage-code { font-size: 16px; text-align: left; }
.stage-arrow {
  text-align: center;
  font-weight: 900;
  color: var(--ink-soft);
  font-size: .95rem;
}
.stage-question { text-align: center; margin: 0; }
.stage-options { display: flex; flex-direction: column; gap: 10px; max-width: 460px; width: 100%; margin: 0 auto; }
.quiz-option.big { font-size: 1.1rem; padding: 16px 18px; }

/* type, fill in the blank */
.blank-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  font-family: var(--mono);
  font-size: clamp(16px, 3vw, 22px);
  background: #fbfaff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 18px 14px;
}
[data-theme="dark"] .blank-line { background: #1a1636; }
.blank-code { white-space: pre; }
.blank-input {
  font-family: var(--mono);
  font-size: inherit;
  font-weight: 700;
  /* Sized by the `size` attribute (fits the placeholder); field-sizing refines it live
     in browsers that support it, growing as the kid types. */
  width: auto;
  min-width: 8ch;
  max-width: min(70vw, 42ch);
  field-sizing: content;
  padding: 6px 10px;
  border: 3px dashed var(--orange);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
}
.blank-input:focus { outline: none; border-style: solid; border-color: var(--purple); }
.blank-input.pass { border-style: solid; border-color: var(--green); background: rgba(35, 196, 131, .1); }

.player-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player-nav .next { min-width: 150px; }

/* Every new step breathes in, a soft rise that makes progress feel like motion. */
@keyframes stage-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.stage { animation: stage-in .28s ease-out; }

/* The Enter hint on the Next button: quiet, keyboard-shaped, desktop-only. */
.key-hint {
  font-size: .78em;
  padding: 1px 7px;
  border: 1.5px solid rgba(255, 255, 255, .55);
  border-radius: 6px;
  opacity: .8;
}
@media (max-width: 640px) {
  .key-hint { display: none; }

  /* On phones the nav sticks to the bottom, so Next is always one thumb away. */
  .player-nav {
    position: sticky;
    bottom: 0;
    z-index: 30;
    padding: 10px 4px;
    margin: 0 -4px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(10px);
    border-top: 2px solid var(--line);
  }
}

/* build steps + the My Website area */
.task-card.build { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.site-frame {
  width: 100%;
  height: min(62vh, 640px);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.site-card {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--green) 35%, var(--line));
  transition: transform .12s ease;
}
.site-card:hover { transform: translateY(-2px); text-decoration: none; }

/* ---------------------------------------------------------------- daily quests */
.quest-card {
  border-color: color-mix(in srgb, var(--orange) 45%, var(--line));
}
.quest-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 13px;
  background: var(--bg-2);
  transition: background .25s ease;
}
.quest-row.done { background: rgba(35, 196, 131, .14); }
.quest-row .q-emoji { font-size: 1.3rem; line-height: 1; flex: none; }
.quest-row .q-check { flex: none; }

.btn.claim { animation: wiggle 1.8s ease-in-out infinite; }

/* The Check button turns into "Finish!" and glows when the live checklist is all green. */
.btn.ready { animation: readypulse 1.2s ease-in-out infinite; }
@keyframes readypulse {
  0%, 100% { box-shadow: 0 4px 0 var(--btn-shadow), 0 0 0 0 rgba(35, 196, 131, .55); }
  55% { box-shadow: 0 4px 0 var(--btn-shadow), 0 0 0 11px rgba(35, 196, 131, 0); }
}
@keyframes wiggle {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-2.5deg) scale(1.02); }
  90% { transform: rotate(2.5deg) scale(1.02); }
  94% { transform: rotate(-1.5deg); }
}

.quest-prize-note {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  background: rgba(255, 210, 63, .2);
  border: 2px dashed rgba(255, 159, 67, .55);
  font-weight: 700;
  font-size: .92rem;
}

/* The one-sentence streak status inside the player card. */
.streak-strip {
  margin-top: 10px;
  padding: 8px 13px;
  border-radius: 12px;
  background: rgba(255, 92, 92, .1);
  font-weight: 800;
  font-size: .9rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.streak-strip.safe { background: rgba(35, 196, 131, .13); }
.streak-strip .flame {
  display: inline-block;
  transform-origin: 50% 90%;
  animation: flame .8s ease-in-out infinite alternate;
}
.streak-strip.safe .flame { animation: none; }
@keyframes flame {
  from { transform: scale(1) rotate(-4deg); }
  to { transform: scale(1.18) rotate(4deg); }
}

/* On the home page, keep the quest board and Foxy side by side down to tablet size. */
.home-daily { align-items: start; }

/* Small number tiles: emoji on top, value, label. */
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 16px;
  background: var(--bg-2);
}
.stat > span:first-child { font-size: 1.5rem; line-height: 1; }
.stat strong { font-size: 1.25rem; }

/* ---------------------------------------------------------------- lesson nodes (the "map") */
.chapter-block { position: relative; }
.chapter-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.chapter-head .num {
  width: 46px; height: 46px;
  border-radius: 15px;
  display: grid; place-items: center;
  background: var(--accent, var(--purple));
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  flex: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .12);
}

.lesson-list { display: grid; gap: 10px; }
.lesson-node {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--card);
  border: 2px solid var(--line);
  color: var(--ink);
  transition: transform .12s ease, border-color .12s ease;
}
.lesson-node:hover { transform: translateX(5px); text-decoration: none; border-color: var(--accent, var(--purple)); }
.lesson-node .bubble {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.3rem;
  background: var(--bg-2);
  border: 2px solid var(--line);
  flex: none;
}
.lesson-node.done .bubble { background: rgba(35, 196, 131, .2); border-color: var(--green); }
.lesson-node.done { border-color: rgba(35, 196, 131, .45); }
.lesson-node.current {
  border-color: var(--accent, var(--purple));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, var(--purple)) 18%, transparent);
  /* A slow heartbeat on the next lesson: "this one, right here". */
  animation: next-pulse 2.4s ease-in-out infinite;
}
@keyframes next-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, var(--purple)) 18%, transparent); }
  50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent, var(--purple)) 8%, transparent); }
}
.lesson-node.locked {
  opacity: .55;
  filter: grayscale(.6);
  cursor: default;
}
.lesson-node.locked:hover { transform: none; border-color: var(--line); }
.lesson-node .title { font-weight: 800; }
.lesson-node .grow { flex: 1; min-width: 0; }

.stars { letter-spacing: 1px; font-size: .95rem; white-space: nowrap; }
.stars .off { opacity: .25; }

/* ---------------------------------------------------------------- lesson workspace */
.lesson-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.lesson-header .back { color: var(--ink-soft); font-size: .9rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 18px;
  align-items: start;
}
.workspace.solo { grid-template-columns: minmax(0, 900px); justify-content: center; }
@media (max-width: 1000px) { .workspace { grid-template-columns: 1fr; } }

.teach { display: flex; flex-direction: column; gap: 14px; }
.teach .card { padding: 18px; }

.block-tip, .block-warn, .block-fact {
  border-radius: 16px;
  padding: 14px 16px;
  border: 2px dashed var(--line);
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.block-tip { background: rgba(255, 210, 63, .14); border-color: rgba(255, 159, 67, .5); }
.block-warn { background: rgba(255, 92, 92, .1); border-color: rgba(255, 92, 92, .45); }
.block-fact { background: rgba(59, 167, 255, .11); border-color: rgba(59, 167, 255, .45); }
.block-tip .ico, .block-warn .ico, .block-fact .ico { font-size: 1.4rem; line-height: 1.2; flex: none; }
.block-tip p:last-child, .block-warn p:last-child, .block-fact p:last-child { margin-bottom: 0; }

.task-card {
  border-radius: 18px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .13), rgba(59, 167, 255, .1));
  border: 2px solid var(--line);
}

/* ---------------------------------------------------------------- checklist */
.checklist { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  font-weight: 700;
  font-size: .93rem;
  transition: background .2s ease;
}
.checklist li .mark { flex: none; width: 20px; }
.checklist li.pass { background: rgba(35, 196, 131, .16); color: var(--green-dark); }
.checklist li.fail { background: rgba(255, 92, 92, .12); }
[data-theme="dark"] .checklist li.pass { color: #6ee7b0; }
.checklist li .fix { display: block; font-weight: 600; font-size: .85rem; color: var(--ink-soft); }

/* ---------------------------------------------------------------- quiz */
.quiz-option {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 15px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .1s ease, border-color .1s ease;
}
.quiz-option:hover:not(:disabled) { transform: translateX(4px); border-color: var(--purple); }
.quiz-option .key {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--bg-2);
  font-weight: 900;
  flex: none;
}
.quiz-option.right { border-color: var(--green); background: rgba(35, 196, 131, .14); }
.quiz-option.wrong { border-color: var(--red); background: rgba(255, 92, 92, .12); }
.quiz-option:disabled { cursor: default; }

/* ---------------------------------------------------------------- admin reports */
.report-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 1.7rem; font-weight: 900; line-height: 1.1; }
.stat-label { font-weight: 700; color: var(--ink-soft); font-size: .85rem; }

.daychart { display: flex; gap: 6px; align-items: flex-end; height: 140px; margin-bottom: 6px; }
.daycol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.daybar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.daybar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--purple);
  min-height: 0;
  transition: filter .1s ease;
}
.daycol:hover .daybar { filter: brightness(1.2); }

.heatmap {
  display: grid;
  grid-template-columns: 42px repeat(24, 1fr);
  gap: 2px;
  align-items: center;
  margin-bottom: 8px;
}
.heat-hour { text-align: center; font-size: .68rem; }
.heat-day { font-size: .72rem; }
.heat-cell {
  aspect-ratio: 1 / 1;
  min-height: 12px;
  border-radius: 3px;
  background: var(--purple);
}

.hbar-track {
  height: 14px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
  margin-top: 4px;
}
.hbar { height: 100%; border-radius: 999px; min-width: 6px; }

/* ---------------------------------------------------------------- badges */
.badge-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  border-radius: 18px;
  background: var(--card);
  border: 2px solid var(--line);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.badge-tile .ico { font-size: 2.6rem; line-height: 1; }

/* Earned badges CELEBRATE, a purple ring and glow makes them unmissable in both themes. */
.badge-tile.earned {
  border-color: var(--purple);
  background: linear-gradient(180deg, color-mix(in srgb, var(--purple) 14%, var(--card)), var(--card) 75%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 30%, transparent), var(--shadow-sm);
}
.badge-tile.earned .ico { text-shadow: 0 0 18px color-mix(in srgb, var(--purple) 55%, transparent); }

/* Locked badges recede: dashed outline, flat background, grey icon, but text stays readable. */
.badge-tile.locked { background: var(--bg-2); box-shadow: none; border-style: dashed; }
.badge-tile.locked .ico { filter: grayscale(1); opacity: .4; }
.badge-tile.locked .name { color: var(--ink-soft); }
.badge-tile .name { font-weight: 900; font-size: .95rem; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-weight: 800; font-size: .9rem; }
.input {
  width: 100%;
  padding: 12px 15px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
}
.input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(124, 92, 255, .18); }

.avatar-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 9px; }
/* Radio version, so avatar picking works on pages with no JavaScript. */
.avatar-picker input { position: absolute; opacity: 0; width: 0; height: 0; }
.avatar-picker label {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 15px;
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform .1s ease;
}
.avatar-picker label:hover { transform: scale(1.08); }
.avatar-picker input:checked + label {
  border-color: var(--purple);
  background: rgba(124, 92, 255, .15);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .18);
}
.avatar-picker input:focus-visible + label { outline: 3px solid var(--yellow); outline-offset: 2px; }

.avatar-picker button {
  aspect-ratio: 1;
  border-radius: 15px;
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform .1s ease;
}
.avatar-picker button:hover { transform: scale(1.08); }
.avatar-picker button.sel {
  border-color: var(--purple);
  background: rgba(124, 92, 255, .15);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .18);
}

.alert {
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  /* Neutral fallback so a bare .alert never renders as a stark currentColor outline. */
  border: 2px solid var(--line);
  background: var(--bg-2);
}
.alert.error { background: rgba(255, 92, 92, .12); border-color: rgba(255, 92, 92, .4); color: #c93b3b; }
.alert.ok { background: rgba(35, 196, 131, .14); border-color: rgba(35, 196, 131, .4); color: var(--green-dark); }
[data-theme="dark"] .alert.error { color: #ff9a9a; }
[data-theme="dark"] .alert.ok { color: #6ee7b0; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 2px solid var(--line); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.table tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------- celebration */
.celebrate-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(20, 16, 45, .55);
  backdrop-filter: blur(4px);
  padding: 20px;
  animation: fade .25s ease;
}
.celebrate {
  width: min(480px, 100%);
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 28px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: pop .4s cubic-bezier(.2, 1.4, .4, 1);
}
.celebrate .big-emoji { font-size: 4rem; line-height: 1; animation: bob 1.4s ease-in-out infinite; }
.celebrate .reward-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 18px; }
.celebrate .reward {
  padding: 9px 14px;
  border-radius: 14px;
  background: var(--bg-2);
  font-weight: 900;
}
@keyframes pop { from { transform: scale(.75); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.star-pop { display: inline-block; animation: starpop .5s cubic-bezier(.2, 1.6, .4, 1) both; font-size: 2.2rem; }
.star-pop:nth-child(2) { animation-delay: .18s; }
.star-pop:nth-child(3) { animation-delay: .36s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  font-weight: 800;
  animation: slidein .3s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------- Foxy's step-up help (AI questions)
   Stacked banners: the newest help is always open; older ones fold to a clickable line. */
.assist-area {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assist-banner {
  border: 2px solid var(--orange);
  border-radius: var(--radius-sm);
  background: rgba(255, 159, 67, .1);
  overflow: hidden;
}
.assist-banner:not(.open) { opacity: .75; }
.assist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 6px 10px;
  font-size: .82rem;
  font-weight: 800;
  color: var(--ink);
}
.assist-head.as-btn {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
  text-align: left;
}
.assist-head.as-btn:hover { background: rgba(255, 159, 67, .14); }
.assist-body {
  padding: 0 10px 8px;
  font-size: .92rem;
}
.assist-body p { margin: 0 0 .5em; }

/* ------------------------------------------------- friends dock (the corner popup)
   Anchored bottom-right on top of everything, and on a phone it takes the full width
   rather than squeezing a chat into a 280px column. */
.dock {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.dock-fab {
  width: 58px; height: 58px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  position: relative;
  font-size: 1.6rem;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.dock-fab:hover { transform: translateY(-2px) scale(1.04); }
.dock-fab:active { transform: translateY(1px) scale(.98); }

.dock-fab-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 22px; height: 22px;
  padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--red);
  border: 2px solid var(--card);
  font-size: .72rem;
  font-weight: 900;
}

.dock-panel {
  width: min(340px, calc(100vw - 32px));
  /* FIXED height, not max-height: switching tabs (or opening a chat) must never make
     the whole panel jump around, the body scrolls inside it instead. */
  height: min(500px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dock-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  background: var(--bg-2);
}
.dock-head .spacer { flex: 1; }
.dock-title { font-size: 1rem; }

.dock-tabs { display: flex; border-bottom: 2px solid var(--line); }
.dock-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: .86rem;
  color: var(--ink-faint);
  border-bottom: 3px solid transparent;
}
.dock-tab.on { color: var(--purple); border-bottom-color: var(--purple); }

.dock-count {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  margin-left: 3px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: .68rem;
  font-weight: 900;
}
.dock-count.alert { background: var(--red); color: #fff; }

.dock-body {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Themed scrollbar: --line/--ink-faint track the light/dark palette automatically. */
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.dock-body::-webkit-scrollbar { width: 8px; }
.dock-body::-webkit-scrollbar-track { background: transparent; }
.dock-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}
.dock-body::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }
.dock-empty { text-align: center; padding: 18px 8px; }
.dock-empty .ico { font-size: 2.2rem; }

.dock-foot {
  border-top: 2px solid var(--line);
  padding: 8px 10px;
  background: var(--bg-2);
}

.friend-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.friend-card .avatar { margin-top: 2px; }

/* The friends list stacks each card: name+status / progress / buttons. */
.friend-card.vert {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.friend-card.vert .avatar { margin-top: 0; }
.friend-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.friend-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-top .spacer { flex: 1; }
.friend-buttons {
  display: flex;
  gap: 6px;
}
.friend-buttons .btn { flex: 1; }
.friend-buttons .tiny { flex: 1; }
.friend-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.friend-name {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
.friend-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Level and streak read as quiet metadata, not more pills fighting the name. */
.friend-level, .friend-streak {
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
  flex: none;
}
.friend-level { color: var(--ink-faint); }
.friend-streak { color: var(--orange); }
.friend-stats {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  row-gap: 2px;
}
.friend-stats span { white-space: nowrap; }
.friend-now {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Chat on top, remove below: a narrow column leaves the text the full width. */
.friend-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: none;
}

/* The little online light. Sits on the name's baseline row in lists and the chat header. */
.presence {
  width: 9px; height: 9px;
  border-radius: 999px;
  flex: none;
  align-self: center;
  background: var(--line);
  border: 1px solid var(--ink-faint);
}
.presence.on {
  background: var(--green);
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(35, 196, 131, .22);
}

/* ---- the conversation ---- */
.chat-log { gap: 6px; }

.bubble {
  max-width: 82%;
  padding: 7px 11px;
  border-radius: 16px;
  font-size: .95rem;
  word-break: break-word;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--purple);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.bubble.theirs {
  align-self: flex-start;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-bottom-left-radius: 5px;
}
.bubble-when { font-size: .64rem; opacity: .75; white-space: nowrap; }

.chat-compose { display: flex; gap: 6px; align-items: center; }
.chat-compose .input { flex: 1; padding: 8px 12px; }

/* The safety helper's answer. Loud enough to read, kind enough not to scare anybody. */
.chat-warn {
  margin: 0 0 6px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 159, 67, .16);
  border: 2px solid var(--orange);
  font-size: .8rem;
  font-weight: 700;
  white-space: pre-line;
}

@media (max-width: 520px) {
  .dock { right: 10px; bottom: 10px; left: 10px; align-items: flex-end; }
  .dock-panel { width: 100%; height: calc(100vh - 110px); }
}

/* ---------------------------------------------------------------- misc */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty .ico { font-size: 3rem; }

.hr { height: 2px; background: var(--line); border: none; margin: 18px 0; border-radius: 2px; }

.badge-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 12px; top: 10px;
  z-index: 999;
  background: var(--card);
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid var(--purple);
}

/* Tables (admin, leaderboard) scroll sideways on narrow screens instead of crushing. */
.card:has(> .table) { overflow-x: auto; }

@media (max-width: 820px) {
  /* The top bar folds into two tidy rows: brand + pills + buttons, then the nav
     as a full-width horizontally-scrollable strip. No more overlap soup. */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topnav {
    order: 10;
    flex-basis: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { flex: 0 0 auto; }
}

@media (max-width: 640px) {
  .topnav a { padding: 9px 12px; font-size: .9rem; }
  .brand .logo-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Blazor's built-in error UI */
#blazor-error-ui {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: none;
  z-index: 1000;
  padding: 14px 20px;
  background: var(--yellow);
  color: #4a3a00;
  font-weight: 800;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .2);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; font-size: 1.2rem; }

/* ==================== STAGE ANIMATIONS ====================
   Little looping cartoons that act out one idea in a lesson.
   Rule: every keyframe track ends fully visible at 100%, so the
   global prefers-reduced-motion override leaves a complete picture. */

.stage-anim { display: flex; justify-content: center; }

.anim-scene {
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  width: min(460px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  overflow: hidden;
}

.anim-scene .chip {
  font-family: var(--mono);
  font-weight: 700;
  font-size: .95rem;
  background: rgba(124, 92, 255, .14);
  color: var(--purple);
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.anim-scene .chip.strong { background: rgba(255, 159, 67, .18); color: var(--orange); }
.anim-scene .chip.mini { font-size: .68rem; opacity: .65; padding: 1px 5px; }
.anim-scene .words { font-weight: 800; }

.anim-label {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: .92rem;
  text-align: center;
}
.anim-label code { font-family: var(--mono); color: var(--purple); font-size: .85em; }

/* Shared build-up sequence: things pop in one at a time, then hold. */
.anim-scene .seq1 { animation: seq-pop-1 8s ease infinite; }
.anim-scene .seq2 { animation: seq-pop-2 8s ease infinite; }
.anim-scene .seq3 { animation: seq-pop-3 8s ease infinite; }
.anim-scene .seq4 { animation: seq-pop-4 8s ease infinite; }

@keyframes seq-pop-1 { 0%, 4%  { opacity: 0; transform: scale(.5); } 11%, 100% { opacity: 1; transform: scale(1); } }
@keyframes seq-pop-2 { 0%, 26% { opacity: 0; transform: scale(.5); } 33%, 100% { opacity: 1; transform: scale(1); } }
@keyframes seq-pop-3 { 0%, 48% { opacity: 0; transform: scale(.5); } 55%, 100% { opacity: 1; transform: scale(1); } }
@keyframes seq-pop-4 { 0%, 70% { opacity: 0; transform: scale(.5); } 77%, 100% { opacity: 1; transform: scale(1); } }

/* ---- tag-pair: starter tag + words + stopper tag assemble ---- */
.tagpair { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; padding: 6px 0; }

/* ---- nesting: a small box inside a big box, closing inside-out ---- */
.nest-outer {
  display: inline-flex; align-items: center; gap: 10px;
  border: 3px solid var(--purple);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(124, 92, 255, .05);
}
.nest-inner {
  display: inline-flex; align-items: center; gap: 8px;
  border: 3px solid var(--orange);
  border-radius: 12px;
  padding: 9px 11px;
  background: rgba(255, 159, 67, .07);
}

/* ---- list-pop: bullets pop into the ul box one by one ---- */
.listbox {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  border: 3px solid var(--blue);
  border-radius: 16px;
  padding: 12px 18px;
  background: rgba(59, 167, 255, .06);
}
.listrow { display: flex; align-items: center; gap: 9px; font-weight: 800; padding-left: 16px; }
.listrow .bullet { color: var(--blue); font-size: 1.35rem; line-height: 1; }

/* ---- link-jump: a click on page one lights up page two ---- */
.linkpages { display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.minipage {
  width: 122px; height: 92px;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  position: relative;
  padding: 9px;
  text-align: left;
}
.minibar { height: 8px; border-radius: 4px; background: var(--line); margin-bottom: 7px; }
.minih { height: 10px; width: 62%; border-radius: 5px; background: var(--purple); margin-bottom: 8px; }
.minih.fun { background: var(--pink); }
.minilink { color: var(--blue); text-decoration: underline; font-size: .7rem; font-weight: 800; }
.miniemoji { font-size: 1.25rem; }
.pointer {
  position: absolute; right: 4px; bottom: -8px;
  font-size: 1.5rem;
  animation: link-tap 6s ease infinite;
}
.minipage.there { animation: page-arrive 6s ease infinite; }
.jump-arrow { font-size: 1.5rem; animation: arrow-wake 6s ease infinite; }

@keyframes link-tap {
  0%, 22%  { transform: translate(12px, 8px); }
  38%, 44% { transform: translate(-16px, -32px) scale(1); }
  50%      { transform: translate(-16px, -32px) scale(.72); }
  56%, 100% { transform: translate(-16px, -32px) scale(1); }
}
@keyframes page-arrive {
  0%, 52%   { opacity: .35; transform: scale(.9); }
  64%, 100% { opacity: 1; transform: scale(1.05); }
}
@keyframes arrow-wake {
  0%, 52%   { opacity: .25; color: var(--ink-faint); }
  64%, 100% { opacity: 1; color: var(--green); }
}

/* ---- paint: a brush sweeps by and the word changes colour ---- */
.paintline { position: relative; font-size: 2.3rem; font-weight: 900; padding: 10px 0 4px; }
.paint-word { animation: paint-colour 6s ease infinite; }
.brush {
  position: absolute; top: -16px; left: -34px;
  font-size: 1.9rem;
  animation: brush-sweep 6s ease infinite;
}
@keyframes paint-colour {
  0%, 32%   { color: var(--ink); }
  58%, 100% { color: hotpink; }
}
@keyframes brush-sweep {
  0%, 18%   { transform: translateX(0) rotate(0deg); opacity: 0; }
  28%       { transform: translateX(12px) rotate(-8deg); opacity: 1; }
  58%       { transform: translateX(150px) rotate(-18deg); opacity: 1; }
  70%, 100% { transform: translateX(170px) rotate(-18deg); opacity: 0; }
}

/* ---- magic-button: a finger taps, the button presses, a message pops ---- */
.magicbtn-scene { position: relative; padding: 46px 26px 16px; }
.magic-btn {
  pointer-events: none;
  font-family: var(--font); font-weight: 800; font-size: 1rem;
  background: var(--purple); color: #fff;
  border: 0; border-radius: 12px;
  padding: 11px 20px;
  box-shadow: 0 4px 0 var(--purple-dark);
  animation: magic-press 5s ease infinite;
}
.magic-finger {
  position: absolute; right: 6px; bottom: 2px;
  font-size: 1.7rem;
  animation: magic-tap 5s ease infinite;
}
.magic-pop {
  position: absolute; top: 0; left: 50%;
  background: var(--yellow); color: #4a3a00;
  font-weight: 900; font-size: .95rem;
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  animation: magic-pop-in 5s ease infinite;
}
@keyframes magic-tap {
  0%, 26%  { transform: translate(14px, 10px) scale(1); }
  40%      { transform: translate(-14px, -20px) scale(1); }
  46%      { transform: translate(-14px, -20px) scale(.72); }
  52%, 100% { transform: translate(-14px, -20px) scale(1); }
}
@keyframes magic-press {
  0%, 42%  { transform: translateY(0); box-shadow: 0 4px 0 var(--purple-dark); }
  47%      { transform: translateY(4px); box-shadow: 0 0 0 var(--purple-dark); }
  52%, 100% { transform: translateY(0); box-shadow: 0 4px 0 var(--purple-dark); }
}
@keyframes magic-pop-in {
  0%, 50%   { opacity: 0; transform: translateX(-50%) scale(.3); }
  62%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* ---- counter: a finger taps +1 and the number counts up ---- */
.counter-scene { position: relative; display: flex; align-items: center; gap: 22px; padding: 14px 30px 14px 10px; }
.count-digits {
  position: relative;
  width: 64px; height: 64px;
  border: 3px solid var(--green);
  border-radius: 16px;
  background: rgba(35, 196, 131, .08);
}
.count-digits .d {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 2rem; font-weight: 900;
  color: var(--green);
  opacity: 0;
}
.count-digits .d0 { animation: count-d0 8s ease infinite; }
.count-digits .d1 { animation: count-d1 8s ease infinite; }
.count-digits .d2 { animation: count-d2 8s ease infinite; }
.count-digits .d3 { animation: count-d3 8s ease infinite; }
.count-btn { animation: count-press 8s ease infinite; }
.count-finger {
  position: absolute; right: 0; bottom: -4px;
  font-size: 1.7rem;
  animation: count-tap 8s ease infinite;
}

/* The number holds, then hops to the next value right after each tap (25/50/75%). */
@keyframes count-d0 { 0% { opacity: 1; } 24% { opacity: 1; } 26%, 100% { opacity: 0; } }
@keyframes count-d1 { 0%, 24% { opacity: 0; } 26% { opacity: 1; transform: scale(1.3); } 30% { transform: scale(1); } 49% { opacity: 1; } 51%, 100% { opacity: 0; } }
@keyframes count-d2 { 0%, 49% { opacity: 0; } 51% { opacity: 1; transform: scale(1.3); } 55% { transform: scale(1); } 74% { opacity: 1; } 76%, 100% { opacity: 0; } }
@keyframes count-d3 { 0%, 74% { opacity: 0; } 76%, 100% { opacity: 1; } }
@keyframes count-tap {
  0%, 10% { transform: translate(6px, 8px) scale(1); }
  20%     { transform: translate(-30px, -26px) scale(1); }
  24%     { transform: translate(-30px, -26px) scale(.72); }
  28%, 46% { transform: translate(-30px, -26px) scale(1); }
  49%     { transform: translate(-30px, -26px) scale(.72); }
  53%, 71% { transform: translate(-30px, -26px) scale(1); }
  74%     { transform: translate(-30px, -26px) scale(.72); }
  78%, 100% { transform: translate(-30px, -26px) scale(1); }
}
@keyframes count-press {
  0%, 22% { transform: translateY(0); }
  25%     { transform: translateY(4px); }
  28%, 47% { transform: translateY(0); }
  50%     { transform: translateY(4px); }
  53%, 72% { transform: translateY(0); }
  75%     { transform: translateY(4px); }
  78%, 100% { transform: translateY(0); }
}
