:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --ink: #23262b;
  --muted: #6b7078;
  --line: #e3e0d6;
  --green: #2f9e6e;
  --green-dark: #23784f;
  --green-soft: #d9f2e5;
  --red: #d6455f;
  --red-dark: #a93148;
  --red-soft: #fbe1e6;
  --gold: #e9b024;
  --gold-dark: #b98a12;
  --blue: #3a7be8;
  --blue-dark: #2a5db3;
  --locked: #cfcbc0;
  --radius: 16px;
  --font: "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c; --card: #1f242a; --ink: #eef0f2; --muted: #9aa1aa; --line: #333a42;
    --green-soft: #183a2b; --red-soft: #432029; --locked: #444b54;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.4; }
#app { max-width: 640px; margin: 0 auto; min-height: 100%; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
#confetti { position: fixed; inset: 0; pointer-events: none; width: 100%; height: 100%; z-index: 50; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* chunky buttons */
.btn { display: block; width: 100%; border: 0; border-radius: var(--radius); padding: 15px 18px; font-weight: 800; font-size: 18px; letter-spacing: .03em; text-transform: uppercase; background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); transition: transform .05s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn:disabled, .btn.blue:disabled, .btn.red:disabled { background: var(--locked); box-shadow: 0 4px 0 var(--locked); color: #fff; cursor: default; }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; text-transform: none; font-weight: 700; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; font-size: 15px; }

/* centered screens */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 18px; padding: 32px 0; }
.mascot { font-size: 72px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.title { font-size: 30px; font-weight: 900; }
.subtitle { color: var(--muted); }
.code-input { font: inherit; font-size: 24px; text-align: center; padding: 14px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); color: var(--ink); width: 100%; max-width: 320px; }
.err { color: var(--red); font-weight: 700; min-height: 1.4em; }

