/* Koda: Apple-style light theme. White and studio-gray surfaces, near-black ink, one blue accent. */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --sunken: #F5F5F7;
  --line: #E8E8ED;
  --line-strong: #D2D2D7;
  --ink: #1D1D1F;
  --muted: #6E6E73;
  --accent: #007AFF;
  --accent-hover: #0066D6;
  --accent-ink: #FFFFFF;
  --accent-soft: #EBF5FF;
  --sky: #38BDF8;
  --warn: #B25000;
  --warn-soft: #FFF4E5;
  --error: #D70015;
  --error-soft: #FFF0F1;
  --term: #1D1D1F;
  /* older names still used by some rules */
  --cyan: var(--accent);
  --blue: var(--accent);
  --green: #248A3D;
  --green-soft: #EAF7EE;
  --yellow: #FF9F0A;
  --radius: 14px;
  --radius-lg: 1.5rem; /* rounded-3xl */
  --lift: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --lift-hover: 0 2px 6px rgba(0, 0, 0, 0.05), 0 16px 40px rgba(0, 0, 0, 0.09);
  --tap: 2.75rem; /* 44px minimum touch target */
  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font: 16px/1.5 var(--font);
}
* { box-sizing: border-box; }

/* `hidden` must win over any display rule (e.g. #app's grid), so login and app never show together. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { -webkit-text-size-adjust: 100%; }
a { color: var(--ink); text-underline-offset: 0.2em; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0.5rem 0; }
.muted { color: var(--muted); }
small { font-size: 0.85rem; }
.error { color: var(--error); }
.pre { white-space: pre-wrap; }
.label { font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* ---------- controls ---------- */
button, .button, input, textarea, select { font: inherit; color: var(--ink); }
button, .button {
  min-height: var(--tap);
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  touch-action: manipulation;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--sunken); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--sunken); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 16px+ text stops iOS Safari zooming into inputs */
input, textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: max(16px, 1rem);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: 1.25rem; min-height: 1.25rem; height: 1.25rem; accent-color: var(--accent); flex: none; margin: 0; box-shadow: none; }
label { display: grid; gap: 0.25rem; }

/* Segmented control: attached buttons, one selected */
.segs { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }
.seg { min-height: 2.75rem; padding: 0 0.85rem; border: 0; border-right: 1px solid var(--line-strong); border-radius: 0; background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
.seg:last-child { border-right: 0; }
.seg[aria-pressed=true] { background: var(--ink); color: var(--bg); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.section { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-top: 1.6rem; }
.section > h2 { margin-bottom: 0.5rem; }
.note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 0.55rem 0.8rem; margin: 0.6rem 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.status { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* ---------- login ---------- */
.login { max-width: 24rem; padding: max(3rem, env(safe-area-inset-top)) 1.25rem 2rem; margin: 0 auto; }
.login h1 { font-size: 2rem; }
.login p { color: var(--muted); margin: 0.4rem 0 1.5rem; }
.login form { display: grid; gap: 0.9rem; }

/* ---------- app shell ---------- */
#app {
  display: grid; height: 100dvh;
  grid-template: "top" auto "body" 1fr "nav" auto / minmax(0, 1fr);
}
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 1rem;
  padding: calc(env(safe-area-inset-top) + 0.35rem) max(1rem, env(safe-area-inset-right)) 0.35rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.top strong { flex: 1; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .top { flex-wrap: nowrap; gap: 0.35rem; padding: calc(env(safe-area-inset-top) + 0.4rem) 0.65rem 0.4rem; }
  .top .brand { flex: 0 0 auto; min-width: 0; margin-right: auto; }
  .top .brand > span:last-child { display: none; }
  #mypoints { font-size: 0.82rem; gap: 0.45rem; }
  .top select { min-height: 2.1rem; padding: 0.2rem 0.35rem; font-size: 0.85rem; }
  .top #logout { min-height: 2.1rem; padding: 0 0.45rem; font-size: 0.85rem; }
}
#mypoints { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.body { grid-area: body; display: flex; min-height: 0; min-width: 0; }
#view { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1.25rem max(1rem, env(safe-area-inset-left)) 2rem; }
#view > * { max-width: 46rem; }
.tabs {
  grid-area: nav;
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 0 max(0.25rem, env(safe-area-inset-right)) max(0.25rem, env(safe-area-inset-bottom)) max(0.25rem, env(safe-area-inset-left));
}
.tab {
  flex: 1; max-width: 7rem; min-height: 3.4rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600;
  border-top: 2px solid transparent;
}
.tab svg { width: 1.3rem; height: 1.3rem; }
.tab-icon { position: relative; display: inline-flex; }
.tab[aria-current=page] { color: var(--ink); border-top-color: var(--accent); }
@media (min-width: 1000px) {
  #app { grid-template: "top top" auto "nav body" 1fr / 12rem minmax(0, 1fr); }
  .tabs { flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding: 0.75rem 0.5rem; gap: 0.1rem; }
  .tab { flex: none; max-width: none; min-height: 2.75rem; flex-direction: row; justify-content: flex-start; gap: 0.6rem; padding: 0 0.7rem; font-size: 0.95rem; border-top: 0; border-left: 2px solid transparent; border-radius: 0 var(--radius) var(--radius) 0; }
  .tab:hover { background: var(--sunken); }
  .tab[aria-current=page] { border-left-color: var(--accent); background: var(--sunken); }
  .tab svg { width: 1.15rem; height: 1.15rem; }
  #view { padding: 1.75rem 2.25rem 3rem; }
}

/* ---------- page headings ---------- */
.page-head { margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); }

/* ---------- code ---------- */
.code { display: flex; flex-direction: column; gap: 0.6rem; height: calc(100dvh - 9.5rem); }
@media (min-width: 1000px) {
  .code { height: calc(100dvh - 7rem); }
}

/* ---------- tables (scores, admin, reports) ---------- */
.table-wrap { overflow-x: auto; margin: 0.4rem 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--line-strong); padding: 0.5rem 0.75rem 0.5rem 0; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--line); padding: 0.6rem 0.75rem 0.6rem 0; vertical-align: middle; }
.table .right { text-align: right; padding-right: 0; }
.admin > .stack > * { min-width: 0; }
.admin .table pre { margin: 0 0 0.25rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 22rem; font-size: 0.85rem; }
.table tr.me td { background: var(--accent-soft); }
.table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 0.5rem; }
.rank-num { font-family: var(--mono); color: var(--muted); width: 2.5rem; }
.points { font-weight: 750; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.badges { font-size: 1rem; letter-spacing: 0.1em; }

details summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--muted); font-weight: 600; }
details[open] summary { color: var(--ink); }

/* ---------- admin ---------- */
.stat { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.toast {
  position: fixed; left: 50%; bottom: calc(4.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--radius); font-weight: 600; z-index: 30; max-width: 92vw;
}
@media (min-width: 1000px) {
  .toast { bottom: 1.5rem; }
}
@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  .table .hide-sm { display: none; }
}
@keyframes fade { from { opacity: 0.4; } to { opacity: 1; } }
#view > .admin { max-width: 66rem; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ================= Apple-style surfaces, type, and components ================= */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; }
.eyebrow { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: 600; letter-spacing: 0.025em; color: var(--accent); }
.label { font-size: 0.875rem; font-weight: 600; letter-spacing: 0.025em; text-transform: none; color: var(--muted); }

/* Buttons: pills, filled gray by default, solid blue for the main action */
button, .button {
  border-radius: 980px; border-color: transparent; background: var(--sunken); padding: 0 1.1rem;
  transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .button:hover { background: var(--line); }
button:active:not(:disabled), .button:active { transform: scale(0.97); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); filter: none; }
button.ghost { background: transparent; }
input, textarea, select { border-radius: 12px; border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 4px var(--accent-soft); }

/* Segmented control, iOS style */
.segs { border: 0; padding: 2px; gap: 2px; border-radius: 10px; background: var(--sunken); }
.seg { border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.seg:last-child { border: 0; }
.seg[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.panel { background: var(--sunken); border: 0; border-radius: var(--radius-lg); padding: 1.5rem; }
.section { border-top: 1px solid var(--line); padding-top: 2rem; margin-top: 2.5rem; }
.note { border: 0; border-radius: var(--radius); background: var(--accent-soft); padding: 0.85rem 1.1rem; }

/* Header: translucent white bar */
.top {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.brand, .brand-lockup { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 0.45rem; background: url(/icon.svg) center / cover; }
.top #logout { border-radius: 980px; }
#mypoints { background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 0.3rem 0.8rem; border-radius: 980px; white-space: nowrap; }
#mypoints.bump { animation: bump 0.5s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); } }

/* Navigation */
.tabs { background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.tab { border-top: 0; }
.tab[aria-current=page] { color: var(--accent); }
@media (min-width: 1000px) {
  .tabs { background: var(--sunken); border-right: 0; padding: 1rem 0.75rem; gap: 0.2rem; }
  .tab { border-left: 0; border-radius: 10px; color: var(--ink); }
  .tab:hover { background: rgba(0, 0, 0, 0.04); }
  .tab[aria-current=page] { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
  #view { padding: 2rem 3rem 4rem; }
}

/* Login */
.login { max-width: 27rem; padding: max(clamp(4rem, 14vh, 8rem), env(safe-area-inset-top)) 1.5rem 3rem; }
.brand-lockup { margin-bottom: 2rem; font-size: 1.125rem; }
.login h1 { font-size: clamp(2.25rem, 7vw, 2.75rem); line-height: 1.08; letter-spacing: -0.035em; }
.login p { font-size: 1.0625rem; margin: 0.9rem 0 2.25rem; }
.login form small { margin-top: -0.6rem; }
.login .login-switch { margin: 1.5rem 0 0; text-align: center; font-weight: 800; }
.login-switch a { color: var(--accent-hover); }
.login form { gap: 1rem; margin-top: 1rem; }
.login form .primary { min-height: 3.1rem; font-size: 1.0625rem; }

/* ---------- the road ---------- */
#view > .learn { max-width: 64rem; margin: 0 auto; }

.login h1 { text-wrap: balance; }
.stat { margin: 0.25rem 0 0; font-size: 3rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.dots { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.75rem; }
.dots i { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--line-strong); }
.dots i.on { background: var(--accent); }

.learn > .page-head { max-width: 46rem; margin-bottom: 1.5rem; }
.learn > .page-head p { margin-top: 0.5rem; font-size: 1.0625rem; }
.learn > .note { max-width: 46rem; margin-left: auto; margin-right: auto; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.6rem; border-radius: 980px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--muted); }

/* Progress bar */
.progress-bar { height: 0.5rem; border-radius: 980px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; min-width: 0.5rem; border-radius: inherit; background: var(--accent); transition: width 0.6s ease; }

@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Toast and celebration */
#toast { border-radius: 980px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--lift-hover); animation: pop 0.3s ease-out; }

/* Scores */
.points { color: var(--accent); }
.table .rank-num { width: 3.6rem; white-space: nowrap; }
.table tr.rank:nth-child(-n+3) .rank-num { color: var(--accent); font-weight: 700; }
.table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.badges { letter-spacing: 0; }
.badges .chip { margin: 0.15rem 0.3rem 0.15rem 0; }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); opacity: 0.8; } }
@media (max-width: 600px) {
  /* one header row: hide the brand name, keep 40px+ tap targets */
  .top { flex-wrap: nowrap; }
  .top strong { min-width: 0; flex: 1 1 auto; }
  .top select { max-width: 6.5rem; min-height: 2.5rem; }
  .top #logout { padding: 0 0.75rem; min-height: 2.5rem; }
  #view > .learn { margin: 0; }
}
@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #mypoints.bump, #toast, button, .button { animation: none !important; transition: none !important; }
}

