/*
  CodePlay — how everything looks.
  CSS is the "stage lighting": it doesn't change what's on stage, only how it looks.
  Colors live in variables at the top, like a color palette preset.
*/

/* ---------- Color palette (light) ---------- */
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1f2330;
  --muted: #6b7080;
  --line: #e3e1da;
  --accent: #5b5bd6;
  --accent-soft: #ecebfb;
  --done: #23a26d;
  --done-soft: #e2f5ec;
  --progress: #e09b21;
  --progress-soft: #fbf0db;
  --bad: #d64545;
  --bad-soft: #fdeaea;
  --code-bg: #1e2130;
  --code-ink: #e6e8f0;
  --code-gutter: #5d6580;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  --radius: 16px;
}

/* ---------- Color palette (dark) ---------- */
:root[data-theme="dark"] {
  --bg: #14161d;
  --card: #1d2029;
  --ink: #eceef4;
  --muted: #9aa0b2;
  --line: #2d313d;
  --accent: #8b8cf6;
  --accent-soft: #272a45;
  --done: #3cc98b;
  --done-soft: #1b3329;
  --progress: #f0b44c;
  --progress-soft: #3a2f1a;
  --bad: #f07070;
  --bad-soft: #3b2023;
  --code-bg: #10121a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

/* ---------- Basics ---------- */
* { box-sizing: border-box; }
html { font-size: 19px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  line-height: 1.55;
}
a { color: var(--accent); }
button {
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: .45rem 1rem;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; }
code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--accent-soft);
  padding: .1em .35em;
  border-radius: 6px;
}
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1.25rem;
  background: var(--bg);                                   /* older browsers */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.logo img { width: 28px; height: 28px; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 5rem; }
.loading { color: var(--muted); text-align: center; margin-top: 4rem; }

/* ---------- Home: progress tracker ---------- */
.hello h1 { font-size: 2rem; margin: .5rem 0 .25rem; }
.hello p { color: var(--muted); margin: 0 0 1.5rem; }
.tracker {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem;
}
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; box-shadow: var(--shadow);
}
.tile .big { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile .label { color: var(--muted); font-size: .85rem; }
.bar { height: 8px; border-radius: 99px; background: var(--line); margin-top: .6rem; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--done); border-radius: 99px; }
.tile.continue { display: flex; flex-direction: column; justify-content: center; gap: .4rem; grid-column: span 3; }
.tile.continue button { align-self: flex-start; font-size: 1rem; padding: .6rem 1.3rem; }

/* ---------- Game: level, goal ring, records ---------- */
.level-tile { grid-column: span 2; display: flex; gap: 1rem; align-items: center; }
.level-icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 2rem;
  background: linear-gradient(135deg, #6f6cf2, #a45cd4);
}
.level-title { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.xp-bar span { background: linear-gradient(90deg, #6f6cf2, #a45cd4); }
.goal-tile { display: flex; gap: .8rem; align-items: center; }
.goal-tile select {
  font: inherit; font-size: .85rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); padding: .1rem .3rem; margin: .15rem 0;
}
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--progress); transition: stroke-dasharray .4s; }
.ring.full .ring-fg { stroke: var(--done); }
.ring-text { fill: var(--ink); font-size: 17px; font-weight: 700; }