/* profile picker */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; width: 100%; }
.profile { background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 20px; padding: 22px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.profile:active { transform: translateY(2px); }
.profile .face { font-size: 54px; }
.profile .name { font-weight: 900; font-size: 22px; }
.profile .track { color: var(--muted); font-size: 14px; }
.profile .mini { font-size: 14px; color: var(--muted); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 12px 0 10px; border-bottom: 2px solid var(--line); }
.topbar .who { display: flex; align-items: center; gap: 6px; font-weight: 800; background: none; border: 0; padding: 4px; }
.topbar .who .face { font-size: 28px; }
.topbar .stats { margin-left: auto; display: flex; gap: 14px; font-weight: 900; }
.stat { display: flex; align-items: center; gap: 4px; }
.stat.fire { color: #e8833a; }
.stat.fire.off { color: var(--locked); filter: grayscale(1); }
.stat.xp { color: var(--gold-dark); }
.iconbtn { background: none; border: 0; font-size: 22px; padding: 4px 6px; }

/* daily goal */
.goal { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; display: flex; gap: 12px; align-items: center; }
.goal .bar { flex: 1; height: 14px; background: var(--line); border-radius: 99px; overflow: hidden; }
.goal .bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .6s; }
.goal .lbl { font-weight: 800; font-size: 15px; white-space: nowrap; }
.row-btns { display: flex; gap: 10px; margin-top: 12px; }
.row-btns .btn { font-size: 15px; padding: 12px; }

/* the path */
.unit { margin-top: 22px; }
.unit-head { border-radius: var(--radius); padding: 14px 16px; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.unit-head .n { font-size: 13px; font-weight: 800; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.unit-head h2 { font-size: 22px; font-weight: 900; }
.path { display: flex; flex-direction: column; align-items: center; gap: 40px; padding: 40px 0 6px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.node { width: 76px; height: 72px; border-radius: 50%; border: 0; font-size: 32px; display: grid; place-items: center; color: #fff; position: relative; box-shadow: 0 7px 0 rgba(0,0,0,.22); }
.node:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(0,0,0,.22); }
.node.locked { background: var(--locked) !important; box-shadow: 0 7px 0 rgba(0,0,0,.12); filter: grayscale(1); opacity: .8; }
.node.current::after { content: "START"; position: absolute; top: -30px; background: var(--card); color: var(--green); font-size: 13px; font-weight: 900; padding: 4px 10px; border-radius: 10px; border: 2px solid var(--line); animation: bob 1.6s ease-in-out infinite; }
.node .laurels { position: absolute; bottom: -10px; right: -6px; background: var(--gold); color: #fff; font-size: 13px; font-weight: 900; border-radius: 99px; padding: 1px 7px; border: 2px solid var(--card); }
.node.gold { background: var(--gold) !important; }
.node-title { font-size: 14px; font-weight: 800; color: var(--muted); max-width: 170px; text-align: center; margin-top: 8px; }

/* lesson */
.lesson { flex: 1; display: flex; flex-direction: column; padding-top: 14px; }
.lesson-top { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 18px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .4s; box-shadow: inset 0 -5px 0 rgba(0,0,0,.08); }
.combo { font-weight: 900; color: #e8833a; min-width: 44px; text-align: right; }
.ex { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 22px 0 16px; }
.prompt { font-size: 24px; font-weight: 900; }
.newtag { display: inline-block; font-size: 13px; font-weight: 900; color: #8a4fd6; text-transform: uppercase; letter-spacing: .08em; }
.bigword { display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; }
.bigword .w { font-size: 32px; font-weight: 900; font-family: Georgia, "Times New Roman", serif; }
.bigword .s { color: var(--muted); font-size: 15px; }
.say { border: 0; background: var(--blue); color: #fff; width: 48px; height: 48px; border-radius: 14px; font-size: 22px; flex: none; box-shadow: 0 4px 0 var(--blue-dark); }
.options { display: grid; gap: 12px; }
.opt { text-align: left; background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: var(--radius); padding: 14px 16px; font-size: 20px; font-weight: 700; display: flex; gap: 12px; align-items: center; }
.opt .k { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; color: var(--muted); }
.opt.sel { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--card)); }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt:disabled { cursor: default; }
.la { font-family: Georgia, "Times New Roman", serif; }
.typein { font: inherit; font-size: 22px; padding: 16px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); width: 100%; }
.hint { color: var(--muted); font-size: 14px; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match .col { display: grid; gap: 12px; }
.tile { background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 14px; padding: 14px 10px; font-size: 18px; font-weight: 800; min-height: 58px; }
.tile.sel { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--card)); }
.tile.done { opacity: .3; border-color: var(--line); pointer-events: none; }
.tile.bad { border-color: var(--red); background: var(--red-soft); animation: shake .3s; }
.tile.good { border-color: var(--green); background: var(--green-soft); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.answer-line { min-height: 72px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; align-items: center; }
.bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; padding: 10px 14px; font-weight: 800; font-size: 20px; font-family: Georgia, serif; }
.chip.used { visibility: hidden; }

/* feedback footer */
.footer { position: sticky; bottom: 0; margin: 0 -16px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 2px solid var(--line); }
.footer.right { background: var(--green-soft); border-color: transparent; }
.footer.wrong { background: var(--red-soft); border-color: transparent; }
.fb { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.fb .icon { font-size: 30px; line-height: 1; }
.fb .head { font-weight: 900; font-size: 22px; }
.footer.right .head { color: var(--green-dark); }
.footer.wrong .head { color: var(--red-dark); }
.fb .body { font-size: 16px; }

table.decl { border-collapse: collapse; margin-top: 8px; font-size: 15px; background: var(--card); border-radius: 10px; overflow: hidden; }
table.decl th, table.decl td { padding: 4px 10px; border: 1px solid var(--line); text-align: left; }
table.decl td { font-family: Georgia, serif; }
table.decl td.hl { background: var(--gold); color: #fff; font-weight: 800; }

/* results */
.big-num { display: flex; gap: 12px; justify-content: center; width: 100%; }
.pill { flex: 1; max-width: 160px; border-radius: var(--radius); border: 2px solid; padding: 10px; font-weight: 900; }
.pill .k { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.pill .v { font-size: 26px; }
.pill.xp { border-color: var(--gold); color: var(--gold-dark); }
.pill.acc { border-color: var(--green); color: var(--green); }
.pill.fire { border-color: #e8833a; color: #e8833a; }

/* parent view */
.parent { padding-top: 16px; display: grid; gap: 16px; }
.pcard { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.pcard h3 { display: flex; gap: 8px; align-items: center; font-size: 22px; }
.pcard dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0 0; font-size: 16px; }
.pcard dt { color: var(--muted); }
.pcard dd { margin: 0; font-weight: 700; }
.board { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; }
.board h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.board .r { display: flex; justify-content: space-between; font-weight: 800; padding: 4px 0; }
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 800; z-index: 60; }