/* ================= Pages, answers, leaderboard, profile ================= */
.page { margin: 0 auto; width: 100%; }
#view > .page { max-width: 64rem; }
.page.player, .page.profile { max-width: 36rem !important; }
.page-head .button { margin-top: 0.25rem; }
.player { display: grid; gap: 1rem; align-content: start; }
.screen-text { font-size: 1.4rem; line-height: 1.35; }
.answers { display: grid; gap: 0.6rem; }
.answer { justify-content: flex-start; text-align: left; white-space: normal; height: auto; min-height: 3.25rem; padding: 0.75rem 1rem; border-width: 2px; }
.answer.right { border-color: var(--green); background: var(--green-soft); opacity: 1; }
.answer.wrong { border-color: var(--error); background: var(--error-soft); }
.answer.right:disabled { opacity: 1; }
.stack { display: grid; gap: 0.75rem; min-width: 0; align-content: start; }
.panel .row { margin-top: 0.6rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.stats .stat { font-size: 2rem; }
.board .segs { margin-bottom: 0.75rem; }

/* ================= The car mascot ================= */
.says { display: flex; align-items: flex-end; gap: 0.6rem; }
.mascot { display: inline-block; flex: none; width: 4.5rem; animation: idle 2.4s ease-in-out infinite; }
.mascot svg { display: block; width: 100%; height: auto; }
.mascot.cheer { animation: hop 0.6s ease 2; }
.mascot.oops { animation: shake 0.4s ease; }
.speech { position: relative; min-width: 0; padding: 0.7rem 0.95rem; border-radius: 18px; border-bottom-left-radius: 6px; background: var(--sunken); line-height: 1.45; overflow-wrap: anywhere; }
.speech .screen-text { font-size: 1.15rem; }
@keyframes idle { 50% { transform: translateY(-4px); } }
@keyframes hop { 40% { transform: translateY(-14px) rotate(-6deg); } 70% { transform: translateY(0) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  .mascot { animation: none !important; }
}

.lab-choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lab-choice { flex: 1 1 6rem; min-height: 3rem; white-space: normal; border-width: 2px; }
.lab-choice[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.code-line { font-family: var(--mono); font-size: 0.95rem; }
#sound { min-width: var(--tap); padding: 0 0.4rem; font-size: 1.15rem; }
.mascot { cursor: pointer; }

/* ================= Matching ================= */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; align-items: start; }
.match-col { display: grid; gap: 0.5rem; min-width: 0; }
.match-col button { display: grid; gap: 0.15rem; height: auto; min-height: 3.5rem; padding: 0.5rem 0.65rem; white-space: normal; overflow-wrap: anywhere; font-size: 0.92rem; justify-content: stretch; text-align: left; }
@media (max-width: 420px) {
  .tab { font-size: 0.66rem; }
}

/* ================= The ladder ================= */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.page.learn { max-width: 36rem !important; }
.unit { margin-top: 1.75rem; }
.unit-banner { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.2rem; border-radius: 20px; background: var(--accent); color: #fff; box-shadow: 0 6px 0 var(--accent-hover); }
.unit-banner .label { color: rgba(255, 255, 255, 0.85); }
.unit-banner h2 { margin: 0.1rem 0; font-size: 1.25rem; }
.unit-banner p { margin: 0; font-size: 0.9rem; }
.unit-banner.locked { background: var(--sunken); color: var(--muted); box-shadow: 0 6px 0 var(--line-strong); }
.unit-banner.locked .label { color: var(--muted); }
.ladder { list-style: none; margin: 0; padding: 1.5rem 0 0.25rem; display: grid; gap: 1.1rem; justify-items: center; }
.rung { position: relative; transform: translateX(calc(var(--sway) * 3.2rem)); }
.node-link { display: grid; justify-items: center; gap: 0.45rem; width: 9.5rem; text-align: center; text-decoration: none; color: var(--ink); cursor: pointer; }
.node-circle { position: relative; display: grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.7rem; font-weight: 800; box-shadow: 0 6px 0 var(--accent-hover); transition: transform 0.1s ease, box-shadow 0.1s ease; }
a.node-link:active .node-circle { transform: translateY(5px); box-shadow: 0 2px 0 var(--accent-hover); }
.rung.done .node-circle { background: #34C759; box-shadow: 0 6px 0 var(--green); }
.rung.locked .node-circle { background: var(--line); color: var(--muted); box-shadow: 0 6px 0 var(--line-strong); font-size: 1.3rem; }
.rung.locked .node-name { color: var(--muted); }

/* The current step: a fixed ring drawn by box-shadow (it always follows the button's shape, so it can't drift),
   plus one soft wave that grows out of the button. Only transform and opacity animate, so it stays smooth. */
.rung.current .node-circle { margin: 0.9rem 0 1.2rem; box-shadow: 0 6px 0 var(--accent-hover), 0 0 0 7px #fff, 0 0 0 12px #C7E2FF; }
.rung.current a.node-link:active .node-circle { box-shadow: 0 2px 0 var(--accent-hover), 0 0 0 7px #fff, 0 0 0 12px #C7E2FF; }
.rung.current .node-circle::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); opacity: 0; animation: pulse 2s ease-out infinite; pointer-events: none; z-index: -1; }
.node-name { font-size: 0.85rem; font-weight: 650; line-height: 1.25; }
.start-flag { padding: 0.25rem 0.7rem; margin-bottom: 0.5rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--accent); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.05em; }
.rung-car { position: absolute; top: 3rem; }
.rung-car .mascot { width: 4.2rem; }
.rung-car { right: calc(100% - 1.2rem); }
.rung[style*="--sway:-"] .rung-car { right: auto; left: calc(100% - 1.2rem); }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.35; } 70%, 100% { transform: scale(1.55); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .rung.current .node-circle::after { animation: none; }
}

/* ================= Projects ================= */
.rung.project .node-circle { border-radius: 26%; }
.rung.project .node-name { color: var(--accent); }
.player > * { min-width: 0; }
.page.player { grid-template-columns: minmax(0, 1fr); }

/* Leading spaces matter in Python, so code answers keep them. */
.answer.code-line { white-space: pre-wrap; overflow-wrap: anywhere; }

.small { font-size: 0.82rem; margin: 0; }

/* a unit fades in */
.page.learn .unit { margin-top: 1rem; animation: fade 0.25s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .page.learn .unit { animation: none; }
}

/* Python course */
.py-exercise { display: grid; gap: 0.9rem; min-width: 0; }
.py-code, .py-output { margin: 0; padding: 0.9rem 1rem; border-radius: var(--radius); background: var(--sunken); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.py-exercise .answer.code-line { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.py-exercise .answer[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.py-exercise .answer[data-match]::after { content: attr(data-match); margin-left: auto; padding-left: 0.6rem; color: var(--muted); }
.py-exercise .match { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.py-exercise .match-col { display: grid; gap: 0.6rem; align-content: start; }
.py-ordered { display: grid; gap: 0.4rem; margin: 0; padding-left: 1.4rem; min-height: 3.5rem; }
.py-ordered .answer { width: 100%; }
.py-slot { display: inline-block; min-width: 4rem; min-height: 2.5rem; padding: 0 0.6rem; border: 2px solid var(--accent); background: #fff; font-family: inherit; vertical-align: middle; }
.py-slot.empty { border-style: dashed; border-color: var(--muted); color: var(--muted); }
.py-gap, .py-editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1rem; }
.py-gap { display: inline-block; width: auto; max-width: 100%; min-height: 2.5rem; padding: 0.2rem 0.5rem; vertical-align: middle; }
.py-editor { width: 100%; box-sizing: border-box; min-height: 5rem; padding: 0.8rem 1rem; line-height: 1.6; resize: vertical; }
.py-run { display: grid; gap: 0.35rem; }
/* HTML course: the child's page, drawn. It cannot be clicked, so a link in it never leads away. */
.web-preview { display: grid; gap: 0.35rem; }
.web-preview iframe { width: 100%; box-sizing: border-box; height: 4rem; max-height: 18rem; border: 2px solid var(--line); border-radius: 16px; background: #fff; pointer-events: none; }
.py-result { display: grid; gap: 0.4rem; padding: 1rem; border: 2px solid var(--green); border-radius: var(--radius-lg); background: var(--green-soft); }
.py-result.wrong { border-color: var(--error); background: var(--error-soft); }
.py-result p { margin: 0; }
.py-replay { margin: 0; font-weight: 700; color: var(--accent); }
.py-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.py-summary strong { font-size: 1.6rem; }

/* ================= Koda identity: rounded type, tactile cards, cobalt & emerald palette ================= */
:root {
  --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --ink: #121B2E; --muted: #4F5D75; --line: #DCE3EE; --line-strong: #C3CEDE; --sunken: #EEF2F8;
  --accent: #1D5CE5; --accent-hover: #1548BD; --accent-soft: #EFF6FF; --accent-line: #2563EB;
  --green: #065F46; --green-bright: #059669; --green-deep: #047857; --green-soft: #ECFDF5;
  --error: #991B1B; --error-bright: #B42318; --error-soft: #FEF2F2;
  --practice: #92400E; --practice-bright: #B45309; --practice-soft: #FFFBEB; --practice-line: #D97706;
  --radius: 12px;
}
body { font-weight: 600; background: var(--bg); letter-spacing: 0; }
h1 { font-weight: 900; letter-spacing: -0.02em; }
h2 { font-weight: 800; letter-spacing: -0.015em; }
h3, strong { font-weight: 800; letter-spacing: -0.005em; }
.label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; }

/* pictures that replace emojis */
.ico { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -0.25em; flex: none; }
.ico svg { display: block; width: 100%; height: 100%; }

/* refined tactile buttons */
button, .button {
  border: 1.5px solid var(--line-strong); border-radius: 12px; background: #fff; color: var(--ink);
  box-shadow: 0 2px 0 var(--line); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 0.94rem;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
}
button:hover, .button:hover { background: var(--sunken); border-color: var(--line-strong); }
button:active:not(:disabled), .button:active { transform: translateY(2px); box-shadow: none; }
button.primary, .button.primary { background: #1D5CE5; border-color: #1548BD; color: #fff; box-shadow: 0 2px 0 #143EA8; }
button.primary:hover, .button.primary:hover { background: #1548BD; border-color: #143EA8; }
button.primary:active:not(:disabled), .button.primary:active { transform: translateY(2px); box-shadow: none; }
button:disabled, button.primary:disabled { opacity: 0.72; background: var(--sunken); border-color: var(--line); color: var(--muted); box-shadow: none; cursor: not-allowed; }
button.ghost, button.ghost:hover { border-color: transparent; background: transparent; box-shadow: none; }
button.ghost:hover { background: var(--sunken); }
.answer, .lab-choice, .seg, .py-slot, summary, .tab { text-transform: none; letter-spacing: normal; }
.seg { box-shadow: none; }
input, textarea, select { border: 1.5px solid var(--line-strong); border-radius: 12px; font-weight: 500; background: #fff; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: #fff; }

/* answer cards */
.answer, .lab-choice { border: 1.5px solid var(--line-strong); border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--line); font-weight: 600; }
.answer:hover:not(:disabled), .lab-choice:hover:not(:disabled) { background: #F8FAFC; border-color: #94A3B8; }
.answer:active:not(:disabled), .lab-choice:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.answer:disabled, .lab-choice:disabled { background: #fff; color: #94A3B8; border-color: var(--line); box-shadow: none; }
.answer[aria-pressed=true], .lab-choice[aria-pressed=true], .py-exercise .answer[aria-pressed=true] { background: #EFF6FF; border-color: #1D5CE5; color: #1548BD; box-shadow: 0 2px 0 #1D5CE5; }
.answer.right, .answer.right:disabled { background: var(--green-soft); border-color: var(--green-bright); color: var(--green); box-shadow: 0 2px 0 var(--green-bright); }
.answer.wrong { background: var(--error-soft); border-color: var(--error-bright); color: var(--error); box-shadow: 0 2px 0 var(--error-bright); animation: shake 0.4s ease; }
.wrong-answer .answer[aria-pressed=true] { background: var(--error-soft); border-color: var(--error-bright); color: var(--error); box-shadow: 0 2px 0 var(--error-bright); animation: shake 0.45s ease; }
.right-answer .answer[aria-pressed=true], .right-answer .py-slot, .right-answer .py-gap, .right-answer .py-editor { background: var(--green-soft); border-color: var(--green-bright); color: var(--green); box-shadow: 0 2px 0 var(--green-bright); animation: pop-good 0.45s ease; }
.wrong-answer .py-slot, .wrong-answer .py-gap, .wrong-answer .py-editor { background: var(--error-soft); border-color: var(--error-bright); color: var(--error); animation: shake 0.45s ease; }
.py-slot { box-shadow: 0 2px 0 #1D5CE5; border-radius: 10px; border-color: #1D5CE5; color: #1548BD; }
.py-slot.empty { box-shadow: none; }
.py-code, .py-output { border: 2px solid var(--line); border-radius: 16px; font-weight: 600; }
.py-exercise > * { animation: rise 0.35s ease both; }
.py-exercise .answers > .answer, .py-exercise .lab-choices > .lab-choice { animation: pop-in 0.35s cubic-bezier(.34, 1.56, .64, 1) both; }
.py-exercise .answers > :nth-child(2), .py-exercise .lab-choices > :nth-child(2) { animation-delay: 0.06s; }
.py-exercise .answers > :nth-child(3), .py-exercise .lab-choices > :nth-child(3) { animation-delay: 0.12s; }
.py-exercise .answers > :nth-child(n+4), .py-exercise .lab-choices > :nth-child(n+4) { animation-delay: 0.18s; }

/* top bar: streak and XP */
.top { justify-content: flex-end; background: #fff; border-bottom: 2px solid var(--line); -webkit-backdrop-filter: none; backdrop-filter: none; }
#mypoints { display: inline-flex; gap: 1rem; padding: 0; background: none; font-size: 1.05rem; font-weight: 900; }
#mypoints[hidden] { display: none; }
.stat-chip { display: inline-flex; align-items: center; gap: 0.3rem; }
.stat-chip .ico { width: 1.7rem; height: 1.7rem; }
.stat-chip.streak { color: #FF8A00; }
.stat-chip.streak.none { color: #A7B0C4; }
.stat-chip.streak.none .ico { filter: grayscale(1); opacity: 0.55; }
.stat-chip.xp { color: #D99400; }
.top #sound, .top #logout { width: 2.75rem; padding: 0; min-height: 2.75rem; display: inline-grid; place-items: center; }
.top #sound .ico, .top #logout .ico { width: 1.6rem; height: 1.6rem; }
.top .brand { margin-right: auto; flex: 1; font-size: 1.4rem; font-weight: 900; color: var(--accent); }

/* navigation with labels on both mobile and desktop */
.tabs { background: #fff; border-top: 1.5px solid var(--line); -webkit-backdrop-filter: none; backdrop-filter: none; }
.tab { font-weight: 700; color: var(--muted); border: 1.5px solid transparent; border-radius: 12px; margin: 0.25rem 0.15rem; min-height: 3.3rem; transition: background-color 0.15s ease, color 0.15s ease; }
.tab .ico { width: 1.5rem; height: 1.5rem; transition: transform 0.18s ease; }
.tab:hover .ico { transform: scale(1.08); }
.tab[aria-current=page] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); }
.nav-brand { display: none; }
@media (max-width: 999px) {
  .tab-name { font-size: 0.72rem; font-weight: 700; line-height: 1.1; }
  .tab { position: relative; gap: 0.2rem; padding: 0.3rem 0.25rem; }
}
@media (min-width: 1000px) {
  #app { grid-template: "nav top" auto "nav body" 1fr / 15.5rem minmax(0, 1fr); }
  .top { border-bottom: 1.5px solid var(--line); background: #fff; padding: 0.75rem 2rem; }
  .top .brand { visibility: hidden; }
  .tabs { background: #fff; border-top: 0; border-right: 1.5px solid var(--line); padding: 1.25rem 0.9rem; gap: 0.35rem; }
  .nav-brand { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 1.25rem 0.5rem; font-size: 1.65rem; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
  .nav-brand .brand-mark { width: 2.15rem; height: 2.15rem; }
  .tab { margin: 0; min-height: 3rem; padding: 0 0.85rem; gap: 0.8rem; font-size: 0.94rem; text-transform: none; letter-spacing: -0.01em; border-radius: 12px; border: 1.5px solid transparent; }
  .tab:hover { background: var(--sunken); color: var(--ink); }
  .tab[aria-current=page] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); box-shadow: none; }
  .tab .ico { width: 1.45rem; height: 1.45rem; }
}

/* a lesson fills the screen cleanly with an independent scroll body so the footer never overlaps content */
body.focus .top, body.focus .tabs { display: none !important; }
body.focus #app { grid-template: "body" 100% / minmax(0, 1fr); }
body.focus #view { padding: 0; overflow: hidden; }
body.focus #view > .page.lesson-page { display: flex; flex-direction: column; height: 100%; max-width: none !important; gap: 0; overflow: hidden; }
body.focus #view > .page:not(.lesson-page) { padding: 1rem; }
.lesson-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 0.9rem; width: 100%; max-width: 62rem; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 1rem) 1rem 0.75rem; background: #fff; }
.lesson-close { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; color: #A7B0C4; border-radius: 12px; }
.lesson-close:hover { background: var(--sunken); color: var(--muted); }
.lesson-close .ico { width: 1.5rem; height: 1.5rem; }
.lesson-top .progress-bar { flex: 1; height: 1.1rem; border-radius: 99px; background: var(--line); }
.lesson-top .progress-bar span { position: relative; min-width: 1.1rem; border-radius: 99px; background: linear-gradient(90deg, #1A8CFF, #38BDF8); transition: width 0.7s cubic-bezier(.34, 1.4, .64, 1); }
.lesson-top .progress-bar span::after { content: ''; position: absolute; left: 0.5rem; right: 0.5rem; top: 0.22rem; height: 0.28rem; border-radius: 99px; background: rgba(255, 255, 255, 0.45); }
.lesson-top.hot .progress-bar span { background: linear-gradient(90deg, #FFB000, #FFD43B); }
.combo { min-width: 3.2rem; display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 900; color: #FF8A00; }
.combo.on { animation: pop-in 0.4s cubic-bezier(.34, 1.56, .64, 1); }
.lesson-body { flex: 1; display: grid; gap: 1rem; align-content: center; width: 100%; max-width: 38rem; margin: 0 auto; padding: 0.75rem 1rem 2rem; }
.lesson-body .eyebrow { margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; color: var(--accent); }
.lesson-body .screen-text { font-size: clamp(1.4rem, 4.5vw, 1.9rem); font-weight: 900; }
.lesson-footer { position: sticky; bottom: 0; z-index: 5; border-top: 2px solid var(--line); background: #fff; transition: background-color 0.25s ease; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.75rem 1.25rem; width: 100%; max-width: 62rem; margin: 0 auto; padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 1.1rem); }
.footer-inner .row { margin: 0; }
.footer-inner .row button, .footer-inner .row .button { min-width: 12rem; min-height: 3.2rem; font-size: 1rem; }
@media (max-width: 600px) {
  .footer-inner .row { width: 100%; }
  .footer-inner .row button, .footer-inner .row .button { width: 100%; }
}
.lesson-footer.right { background: var(--green-soft); border-color: var(--green-soft); }
.lesson-footer.wrong { background: var(--error-soft); border-color: var(--error-soft); }
.lesson-footer.right button.primary { background: var(--green-bright); border-color: var(--green-bright); box-shadow: 0 4px 0 var(--green-deep); }
.lesson-footer.wrong button.primary { background: var(--error-bright); border-color: var(--error-bright); box-shadow: 0 4px 0 var(--error); }
.lesson-footer button.primary:active { box-shadow: none !important; }
.footer-inner > [aria-live] { flex: 1 1 20rem; min-width: 0; }
.footer-inner > [aria-live]:empty { display: none; }
.py-result, .py-result.wrong { display: flex; align-items: flex-start; gap: 0.9rem; padding: 0; border: 0; background: none; color: var(--green); animation: slide-up 0.35s cubic-bezier(.34, 1.4, .64, 1); }
.py-result.wrong { color: var(--error); }
.py-result .words { display: grid; gap: 0.35rem; min-width: 0; flex: 1; }
.py-result .words > strong { font-size: 1.45rem; font-weight: 900; }
.py-result .label { color: inherit; }
.py-result .py-code { background: #fff; border-color: transparent; color: var(--ink); max-height: 9rem; overflow: auto; padding: 0.5rem 0.8rem; }
.py-result .muted { color: inherit; opacity: 0.85; }
.result-badge { display: grid; place-items: center; flex: none; width: 3.6rem; height: 3.6rem; border-radius: 50%; background: #fff; animation: pop-in 0.5s cubic-bezier(.34, 1.8, .64, 1) both; }
.result-badge .ico { width: 2.2rem; height: 2.2rem; }
.py-replay { display: inline-flex; align-items: center; gap: 0.4rem; color: #E07B00; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.05em; }

/* end of a lesson */
.finish { display: grid; justify-items: center; gap: 1rem; text-align: center; }
.finish .mascot { width: 12rem; }
.finish > div[data-project-end] { width: 100%; }
.finish .py-code { width: 100%; text-align: left; }
.finish h1 { color: #E59E00; font-size: 2rem; animation: pop-in 0.5s 0.15s cubic-bezier(.34, 1.7, .64, 1) both; }
.py-summary { width: 100%; max-width: 24rem; }
.stat-card { overflow: hidden; border: 3px solid #FFC800; border-radius: 18px; background: #FFC800; animation: pop-in 0.5s 0.35s cubic-bezier(.34, 1.6, .64, 1) both; }
.stat-card + .stat-card { border-color: var(--green-bright); background: var(--green-bright); animation-delay: 0.5s; }
.stat-card .label { display: block; padding: 0.25rem; color: #fff; }
.stat-card strong { display: flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.9rem; border-radius: 15px; background: #fff; font-size: 1.7rem; font-weight: 900; color: #D99400; }
.stat-card + .stat-card strong { color: var(--green); }

/* the road */
.unit-banner { border-radius: 20px; background: linear-gradient(135deg, #1A8CFF 0%, #38BDF8 100%); box-shadow: 0 5px 0 var(--accent-hover); animation: rise 0.4s ease both; }
.unit-banner h2 { font-size: 1.4rem; font-weight: 900; }
.unit-banner.locked { background: var(--sunken); box-shadow: 0 5px 0 var(--line-strong); }
.rung { animation: pop-in 0.45s cubic-bezier(.34, 1.56, .64, 1) both; }
.rung:nth-child(2) { animation-delay: 0.07s; }
.rung:nth-child(3) { animation-delay: 0.14s; }
.rung:nth-child(4) { animation-delay: 0.21s; }
.rung:nth-child(n+5) { animation-delay: 0.28s; }
.rung.open { z-index: 4; }
button.node-link { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; text-transform: none; letter-spacing: normal; font-size: inherit; color: var(--ink); }
button.node-link:hover { background: none; }
button.node-link:active:not(:disabled) { transform: none; box-shadow: none; }
.node-circle { width: 5rem; height: 4.5rem; font-size: 1.9rem; box-shadow: 0 8px 0 var(--accent-hover); background: linear-gradient(160deg, #3AA0FF, #1A8CFF 60%); }
.node-circle::before { content: ''; position: absolute; left: 18%; top: 12%; width: 38%; height: 22%; border-radius: 50%; background: rgba(255, 255, 255, 0.28); transform: rotate(-18deg); }
.node-circle .ico { width: 2.5rem; height: 2.5rem; color: #fff; }
a.node-link:hover .node-circle, button.node-link:hover .node-circle { filter: brightness(1.07); }
a.node-link:active .node-circle, button.node-link:active .node-circle { transform: translateY(6px); box-shadow: 0 2px 0 var(--accent-hover); }
.rung.done .node-circle { background: linear-gradient(160deg, #7BDD2B, #58CC02 60%); box-shadow: 0 8px 0 var(--green-deep); }
.rung.locked .node-circle { background: var(--line); box-shadow: 0 8px 0 var(--line-strong); }
.rung.locked .node-circle .ico { color: #A7B0C4; }
.rung.current .node-circle { box-shadow: 0 8px 0 var(--accent-hover), 0 0 0 8px #fff, 0 0 0 14px #CBE6FF; }
.rung.current a.node-link:active .node-circle, .rung.current button.node-link:active .node-circle { box-shadow: 0 2px 0 var(--accent-hover), 0 0 0 8px #fff, 0 0 0 14px #CBE6FF; }
.rung.project .node-circle .ico { width: 2.9rem; height: 2.9rem; }
.rung.project.current .node-circle { background: linear-gradient(160deg, #FFE066, #FFC800 60%); box-shadow: 0 8px 0 #D99400, 0 0 0 8px #fff, 0 0 0 14px #FFEFB0; }
.node-name { font-weight: 800; }
.start-flag { border-radius: 14px; font-weight: 900; text-transform: uppercase; animation: float 1.6s ease-in-out infinite; box-shadow: 0 3px 0 var(--line); }
.node-pop { position: absolute; left: 50%; top: calc(100% + 0.6rem); z-index: 6; width: 15.5rem; display: grid; gap: 0.5rem; padding: 1rem; border-radius: 18px; background: var(--accent); color: #fff; text-align: left; translate: calc(-50% - var(--sway, 0) * 2.4rem) 0; box-shadow: 0 6px 0 var(--accent-hover); animation: pop-down 0.28s cubic-bezier(.34, 1.56, .64, 1) both; }
.node-pop::before { content: ''; position: absolute; left: calc(50% + var(--sway, 0) * 2.4rem); top: -0.45rem; width: 1rem; height: 1rem; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
.node-pop p { margin: 0; font-size: 0.9rem; opacity: 0.92; }
.node-pop .button { justify-content: center; border-color: #fff; background: #fff; color: var(--accent-hover); box-shadow: 0 4px 0 #BFE0FF; }
.page-head h1 .ico { margin-right: 0.35rem; }

/* the car */
.mascot { width: 5.5rem; }
.mascot, .mascot.cheer, .mascot.oops { animation: none; }
.mascot svg { overflow: visible; }
.mascot .body-car { animation: car-breathe 2.2s ease-in-out infinite; transform-origin: 120px 180px; }
.mascot .antenna { animation: antenna 2.2s ease-in-out infinite; transform-origin: 120px 42px; }
.mascot .eye { animation: blink 4.4s infinite; transform-box: fill-box; transform-origin: center; }
.mascot .sparkles path { animation: twinkle 1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.mascot .sparkles path:nth-child(2) { animation-delay: 0.3s; }
.mascot .sparkles path:nth-child(3) { animation-delay: 0.6s; }
.mascot .sweat { animation: drip 1.4s ease-in infinite; }
.mascot .dots circle { animation: twinkle 0.8s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.mascot .dots circle:nth-child(2) { animation-delay: 0.2s; }
.mascot .dots circle:nth-child(3) { animation-delay: 0.4s; }
.mascot.cheer .body-car { animation: car-jump 0.8s cubic-bezier(.3, 1.6, .6, 1) 3, car-breathe 2.2s 2.4s ease-in-out infinite; }
.mascot.oops .body-car { animation: shake 0.45s ease 2, car-breathe 2.2s 0.9s ease-in-out infinite; }
.mascot.think .body-car { animation: car-think 2.6s ease-in-out infinite; }
.mascot.poked .body-car { animation: car-poke 0.6s ease; }
.rung-car .mascot { width: 5.4rem; }
.speech { border: 2px solid var(--line); border-radius: 18px; font-weight: 700; animation: pop-in 0.35s cubic-bezier(.34, 1.56, .64, 1) both; }
.login-card > .mascot { width: 10rem; margin: 0 auto 0.5rem; display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.75); } }
@keyframes pop-down { from { opacity: 0; scale: 0.85; margin-top: -0.6rem; } }
@keyframes pop-good { 40% { transform: scale(1.04); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(1.5rem); } }
@keyframes float { 50% { translate: 0 -7px; } }
@keyframes flicker { 50% { transform: scale(1.08, 1.14) rotate(-3deg); } }
@keyframes car-breathe { 50% { transform: translateY(-5px) scale(1.012, 0.99); } }
@keyframes antenna { 25% { transform: rotate(9deg); } 75% { transform: rotate(-9deg); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.08); } }
@keyframes twinkle { from { transform: scale(0.55) rotate(0); opacity: 0.45; } to { transform: scale(1.15) rotate(25deg); opacity: 1; } }
@keyframes drip { 0% { transform: translateY(-3px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }
@keyframes car-jump { 0%, 100% { transform: translateY(0) scale(1); } 15% { transform: translateY(0) scale(1.08, 0.9); } 45% { transform: translateY(-30px) scale(0.96, 1.06); } 70% { transform: translateY(0) scale(1.05, 0.94); } }
@keyframes car-think { 50% { transform: rotate(-5deg); } }
@keyframes car-poke { 20% { transform: rotate(-9deg) translateY(-10px); } 45% { transform: rotate(8deg) translateY(-5px); } 70% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) {
  .mascot *, .py-exercise > *, .py-exercise .answers > *, .py-exercise .lab-choices > *, .rung, .unit-banner, .start-flag, .node-pop, .py-result, .result-badge, .finish h1, .stat-card, .speech, .combo.on, .tab .ico, .stat-chip .ico, .answer.wrong, .right-answer *, .wrong-answer * { animation: none !important; }
  .lesson-top .progress-bar span { transition: none; }
}

/* Ayarlar: sound picker */
.sound-settings { display: grid; gap: 0.75rem; }
.sound-settings h3 { margin: 0 0 0.5rem; }
.sound-option { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 4.2rem; min-height: var(--tap); }
.sound-option .ico { width: 1rem; height: 1rem; }
.sound-option[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); color: var(--green); }

/* course switcher: the button in the top bar and the list it opens */
.course-button { display: inline-flex; align-items: center; gap: 0.45rem; min-height: var(--tap); padding: 0 0.7rem; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.course-button .ico { width: 1.7rem; height: 1.7rem; }
.course-list { position: fixed; inset: calc(env(safe-area-inset-top) + 4.25rem) 0.75rem auto auto; width: min(20rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 6rem); overflow-y: auto; margin: 0; padding: 1rem; border: 2px solid var(--line); border-radius: 20px; background: #fff; color: var(--ink); font-size: 1rem; font-weight: 800; box-shadow: var(--lift-hover); }
.course-list h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.course-list ul { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.course { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 3.25rem; padding: 0 0.75rem; border: 2px solid transparent; border-radius: 14px; text-align: left; }
button.course { text-transform: none; letter-spacing: normal; }
button.course[aria-current] { border-color: var(--accent); background: var(--accent-soft); }
.course.soon { color: var(--muted); }
.course.soon .course-mark { filter: grayscale(1); opacity: 0.6; }
.course-mark { display: grid; place-items: center; width: 2rem; }
.course-mark .ico { width: 1.7rem; height: 1.7rem; }
.course-name { flex: 1; }
@media (max-width: 480px) {
  #mypoints { gap: 0.5rem; font-size: 0.95rem; }
  .top .course-title { display: none; }
  .course-button { padding: 0 0.5rem; }
}
/* Browsers without popover (iPad before iOS 17) would show the list all the time. */
@supports not selector(:popover-open) { .course-list { display: none; } }

/* ================= Front page (signed out) ================= */
.login .back { display: inline-flex; align-items: center; min-height: var(--tap); margin-bottom: 0.5rem; color: var(--accent-hover); font-weight: 800; text-decoration: none; }
.login { padding-top: max(1.5rem, env(safe-area-inset-top)); }
.home { overflow-x: clip; --ease: cubic-bezier(0.22, 1, 0.36, 1); }
.home-wrap { width: 100%; max-width: 68rem; margin: 0 auto; padding: 0 24px; }
.home-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: calc(env(safe-area-inset-top) + 12px) max(24px, calc((100% - 68rem) / 2 + 24px)) 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.home-top .brand { font-size: 1.4rem; font-weight: 800; color: var(--ink); }
.home-top .brand-mark { width: 2rem; height: 2rem; }
.home-top .brand > span:last-child { display: inline; } /* phones hide the name only in the app's header */
.home-top .button { min-height: 40px; padding: 0 20px; }
.home .button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.home .hero .button, .home .cta .button { border-color: var(--accent-hover); background: var(--accent); color: #fff; box-shadow: 0 2px 0 #143EA8; }
.home .hero .button:hover, .home .cta .button:hover { background: var(--accent-hover); }
.home .hero .button:active, .home .cta .button:active { box-shadow: none; }

/* hero: text on the left, a real code window on the right, the car on a yellow-dashed road */
.hero { position: relative; padding: clamp(48px, 8vw, 96px) 0 0; background: var(--bg); }
.hero .home-wrap { display: grid; gap: 48px; align-items: center; }
.hero-text { padding-bottom: 48px; }
.hero-text > * { animation: rise 0.5s var(--ease) both; }
.hero-text > :nth-child(2) { animation-delay: 0.05s; }
.hero-text > :nth-child(3) { animation-delay: 0.1s; }
.hero h1 { font-size: clamp(2.25rem, 6vw, 3.75rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
.hero-lead { max-width: 34rem; margin: 20px 0 32px; color: var(--muted); font-size: 1.125rem; font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-actions > * { min-height: 48px; padding: 0 24px; font-size: 1rem; }
.hero-art { position: relative; width: 100%; max-width: 30rem; margin: 0 auto; padding-bottom: 56px; animation: rise 0.5s 0.1s var(--ease) both; }
.demo { overflow: hidden; border-radius: 16px; background: #17213C; box-shadow: 0 8px 24px rgba(18, 27, 46, 0.14); text-align: left; }
.demo-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; background: #22305A; color: #AFC0E8; font-size: 0.8rem; }
.demo-bar i { width: 10px; height: 10px; border-radius: 50%; background: #4A5A8A; }
.demo-bar span { margin-left: auto; font-family: var(--mono); }
.demo pre { margin: 0; font-family: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.demo .demo-code { height: 6.5rem; padding: 20px; color: #fff; font-size: clamp(0.95rem, 3.6vw, 1.125rem); line-height: 1.6; }
.demo-code code { font: inherit; }
.caret { display: inline-block; width: 0.55ch; height: 1.15em; margin-left: 2px; vertical-align: text-bottom; background: #5CF2C8; animation: caret 0.9s steps(1) infinite; }
.demo-result { height: 6rem; padding: 12px 20px; border-top: 1px solid #2E3D6B; }
.demo-result span { color: #AFC0E8; font-size: 0.8rem; }
.demo-result pre { color: #5CF2C8; line-height: 1.5; }
.demo-result.ran pre { animation: rise 0.3s var(--ease) both; }
.hero-car { position: absolute; right: 24px; bottom: -14px; z-index: 2; }
.hero-car .mascot { width: 7rem; }
.hero-road { position: relative; height: 40px; background: #17213C; }
.hero-road::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: repeating-linear-gradient(90deg, #FFD43B 0 40px, transparent 40px 80px); }

/* sections */
.home-section { padding: clamp(56px, 8vw, 96px) 0; scroll-margin-top: 64px; }
.home-section.tinted { background: var(--sunken); }
.home h2 { font-size: clamp(1.75rem, 4vw, 2.25rem); font-weight: 800; line-height: 1.15; text-wrap: balance; }
.home h2:focus { outline: none; }
.section-lead { margin: 8px 0 0; color: var(--muted); font-size: 1.0625rem; }
.home ol, .home ul { margin: 0; padding: 0; list-style: none; }
.home .steps, .home .features, .home .courses { margin-top: 32px; }
.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.home .card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.home .card h3 { margin: 4px 0 8px; font-size: 1.125rem; }
.home .card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.step-number { display: block; margin-top: 20px; color: var(--muted); font-family: var(--mono); font-size: 0.8rem; font-weight: 500; }
.step-number::before { content: '0'; }

/* the small picture on top of each step (still, not looping) */
.mini { display: flex; align-items: center; justify-content: center; gap: 8px; height: 104px; border-radius: 12px; background: var(--accent-soft); }
.mini-example code { padding: 8px 12px; border-radius: 8px; background: #17213C; color: #fff; font-family: var(--mono); font-size: 0.95rem; }
.mini-tiles { position: relative; }
.mini-tiles b { padding: 4px 12px; border: 1.5px solid var(--accent-line); border-radius: 8px; background: #fff; color: var(--accent-hover); font-family: var(--mono); font-weight: 500; }
.mini-slot { position: relative; width: 4.5rem; height: 2rem; border: 1.5px dashed var(--accent); border-radius: 8px; order: -1; }
.mini-tiles .fly { animation: none; }
.mini-master [data-icon] { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--green-bright); }
.mini-master [data-icon]:nth-child(3) { color: var(--muted); }
.mini .ico { width: 1.5rem; height: 1.5rem; }
.mini-cup .ico { width: 3.5rem; height: 3.5rem; }

/* why: four plain items, no boxes */
.features { display: grid; gap: 32px 40px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.feature-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.feature-icon .ico { width: 1.5rem; height: 1.5rem; }
.features h3 { margin: 16px 0 4px; font-size: 1.125rem; }
.features p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* courses: one list per language, Python leads */
.courses { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.lang-card { display: grid; align-content: start; gap: 4px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.lang-card.wide { grid-column: 1 / -1; }
.lang-card h3 { margin: 0; font-size: 1.25rem; }
.lang-count { margin-bottom: 12px; color: var(--muted); font-family: var(--mono); font-size: 0.8rem; font-weight: 500; }
.lang-card ol { counter-reset: unit; display: grid; gap: 8px 32px; }
.lang-card.wide ol { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.lang-card li { counter-increment: unit; display: flex; gap: 12px; font-size: 0.95rem; }
.lang-card li::before { content: counter(unit, decimal-leading-zero); flex: none; width: 1.5rem; color: var(--muted); font-family: var(--mono); font-size: 0.8rem; line-height: 1.7; }

/* parents */
.parents { display: grid; gap: 32px; align-items: center; }
.parents h2 { text-align: left; }
.home .parents ul { display: grid; gap: 12px; margin-top: 20px; padding-left: 20px; list-style: disc; color: var(--muted); }

.cta { padding: 64px 0; background: #17213C; color: #fff; }
.cta .home-wrap { display: grid; justify-items: start; gap: 16px; }
.cta .mascot { width: 6rem; }
.cta h2 { margin: 0 0 8px; }
.cta .button { min-height: 48px; padding: 0 28px; font-size: 1rem; }
.home-footer { padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); background: #17213C; border-top: 1px solid #2E3D6B; color: #AFC0E8; text-align: center; font-size: 0.9rem; }
.home-footer a { color: #D2E3FF; padding: 4px 2px; }

/* sections rise into view once (the script adds .waiting) */
.home [data-reveal] { transition: opacity 0.4s var(--ease), translate 0.4s var(--ease); transition-delay: calc(var(--i, 0) * 50ms); }
.home [data-reveal].waiting { opacity: 0; translate: 0 12px; }

@media (min-width: 860px) {
  .hero .home-wrap { grid-template-columns: 1fr 1fr; align-items: end; }
  .hero-art { margin-right: 0; }
  .parents { grid-template-columns: 1.1fr 1fr; gap: 56px; }
}
@media (max-width: 480px) {
  .home-wrap { padding: 0 16px; }
  .home-top { padding-inline: 16px; }
  .hero { padding-top: 32px; }
  .hero .home-wrap { gap: 32px; }
  .hero-text { padding-bottom: 0; }
  .hero-lead { margin: 16px 0 24px; font-size: 1.02rem; }
  .hero-actions > * { width: 100%; }
  .demo .demo-code { height: 5.5rem; padding: 16px; }
  .demo-result { height: 5.25rem; padding: 12px 16px; }
  .hero-car .mascot { width: 5.5rem; }
  .home-section { padding: 48px 0; }
  .home .steps, .home .features, .home .courses { margin-top: 24px; }
  .cta { padding: 48px 0; }
}

/* ---- scroll and entrance effects (all off for reduced motion: the script adds nothing and the rule below stops the rest) ---- */
.road-progress { position: relative; order: 1; flex: 1; align-self: flex-end; height: 3px; margin: 0 16px 14px; background: var(--line); border-radius: 2px; }
.home-top .button { order: 2; }
.road-progress::before { content: ''; position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); border-radius: 2px; background: repeating-linear-gradient(90deg, #FFD43B 0 10px, #F59E0B 10px 14px); }
.rp-car { position: absolute; bottom: 2px; left: calc(var(--p, 0) * (100% - 36px)); width: 36px; pointer-events: none; }
.rp-car .mascot { width: 36px; }
.hero h1 .word { display: inline-block; animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--w) * 90ms + 100ms); }
.hero-text { translate: 0 calc(var(--hero, 0) * -32px); opacity: calc(1 - var(--hero, 0) * 0.9); }
.hero-art { translate: 0 calc(var(--hero, 0) * -56px); }
.hero-car { translate: calc(var(--hero, 0) * 60vw) 0; rotate: calc(var(--hero, 0) * -4deg); }
.home h2::after { content: ''; display: block; width: 0; height: 4px; margin-top: 12px; background: repeating-linear-gradient(90deg, #FFD43B 0 12px, transparent 12px 20px); transition: width 0.9s var(--ease) 0.25s; }
.home h2:not(.waiting)::after { width: 96px; }
.cta h2::after { display: none; }
.steps .card:not(.waiting) .mini-tiles .fly { animation: drop 0.8s 0.4s var(--ease) both; }
.steps .card:not(.waiting) .mini-master [data-icon] { animation: tick 0.5s var(--ease) both; }
.steps .card:not(.waiting) .mini-master [data-icon]:nth-child(2) { animation-delay: 0.35s; }
.steps .card:not(.waiting) .mini-master [data-icon]:nth-child(3) { animation-delay: 0.7s; }
.steps .card:not(.waiting) .mini-cup .ico { animation: cup 1s 0.4s var(--ease) both; }
.steps .card:not(.waiting) .mini-example code { animation: read 1.2s 0.3s var(--ease) both; }
.lang-card:not(.waiting) li { animation: rise 0.45s var(--ease) both; animation-delay: calc(var(--n, 0) * 50ms + 150ms); }
.home .card, .home .lang-card { transition: opacity 0.4s var(--ease), border-color 0.2s var(--ease), translate 0.4s var(--ease); }
.home .card:not(.waiting):hover, .home .lang-card:not(.waiting):hover { border-color: var(--accent-line); translate: 0 -4px; transition-delay: 0s; }
.features li:not(.waiting) .feature-icon { animation: tick 0.5s 0.2s var(--ease) both; }
.cta .cta-car { transition: translate 1s var(--ease) 0.2s, rotate 1s var(--ease) 0.2s; }
.cta .waiting .cta-car { translate: -70vw 0; rotate: -8deg; }
@keyframes drop { from { translate: 5rem -1.5rem; opacity: 0; } }
@keyframes tick { from { scale: 0.5; opacity: 0; } }
@keyframes cup { 40% { rotate: -12deg; scale: 1.15; } 70% { rotate: 8deg; } }
@keyframes read { from { box-shadow: inset 0 0 0 0 transparent; clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .home *, .home *::before, .home *::after { animation: none !important; transition: none !important; }
}

.lang-mark { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 0.35em; background: #f7df1e; color: #222; font-size: 0.8em; font-weight: 900; line-height: 1; vertical-align: -0.15em; }
.lang-mark.java { background: #c05a00; color: #fff; }
.lang-mark.c { background: #1f5fa8; color: #fff; }
.lang-mark.web { background: #c63d16; color: #fff; font-size: 0.65em; }

/* The coach: help on a question, and its verdict */
.coach-help:empty { display: none; }
.coach-help p, .coach p { margin: 0.35rem 0; }
.coach { text-align: left; }
button.linklike { background: none; border: 0; box-shadow: none; padding: 0; min-height: 0; font: inherit; text-decoration: underline; color: inherit; text-transform: none; }

/* ---------- account settings and Google ---------- */
.account-settings { display: grid; gap: 0.75rem; margin-bottom: 2rem; }
.settings .panel h3 { margin: 0 0 0.5rem; }
.settings .panel p { margin: 0.25rem 0 0.75rem; overflow-wrap: anywhere; }
.settings form { display: grid; gap: 0.75rem; max-width: 24rem; }
.settings form p { margin: 0; }
.settings form p:empty { display: none; }
.settings .panel input { background: #fff; }
.settings .panel button:not(.sound-option) { justify-self: start; }
.settings button.danger { color: var(--error); border-color: var(--error-bright); box-shadow: 0 4px 0 var(--error-bright); }
.settings .sound-settings { margin-bottom: 2rem; }
.settings h2 { margin-bottom: 0.75rem; }
.login .or { margin: 1.25rem 0 0.75rem; text-align: center; font-weight: 800; }
button.google { display: flex; align-items: center; justify-content: center; gap: 0.6rem; width: 100%; min-height: 3.1rem; color: var(--ink); text-transform: none; letter-spacing: normal; }
button.google svg { width: 1.25rem; height: 1.25rem; flex: none; }
.login .error { margin: 0; color: var(--error); }

/* ---------- the apps' first screens (views/welcome.js) ---------- */
.welcome { --welcome-bg: #101c26; --welcome-line: #344755; position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--welcome-bg); color: #F3F8FC; }
.welcome > * { width: 100%; max-width: 48rem; margin-inline: auto; }
.welcome-top { display: flex; align-items: center; gap: 0.75rem; padding: calc(env(safe-area-inset-top) + 0.75rem) 1.25rem 0 0.6rem; }
.welcome .welcome-back { min-width: var(--tap); padding: 0; font-size: 1.6rem; color: #B5C9D7; }
.welcome .welcome-back:hover { background: #243746; }
.welcome-top .progress-bar { flex: 1; height: 1rem; background: #344755; }
.welcome-top .progress-bar span { min-width: 0; background: #35A4FF; }
.welcome-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem 1.25rem; }
.welcome-body.middle { display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 0.75rem; text-align: center; }
.welcome-body.middle .mascot { width: 12rem; }
.welcome-body.middle p { max-width: 20rem; margin: 0; font-size: 1.15rem; font-weight: 700; color: #C4D3DD; }
.welcome .wordmark { font-size: 3.75rem; font-weight: 900; letter-spacing: -0.04em; color: #61B9FF; }
.welcome .eyebrow { margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.1em; color: #B8DFFF; }
.welcome-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 0.9rem; padding: 0.9rem 1.25rem calc(env(safe-area-inset-bottom) + 1.25rem); }
.welcome-actions button, .welcome-actions .button { width: 100%; min-height: 3.25rem; font-weight: 800; }
.welcome-actions button.primary { background: #258DF0; border-color: #258DF0; box-shadow: 0 4px 0 #1260B5; color: #fff; }
.welcome-actions button.primary:hover:not(:disabled) { background: #147BD8; }
.welcome-actions button.primary:disabled { background: #344755; border-color: #344755; box-shadow: none; color: #C4D3DD; }
.welcome-actions .button { background: transparent; border-color: #526B7C; color: #E5F3FC; box-shadow: 0 3px 0 #344755; }
.ask { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.25rem; }
.ask .mascot { flex: none; width: 5.5rem; }
.bubble { position: relative; padding: 0.8rem 1rem; border: 2px solid var(--welcome-line); border-radius: 16px; font-size: 1.15rem; font-weight: 800; color: #F3F8FC; }
/* the bubble's tail points at the car: to the left, or down when it sits above */
.bubble::before { content: ""; position: absolute; top: calc(50% - 7px); left: -8px; width: 12px; height: 12px; border: solid var(--welcome-line); border-width: 0 0 2px 2px; background: var(--welcome-bg); transform: rotate(45deg); }
.bubble.above { margin-bottom: 0.5rem; }
.bubble.above::before { top: auto; bottom: -8px; left: calc(50% - 6px); border-width: 0 2px 2px 0; }
.welcome h1:focus { outline: none; }
.options { display: flex; flex-direction: column; gap: 0.8rem; }
.welcome .options .option { justify-content: flex-start; gap: 0.9rem; width: 100%; min-height: 4.25rem; padding: 0.75rem 1rem; background: transparent; border: 2px solid var(--welcome-line); box-shadow: 0 3px 0 #263946; color: #F3F8FC; text-align: left; text-transform: none; letter-spacing: normal; font-size: 1.05rem; font-weight: 800; white-space: normal; }
.welcome .options .option:hover { background: #1D303E; }
.welcome .options .option[aria-pressed=true] { border-color: #56B4FF; background: #1D394E; box-shadow: 0 3px 0 #2184CF; color: #D9F0FF; }
.welcome .options, .welcome .promises { max-width: 31rem; margin-inline: auto; }
.option > .ico, .option-mark .ico { width: 1.9rem; height: 1.9rem; }
.option-mark { display: grid; place-items: center; width: 2.2rem; font-size: 1.25rem; }
.option-note { margin-left: auto; font-size: 0.9rem; font-weight: 700; color: #BCCDD8; }
.tick { flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-left: auto; border: 2px solid var(--line-strong); border-radius: 8px; }
.option[aria-pressed=true] .tick { border-color: var(--accent); background: var(--accent); }
.option[aria-pressed=true] .tick::after { content: "✓"; color: #fff; font-size: 1rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 1.5rem; }
.bars i { width: 6px; border-radius: 3px; background: var(--line-strong); }
.bars i:nth-child(1) { height: 45%; } .bars i:nth-child(2) { height: 70%; } .bars i:nth-child(3) { height: 100%; }
.bars i.on { background: var(--accent); }
.promises { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.5rem; }
.promises li { display: flex; gap: 1rem; align-items: flex-start; }
.promises .ico { width: 2.5rem; height: 2.5rem; }
.promises p { margin: 0.25rem 0 0; color: #C4D3DD; font-weight: 700; }
@media (min-width: 700px) {
  .welcome[data-step="course"] .options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; }
  .welcome-actions { align-items: flex-end; }
  .welcome-actions button, .welcome-actions .button { max-width: 16rem; }
  .welcome[data-step=""] .welcome-actions { align-items: center; }
}

/* ================= Chests, quests, profile, own car ================= */
a.stat-chip.gems { color: #1673B1; text-decoration: none; }
#view progress { -webkit-appearance: none; appearance: none; width: 100%; height: 0.7rem; border: 0; border-radius: 980px; overflow: hidden; background: var(--line); }
#view progress::-webkit-progress-bar { background: var(--line); }
#view progress::-webkit-progress-value { background: var(--accent); border-radius: 980px; }
#view progress::-moz-progress-bar { background: var(--accent); border-radius: 980px; }
.quests { max-width: 36rem; margin: 0 auto 1rem; }
.quests summary { cursor: pointer; font-weight: 800; min-height: 1.75rem; }
.quests[open] summary { margin-bottom: 0.8rem; }
.quests ul, .achievements { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.quest { display: flex; align-items: center; gap: 0.8rem; }
.quest > .ico { flex: none; width: 2.6rem; height: 2.6rem; }
.quest-main, .achievement-main { flex: 1; min-width: 0; display: grid; gap: 0.15rem; }
.quest-end { flex: none; min-width: 3.5rem; text-align: center; font-weight: 800; }
.chest-button { min-height: 0; width: 4.5rem; height: 4.5rem; padding: 0; border: 0; background: none; box-shadow: none; }
.chest-button:hover:not(:disabled) { background: none; }
.chest-button .ico { width: 4rem; height: 4rem; }
.chest-rung:not(.opened) .ico { animation: hop 1.6s ease infinite; }
.chest-rung.opened .chest-button { opacity: 0.45; filter: grayscale(0.8); }
.profile-head { display: grid; justify-items: center; gap: 0.4rem; text-align: center; }
.profile-head .mascot, .car-preview .mascot { width: 11rem; }
.car-preview { display: grid; justify-items: center; position: sticky; top: 0; z-index: 2; background: var(--bg); }
.records { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.record { display: flex; align-items: center; gap: 0.6rem; }
.record > .ico { flex: none; width: 2.2rem; height: 2.2rem; }
.record .stat { margin: 0; font-size: 1.6rem; }
.freeze { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; }
.freeze > .ico { width: 2.8rem; height: 2.8rem; }
.freeze > div { flex: 1; min-width: 10rem; }
.freeze p { margin: 0.2rem 0 0; }
.achievement { display: flex; align-items: center; gap: 0.8rem; }
.achievement-art { flex: none; width: 4.6rem; display: grid; justify-items: center; gap: 0.15rem; font-size: 0.72rem; font-weight: 800; }
.achievement-art .ico { width: 3rem; height: 3rem; }
.achievement.locked .achievement-art { filter: grayscale(1); opacity: 0.55; }
.parts { border: 0; margin: 0 0 1.25rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.parts legend { font-weight: 800; margin-bottom: 0.4rem; }
.part { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.75rem; }
.part[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.swatch { width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 2px solid var(--line-strong); }
.who { display: flex; align-items: center; gap: 0.5rem; }
.who .mascot { width: 2.6rem; animation: none; }
@media (prefers-reduced-motion: reduce) { .chest-rung:not(.opened) .ico { animation: none; } }
/* Three numbers and two buttons must fit one narrow row, however big the numbers get. */
@media (max-width: 420px) {
  #mypoints { gap: 0.35rem; font-size: 0.85rem; }
  #mypoints .stat-chip .ico, #mypoints .course-button .ico { width: 1.3rem; height: 1.3rem; }
  #mypoints .course-button { padding: 0 0.35rem; gap: 0.25rem; }
}

/* ================= Screens overhaul: shell, dialogs, quests, board, settings, admin, auth ================= */

/* ---------- Top bar & navigation polish ---------- */
.top {
  gap: 8px;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: calc(env(safe-area-inset-top) + 6px) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
}
.top #sound,
.top #logout {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  border: 2px solid transparent;
  border-radius: 12px;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.top #sound:hover,
.top #logout:hover {
  background: var(--sunken);
  border-color: var(--line);
}
.top #sound:active,
.top #logout:active {
  transform: scale(0.94);
  box-shadow: none;
}
.top #sound[aria-pressed="false"] {
  background: var(--sunken);
  border-color: var(--line);
}

#mypoints {
  align-items: center;
  gap: 10px;
}
#mypoints .stat-chip.xp,
#mypoints a.stat-chip.gems {
  min-height: 40px;
  padding: 0 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}
#mypoints .stat-chip.xp {
  border-color: #FFE499;
  background: #FFFDF2;
  color: #B87900;
  box-shadow: 0 3px 0 #F5D77F;
}
#mypoints a.stat-chip.gems {
  min-height: var(--tap);
  border-color: #BCE3FF;
  background: #F2FAFF;
  color: #0D6EB8;
  box-shadow: 0 3px 0 #BCE3FF;
}
#mypoints a.stat-chip.gems:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
#mypoints a.stat-chip.gems:active {
  transform: translateY(3px);
  box-shadow: none;
}

.stat-chip.chip-grow {
  animation: chip-grow 0.34s cubic-bezier(.34, 1.6, .64, 1);
}
@keyframes chip-grow {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* Keep top bar guaranteed inside 360px/375px even with big numbers (888 / 88888 XP / 8888) */
@media (max-width: 560px) {
  .top { gap: 4px; padding: calc(env(safe-area-inset-top) + 6px) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
  #mypoints { gap: 6px; font-size: 0.92rem; }
  #mypoints .stat-chip.xp,
  #mypoints a.stat-chip.gems {
    padding: 0 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #mypoints .stat-chip.xp { min-height: 36px; color: #C28200; }
  #mypoints a.stat-chip.gems { min-height: var(--tap); color: #0D6EB8; }
  #mypoints a.stat-chip.gems:hover { background: var(--accent-soft); }
  #mypoints a.stat-chip.gems:active { transform: scale(0.94); }
}
@media (max-width: 420px) {
  .top { gap: 2px; }
  #mypoints { gap: 4px; font-size: 0.84rem; }
  #mypoints .stat-chip.xp,
  #mypoints a.stat-chip.gems { padding: 0 2px; gap: 3px; }
  #mypoints .stat-chip .ico,
  #mypoints .course-button .ico { width: 1.25rem; height: 1.25rem; }
}

/* Bottom & side navigation pressed/current states */
.tabs {
  gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 6px) max(8px, env(safe-area-inset-left));
}
.tab {
  margin: 0;
  min-height: 48px;
  border: 2px solid transparent;
  border-radius: 14px;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.1s ease;
}
.tab:hover {
  background: var(--sunken);
}
.tab:active {
  transform: translateY(2px) scale(0.96);
}
.tab[aria-current=page] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hover);
  box-shadow: 0 3px 0 var(--accent-line);
}
.tab[aria-current=page]:active {
  transform: translateY(3px);
  box-shadow: none;
}
.tab[aria-current=page] .ico {
  animation: tab-pop 0.28s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes tab-pop {
  0% { transform: scale(0.84); }
  65% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
@media (min-width: 1000px) {
  .top { padding: 12px 32px 4px; }
  .tabs { padding: 20px 16px; gap: 8px; }
  .tab { min-height: 52px; padding: 0 14px; }
  .tab[aria-current=page] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-hover);
    box-shadow: 0 3px 0 var(--accent-line);
  }
  .tab[aria-current=page]:active {
    transform: translateY(3px);
    box-shadow: none;
  }
}

/* ---------- Consistent toasts, loading & error states ---------- */
#toast {
  bottom: calc(5.25rem + env(safe-area-inset-bottom));
  border-radius: 16px;
  padding: 12px 16px;
  max-width: min(24rem, calc(100vw - 24px));
  background: #17213C;
  color: #fff;
  border: 2px solid #2A3860;
  box-shadow: 0 6px 20px rgba(23, 33, 60, 0.22);
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  animation: none;
}
#toast.toast-show {
  animation: toast-in 0.22s cubic-bezier(.34, 1.4, .64, 1) both;
}
#toast[data-tone="success"] {
  border-color: var(--green-bright);
}
#toast[data-tone="error"] {
  border-color: var(--error-bright);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@media (min-width: 1000px) {
  #toast { bottom: 24px; }
}

.state-loading {
  display: grid;
  gap: 16px;
  max-width: 40rem !important;
  animation: state-in 0.2s ease both;
}
.skel {
  display: block;
  border-radius: 14px;
  background: var(--line);
}
.skel-head { display: grid; gap: 8px; }
.skel-title { width: 12rem; max-width: 70%; height: 28px; }
.skel-sub { width: 16rem; max-width: 85%; height: 16px; opacity: 0.7; }
.skel-card {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
}
.skel-line { height: 18px; width: 100%; }
.skel-line.short { width: 62%; }
.skel-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--sunken);
}
.skel-podium-col { width: 100%; border-radius: 16px; }
.skel-podium-col.p1 { height: 132px; }
.skel-podium-col.p2 { height: 104px; }
.skel-podium-col.p3 { height: 88px; }
.skel-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
}
.skel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
}
.skel-dot { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.skel-num { width: 48px; height: 20px; flex: none; margin-left: auto; }
.state-label { margin: 0; font-size: 0.92rem; font-weight: 700; text-align: center; }

.state-error {
  display: grid;
  gap: 16px;
  max-width: 34rem;
  margin: 16px auto;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  animation: state-in 0.22s ease both;
}
.state-actions { justify-content: flex-start; gap: 10px; }
.state-actions button .ico { width: 1.15rem; height: 1.15rem; }
@keyframes state-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Shared native <dialog> & streak milestone moment ---------- */
.koda-dialog {
  width: min(25rem, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.koda-dialog::backdrop {
  background: rgba(23, 33, 60, 0.62);
  animation: dlg-fade 0.16s ease-out both;
}
.dialog-card {
  position: relative;
  display: grid;
  gap: 12px;
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  padding: 24px 20px 20px;
  border: 2px solid var(--line-strong);
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 0 var(--line-strong);
  animation: dlg-pop 0.22s cubic-bezier(.34, 1.45, .64, 1) both;
}
.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border-radius: 12px;
  color: var(--muted);
}
.dialog-close .ico { width: 1.25rem; height: 1.25rem; }
.dialog-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-hover);
}
.dialog-title {
  margin: 0;
  padding-right: 36px;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.2;
}
.dialog-title:focus { outline: none; }
.dialog-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.5;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.dialog-actions button { min-height: 48px; flex: 1 1 8rem; }

.streak-dialog .dialog-card {
  text-align: center;
  border-color: #FFC800;
  box-shadow: 0 6px 0 #E5A000;
}
.streak-dialog .dialog-kicker { color: #C26B00; }
.streak-dialog .dialog-title { padding-right: 0; font-size: 1.75rem; color: #17213C; }
.streak-moment { display: grid; gap: 16px; justify-items: center; }
.streak-stage {
  position: relative;
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 12px 12px;
  border: 2px solid #FFE299;
  border-radius: 18px;
  background: #FFF9E6;
}
.streak-stage .mascot { width: 8.5rem; }
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border: 2px solid #FFB020;
  border-radius: 99px;
  background: #fff;
  color: #C26B00;
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.streak-badge .ico { width: 1.4rem; height: 1.4rem; }
.milestone-track {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.milestone-step {
  display: grid;
  justify-items: center;
  gap: 4px;
}
.milestone-dot {
  width: 34px;
  height: 34px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--sunken);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.milestone-dot .ico { width: 18px; height: 18px; }
.milestone-step.is-done .milestone-dot {
  border-color: #FFB020;
  background: #FFF3D1;
}
.milestone-step.is-now .milestone-dot {
  border-color: #FF8A00;
  background: #FFC800;
  box-shadow: 0 3px 0 #C77D00;
}
.milestone-day {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.milestone-step.is-now .milestone-day { color: #C26B00; font-weight: 900; }

@keyframes dlg-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dlg-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

/* ---------- Daily quest panel (views/rewards.js) ---------- */
.quests.panel {
  max-width: 40rem;
  margin: 0 auto 20px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  overflow: hidden;
}
.quests.panel.has-ready {
  border-color: #FFC800;
  box-shadow: 0 4px 0 #E5A000;
}
.quests-head {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}
.quests-head::-webkit-details-marker { display: none; }
.quests-head:hover { background: var(--sunken); }
.quests[open] .quests-head {
  margin-bottom: 0;
  border-bottom: 2px solid var(--line);
}
.quests.has-ready[open] .quests-head { border-bottom-color: #FFE499; }
.quests-lead {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.quests-lead .ico { width: 24px; height: 24px; flex: none; }
.quests-title { font-size: 1rem; font-weight: 900; }
.quests-status { flex: none; }
.quest-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.quest-pill .ico { width: 14px; height: 14px; }
.quest-pill.is-ready {
  background: #FFC800;
  color: #5C3A00;
}
.quest-pill.is-claimed {
  background: var(--green-soft);
  color: var(--green);
}
.quests-caret {
  flex: none;
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}
.quests[open] .quests-caret { transform: rotate(180deg); }

.quests ul {
  padding: 12px;
  gap: 10px;
  background: var(--sunken);
}
.quest {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}
.quest.is-ready {
  border-color: #FFC800;
  background: #FFFDF0;
  box-shadow: 0 3px 0 #E5A000;
}
.quest.is-claimed {
  border-color: #C7EEB0;
  background: #F4FCEF;
  box-shadow: none;
}
.quest-ico {
  flex: none;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--sunken);
  display: grid;
  place-items: center;
}
.quest-ico .ico { width: 24px; height: 24px; }
.quest.is-ready .quest-ico {
  border-color: #FFC800;
  background: #FFF3BF;
}
.quest.is-claimed .quest-ico {
  border-color: #BFEFA2;
  background: #E2F8D1;
}
.quest-main { gap: 4px; }
.quest-main strong { font-size: 0.95rem; line-height: 1.25; }
.quest-main progress { height: 10px; }
.quest.is-ready progress::-webkit-progress-value,
.quest.is-claimed progress::-webkit-progress-value { background: var(--green-bright); }
.quest.is-ready progress::-moz-progress-bar,
.quest.is-claimed progress::-moz-progress-bar { background: var(--green-bright); }
.quest-progress-text { font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.quest.is-ready .quest-progress-text { color: #8A5600; font-weight: 800; }
.quest.is-claimed .quest-progress-text { color: var(--green); }

.quest-end { min-width: 0; }
.quest-prize {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 2px solid #BCE3FF;
  border-radius: 12px;
  background: #F2FAFF;
  color: #0D6EB8;
  font-size: 0.88rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.quest-prize .ico { width: 16px; height: 16px; }
.quest-claim {
  min-height: var(--tap);
  padding: 0 14px;
  background: var(--green-bright);
  border-color: var(--green-bright);
  box-shadow: 0 4px 0 var(--green-deep);
  font-size: 0.88rem;
}
.quest-claim:hover:not(:disabled) { background: #61D40A; }
.quest-claim:active:not(:disabled) { box-shadow: none; }
.quest-claim .ico { width: 18px; height: 18px; }
.quest-done {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}
.quest-done .ico { width: 14px; height: 14px; }

/* ---------- Leaderboard (views/board.js) ---------- */
#view > .page.board {
  max-width: 42rem;
  display: grid;
  gap: 16px;
  align-content: start;
}
.board-head { margin-bottom: 0; }
.board-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.board-title-row .section-count {
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.board-head p { margin: 4px 0 0; }

.board-segs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 22rem;
  padding: 4px;
  gap: 4px;
  margin-bottom: 0;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--sunken);
}
.board-segs .seg {
  justify-content: center;
  min-height: var(--tap);
  border: 2px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.board-segs .seg:active { transform: translateY(2px); }
.board-segs .seg[aria-pressed="true"] {
  background: #fff;
  border-color: var(--accent-line);
  color: var(--accent-hover);
  box-shadow: 0 2px 0 var(--accent-line);
}

.board-me-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--accent-line);
  border-radius: 18px;
  background: var(--accent-soft);
  box-shadow: 0 3px 0 var(--accent-line);
}
.board-me-info { display: grid; gap: 2px; min-width: 0; flex: 1; }
.board-me-info strong { font-size: 1rem; overflow-wrap: anywhere; }
.board-me-xp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  background: #fff;
  color: #B87900;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.board-me-xp .ico { width: 16px; height: 16px; }

/* Top-three podium */
.podium-stage {
  padding: 16px 12px 0;
  border: 2px solid #C6D9F2;
  border-radius: 22px;
  background: #EBF4FF;
  box-shadow: 0 4px 0 var(--line);
  overflow: hidden;
}
.podium {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
}
.podium.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 24rem;
  margin: 0 auto;
}
.podium-slot {
  display: grid;
  gap: 8px;
  min-width: 0;
  animation: podium-rise 0.28s cubic-bezier(.34, 1.4, .64, 1) both;
}
.podium-slot.place-1 { animation-delay: 0.04s; }
.podium-slot.place-2 { animation-delay: 0.1s; }
.podium-slot.place-3 { animation-delay: 0.14s; }
@keyframes podium-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.podium-head {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  min-width: 0;
}
.podium-medal .ico { width: 26px; height: 26px; }
.podium-slot.place-1 .podium-medal .ico { width: 32px; height: 32px; }
.podium-car .mascot { width: 4rem; cursor: default; }
.podium-slot.place-1 .podium-car .mascot { width: 4.8rem; }
.podium-car .mascot *,
.board-me-banner .mascot * { animation: none !important; }
.podium-name {
  max-width: 100%;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.2;
  color: #17213C;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.podium-xp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 99px;
  background: #fff;
  color: #B87900;
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.podium-xp .ico { width: 13px; height: 13px; }
.podium-base {
  display: grid;
  place-items: center;
  border-radius: 14px 14px 0 0;
  border: 2px solid transparent;
  border-bottom: 0;
  font-weight: 900;
}
.podium-rank { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.podium-slot.place-1 .podium-base {
  height: 68px;
  background: #FFC800;
  border-color: #E5A000;
  color: #5C3A00;
}
.podium-slot.place-2 .podium-base {
  height: 50px;
  background: #D8E2F0;
  border-color: #B0C1D9;
  color: #37415C;
}
.podium-slot.place-3 .podium-base {
  height: 38px;
  background: #F3C49A;
  border-color: #D19462;
  color: #5E3413;
}
.podium-slot.is-me .podium-name { color: var(--accent-hover); }

/* Leaderboard player table */
.board-card {
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  overflow-x: auto;
}
.board-table th {
  padding: 12px 12px;
  background: var(--sunken);
  border-bottom: 2px solid var(--line);
}
.board-table th.right { padding-right: 14px; }
.board-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.board-table td.right { padding-right: 14px; }
.board-table tbody tr:last-child td { border-bottom: 0; }
.board-table .rank-num {
  width: 48px;
  padding-left: 14px;
  text-align: center;
}
.rank-medal .ico { width: 26px; height: 26px; }
.rank-plain {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--sunken);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.board-table tr.me td {
  background: var(--accent-soft);
}
.board-table tr.me td:first-child {
  box-shadow: inset 4px 0 0 var(--accent);
  padding-left: 14px;
}
.board-table tr.me .points { color: var(--accent-hover); }
.who { gap: 10px; min-width: 0; }
.who-car {
  flex: none;
  width: 46px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #F5F9FF;
  display: grid;
  place-items: center;
}
.board-table tr.me .who-car,
.board-me-banner .who-car {
  border-color: var(--accent-line);
  background: #fff;
}
.who-car .mascot { width: 38px; cursor: default; }
.who-info { display: grid; gap: 2px; min-width: 0; }
.who-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.who-name strong { overflow-wrap: anywhere; line-height: 1.25; }
.me-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.who-streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #C26B00;
}
.who-streak .ico { width: 14px; height: 14px; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.empty-state .mascot { width: 7.5rem; }
.empty-state h2 { margin-top: 4px; font-size: 1.25rem; font-weight: 900; }
.empty-state p { margin: 0 0 8px; max-width: 22rem; }

@media (max-width: 400px) {
  .podium-stage { padding: 12px 8px 0; }
  .podium { gap: 6px; }
  .podium-car .mascot { width: 3.4rem; }
  .podium-slot.place-1 .podium-car .mascot { width: 4.1rem; }
  .podium-name { font-size: 0.8rem; }
  .board-table td { padding: 10px 8px; }
  .board-table .rank-num { width: 40px; padding-left: 10px; }
}

/* ---------- Settings (views/settings.js) ---------- */
#view > .page.settings {
  max-width: 40rem;
  display: grid;
  gap: 20px;
  align-content: start;
}
.settings .page-head { margin-bottom: 0; }
.settings-group {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}
.settings .account-settings,
.settings .sound-settings { margin-bottom: 0; }
.group-head { display: grid; gap: 4px; }
.group-head h2 { margin: 0; font-size: 1.2rem; font-weight: 900; }
.group-head p { margin: 0; font-size: 0.9rem; }

.settings-note {
  margin: 0;
  border: 2px solid var(--accent-line);
  border-radius: 16px;
  font-weight: 800;
}
.settings-note.is-ok {
  border-color: var(--green-bright);
  background: var(--green-soft);
  color: var(--green);
}
.settings-note.is-warn {
  border-color: #FFD199;
  background: var(--warn-soft);
  color: var(--warn);
}

.settings .panel {
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  padding: 16px;
}
.settings .panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.settings .panel-head h3 { margin: 0; font-size: 1.05rem; font-weight: 900; }
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}
.status-pill.is-ok {
  background: var(--green-soft);
  color: var(--green);
}
.settings-identity {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--sunken);
}
.settings .panel .identity-name,
.settings .panel .identity-login { margin: 0; font-size: 0.94rem; }
.settings-identity code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--ink);
}
.settings .panel input { background: var(--sunken); }
.settings .panel input:focus { background: #fff; }
.settings .panel .error:not(:empty) {
  padding: 10px 12px;
  border: 2px solid var(--error-bright);
  border-radius: 12px;
  background: var(--error-soft);
  color: var(--error);
  font-weight: 800;
}

/* Unified sound settings card */
.settings .panel.sound-card { padding: 0; overflow: hidden; }
.sound-master {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--sunken);
  border-bottom: 2px solid var(--line);
}
.sound-master-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sound-master-info .ico { width: 28px; height: 28px; }
.sound-master-info strong { display: block; font-size: 0.98rem; }
.sound-master-info small { display: block; font-size: 0.82rem; }
.sound-toggle { min-height: var(--tap); font-size: 0.86rem; }
.sound-rows { display: grid; }
.sound-row {
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.sound-row:last-child { border-bottom: 0; }
.sound-name { font-size: 0.92rem; font-weight: 800; color: var(--ink); }
.sound-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.sound-choices .sound-option {
  min-width: 0;
  width: 100%;
  justify-content: center;
  padding: 0 8px;
}
.sound-option[aria-pressed="true"] {
  border-color: var(--green-bright);
  background: var(--green-soft);
  color: var(--green);
  box-shadow: 0 3px 0 var(--green-bright);
}
@media (min-width: 600px) {
  .sound-row {
    grid-template-columns: 11.5rem minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }
}

.settings .panel.panel-danger {
  border-color: #FFCDD2;
  background: #FFF9F9;
  box-shadow: 0 3px 0 #FFCDD2;
}
.danger-details summary {
  color: var(--error);
  font-weight: 800;
}
.danger-warn {
  margin: 8px 0 12px !important;
  color: var(--error);
  font-size: 0.92rem;
  font-weight: 700;
}
.settings-footer { padding-top: 4px; }
.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}
.settings-link:hover { background: var(--sunken); }
.settings-link:active { transform: translateY(3px); box-shadow: none; }
.settings-link .ico { width: 22px; height: 22px; }
.settings-link-arrow { margin-left: auto; color: var(--muted); font-size: 1.1rem; }

/* ---------- Admin tidy-up (views/admin.js) ---------- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.admin .panel.admin-stat {
  min-width: 0;
  padding: 12px 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.admin-stat .label { display: block; overflow-wrap: anywhere; }
.admin-stat .stat { margin: 4px 0 0; font-size: 1.5rem; font-weight: 900; }
.admin .panel.admin-form {
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  padding: 16px;
}
.admin-fields {
  display: grid;
  gap: 12px;
}
@media (min-width: 720px) {
  .admin-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.admin-section { display: grid; gap: 8px; min-width: 0; }
.admin-section-head h2 { margin: 0; font-size: 1.15rem; font-weight: 900; }
.admin-empty {
  margin: 0;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--sunken);
}
.admin-table {
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  max-width: 100%;
}
.admin-table .table th {
  padding: 10px 12px;
  background: var(--sunken);
  border-bottom: 2px solid var(--line);
}
.admin-table .table td { padding: 10px 12px; }
.admin-table .table tbody tr:last-child td { border-bottom: 0; }
.plan-toggle {
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: normal;
}
.plan-toggle[aria-pressed="true"] {
  border-color: var(--green-bright);
  background: var(--green-soft);
  color: var(--green);
  box-shadow: 0 3px 0 var(--green-bright);
}
.admin-flag { color: var(--error); }

/* ---------- Welcome polish (views/welcome.js) ---------- */
.welcome-top .progress-bar span {
  transition: width 0.3s cubic-bezier(.22, 1, .36, 1);
}
.welcome-body.welcome-enter {
  animation: state-in 0.2s ease both;
}
.welcome-actions {
  border-top: 2px solid var(--welcome-line);
  background: var(--welcome-bg);
}

/* ---------- Sign-in / sign-up & front page spacing/phone layout ---------- */
.login {
  max-width: 28rem;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(env(safe-area-inset-bottom) + 32px);
}
.login .back { margin-bottom: 4px; }
.login-card > .mascot { width: 7.5rem; margin: 0 auto 8px; }
.login .brand-lockup { margin-bottom: 12px; font-size: 1.15rem; font-weight: 900; color: var(--accent); }
.login h1 { font-size: clamp(1.75rem, 6vw, 2.25rem); line-height: 1.12; }
.login p { margin: 6px 0 16px; font-size: 1rem; }
.login form { gap: 12px; margin-top: 8px; }
.login form small { margin: -6px 0 4px; font-size: 0.82rem; line-height: 1.4; }
.login .error:not(:empty) {
  padding: 10px 12px;
  border: 2px solid var(--error-bright);
  border-radius: 12px;
  background: var(--error-soft);
  color: var(--error);
  font-weight: 800;
}
.login .login-switch { margin: 20px 0 0; }
@media (min-width: 600px) {
  .login { padding: max(40px, env(safe-area-inset-top)) 20px 48px; }
  .login-card {
    padding: 28px 32px;
    border: 2px solid var(--line);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 5px 0 var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat-chip.chip-grow,
  .tab[aria-current=page] .ico,
  #toast.toast-show,
  .state-loading,
  .state-error,
  .koda-dialog::backdrop,
  .dialog-card,
  .podium-slot,
  .welcome-body.welcome-enter {
    animation: none !important;
    transition: none !important;
  }
  .quests-caret,
  .welcome-top .progress-bar span,
  .tab,
  .top #sound,
  .top #logout,
  #mypoints .stat-chip.xp,
  #mypoints a.stat-chip.gems,
  .board-segs .seg,
  .settings-link {
    transition: none !important;
  }
}

/* Huge numbers on a narrow phone: clip the logo instead of drawing under the course button. */
.top .brand { overflow: hidden; }