.records { margin-bottom: 2.2rem; }
.records h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
.records h2 span { color: var(--muted); font-weight: 400; font-size: .9rem; }
.record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .8rem; }
.record { text-align: center; }
.disc {
  width: 64px; height: 64px; margin: 0 auto .4rem; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.5rem; background: radial-gradient(circle, var(--card) 22%, var(--line) 24%, var(--line) 100%);
  opacity: .55;
}
.record.got .disc {
  opacity: 1; box-shadow: 0 2px 10px rgba(224, 155, 33, .35);
  background: radial-gradient(circle, #fff6d8 20%, #b8860b 22%, #f3cc54 45%, #c9971f 70%, #f6d77a 100%);
}
.record-name { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.record-how { font-size: .7rem; color: var(--muted); line-height: 1.25; margin-top: .15rem; }

/* Top bar: level chip, mini goal ring, sound */
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.level-chip {
  text-decoration: none; color: var(--ink); font-size: .82rem; border: 1px solid var(--line);
  border-radius: 99px; padding: .3rem .8rem; background: var(--card); white-space: nowrap;
}
.goal-mini { display: flex; }

/* Pop-up messages and confetti */
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; }
.toast {
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: .55rem 1rem; font-size: .9rem;
  box-shadow: var(--shadow); animation: toast-in .25s ease-out; transition: opacity .5s, transform .5s;
}
.toast.big { background: linear-gradient(135deg, #6f6cf2, #a45cd4); color: #fff; font-weight: 600; font-size: 1rem; }
.toast.gone { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* Challenges */
.challenge { border: 2px dashed var(--line); border-radius: 14px; padding: 1rem 1.1rem; }
.challenge + .challenge { margin-top: 1rem; }
.challenge.passed { border: 2px solid var(--done); background: var(--done-soft); background: color-mix(in srgb, var(--done-soft) 50%, transparent); }
.chal-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .3rem; }
.chal-tag { font-weight: 700; }
.chal-xp { font-size: .78rem; border-radius: 99px; padding: .1rem .55rem; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chal-status { margin-left: auto; font-size: .88rem; font-weight: 600; color: var(--muted); }
.challenge.passed .chal-status { color: var(--done); }
.hint-btn:disabled { opacity: .6; cursor: default; }

/* ---------- Home: the language cards ---------- */
.tracks { margin-bottom: 2.2rem; }
.tracks h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.track-card {
  display: flex; gap: 1rem; align-items: flex-start; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; box-shadow: var(--shadow); transition: transform .1s, border-color .1s;
}
.track-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.track-icon { font-size: 2.2rem; line-height: 1; }
.track-text { flex: 1; }
.track-title { font-weight: 700; font-size: 1.1rem; }
.track-sum { color: var(--muted); font-size: .88rem; margin: .15rem 0 .2rem; line-height: 1.4; }
.tag { font-size: .7rem; font-weight: 600; border-radius: 99px; padding: .05rem .5rem; background: var(--progress-soft); color: var(--progress); vertical-align: middle; }
.track-hello { margin-bottom: 1.5rem; }
.track-hello button { margin-top: .4rem; font-size: 1rem; padding: .6rem 1.3rem; }

/* ---------- Home: the stage map ---------- */
.map { position: relative; }
.map::before {               /* the vertical "cable" joining every stage */
  content: ""; position: absolute; left: 31px; top: 20px; bottom: 20px;
  width: 4px; background: var(--line); border-radius: 4px;
}
.stage { position: relative; display: grid; grid-template-columns: 66px 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.stage-node {
  position: relative; z-index: 1;
  width: 66px; height: 66px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.7rem;
  background: var(--card); border: 4px solid var(--line);
}
.stage.is-done .stage-node { border-color: var(--done); background: var(--done-soft); }
.stage.is-progress .stage-node { border-color: var(--progress); background: var(--progress-soft); }
.stage-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.3rem 1.3rem; box-shadow: var(--shadow);
}
.stage.is-later .stage-card { opacity: .82; }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.stage-head h2 { margin: 0; font-size: 1.3rem; }
.stage-head .count { color: var(--muted); font-size: .85rem; }
.stage-card > p { margin: .2rem 0 .9rem; color: var(--muted); }
.group-title { font-weight: 600; font-size: .9rem; margin: 1rem 0 .5rem; }
.group-title span { color: var(--muted); font-weight: 400; }

/* Lessons look like drum pads */
.pads { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.pad {
  display: flex; flex-direction: column; gap: .2rem;
  text-align: left; text-decoration: none; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
  padding: .6rem .7rem; background: var(--bg); min-height: 78px;
  transition: transform .1s, border-color .1s;
}
.pad:hover { transform: translateY(-2px); border-color: var(--accent); }
.pad .num { font-size: .75rem; color: var(--muted); font-weight: 600; }
.pad .name { font-size: .88rem; line-height: 1.3; font-weight: 600; }
.pad.is-done { border-color: var(--done); background: var(--done-soft); }
.pad.is-done .num::after { content: "  ✓ done"; color: var(--done); }
.pad.is-progress { border-color: var(--progress); background: var(--progress-soft); }
.pad.is-progress .num::after { content: "  • in progress"; color: var(--progress); }
.pad.is-soon { border-style: dashed; opacity: .6; }
.pad.is-soon .num::after { content: "  coming soon"; }

/* ---------- Lesson screen ---------- */
.lesson-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .3rem; }
.crumbs { color: var(--muted); font-size: .85rem; }
/* The lesson clock (top right of a lesson) */
.timer-pill {
  font-size: .82rem; color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 99px; padding: .25rem .8rem;
  font-variant-numeric: tabular-nums;
}
.timer-pill strong { color: var(--ink); }
.timer-pill .paused-note { display: none; }
.timer-pill.paused { opacity: .6; }
.timer-pill.paused .paused-note { display: inline; }
.crumbs a { color: var(--muted); }
.lesson-title { font-size: 2rem; margin: 0 0 .2rem; line-height: 1.2; }
.lesson-sub { color: var(--muted); margin: 0 0 1rem; }
.steps {                     /* the 5 little step buttons near the top */
  display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.steps button {
  font-size: .82rem; padding: .25rem .8rem;
  border: 1px solid var(--line); border-radius: 99px; padding: .25rem .8rem; background: var(--card);
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
  scroll-margin-top: 80px;
}
.card h3 { margin: 0 0 .7rem; font-size: 1.1rem; display: flex; align-items: center; gap: .6rem; }
.card h3 .n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: .8rem;
}
.card p { margin: .3rem 0; }
.idea { font-size: 1.12rem; }
.music {
  margin-top: .8rem; padding: .8rem 1rem; border-radius: 12px;
  background: var(--accent-soft); font-size: 1rem;
}
.caption { color: var(--muted); font-size: .88rem; margin-top: .5rem; }
iframe {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; display: block;
  background: var(--bg);
}
.task { margin-bottom: .8rem; }
.workbench { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1rem; align-items: start; }
.workbench > * { min-width: 0; }   /* long code lines scroll inside the editor instead of squeezing the preview */
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.hint, .meaning {
  margin-top: .8rem; padding: .8rem 1rem; border-radius: 12px;
  background: var(--progress-soft); border: 1px solid var(--progress);
}
.meaning { background: var(--accent-soft); border-color: var(--accent); }
.error-box {
  margin-top: .8rem; padding: .8rem 1rem; border-radius: 12px;
  background: var(--bad-soft); border: 1px solid var(--bad); font-size: .95rem;
}
.error-box .raw { font-family: "SF Mono", Menlo, monospace; font-size: .85rem; color: var(--bad); font-weight: 600; }
.ok-box {
  margin-top: .8rem; padding: .5rem 1rem; border-radius: 12px; font-size: .9rem;
  background: var(--done-soft); color: var(--done);
}

/* ---------- Code editor (CodeMirror, see app.js section 6) ---------- */
.editor {
  position: relative; border-radius: 12px; background: var(--code-bg); overflow: hidden;
}
.editor .cm-editor { color: var(--code-ink); background: transparent; min-height: 174px; }  /* about 5 lines tall */
.editor .cm-editor.cm-focused { outline: none; }
.editor .cm-scroller {
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 16px; line-height: 26px;
  padding: 12px 0 16px;
}
.editor .cm-content { padding: 0; caret-color: #fff; }
.editor .cm-line { padding: 0 16px 0 10px; }
.editor .cm-cursor { border-left: 2px solid #fff; }
.editor .cm-gutters { background: transparent; border: 0; color: var(--code-gutter); }
.editor .cm-lineNumbers .cm-gutterElement { padding: 0 2px 0 12px; min-width: 2.2em; }
.editor .cm-selectionBackground, .editor .cm-focused .cm-selectionBackground { background: rgba(140, 150, 255, .35) !important; }
.editor .cm-matchingBracket { background: rgba(255, 255, 255, .14); outline: 1px solid rgba(255, 255, 255, .3); }
.editor .cm-nonmatchingBracket { background: transparent; }
.editor .cm-editor:not(.cm-focused) .cm-matchingBracket { background: none; outline: none; }   /* only while typing */
.editor.read-only .cm-content { cursor: default; }
.editor.wrap .cm-scroller { font-family: inherit; }
.editor.wrap .cm-line { padding: 0 16px; }
.editor .err-line { background: rgba(240, 80, 80, .25); }
.tok-comment { color: #7f8aa3; font-style: italic; }
.tok-string  { color: #a6e3a1; }
.tok-number  { color: #fab387; }
.tok-keyword { color: #cba6f7; }
.tok-call    { color: #89b4fa; }
.tok-tag     { color: #f38ba8; }

/* ---------- Checkpoint ---------- */
.options { display: grid; gap: .5rem; }
.options button {
  text-align: left; border-radius: 12px; padding: .7rem 1rem; font-size: 1rem;
}
.options button.right { border-color: var(--done); background: var(--done-soft); }
.options button.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.result { margin-top: .8rem; font-weight: 600; }
.result.good { color: var(--done); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.pager a {
  flex: 1; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; background: var(--card);
}
.pager a:hover { border-color: var(--accent); }
.pager a.next { text-align: right; }
.pager small { color: var(--muted); display: block; }

.soon-card { text-align: center; padding: 3rem 1.5rem; }
.soon-card .big { font-size: 3rem; }
.soon-card .ask { display: inline-block; margin-top: .8rem; text-align: left; }
.load-errors { margin-bottom: 1.5rem; }

/* ---------- Small screens: stack things ---------- */
@media (max-width: 860px) {
  html { font-size: 17px; }
  .tracker { grid-template-columns: 1fr 1fr; }
  .level-tile, .tile.continue { grid-column: span 2; }
  .tile .big { font-size: 1.5rem; }
  .level-chip .level-name { display: none; }
  .tile.continue { grid-column: 1 / -1; }
  .workbench { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 48px 1fr; }
  .stage-node { width: 48px; height: 48px; font-size: 1.2rem; }
  .map::before { left: 22px; }
}


/* ==========================================================
   Look refresh — a warmer, friendlier skin on top of the above.
   (Later rules win, so these replace some earlier looks.)
   ========================================================== */

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(900px 400px at -10% 10%, color-mix(in srgb, #e8613c 7%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { letter-spacing: -0.01em; }

/* Buttons: a soft gradient and a little lift */
button { transition: transform .08s, box-shadow .15s, border-color .15s; }
button:hover { transform: translateY(-1px); }
button.primary {
  background: linear-gradient(135deg, #6f6cf2, #a45cd4); border: 0; color: #fff;
  box-shadow: 0 4px 14px rgba(111, 108, 242, .35);
}
button.primary:hover { box-shadow: 0 6px 20px rgba(111, 108, 242, .45); }
.big-btn { font-size: 1.05rem; padding: .75rem 1.5rem; margin-top: .6rem; }

/* Home: the welcome banner */
.hero {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.5rem; align-items: center;
  padding: 2rem 2.2rem; margin: .5rem 0 1.8rem; border-radius: 24px; color: #fff;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%);
  box-shadow: 0 12px 40px rgba(79, 70, 229, .3); overflow: hidden; position: relative;
}
.hero::after {   /* a soft glow in the corner */
  content: ""; position: absolute; right: -80px; top: -80px; width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero h1 { font-size: 2.3rem; line-height: 1.15; margin: .2rem 0 .5rem; }
.hero p { margin: 0; opacity: .9; font-size: 1.05rem; }
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.hero button.primary { background: #fff; color: #4f46e5; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.hero-art { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; position: relative; z-index: 1; }
.hero-art span {
  aspect-ratio: 1; border-radius: 22px; display: grid; place-items: center; font-size: 2rem;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(4px); animation: bob 4.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .hero-art span { animation: none; } }

/* The numbers row */
.tracker { grid-template-columns: repeat(5, 1fr); }
.tile { border-radius: 18px; }

/* Language cards: each language's own colour */
.track-card { position: relative; overflow: hidden; border-radius: 18px; padding: 1.1rem 1.2rem 1.1rem 1.3rem; }
.track-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--track); }
.track-card:hover { border-color: var(--track); box-shadow: 0 8px 24px color-mix(in srgb, var(--track) 25%, transparent); }
.track-icon {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: none; font-size: 1.8rem;
  background: var(--card);
  background: color-mix(in srgb, var(--track) 16%, var(--card));
}
.track-card .bar span { background: var(--track); }
.track-hello {
  padding: 1.5rem 1.7rem; border-radius: 22px;
  background: var(--card);
  background: linear-gradient(135deg, color-mix(in srgb, var(--track) 22%, var(--card)), var(--card));
  border: 1px solid var(--line);
  border: 1px solid color-mix(in srgb, var(--track) 35%, var(--line));
}

/* Lesson steps: a colour per step, so you always know where you are */
#step-idea { --step: #8b5cf6; }
#step-picture { --step: #3b82f6; }
#step-tweak { --step: #14b8a6; }
#step-break { --step: #ef4444; }
#step-challenge { --step: #f59e0b; }
#step-check { --step: #22c55e; }
.card[id^="step-"] { border-top: 4px solid var(--step); border-radius: 18px; }
.card[id^="step-"] h3 .n { background: var(--step); }
.steps button { border-radius: 99px; }

/* Map pads: softer */
.pad { border-radius: 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.stage-card { border-radius: 20px; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding: 1.5rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero-art { display: none; }
  .tracker { grid-template-columns: 1fr 1fr; }
}


/* ==========================================================
   🕹  ARCADE LOOK — neon colours, pixel font, scanlines.
   Everything here only applies when the look is "arcade"
   (the 🕹 button in the top bar switches looks).
   ========================================================== */

/* The pixel font, kept in vendor/fonts so it works offline (free, Open Font License) */
@font-face {
  font-family: "Pixel";
  src: url("../vendor/fonts/PressStart2P.woff2") format("woff2");
  font-display: swap;
}

.arcade-only { display: none; }
[data-theme="arcade"] .arcade-only { display: flex; }

/* Arcade colour palette: deep space blue with neon lights */
:root[data-theme="arcade"] {
  --bg: #0a0a1f;
  --card: #13133a;
  --ink: #f2f4ff;
  --muted: #9aa3d6;
  --line: #2c2d70;
  --accent: #29f3ff;
  --accent-soft: #142e55;
  --done: #39ff88;
  --done-soft: #0e3828;
  --progress: #ffe14d;
  --progress-soft: #3a3312;
  --bad: #ff4d6d;
  --bad-soft: #3b1326;
  --code-bg: #05051a;
  --code-gutter: #4a4c9a;
  --radius: 6px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --pink: #ff3ea5;
  --cyan: #29f3ff;
  --yellow: #ffe14d;
  --green: #39ff88;
}

[data-theme="arcade"] body {
  background:
    radial-gradient(800px 400px at 80% -5%, rgba(255, 62, 165, .18), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(41, 243, 255, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
/* Old-TV scanlines over everything */
[data-theme="arcade"] body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 80;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px);
}
/* A glowing grid floor at the bottom of the screen, like an 80s arcade cabinet */
[data-theme="arcade"] body::before {
  content: ""; position: fixed; left: -20%; right: -20%; bottom: -10vh; height: 45vh; pointer-events: none; z-index: -1;
  background:
    linear-gradient(to top, rgba(255, 62, 165, .25), transparent 70%),
    repeating-linear-gradient(90deg, rgba(41, 243, 255, .18) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(0deg, rgba(41, 243, 255, .18) 0 2px, transparent 2px 50px);
  transform: perspective(320px) rotateX(60deg); transform-origin: bottom;
}

/* Pixel font for titles, scores, labels and buttons. Normal text stays easy to read. */
[data-theme="arcade"] :is(.logo, h1, h2, h3, .level-chip, .tile .big, .level-title, .eyebrow, .pad .num,
  .chal-tag, .chal-xp, .chal-status, .toast, .steps button, button.primary, .track-title, .stage-head h2,
  .records h2, .record-name, .score-strip, .press-start, .ring-text, .timer-pill, .count, .group-title, .crumbs) {
  font-family: "Pixel", ui-monospace, monospace; letter-spacing: 0; font-weight: 400;
}
[data-theme="arcade"] :is(h1, h2, h3, .level-title, .track-title, .eyebrow) { text-transform: uppercase; }
[data-theme="arcade"] h1 { font-size: 1.35rem; line-height: 1.5; }
[data-theme="arcade"] .lesson-title { font-size: 1.15rem; line-height: 1.5; color: var(--yellow); text-shadow: 0 0 12px rgba(255, 225, 77, .45); }
[data-theme="arcade"] h2, [data-theme="arcade"] .stage-head h2 { font-size: .85rem; line-height: 1.6; }
[data-theme="arcade"] .card h3 { font-size: .78rem; }
[data-theme="arcade"] .tile .big { font-size: 1.05rem; color: var(--yellow); }
[data-theme="arcade"] .level-title { font-size: .8rem; color: var(--cyan); line-height: 1.6; }
[data-theme="arcade"] :is(.pad .num, .count, .crumbs, .timer-pill, .chal-xp, .chal-status, .record-name, .group-title) { font-size: .55rem; line-height: 1.6; }
[data-theme="arcade"] .steps button { font-size: .55rem; padding: .45rem .7rem; }
[data-theme="arcade"] .track-title { font-size: .75rem; line-height: 1.6; }
[data-theme="arcade"] .logo { font-size: .8rem; color: var(--yellow); text-shadow: 0 0 10px rgba(255, 225, 77, .6); }
[data-theme="arcade"] .level-chip { font-size: .55rem; color: var(--yellow); border-color: var(--yellow); }

/* Blocky screens with a neon edge */
[data-theme="arcade"] :is(.tile, .card, .track-card, .stage-card, .challenge, .stage-node, .pad, iframe, .editor, .hint, .meaning, .error-box, .ok-box, .music) {
  border-radius: 6px;
}
[data-theme="arcade"] :is(.tile, .card, .track-card, .stage-card) {
  border: 2px solid var(--line); background: linear-gradient(180deg, #16164a, #11113a);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 10px 30px rgba(0, 0, 0, .45);
}
[data-theme="arcade"] .topbar { background: rgba(10, 10, 31, .85); border-bottom: 2px solid var(--line); }
[data-theme="arcade"] .editor { border: 2px solid var(--line); box-shadow: 0 0 18px rgba(41, 243, 255, .12); }
[data-theme="arcade"] .editor .cm-cursor { border-left-color: var(--cyan); }
[data-theme="arcade"] .editor .cm-content { caret-color: var(--cyan); }
[data-theme="arcade"] .editor .cm-matchingBracket { outline-color: var(--cyan); }

/* Arcade buttons: chunky, with a 3D edge that presses down */
[data-theme="arcade"] button {
  border-radius: 6px; border: 2px solid var(--line); background: #1a1a4a; color: var(--ink);
}
[data-theme="arcade"] button:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px rgba(41, 243, 255, .35); }
[data-theme="arcade"] button.primary {
  background: var(--pink); color: #fff; border: 0; font-size: .7rem; line-height: 1.6;
  box-shadow: 0 5px 0 #a3196a, 0 0 20px rgba(255, 62, 165, .45);
}
[data-theme="arcade"] button.primary:hover { color: #fff; transform: translateY(-1px); }
[data-theme="arcade"] button.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #a3196a; }

/* The welcome screen = an arcade title screen */
[data-theme="arcade"] .hero {
  background:
    repeating-linear-gradient(0deg, rgba(41, 243, 255, .06) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(90deg, rgba(41, 243, 255, .06) 0 1px, transparent 1px 22px),
    linear-gradient(135deg, #1b1050, #2a0f4f 60%, #3b0a45);
  border: 3px solid var(--pink); border-radius: 8px;
  box-shadow: 0 0 0 3px #000, 0 0 40px rgba(255, 62, 165, .45), inset 0 0 60px rgba(41, 243, 255, .12);
}
[data-theme="arcade"] .hero::after { display: none; }
[data-theme="arcade"] .hero h1 {
  font-size: 1.55rem; line-height: 1.55;
  background: linear-gradient(180deg, #fff6a8, var(--yellow) 45%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 62, 165, .5));
}
[data-theme="arcade"] .eyebrow { color: var(--cyan); font-size: .6rem; opacity: 1; }
[data-theme="arcade"] .hero button.primary { background: var(--pink); color: #fff; }
.score-strip { gap: 1.2rem; flex-wrap: wrap; margin: .3rem 0 .9rem; font-size: .62rem; color: var(--cyan); }
.score-strip b { color: var(--yellow); font-weight: 400; }
.press-start { margin-top: 1rem; font-size: .6rem; color: var(--yellow); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
[data-theme="arcade"] .hero-art span {
  border-radius: 6px; border: 2px solid var(--track); background: rgba(0, 0, 0, .35);
  box-shadow: 0 0 14px color-mix(in srgb, var(--track) 60%, transparent), inset 0 0 12px color-mix(in srgb, var(--track) 30%, transparent);
}

/* Language cards = game cartridges that glow in their colour */
[data-theme="arcade"] .track-card::before { width: 6px; box-shadow: 0 0 12px var(--track); }
[data-theme="arcade"] .track-card:hover { border-color: var(--track); box-shadow: 0 0 22px color-mix(in srgb, var(--track) 45%, transparent); }
[data-theme="arcade"] .track-icon { border-radius: 6px; border: 2px solid var(--track); background: rgba(0, 0, 0, .3); }

/* Map: square stage blocks and level-select pads */
[data-theme="arcade"] .stage-node { border-radius: 6px; background: #13133a; }
[data-theme="arcade"] .map::before { background: repeating-linear-gradient(to bottom, var(--line) 0 8px, transparent 8px 14px); }
[data-theme="arcade"] .pad { background: #0e0e2e; border: 2px solid var(--line); }
[data-theme="arcade"] .pad:hover { border-color: var(--cyan); box-shadow: 0 0 14px rgba(41, 243, 255, .35); }
[data-theme="arcade"] .pad.is-done { border-color: var(--green); background: #0c2a22; box-shadow: 0 0 12px rgba(57, 255, 136, .25); }
[data-theme="arcade"] .pad.is-done .num::after { content: "  CLEAR!"; color: var(--green); }
[data-theme="arcade"] .pad.is-progress { border-color: var(--yellow); background: #2a2610; }
[data-theme="arcade"] .pad.is-progress .num::after { content: "  > PLAYING"; color: var(--yellow); }
[data-theme="arcade"] .pad.is-soon .num::after { content: "  🔒 SOON"; }

/* Lessons: neon step bars */
[data-theme="arcade"] .card[id^="step-"] { border-top: 4px solid var(--step); box-shadow: 0 -2px 18px color-mix(in srgb, var(--step) 35%, transparent), 0 10px 30px rgba(0, 0, 0, .45); }
[data-theme="arcade"] .card h3 .n { border-radius: 4px; font-family: "Pixel", monospace; font-size: .6rem; box-shadow: 0 0 10px var(--step); }
[data-theme="arcade"] .options button.right { border-color: var(--green); box-shadow: 0 0 14px rgba(57, 255, 136, .45); }

/* Game bits: rings, XP bar, records, pop-ups */
[data-theme="arcade"] .ring-fg { stroke: var(--yellow); filter: drop-shadow(0 0 4px rgba(255, 225, 77, .7)); }
[data-theme="arcade"] .ring.full .ring-fg { stroke: var(--green); filter: drop-shadow(0 0 5px rgba(57, 255, 136, .8)); }
[data-theme="arcade"] .ring-text { font-size: 11px; }
[data-theme="arcade"] .bar { border-radius: 0; height: 10px; background: #0a0a24; border: 1px solid var(--line); }
[data-theme="arcade"] .bar span { border-radius: 0; background: repeating-linear-gradient(90deg, var(--green) 0 8px, transparent 8px 10px); }
[data-theme="arcade"] .xp-bar span { background: repeating-linear-gradient(90deg, var(--cyan) 0 8px, transparent 8px 10px); }
[data-theme="arcade"] .level-icon { border-radius: 6px; background: #000; border: 2px solid var(--cyan); box-shadow: 0 0 14px rgba(41, 243, 255, .45); }
[data-theme="arcade"] .record.got .disc { box-shadow: 0 0 16px rgba(255, 225, 77, .6); }
[data-theme="arcade"] .toast {
  background: #000; color: var(--yellow); border: 2px solid var(--cyan); border-radius: 4px; font-size: .62rem; line-height: 1.6;
  box-shadow: 0 0 16px rgba(41, 243, 255, .5);
}
[data-theme="arcade"] .toast.big { background: var(--pink); color: #fff; border-color: #fff; font-size: .7rem; animation: toast-in .25s ease-out, flash .5s steps(2) 3; }
@keyframes flash { 50% { filter: brightness(1.6); } }

@media (max-width: 860px) {
  [data-theme="arcade"] .hero h1 { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .press-start, [data-theme="arcade"] .toast.big { animation: none; }
}
[data-theme="arcade"] span.arcade-only { display: inline; }
[data-theme="arcade"] .tile .big .label { font-family: "Pixel", monospace; font-size: .55rem; }


/* ---------- The "Where should I start?" quiz ---------- */
.quiz { max-width: 720px; margin: 0 auto; }
.quiz h1 { margin: .3rem 0 1.2rem; }
.quiz-dots { display: flex; gap: 6px; margin-bottom: .8rem; }
.quiz-dots span { width: 34px; height: 6px; border-radius: 3px; background: var(--line); }
.quiz-dots span.on { background: var(--accent); }
.quiz-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.quiz-option { display: flex; gap: .8rem; align-items: center; text-align: left; padding: 1rem; border-radius: 16px; font-size: 1rem; background: var(--card); }
.quiz-option:hover { border-color: var(--accent); }
.quiz-option small { display: block; color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.quiz-icon { font-size: 1.8rem; }
.result-track { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.result-track h1 { margin: 0 0 .3rem; }
.result-track p { margin: 0; color: var(--muted); }
.result-start { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; border-left: 5px solid var(--track); }
.result-start button { align-self: flex-start; }
.quiz-link { display: block; margin-top: .9rem; font-size: .9rem; color: inherit; opacity: .92; }
.hero .quiz-link a, .hero a.quiz-link { color: inherit; text-decoration: underline; }
[data-theme="arcade"] .quiz-option { border: 2px solid var(--line); background: linear-gradient(180deg, #16164a, #11113a); }
[data-theme="arcade"] .quiz-option:hover { border-color: var(--cyan); box-shadow: 0 0 14px rgba(41, 243, 255, .35); }
[data-theme="arcade"] .quiz-option strong { font-family: "Pixel", monospace; font-size: .62rem; line-height: 1.7; font-weight: 400; }
[data-theme="arcade"] .quiz-dots span.on { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }


/* ---------- Glossary: tap-a-word ---------- */
.term {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; border-radius: 0;
  text-decoration: underline dotted; text-decoration-color: var(--accent); text-underline-offset: 3px;
  cursor: help;
}
.term:hover { color: var(--accent); transform: none; border: 0; box-shadow: none; }
#term-pop {
  position: absolute; z-index: 70; padding: .8rem 1rem; border-radius: 14px;
  background: var(--card); color: var(--ink); border: 2px solid var(--accent); box-shadow: var(--shadow); font-size: .92rem;
}
#term-pop p { margin: .35rem 0; }
#term-pop .like, .g-item .like { color: var(--muted); font-size: .88rem; }
#term-pop a { font-size: .85rem; }
.glossary { max-width: 760px; margin: 0 auto; }
#g-search { width: 100%; font: inherit; padding: .6rem .9rem; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); margin-bottom: 1rem; }
.g-item { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.g-item p { margin: .2rem 0; }
[data-theme="arcade"] #term-pop { border-color: var(--cyan); box-shadow: 0 0 20px rgba(41, 243, 255, .35); background: #0d0d2b; border-radius: 6px; }
[data-theme="arcade"] #term-pop strong, [data-theme="arcade"] .g-item strong { font-family: "Pixel", monospace; font-size: .7rem; color: var(--yellow); font-weight: 400; }
[data-theme="arcade"] .term { text-decoration-color: var(--cyan); }

/* Glossary: what a short form stands for (API = Application Programming Interface). */
#term-pop .stands, .g-item .stands { font-weight: 600; color: var(--accent); margin: 4px 0; }

/* ---------- Branding: "CodePlay by Ojaymusiq" ---------- */
.logo .by { white-space: nowrap; font-weight: 500; font-size: .7em; color: var(--muted); }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 1rem 2rem; }
.footer strong { color: var(--accent); }
[data-theme="arcade"] .logo .by { color: var(--cyan); text-shadow: none; font-size: .75em; }
[data-theme="arcade"] .footer strong { color: var(--yellow); }
/* Short on space: stack the byline under the name instead of hiding it. */
@media (max-width: 900px) { .logo-text { display: flex; flex-direction: column; line-height: 1.1; } }

/* A link that looks like a button */
a.button {
  display: inline-block; text-decoration: none; font-size: .9rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: .45rem 1rem;
}
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
a.button.ghost { background: transparent; }

/* ---------- Daily warm-up and boss levels (practice.js) ---------- */
.warmup-row { margin-bottom: 1rem; }
.warmup-tile { display: flex; gap: 1rem; align-items: center; text-decoration: none; color: var(--ink); border-left: 5px solid var(--progress); }
a.warmup-tile:hover { border-color: var(--accent); }
.warmup-tile.done { border-left-color: var(--done); }
.warmup-tile.locked { opacity: .7; }
.round { max-width: 760px; margin: 0 auto; }
.round h1 { margin: .3rem 0; }
.round-dots { display: flex; gap: .4rem; margin: 1rem 0; }
.round-dots span { width: 34px; height: 8px; border-radius: 99px; background: var(--line); }
.round-dots span.now { background: var(--progress); }
.round-dots span.right { background: var(--done); }
.round-dots span.wrong { background: var(--bad); }
.round .options button:disabled { cursor: default; opacity: 1; }
.round-end { text-align: center; }
.round-end .big { font-size: 3rem; }
.round-end .toolbar { justify-content: center; }
.q-code { background: var(--code-bg); color: var(--code-ink); padding: .8rem 1rem; border-radius: 10px; overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.5; }
.boss-bar { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; align-items: end; margin: 1rem 0; }
.boss-bar .hp { height: 16px; border-radius: 99px; background: var(--line); overflow: hidden; }
.boss-bar .hp span { display: block; height: 100%; background: var(--bad); transition: width .4s; }
.boss-bar .lives { font-size: 1.3rem; letter-spacing: .1em; }
.boss-pad {
  display: flex; gap: .8rem; align-items: center; margin-top: .8rem; padding: .7rem 1rem;
  border: 2px dashed var(--bad); border-radius: 12px; text-decoration: none; color: var(--ink);
}
.boss-pad small { display: block; color: var(--muted); font-size: .8rem; }
.boss-pad .boss-icon { font-size: 1.6rem; }
a.boss-pad:hover { transform: translateY(-2px); border-style: solid; }
.boss-pad.locked { opacity: .55; border-color: var(--line); }
.boss-pad.beaten { border: 2px solid var(--done); }
[data-theme="arcade"] .boss-pad:not(.locked):not(.beaten) { border-color: var(--pink); box-shadow: 0 0 14px rgba(255, 62, 165, .35); }
[data-theme="arcade"] .boss-bar .hp span { background: var(--pink); box-shadow: 0 0 10px var(--pink); }

/* ---------- Ask Claude about this ---------- */
.ask-box { margin-top: .6rem; padding: .7rem .9rem; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); font-size: .88rem; }
.ask-box pre { white-space: pre-wrap; font-size: .78rem; max-height: 180px; overflow-y: auto; margin: .5rem 0 0; color: var(--ink); }

/* ---------- Bug hunts (practice.js) ---------- */
.bug-hunt { border: 2px dashed var(--progress); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }
.bug-clue { font-size: .9rem; }
.bug-method { font-size: .85rem; margin: .5rem 0 .8rem; }
.bug-method summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.bug-method ol { margin: .4rem 0 0; padding-left: 1.3rem; }
.bug-code { background: var(--code-bg); border-radius: 10px; padding: .5rem 0; overflow-x: auto; }
.bug-line {
  display: flex; gap: .8rem; width: 100%; text-align: left; border: 0; border-left: 4px solid transparent; border-radius: 0;
  background: transparent; color: var(--code-ink); padding: .15rem .8rem;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; white-space: pre;
}
.bug-line:hover:not(:disabled) { background: rgba(255, 255, 255, .07); border-left-color: var(--progress); }
.bug-line:disabled { cursor: default; }
.bug-line .ln { color: #7f8aa3; min-width: 1.6em; text-align: right; user-select: none; }
.bug-line.right { background: rgba(60, 201, 139, .22); border-left-color: var(--done); }
.bug-line.wrong { background: rgba(240, 112, 112, .22); border-left-color: var(--bad); animation: shake .3s; }
.bug-gap { height: .9rem; }
.bug-hunt .result button { margin-left: .5rem; }
[data-theme="arcade"] .bug-line { background: transparent; border: 0; border-left: 4px solid transparent; border-radius: 0; box-shadow: none; margin: 0; text-transform: none; font-family: "SF Mono", Menlo, Consolas, monospace; }
[data-theme="arcade"] .bug-line.right { border-left-color: var(--green); }
[data-theme="arcade"] .bug-line.wrong { border-left-color: var(--bad); }
.bug-hints { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .9rem; }
.bug-hints li { background: var(--progress-soft); border-radius: 10px; padding: .4rem .7rem; margin-top: .35rem; }
.bug-line.dim { opacity: .35; }
.bug-explain { font-weight: 400; margin-top: .5rem; }
.bug-explain p { margin: .4rem 0; color: var(--ink); }

/* ---------- Player profiles (players.js) ---------- */
.players { max-width: 860px; margin: 0 auto; }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.player-card {
  display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center;
  border-radius: var(--radius); padding: 1.1rem .8rem; background: var(--card); border: 2px solid var(--line);
}
.player-card:hover { transform: translateY(-2px); }
.player-card.is-me { border-color: var(--done); }
.player-card.add { border-style: dashed; }
.player-card small { color: var(--muted); font-size: .75rem; }
.player-icon { font-size: 2.4rem; line-height: 1.2; }
.player-form { margin-top: 1rem; }
.player-form label { display: block; margin: .6rem 0; font-size: .9rem; }
.player-form input { display: block; margin-top: .25rem; font: inherit; padding: .45rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: min(100%, 320px); }
.icon-pick { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 .6rem; }
.icon-pick button { font-size: 1.3rem; padding: .2rem .45rem; border-radius: 10px; }
.icon-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
button.danger { color: var(--bad); border-color: var(--bad); }
@media (max-width: 1000px) { #player-chip .level-name { display: none; } }

/* Shown when the browser is too old for some lessons (see browserProblems in app.js) */
.old-browser { background: var(--progress-soft); border: 2px solid var(--progress); border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; }
