/* Arthur's Monster Rally — UI styles
   One committed visual world: night-navy garage panels, rally yellow, hazard stripes. */
:root {
  --ink: #141c3a;
  --ink-2: #1d2850;
  --ink-3: #2a3a72;
  --line: #3b4c8c;
  --sun: #ffc83d;
  --sun-d: #d99400;
  --flame: #ff5a36;
  --flame-d: #b8381a;
  --lime: #5fcf3f;
  --lime-dd: #2f8a1f;
  --sky: #3fb6ff;
  --sky-d: #1b78bd;
  --grape: #9b5cff;
  --grape-d: #6431c4;
  --cherry: #e63946;
  --cherry-d: #a51d2a;
  --cream: #fff8e7;
  --paper: #fffdf6;
  --muted: #a9b3dc;
  --display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Baloo 2', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --zh: 'ZCOOL KuaiLe', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --hazard: repeating-linear-gradient(-45deg, var(--sun) 0 12px, var(--ink) 12px 24px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  font-size: 16px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; }

#app { position: fixed; inset: 0; overflow: hidden; background: var(--ink); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.zh { font-family: var(--zh); }

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--sun); --bd: var(--sun-d); --fg: var(--ink);
  font-family: var(--display);
  font-size: clamp(17px, 2.1vw, 22px);
  letter-spacing: .03em;
  color: var(--fg);
  background: var(--bg);
  border: 0;
  border-radius: 14px;
  padding: .55em 1.1em .5em;
  box-shadow: 0 5px 0 var(--bd), 0 10px 18px rgba(0,0,0,.28);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd), 0 4px 8px rgba(0,0,0,.25); }
.btn:focus-visible, .icon-btn:focus-visible, .card-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn[disabled] { filter: grayscale(.7) brightness(.8); cursor: not-allowed; }
.btn-go { --bg: var(--lime); --bd: var(--lime-dd); --fg: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn-ghost { --bg: var(--ink-3); --bd: #0c1230; --fg: var(--cream); }
.btn-red { --bg: var(--flame); --bd: var(--flame-d); --fg: #fff; }
.btn-big { font-size: clamp(26px, 4vw, 40px); padding: .45em 1.4em .4em; border-radius: 20px; box-shadow: 0 7px 0 var(--bd), 0 14px 26px rgba(0,0,0,.35); }
.btn-big:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--bd); }
.btn-sm { font-size: 15px; padding: .45em .8em .4em; border-radius: 11px; box-shadow: 0 4px 0 var(--bd); }

.icon-btn {
  width: 46px; height: 46px; border-radius: 13px; border: 0;
  background: var(--ink-3); color: var(--cream);
  box-shadow: 0 4px 0 #0c1230;
  font-family: var(--display); font-size: 20px; cursor: pointer;
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0c1230; }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 5;
}
.screen.dim { background: linear-gradient(180deg, rgba(14,20,44,.86), rgba(14,20,44,.72) 60%, rgba(14,20,44,.9)); }
.screen[hidden] { display: none !important; }

.bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.bar h2 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(24px, 3.4vw, 36px); margin: 0; flex: 1; min-width: 160px;
  letter-spacing: .02em; text-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.bar h2 small { display: block; font-family: var(--body); font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; text-shadow: none; }

.wallet {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.35); border: 2px solid rgba(255,200,61,.5);
  border-radius: 999px; padding: 4px 14px 4px 6px;
  font-family: var(--display); font-size: 20px; color: var(--sun);
  font-variant-numeric: tabular-nums;
}
.coin-ico {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0 12%, #ffd23d 13% 55%, #e0a800 56% 100%);
  box-shadow: inset 0 0 0 2px #b88600;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 13px; color: #9a6c00;
}
.coin-ico::after { content: 'A'; }

/* ---------- Title ---------- */
#scr-title { justify-content: center; align-items: flex-start; background: linear-gradient(90deg, rgba(14,20,44,.72), rgba(14,20,44,.1) 70%); }
.title-wrap { width: min(560px, 100%); display: flex; flex-direction: column; gap: clamp(14px, 3vh, 28px); padding-left: clamp(0px, 4vw, 60px); }
.logo { display: flex; flex-direction: column; align-items: flex-start; transform: rotate(-3deg); transform-origin: left center; }
.logo-top {
  font-family: var(--display); font-size: clamp(22px, 3.4vw, 34px);
  background: var(--flame); color: #fff; padding: .05em .55em 0; border-radius: 10px;
  box-shadow: 0 4px 0 var(--flame-d); margin-bottom: -.1em; margin-left: .3em; transform: rotate(-4deg);
  position: relative; z-index: 1;
}
.logo-main {
  font-family: var(--display); font-size: clamp(54px, 9.5vw, 104px); line-height: .9;
  color: var(--sun);
  -webkit-text-stroke: .07em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .07em 0 var(--flame), 0 .14em 0 var(--ink), 0 .2em 24px rgba(0,0,0,.5);
  letter-spacing: .01em; transform: skewX(-7deg);
}
.logo-tag {
  margin-top: .8em; font-weight: 800; font-size: clamp(14px, 1.8vw, 18px); letter-spacing: .18em; text-transform: uppercase;
  background: var(--ink); padding: .2em .8em; border-radius: 6px; border: 2px solid var(--sun); color: var(--sun);
}
.menu { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.menu-row { display: flex; gap: 12px; flex-wrap: wrap; }
.title-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-weight: 600; font-size: 14px; }
.start-hint { color: var(--cream); opacity: .85; font-weight: 700; }

/* ---------- Level map ---------- */
.levels {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px;
  width: 100%; max-width: 1180px; margin: 0 auto; padding-bottom: 20px;
}
.lvl {
  position: relative; border: 0; padding: 0; text-align: left; color: #fff; cursor: pointer;
  border-radius: 20px; overflow: hidden; aspect-ratio: 5 / 4;
  background: linear-gradient(180deg, var(--a), var(--b));
  box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 0 0 3px rgba(255,255,255,.14);
  transition: transform .12s ease;
  font-family: var(--body);
}
.lvl:hover { transform: translateY(-3px) rotate(-.6deg); }
.lvl:active { transform: translateY(2px); }
.lvl:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.lvl .hill { position: absolute; left: -10%; right: -10%; bottom: -30%; height: 62%; border-radius: 50% 50% 0 0; background: var(--g); box-shadow: inset 0 8px 0 var(--t); }
.lvl .num {
  position: absolute; left: 12px; top: 8px; font-family: var(--display); font-size: 46px; line-height: 1;
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; color: #fff;
}
.lvl .icon { position: absolute; right: 10px; top: 10px; font-size: 30px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.3)); }
.lvl .name {
  position: absolute; left: 10px; right: 10px; bottom: 34px; font-family: var(--display); font-size: 19px;
  text-shadow: 0 2px 0 rgba(0,0,0,.55); line-height: 1.05;
}
.lvl .stars { position: absolute; left: 10px; bottom: 8px; font-size: 20px; letter-spacing: 2px; color: rgba(0,0,0,.35); }
.lvl .stars b { color: var(--sun); -webkit-text-stroke: 1px #8a5a00; font-weight: 400; }
.lvl .badge-new {
  position: absolute; right: 10px; bottom: 10px; background: var(--flame); color: #fff; font-family: var(--display);
  font-size: 14px; padding: 2px 9px; border-radius: 999px; box-shadow: 0 3px 0 var(--flame-d);
  animation: bob 1.2s ease-in-out infinite;
}
.lvl .saved-chip { position: absolute; right: 10px; bottom: 10px; background: var(--ink); color: var(--sun); font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.lvl.locked { cursor: not-allowed; }
.lvl.locked::after {
  content: ''; position: absolute; inset: 0; background: rgba(12,16,36,.62);
}
.lvl .lock {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
}
.lvl.locked .num, .lvl.locked .name { z-index: 1; opacity: .75; }
.lvl .lock span { width: 54px; height: 54px; border-radius: 16px; background: var(--ink); display: grid; place-items: center; box-shadow: 0 4px 0 #070b1c; }
.lvl .lock svg { width: 28px; height: 28px; }
.lvl.shake { animation: shake .4s; }

/* trophy shelf */
.trophy-shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.trophy-slot { background: rgba(255,255,255,.08); border-radius: 14px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.trophy-slot .ico { font-size: 34px; }
.trophy-slot b { font-family: var(--display); font-size: 15px; }
.trophy-slot small { font-size: 12px; opacity: .8; }
.trophy-slot.empty { opacity: .6; filter: grayscale(1); }

/* bonus-mode HUD strip */
.mode-hud { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6; background: rgba(12,16,36,.7); color: #fff; font-family: var(--display); font-size: 18px; padding: 6px 16px; border-radius: 999px; pointer-events: none; }

/* world paging */
.world-nav { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; max-width: 1180px; margin: 0 auto 12px; }
.world-nav .nav { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 20px; }
.world-nav .nav:disabled { opacity: .3; cursor: default; }
.world-banner { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.28); border-radius: 999px; padding: 8px 20px; color: #fff; }
.world-banner .w-ico { font-size: 26px; }
.world-banner .w-name { font-family: var(--display); font-size: 20px; }
.world-banner .w-stars { font-size: 15px; color: var(--sun); font-weight: 800; }
.lvl-tag { position: absolute; left: 8px; top: 8px; z-index: 3; font-family: var(--display); font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.45); color: #fff; }
.lvl .num { }
.lvl.bonus .num, .lvl.master .num { top: 26px; }
.lvl.bonus { box-shadow: 0 0 0 4px transparent, 0 6px 0 rgba(0,0,0,.25); background-clip: padding-box; }
.lvl.bonus::before { content: ''; position: absolute; inset: -4px; border-radius: 22px; z-index: -1; background: linear-gradient(90deg,#ff5a5a,#ffc83d,#5fcf3f,#3fb6ff,#c77dff); }
.lvl.master { box-shadow: 0 0 0 4px #ffc83d, 0 0 18px rgba(255,200,61,.6), 0 6px 0 rgba(0,0,0,.25); }
.lvl.world-lock { aspect-ratio: auto; min-height: 160px; grid-column: 1 / -1; display: grid; place-items: center; gap: 10px; background: rgba(12,16,36,.55); }
.lvl.world-lock .name { position: static; text-align: center; }

/* ---------- Subject select ---------- */
.subject-wrap { width: 100%; max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.card-btn {
  --c: var(--sky); --cd: var(--sky-d);
  position: relative; border: 0; cursor: pointer; border-radius: 22px; color: #fff; text-align: center;
  background: var(--c); box-shadow: 0 7px 0 var(--cd), 0 14px 22px rgba(0,0,0,.3);
  padding: 18px 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--body); transition: transform .1s;
  overflow: hidden;
}
.card-btn::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 30% 0%, rgba(255,255,255,.35), transparent 55%); pointer-events: none; }
.card-btn:hover { transform: translateY(-3px); }
.card-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--cd); }
.card-btn .glyph {
  font-family: var(--display); font-size: 48px; line-height: 1; height: 64px; display: grid; place-items: center;
  text-shadow: 0 4px 0 rgba(0,0,0,.22);
}
.card-btn .glyph.zh { font-family: var(--zh); font-size: 50px; }
.card-btn .glyph svg { width: 58px; height: 58px; }
.card-btn .label { font-family: var(--display); font-size: 24px; letter-spacing: .02em; }
.card-btn .sub { font-weight: 700; font-size: 14px; opacity: .92; line-height: 1.2; }
.s-math { --c: #2e9bf0; --cd: #1a67a8; }
.s-english { --c: #ff7a3d; --cd: #c24f1c; }
.s-chinese { --c: #e63946; --cd: #a51d2a; }
.s-science { --c: #3bb54a; --cd: #237a2e; }
.s-mix { --c: #9b5cff; --cd: #6431c4; }

.truck-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: rgba(0,0,0,.28); border-radius: 18px; padding: 10px 14px; border: 2px dashed rgba(255,255,255,.18);
}
.truck-strip canvas { width: 150px; height: 84px; flex: none; }
.truck-strip .who { flex: 1; min-width: 150px; }
.truck-strip .who b { display: block; font-family: var(--display); font-size: 22px; font-weight: 400; }
.truck-strip .who span { color: var(--muted); font-weight: 600; font-size: 14px; }

/* ---------- Garage ---------- */
.garage { width: 100%; max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.showroom {
  position: relative; border-radius: 24px; overflow: hidden; min-height: 240px;
  background:
    radial-gradient(ellipse at 50% 110%, rgba(255,200,61,.35), transparent 60%),
    linear-gradient(180deg, #24336b, #141c3a);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08);
}
.showroom canvas { display: block; width: 100%; height: clamp(220px, 38vh, 340px); }
.showroom .nav { position: absolute; top: 50%; transform: translateY(-50%); }
.showroom .nav.prev { left: 10px; }
.showroom .nav.next { right: 10px; }
.showroom .floor-stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: var(--hazard); opacity: .9; }
.specs { background: var(--ink-2); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.06); }
.specs h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1; }
.specs .tagline { margin: 0; color: var(--muted); font-weight: 600; }
.stat { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 10px; font-weight: 800; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.pips i { height: 14px; border-radius: 4px; background: rgba(255,255,255,.1); transform: skewX(-14deg); }
.pips i.on { background: var(--sun); box-shadow: 0 2px 0 var(--sun-d); }
.garage-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.owned-tag { font-family: var(--display); color: var(--lime); font-size: 18px; }
.thumbs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.thumb {
  position: relative; border: 0; border-radius: 16px; background: var(--ink-2); padding: 6px 6px 8px; cursor: pointer; color: var(--cream);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); font-family: var(--body); font-weight: 700; font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.thumb canvas { width: 100%; height: 56px; }
.thumb.sel { box-shadow: inset 0 0 0 3px var(--sun); background: #2b3a73; }
.thumb .price { display: inline-flex; align-items: center; gap: 4px; color: var(--sun); font-family: var(--display); font-weight: 400; }
.thumb .price .coin-ico { width: 16px; height: 16px; font-size: 9px; }
.thumb.locked canvas { filter: brightness(.35) saturate(.3); }
.tier-badge { position: absolute; top: 4px; right: 6px; font: 400 13px var(--display); color: var(--ink); background: var(--sun); border-radius: 999px; padding: 1px 7px; }
.thumb .using { color: var(--lime); }

/* ---------- Stickers ---------- */
.book { width: 100%; max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.sticker {
  position: relative; background: var(--paper); color: var(--ink); border-radius: 20px; padding: 14px 10px 12px; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.35); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sticker .medal {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 44px;
  background: conic-gradient(from 0deg, #ffd23d, #ff9f1c, #ffd23d, #fff1a8, #ffd23d);
  box-shadow: 0 0 0 5px #fff, 0 0 0 8px var(--ink), 0 6px 0 8px rgba(0,0,0,.2);
}
.sticker b { font-family: var(--display); font-weight: 400; font-size: 17px; line-height: 1.1; }
.sticker small { font-weight: 700; color: #5d6690; font-size: 12px; }
.sticker.empty { background: rgba(255,255,255,.06); color: var(--muted); box-shadow: inset 0 0 0 3px rgba(255,255,255,.1); border: 0; }
.sticker.empty .medal { background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 3px rgba(255,255,255,.12); color: rgba(255,255,255,.3); font-family: var(--display); font-size: 36px; }
.sticker.empty small { color: var(--muted); }
.sticker.champ { grid-column: span 2; background: linear-gradient(135deg, #fff5c7, #ffe07a); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.statbox { background: var(--ink-2); border-radius: 16px; padding: 12px 14px; }
.statbox b { display: block; font-family: var(--display); font-weight: 400; font-size: 30px; color: var(--sun); font-variant-numeric: tabular-nums; }
.statbox span { color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4; pointer-events: none;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
}
#hud[hidden] { display: none; }
#hud button { pointer-events: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  background: rgba(14,20,44,.78); border-radius: 12px; font-family: var(--display); font-size: 18px; color: var(--cream);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.1); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip.coins { color: var(--sun); }
.chip.coins.pop { animation: pop .25s ease; }
.hud-right { display: flex; gap: 8px; align-items: center; }
.hud-progress { min-width: 0; }
.track-bar { position: relative; height: 16px; background: rgba(14,20,44,.72); border-radius: 999px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); margin: 0 26px 0 6px; }
.track-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--sun), var(--flame)); }
.track-bar .mark { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 3px; background: var(--flame); box-shadow: 0 0 0 2px var(--ink); transform: rotate(45deg); }
.track-bar .mark.done { background: var(--lime); }
.track-bar .me { position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--cream); box-shadow: 0 0 0 3px var(--ink); display: grid; place-items: center; font-family: var(--display); font-size: 14px; color: var(--ink); }
.track-bar .flag { position: absolute; right: -26px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 4px; background:
  conic-gradient(#fff 0 25%, #111 0 50%, #fff 0 75%, #111 0) 0 0 / 11px 11px; box-shadow: 0 0 0 2px var(--ink); }

.hint {
  position: absolute; left: 50%; top: calc(66px + var(--safe-t)); transform: translateX(-50%); z-index: 4;
  background: rgba(14,20,44,.86); color: var(--cream); border-radius: 14px; padding: 10px 18px;
  font-weight: 700; font-size: clamp(14px, 1.8vw, 18px); text-align: center; max-width: calc(100% - 32px);
  box-shadow: inset 0 0 0 2px var(--sun); pointer-events: none;
}
.hint kbd { font-family: var(--display); background: var(--sun); color: var(--ink); border-radius: 6px; padding: 0 6px; font-size: .95em; }

#pedals { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; pointer-events: none; }
#pedals[hidden] { display: none; }
.pedal {
  position: absolute; bottom: calc(16px + var(--safe-b)); pointer-events: auto;
  width: clamp(76px, min(15vw, 24vh), 132px); height: clamp(76px, min(15vw, 24vh), 132px);
  border: 0; border-radius: 28px; color: #fff; cursor: pointer;
  font-family: var(--display); font-size: clamp(30px, 5vw, 44px); line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  touch-action: none; -webkit-touch-callout: none;
  opacity: .92;
}
.pedal span { font-size: clamp(13px, 1.8vw, 17px); letter-spacing: .08em; }
.pedal.brake { left: calc(16px + var(--safe-l)); background: var(--flame); box-shadow: 0 7px 0 var(--flame-d), 0 10px 20px rgba(0,0,0,.35); }
.pedal.gas { right: calc(16px + var(--safe-r)); background: var(--lime); box-shadow: 0 7px 0 var(--lime-dd), 0 10px 20px rgba(0,0,0,.35); width: clamp(92px, min(18vw, 30vh), 156px); }
.pedal.down { transform: translateY(6px); box-shadow: 0 1px 0 rgba(0,0,0,.4); opacity: 1; }

.pedal-jump {
  position: absolute; left: calc(16px + var(--safe-l)); bottom: calc(28px + var(--safe-b) + clamp(76px, min(15vw, 24vh), 132px));
  width: clamp(72px, min(13vw, 20vh), 110px); height: clamp(72px, min(13vw, 20vh), 110px); border-radius: 50%; border: 0;
  pointer-events: auto; cursor: pointer; background: var(--lime); color: #fff; box-shadow: 0 6px 0 var(--lime-dd);
  font-family: var(--display); font-size: clamp(26px, 4vw, 36px); line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none;
}
.pedal-jump span { font-size: 13px; letter-spacing: .08em; }
.pedal-jump:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--lime-dd); }

.pedal-fire {
  position: absolute; left: calc(28px + var(--safe-l) + clamp(72px, min(13vw, 20vh), 110px)); bottom: calc(40px + var(--safe-b) + clamp(76px, min(15vw, 24vh), 132px));
  width: 64px; height: 64px; border-radius: 50%; border: 0; pointer-events: auto; cursor: pointer;
  background: #ff4d4d; box-shadow: 0 5px 0 #a51d2a; font-size: 28px; line-height: 1; touch-action: none; position: absolute;
}
.pedal-fire b { position: absolute; right: -4px; top: -4px; min-width: 24px; height: 24px; border-radius: 12px; background: var(--ink); color: #fff; font: 400 14px var(--display); display: grid; place-items: center; }
.pedal-fire:active { transform: translateY(4px); box-shadow: 0 1px 0 #a51d2a; }
.bubble-ring { position: relative; padding: 18px; border-radius: 999px; }
.bubble-ring::before { content: ''; position: absolute; inset: 0; border-radius: 999px; border: 6px solid #ff4d4d; opacity: 0; pointer-events: none; }
.bubble-ring.run::before { opacity: 1; animation: ringshrink var(--dur, 6s) linear forwards; }
@keyframes ringshrink { from { transform: scale(1.06); opacity: 1; } 90% { opacity: .9; } to { transform: scale(.94); opacity: 0; border-color: #ffc83d; } }

.pedal-honk.cue-on { box-shadow: 0 0 0 5px #3fb6ff, 0 0 24px #3fb6ff; animation: bob .5s ease-in-out infinite; }
.pedal-jump.cue-on { box-shadow: 0 0 0 5px #5fcf3f, 0 0 26px #5fcf3f; animation: bob .5s ease-in-out infinite; }
.pedal-fire.cue-on { box-shadow: 0 0 0 5px #ff4d4d, 0 0 26px #ff4d4d; animation: bob .5s ease-in-out infinite; }
.cue-hint { position: absolute; z-index: 8; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: slam .25s ease; }
.cue-hint b { font: 400 clamp(26px, 5vw, 40px) var(--display); color: #fff; background: var(--ink); border-radius: 18px; padding: 6px 16px 2px; box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.cue-arrow { font-size: 36px; animation: bob .6s ease-in-out infinite; }
.cue-hint.jump, .cue-hint.fire { left: calc(12px + var(--safe-l)); bottom: calc(170px + var(--safe-b) + clamp(76px, min(15vw, 24vh), 132px)); }
.cue-hint.honk { right: calc(12px + var(--safe-r)); bottom: calc(110px + var(--safe-b) + clamp(92px, min(18vw, 30vh), 156px)); }
.cue-hint.jump b { border: 4px solid #5fcf3f; } .cue-hint.honk b { border: 4px solid #3fb6ff; } .cue-hint.fire b { border: 4px solid #ff4d4d; }

.boss-banner { position: absolute; top: calc(70px + var(--safe-t)); left: 0; right: 0; z-index: 8; pointer-events: none; text-align: center;
  font: 400 clamp(28px, 6vw, 48px) var(--display); color: var(--ink); background: var(--hazard); padding: 8px 0 4px; animation: bannerIn .35s ease; }
.boss-banner::first-line { text-shadow: 0 2px 0 #fff; }
.boss-card { position: absolute; top: calc(140px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 8; pointer-events: none;
  background: var(--ink); color: #fff; border: 4px solid var(--sun); border-radius: 20px; padding: 8px 20px 10px; text-align: center; animation: slam .3s ease; }
.boss-card small { display: block; font-weight: 800; letter-spacing: .2em; color: var(--sun); }
.boss-card b { font: 400 clamp(26px, 5vw, 38px) var(--display); }
.boss-card .pips { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.boss-card .pips i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.25); }
.boss-card .pips i.on { background: #ff5a36; }
#app.boss-warn::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 3; box-shadow: inset 0 0 0 6px rgba(255,90,54,.8), inset 0 0 60px rgba(255,90,54,.6); animation: edgepulse 1s ease-in-out infinite; }
.track-bar .mark.boss.warn { animation: pop .6s ease-in-out infinite; }
@keyframes bannerIn { from { transform: translateX(-100%); } }
@keyframes edgepulse { 50% { opacity: .35; } }

.rotate-tip { display: none; }
@media (orientation: portrait) and (max-width: 640px) {
  .rotate-tip {
    display: block; position: absolute; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%);
    background: rgba(14,20,44,.8); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 13px; color: var(--muted); z-index: 3; white-space: nowrap; pointer-events: none;
  }
  #hud { grid-template-columns: 1fr auto; }
  .hud-progress { grid-column: 1 / -1; grid-row: 2; }
  #hud .chip.level { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10; display: flex;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  background: rgba(8,12,30,.62);
  overflow-y: auto;
  animation: fade .18s ease;
}
.overlay[hidden] { display: none; }
.overlay > * { margin: auto; flex: none; } /* centred, but still scrollable when taller than the screen */

.panel {
  width: min(560px, 100%); background: var(--ink-2); border-radius: 26px; overflow: hidden;
  box-shadow: 0 10px 0 #0a0f24, 0 24px 60px rgba(0,0,0,.5), inset 0 0 0 3px rgba(255,255,255,.08);
  animation: rise .28s cubic-bezier(.2,1.4,.4,1);
}
.panel .stripe { height: 14px; background: var(--hazard); }
.panel .inner { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(28px, 4vw, 38px); text-align: center; letter-spacing: .02em; }
.panel .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Question card */
.qcard {
  width: min(760px, 100%); background: var(--paper); color: var(--ink); border-radius: 28px; overflow: hidden;
  box-shadow: 0 10px 0 #0a0f24, 0 30px 70px rgba(0,0,0,.55);
  animation: slam .35s cubic-bezier(.2,1.5,.4,1);
}
.qcard .stripe { height: 14px; background: var(--hazard); }
.q-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.q-subject { font-family: var(--display); font-size: 16px; color: #fff; padding: 4px 12px 2px; border-radius: 999px; background: var(--sky-d); letter-spacing: .04em; }
.q-subject.math { background: #1a67a8; }
.q-subject.english { background: #c24f1c; }
.q-subject.chinese { background: #a51d2a; }
.q-subject.science { background: #237a2e; }
.q-alert { flex: 1; font-weight: 800; font-size: 14px; color: #5d6690; line-height: 1.2; }
.q-head .icon-btn { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--sun-d); }
.q-body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.q-visual { display: flex; justify-content: center; align-items: center; min-height: 0; }
.q-visual:empty { display: none; }
.q-visual .emoji { font-size: clamp(40px, 8vw, 72px); line-height: 1.15; text-align: center; letter-spacing: .04em; word-break: break-word; }
.q-visual .emoji.many { font-size: clamp(30px, 5.4vw, 46px); max-width: 520px; }
.q-visual .big {
  font-family: var(--display); font-size: clamp(44px, 8vw, 76px); line-height: 1; color: var(--ink);
  background: #eef3ff; border-radius: 18px; padding: 10px 26px 6px; box-shadow: inset 0 0 0 3px #d5defa;
  font-variant-numeric: tabular-nums;
}
.q-visual .big.zh { font-family: var(--zh); }
.q-visual svg { width: clamp(120px, 22vw, 170px); height: auto; }
.coins-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sgcoin {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 19px;
  box-shadow: inset 0 0 0 4px rgba(0,0,0,.14), 0 4px 0 rgba(0,0,0,.18);
}
.sgcoin.c5, .sgcoin.c10, .sgcoin.c20, .sgcoin.c50 { background: radial-gradient(circle at 35% 30%, #fbe6b8, #d9b26a); color: #6b4a14; }
.sgcoin.c10 { width: 68px; height: 68px; }
.sgcoin.c20 { width: 72px; height: 72px; }
.sgcoin.c50 { width: 78px; height: 78px; }
.sgcoin.c100 { width: 80px; height: 80px; background: radial-gradient(circle at 35% 30%, #fff4c0 0 45%, #e5bf49 46% 100%); color: #6b5310; }
.q-text { margin: 0; text-align: center; font-weight: 800; font-size: clamp(21px, 3.2vw, 30px); line-height: 1.25; text-wrap: balance; }
.q-text.zh { font-family: var(--zh); font-weight: 400; font-size: clamp(26px, 4vw, 36px); }
.q-hint { margin: -6px 0 0; text-align: center; color: #5d6690; font-weight: 700; font-size: 16px; }
.q-hint:empty { display: none; }
.q-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.q-opts.three { grid-template-columns: repeat(3, 1fr); }
.opt {
  --bg: #2a3a72; --bd: #141c3a;
  min-height: 72px; border: 0; border-radius: 18px; cursor: pointer; color: #fff;
  background: var(--bg); box-shadow: 0 6px 0 var(--bd);
  font-family: var(--body); font-weight: 800; font-size: clamp(20px, 3vw, 28px); line-height: 1.15;
  padding: 10px 12px; transition: transform .08s, background .15s;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  position: relative;
}
.opt .k { position: absolute; left: 10px; top: 8px; font-family: var(--display); font-size: 13px; opacity: .5; }
.opt.zh { font-family: var(--zh); font-weight: 400; font-size: clamp(28px, 4.4vw, 40px); }
.opt:nth-child(4n+1) { --bg: #2e9bf0; --bd: #1a67a8; }
.opt:nth-child(4n+2) { --bg: #ff7a3d; --bd: #c24f1c; }
.opt:nth-child(4n+3) { --bg: #9b5cff; --bd: #6431c4; }
.opt:nth-child(4n+4) { --bg: #16a39a; --bd: #0c6f69; }
.opt:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--bd); }
.opt:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }
.opt.wrong { --bg: #c7cbe0; --bd: #9aa0bd; color: #6b7090; animation: shake .4s; cursor: default; }
.opt.wrong::after { content: ''; position: absolute; left: 16%; right: 16%; top: 50%; height: 4px; border-radius: 2px; background: var(--cherry); transform: rotate(-8deg); }
.opt.right { --bg: var(--lime); --bd: var(--lime-dd); animation: pop .35s ease; }
.q-feedback { margin: 0; min-height: 1.4em; text-align: center; font-family: var(--display); font-size: 22px; }
.q-feedback.good { color: var(--lime-dd); }
.q-feedback.bad { color: var(--cherry); }

/* Level complete */
.complete .inner { align-items: center; text-align: center; }
.complete h2 { color: var(--sun); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; font-size: clamp(34px, 5.4vw, 50px); line-height: 1; }
.big-stars { display: flex; gap: 10px; justify-content: center; margin-top: -4px; }
.big-stars i {
  width: 64px; height: 64px; display: block;
  background: rgba(255,255,255,.12);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.big-stars i:nth-child(2) { transform: translateY(-12px) scale(1.15); }
.big-stars i.on { background: linear-gradient(180deg, #fff1a0, #ffc83d 50%, #f09a00); animation: starpop .45s cubic-bezier(.2,1.8,.4,1) both; }
.reward {
  position: relative; width: 100%; border-radius: 20px; padding: 14px; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--paper); color: var(--ink); overflow: hidden;
}
.reward .medal { position: relative; width: 86px; height: 86px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 46px;
  background: conic-gradient(from 0deg, #ffd23d, #ff9f1c, #ffd23d, #fff1a8, #ffd23d); box-shadow: 0 0 0 5px #fff, 0 0 0 8px var(--ink); }
.reward .medal::before { content: ''; position: absolute; inset: -40px; z-index: -1; background: repeating-conic-gradient(rgba(255,200,61,.35) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: spin 8s linear infinite; }
.reward .medal { z-index: 0; isolation: isolate; }
.reward .rt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reward .rt small { font-weight: 800; color: var(--flame); letter-spacing: .1em; text-transform: uppercase; font-size: 12px; }
.reward .rt b { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.05; }
.reward .rt span { font-weight: 700; color: #5d6690; font-size: 14px; }
.tally { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-weight: 700; font-size: 16px; text-align: left; }
.tally dt { color: var(--muted); }
.tally dd { margin: 0; text-align: right; font-family: var(--display); font-size: 18px; font-variant-numeric: tabular-nums; }
.tally .total { border-top: 2px dashed rgba(255,255,255,.2); padding-top: 6px; color: var(--sun); font-size: 22px; }
.tally dt.total { color: var(--cream); font-family: var(--display); font-weight: 400; }

/* Settings */
.set-list { display: flex; flex-direction: column; gap: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; font-weight: 700; }
.set-row label { flex: 1; }
.toggle { position: relative; width: 62px; height: 34px; border-radius: 999px; background: #4a557f; border: 0; cursor: pointer; flex: none; transition: background .15s; }
.toggle::after { content: ''; position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--lime); }
.toggle[aria-checked="true"]::after { transform: translateX(28px); }
.text-in { font: 700 17px var(--body); padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--ink); color: var(--cream); width: 100%; max-width: 220px; }
.text-in:focus-visible { outline: 3px solid var(--sun); outline-offset: 1px; }
textarea.text-in { max-width: none; min-height: 64px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
.set-note { color: var(--muted); font-size: 13px; font-weight: 600; margin: 0; }
.details-box { background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.details-box summary { cursor: pointer; font-weight: 800; }

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px); z-index: 20;
  background: var(--cream); color: var(--ink); font-weight: 800; padding: 10px 18px; border-radius: 999px; box-shadow: 0 6px 0 rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.top { bottom: auto; top: calc(64px + var(--safe-t)); }

/* Typed answers (maths) */
.q-answers { transition: opacity .2s; }
.q-answers.thinking { opacity: .45; pointer-events: none; }
.q-input { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.q-input[hidden] { display: none; }
.ans-box {
  min-width: 190px; height: 72px; padding: 0 22px; border-radius: 18px; background: #eef3ff; box-shadow: inset 0 0 0 4px #c9d5fb;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--display); font-size: 46px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.ans-box .caret { width: 4px; height: 44px; border-radius: 2px; background: var(--sky-d); animation: blink 1s steps(1) infinite; }
.ans-box .unit { color: #5d6690; font-size: 34px; }
.ans-box.right { background: #dcf7d2; box-shadow: inset 0 0 0 4px var(--lime); }
.ans-box.right .caret, .ans-box.reveal .caret { display: none; }
.ans-box.reveal { background: #fff3cf; box-shadow: inset 0 0 0 4px var(--sun); }
.ans-box.shake { animation: shake .4s; box-shadow: inset 0 0 0 4px var(--cherry); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(360px, 100%); }
.keypad button {
  height: 60px; border: 0; border-radius: 16px; cursor: pointer; background: #2a3a72; color: #fff; box-shadow: 0 5px 0 #141c3a;
  font-family: var(--display); font-size: 30px; touch-action: manipulation;
}
.keypad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #141c3a; }
.keypad button:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }
.keypad .del { background: #c7cbe0; color: var(--ink); box-shadow: 0 5px 0 #9aa0bd; }
.keypad .ok { background: var(--lime); box-shadow: 0 5px 0 var(--lime-dd); font-size: 26px; }
.q-foot { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.q-tries { font-weight: 800; font-size: 14px; color: #5d6690; background: #eef3ff; border-radius: 999px; padding: 3px 12px; }
.opt.reveal { outline: 5px solid var(--lime); outline-offset: 2px; }
.shapes-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.shapes-row.many svg { width: clamp(70px, 13vw, 110px); }
@keyframes blink { 50% { opacity: 0; } }
@media (max-height: 520px) {
  .q-input { flex-direction: row; justify-content: center; }
  .ans-box { height: 60px; min-width: 130px; font-size: 38px; }
  .keypad { grid-template-columns: repeat(6, 1fr); width: min(420px, 70%); gap: 6px; }
  .keypad button { height: 46px; font-size: 24px; }
}

/* Cloud save */
.cloud-chip {
  border: 0; cursor: pointer; font: 800 13px var(--body); letter-spacing: .02em; padding: 5px 12px; border-radius: 999px;
  background: rgba(0,0,0,.35); color: var(--cream); box-shadow: inset 0 0 0 2px rgba(255,255,255,.2);
}
.cloud-chip.synced { color: #9ff08a; box-shadow: inset 0 0 0 2px rgba(95,207,63,.6); }
.cloud-chip.offline { color: #ffb4a4; }
.cloud-chip.off { background: var(--sky-d); color: #fff; box-shadow: 0 3px 0 #0f4f80; }
.cloud-chip:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.install-steps { margin: 4px 0 12px; padding-left: 1.4em; display: grid; gap: 10px; font-size: 17px; font-weight: 600; color: var(--cream); text-align: left; }
.install-steps .share-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; vertical-align: middle; border-radius: 8px; background: var(--sky-d); color: #fff; }
.install-steps .share-ico svg { width: 18px; height: 18px; }
.cloud-box > b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.code-big {
  font-family: var(--display); font-size: clamp(30px, 7vw, 40px); letter-spacing: .12em; text-align: center; color: var(--sun);
  background: var(--ink); border: 3px dashed var(--sun); border-radius: 14px; padding: 6px 10px; -webkit-user-select: all; user-select: all;
}
.code-in { text-transform: uppercase; letter-spacing: .12em; font-family: var(--display); max-width: 170px; }

/* Answer types: ordering / spelling tiles */
.q-how { margin: -4px 0 0; text-align: center; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #8a92b8; }
.q-build { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.slots, .tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.slot, .tile {
  min-width: 52px; min-height: 56px; padding: 6px 12px; border-radius: 14px; border: 0; cursor: pointer;
  font: 800 clamp(18px, 2.8vw, 24px) var(--body); line-height: 1.1; touch-action: manipulation;
}
.q-build.spell .slot, .q-build.spell .tile { font-family: var(--display); font-weight: 400; font-size: 30px; min-width: 50px; padding: 4px 8px; }
.slot { background: #eef3ff; color: var(--ink); box-shadow: inset 0 0 0 3px #c9d5fb; }
.slot.empty { background: transparent; box-shadow: inset 0 0 0 3px #c9d5fb; color: #b4bfe6; border: 3px dashed transparent; cursor: default; }
.slot.num { font-family: var(--display); font-weight: 400; font-size: 18px; }
.slot.ok { background: #dcf7d2; box-shadow: inset 0 0 0 3px var(--lime); }
.slot.bad { background: #ffe1dc; box-shadow: inset 0 0 0 3px var(--cherry); animation: shake .4s; }
.tile { background: #2a3a72; color: #fff; box-shadow: 0 5px 0 #141c3a; }
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 #141c3a; }
.tile.used { opacity: .18; box-shadow: none; cursor: default; }
.slot.zh, .tile.zh { font-family: var(--zh); font-weight: 400; font-size: clamp(22px, 3.4vw, 30px); }
.q-check-row { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }
.q-check-row .btn[disabled] { filter: grayscale(.8) brightness(.9); opacity: .6; }

/* Tap-all (multi) */
.q-opts.multi .opt { --bg: #eef3ff; --bd: #c9d5fb; color: var(--ink); }
.q-opts.multi .opt.on { --bg: #2e9bf0; --bd: #1a67a8; color: #fff; }
.q-opts.multi .opt.on::before { content: '✓'; position: absolute; right: 10px; top: 6px; font-family: var(--display); font-size: 18px; }
.q-opts.six { grid-template-columns: repeat(3, 1fr); }
.opt.right { --bg: var(--lime); --bd: var(--lime-dd); color: #fff; }

/* Matching pairs */
.q-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 26px; position: relative; }
.pair-col { display: flex; flex-direction: column; gap: 10px; }
.pair-btn {
  min-height: 56px; border: 0; border-radius: 16px; cursor: pointer; padding: 8px 12px;
  background: #eef3ff; color: var(--ink); box-shadow: 0 5px 0 #c9d5fb; font: 800 clamp(17px, 2.6vw, 22px) var(--body);
}
.pair-btn.zh { font-family: var(--zh); font-weight: 400; font-size: clamp(22px, 3.4vw, 30px); }
.pair-btn.picked { background: var(--sun); box-shadow: 0 5px 0 var(--sun-d); transform: translateY(-2px); }
.pair-btn.matched { color: #fff; box-shadow: none; cursor: default; }
.pair-btn.m1 { background: #2e9bf0; } .pair-btn.m2 { background: #ff7a3d; } .pair-btn.m3 { background: #9b5cff; } .pair-btn.m4 { background: #16a39a; }
.pair-btn.reveal { outline: 4px dashed var(--lime); outline-offset: 2px; }
.pair-btn.shake { animation: shake .4s; background: #ffe1dc; }

/* Explanation */
.q-explain { margin-top: 4px; background: #fff7dc; border-radius: 20px; padding: 14px 16px; box-shadow: inset 0 0 0 3px var(--sun); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; animation: rise .25s ease; }
.ex-head { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 20px; color: #8a5a00; }
.ex-bulb { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff9c2, #ffc83d 60%, #e09a00); box-shadow: 0 0 12px rgba(255,200,61,.8); }
.ex-answer { margin: 0; font-size: 18px; font-weight: 700; }
.ex-answer b { font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--lime-dd); }
.ex-answer.zh b { font-family: var(--zh); }
.ex-text { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.4; color: #3a4270; }
.q-explain .btn { align-self: flex-end; margin-top: 4px; }

/* Picture graph */
.pgraph { background: #eef3ff; border-radius: 16px; padding: 10px 14px; }
.pgraph table { border-collapse: collapse; }
.pgraph th { text-align: right; padding: 4px 10px 4px 0; font-size: 15px; color: #5d6690; }
.pgraph td { font-size: clamp(22px, 4vw, 30px); letter-spacing: 2px; border-left: 3px solid #c9d5fb; padding-left: 8px; }
.pgraph p { margin: 6px 0 0; font-size: 13px; font-weight: 800; color: #5d6690; text-align: center; }

/* Topic levels on the subject cards */
.card-btn { padding-top: 26px; }
.lvl-badge { position: absolute; left: 10px; top: 8px; background: rgba(0,0,0,.28); border-radius: 999px; padding: 1px 10px; font-family: var(--display); font-size: 15px; }
.xpbar { position: absolute; right: 10px; top: 13px; width: 42%; height: 8px; border-radius: 999px; background: rgba(0,0,0,.25); overflow: hidden; }
.xpbar i { display: block; height: 100%; background: #fff; border-radius: 999px; }
.card-btn.resting { filter: grayscale(.85) brightness(.7); cursor: not-allowed; }
.card-btn.resting .glyph::after { content: ' 💤'; font-size: 26px; }
.card-btn.shake { animation: shake .4s; }
.balance-note { margin: 0; color: var(--muted); font-weight: 600; font-size: 14px; line-height: 1.4; max-width: 70ch; }
.balance-note b { color: var(--cream); }

@media (max-width: 520px) {
  .q-opts.six { grid-template-columns: repeat(2, 1fr); }
  .q-pairs { gap: 10px 14px; }
  .slot, .tile { min-width: 44px; min-height: 50px; }
}
@media (max-height: 520px) {
  .slot, .tile, .pair-btn { min-height: 44px; }
  .q-build { gap: 8px; }
  .pgraph td { font-size: 20px; }
}

.q-head .q-cancel { background: var(--ink-3); color: var(--cream); box-shadow: 0 4px 0 #0c1230; }

/* Bolts wallet */
.wallet.bolts { color: #9ff0ff; border-color: rgba(127,247,255,.5); }
.bolt-ico { font-size: 18px; line-height: 1; }
.chip.bolts { color: #9ff0ff; }
.chip.missiles { color: #ff8a7a; }
.chip.missiles.empty { opacity: .45; }

/* Garage tabs */
.gpanel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gtabs { display: flex; gap: 6px; }
.gtab { flex: 1; border: 0; border-radius: 14px 14px 6px 6px; padding: 10px 8px; min-height: 48px; cursor: pointer;
  background: var(--ink-2); color: var(--muted); font: 400 17px var(--display); letter-spacing: .02em; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); position: relative; }
.gtab.on { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--sun-d); }
.gtab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.gp { background: var(--ink-2); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.06); max-height: min(62vh, 560px); overflow-y: auto; }
.gp-h { margin: 6px 0 0; font: 400 19px var(--display); letter-spacing: .02em; }
.gp-h small { font: 700 13px var(--body); color: var(--muted); letter-spacing: 0; }
.part-list { display: flex; flex-direction: column; gap: 8px; }
.part-row { display: grid; grid-template-columns: 40px 1fr 96px auto; align-items: center; gap: 10px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 8px 10px; }
.part-ico { font-size: 26px; text-align: center; }
.part-name b { display: block; font: 400 18px var(--display); }
.part-name small { color: var(--muted); font-weight: 700; font-size: 12.5px; line-height: 1.2; display: block; }
.part-row .btn { min-width: 84px; min-height: 44px; }
.tyre-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tyre { border: 0; border-radius: 14px; background: #2a3a72; color: var(--cream); padding: 8px; min-height: 64px; cursor: pointer; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; align-items: center; }
.tyre .emo { grid-row: span 2; font-size: 26px; text-align: center; }
.tyre b { font: 400 16px var(--display); }
.tyre small { font-weight: 800; color: #9ff0ff; font-size: 12px; }
.tyre.have { background: #1f5a3a; }
.tyre.have small { color: #b8f5a8; }
.tyre[disabled]:not(.have) { opacity: .55; cursor: not-allowed; }
.cos-sec { display: flex; flex-direction: column; gap: 6px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.swatch { border: 0; border-radius: 14px; background: #2a3a72; color: var(--cream); padding: 8px 4px 6px; min-height: 72px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 3px 0 #141c3a; }
.swatch .dot { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px rgba(255,255,255,.3); }
.swatch .emo { font-style: normal; font-size: 26px; line-height: 30px; }
.swatch small { font-weight: 800; font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; color: var(--sun); text-align: center; line-height: 1.1; }
.swatch.have small { color: var(--cream); }
.swatch .coin-ico { width: 14px; height: 14px; font-size: 8px; }
.swatch.on { background: var(--sun); color: var(--ink); box-shadow: 0 3px 0 var(--sun-d); }
.swatch.on small { color: var(--ink); }
.swatch[disabled] { opacity: .45; cursor: not-allowed; }
.thumb .goal { color: var(--sun); font-weight: 800; font-size: 12px; }
.pedal-honk {
  position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(24px + var(--safe-b) + clamp(92px, min(18vw, 30vh), 156px));
  width: 56px; height: 56px; border-radius: 50%; border: 0; pointer-events: auto; cursor: pointer;
  background: var(--sun); box-shadow: 0 5px 0 var(--sun-d); font-size: 26px; line-height: 1;
}
.pedal-honk:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--sun-d); }
#hud.brain .chip.coins { box-shadow: 0 0 0 3px #7ff7ff, 0 0 18px #7ff7ff; }
.tab-badge { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--flame); color: #fff; font: 400 13px var(--display); display: grid; place-items: center; padding: 0 5px; box-shadow: 0 2px 0 var(--flame-d); }
.repair-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.repair-card { border: 0; border-radius: 16px; background: #2a3a72; color: var(--cream); padding: 12px 8px; min-height: 96px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 4px 0 #141c3a; }
.repair-card .emo { font-size: 30px; }
.repair-card b { font: 400 17px var(--display); }
.repair-card small { color: var(--muted); font-weight: 800; }
.repair-card:active { transform: translateY(3px); box-shadow: 0 1px 0 #141c3a; }
.repair-chip { background: var(--flame); color: #fff; box-shadow: 0 3px 0 var(--flame-d); }
@media (max-width: 520px) {
  .part-row { grid-template-columns: 34px 1fr auto; }
  .part-row .pips { grid-column: 2; grid-row: 2; }
  .part-row .btn { grid-row: span 2; }
  .gtab { font-size: 15px; padding: 8px 4px; }
}

/* ---------- Animations ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px) scale(.96); opacity: 0; } }
@keyframes slam { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .garage { grid-template-columns: 1fr; }
  .q-opts.three { grid-template-columns: 1fr; }
  .opt { min-height: 60px; }
  .levels { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .lvl .num { font-size: 38px; }
  .lvl .name { font-size: 16px; }
  .sticker.champ { grid-column: span 1; }
}
@media (max-height: 520px) {
  .panel .inner { padding: 12px 16px 14px; gap: 10px; }
  .panel h2 { font-size: 26px; }
  .set-row { padding: 6px 12px; }
  .q-head { padding-top: 8px; }
  .q-body { gap: 8px; padding-bottom: 14px; }
  .opt { min-height: 54px; }
  .q-visual .emoji { font-size: 40px; }
  .q-visual .big { font-size: 40px; padding: 6px 18px 3px; }
  .q-visual svg { width: 104px; }
  .q-text { font-size: 20px; }
  .showroom canvas { height: 200px; }
  .title-wrap { gap: 12px; }
  .logo-main { font-size: clamp(44px, 12vh, 80px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.q-opts.multi .opt.right { --bg: var(--lime); --bd: var(--lime-dd); color: #fff; }
.q-opts.multi .opt.wrong { --bg: #ffe1dc; --bd: #e6a59a; color: #9a3b2f; }

/* Answer streak */
.chip.streak { color: #ffb02e; animation: pop .25s ease; }

/* Progress bar marks for bubbles and the boss */
.track-bar .mark.bub { border-radius: 50%; transform: none; background: #3fb6ff; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.track-bar .mark.boss { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--sun); }
.track-bar .mark.done { background: var(--lime); }

/* Quick bubbles */
.bubble-overlay { position: absolute; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: calc(70px + var(--safe-t)) 16px 16px; pointer-events: none; background: linear-gradient(180deg, rgba(8,12,30,.55), rgba(8,12,30,0) 70%); }
.bubble-overlay > * { pointer-events: auto; }
.bubble-q { display: flex; align-items: center; gap: 10px; background: var(--paper); color: var(--ink); border-radius: 22px; padding: 10px 12px 10px 16px; box-shadow: 0 6px 0 rgba(0,0,0,.3); max-width: min(640px, 100%); animation: slam .25s ease; }
.bubble-tag { font: 400 14px var(--display); color: #fff; background: var(--grape); border-radius: 999px; padding: 3px 10px 1px; white-space: nowrap; }
.bubble-text { margin: 0; flex: 1; font-weight: 800; font-size: clamp(20px, 3vw, 28px); line-height: 1.2; }
.bubble-pic { font-size: clamp(30px, 4.5vw, 42px); line-height: 1; }
.bubble-pic[hidden] { display: none; }
.bubble-text.zh { font-family: var(--zh); font-weight: 400; }
.bubble-q .icon-btn { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--sun-d); }
.bubbles { display: flex; gap: clamp(12px, 4vw, 40px); flex-wrap: wrap; justify-content: center; }
.bubble { position: relative; width: clamp(104px, 20vw, 150px); height: clamp(104px, 20vw, 150px); border-radius: 50%; border: 4px solid var(--ink); cursor: pointer;
  font: 400 clamp(24px, 4vw, 34px) var(--display); color: var(--ink); animation: bob 1.8s ease-in-out infinite;
  box-shadow: inset -10px -12px 0 rgba(0,0,0,.12), 0 8px 18px rgba(0,0,0,.3); padding: 8px; line-height: 1.05; }
.bubble.zh { font-family: var(--zh); }
.bubble .k { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-size: 13px; opacity: .6; }
.bubble.b0 { background: radial-gradient(circle at 35% 30%, #fff 0 12%, #9fdcff 13%); }
.bubble.b1 { background: radial-gradient(circle at 35% 30%, #fff 0 12%, #ffc2df 13%); animation-delay: -.6s; }
.bubble.b2 { background: radial-gradient(circle at 35% 30%, #fff 0 12%, #b8f5a8 13%); animation-delay: -1.2s; }
.bubble.pop { animation: bubblepop .45s ease forwards; }
.bubble.miss { filter: grayscale(1) brightness(.8); animation: shake .4s; }
.bubble.glow { box-shadow: 0 0 0 6px var(--lime), 0 0 30px var(--lime); }
@keyframes bubblepop { 60% { transform: scale(1.25); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
@media (max-height: 520px) { .bubble-overlay { padding-top: calc(52px + var(--safe-t)); gap: 8px; } .bubble { width: 92px; height: 92px; font-size: 22px; } }

/* Missions */
.missions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.missions li { display: inline-flex; align-items: center; gap: 6px; background: rgba(0,0,0,.25); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; color: var(--muted); }
.missions li .st { font-size: 18px; line-height: 1; color: rgba(255,255,255,.35); }
.missions li.done, .missions li.had { color: var(--cream); }
.missions li.done .st, .missions li.had .st { color: var(--sun); }
.missions .new { color: var(--lime); font-family: var(--display); font-weight: 400; }
.panel .missions { justify-content: center; }
.tyre-note { margin: 0; font-weight: 800; color: #9ff0ff; }

.btn-daily { --bg: var(--grape); --bd: var(--grape-d); --fg: #fff; flex-direction: column; align-items: flex-start; gap: 2px; }
.btn-daily small { font: 700 13px var(--body); opacity: .9; letter-spacing: 0; }
.chip.ghost { color: #d8d8ff; }
.chip.ghost.ahead { color: #b8f5a8; }
.rally-cal { background: var(--ink-2); border-radius: 20px; padding: 14px; }
.rally-cal h3 { margin: 0 0 10px; font: 400 22px var(--display); }
.rally-cal h3 small { font: 700 14px var(--body); color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 420px; }
.cal b { text-align: center; color: var(--muted); font-size: 13px; }
.cal i { font-style: normal; text-align: center; padding: 6px 0; border-radius: 10px; background: rgba(255,255,255,.06); font-weight: 800; font-size: 14px; color: var(--muted); }
.cal i.pad { background: none; }
.cal i.st { background: var(--sun); color: var(--ink); }
@media (max-width: 520px) { #hud .chip.ghost { display: none; } }

/* Grown-ups */
.panel.parent { width: min(880px, 100%); }
.pp { display: flex; flex-direction: column; gap: 16px; max-height: min(64vh, 640px); overflow-y: auto; padding-right: 4px; }
.pp section { display: flex; flex-direction: column; gap: 8px; }
.pp h3 { margin: 0; font: 400 22px var(--display); }
.pp h3 small, .pp h4 small { font: 700 13px var(--body); color: var(--muted); }
.pp h4 { margin: 6px 0 0; font: 400 17px var(--display); color: var(--sun); }
.tscroll { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-weight: 700; font-size: 15px; }
.ptable th, .ptable td { padding: 6px 8px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
.ptable th:first-child { text-align: left; }
.ptable thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.skills, .missed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.skills li { display: grid; grid-template-columns: minmax(0, 1fr) 120px 44px 36px; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.skills li b { text-align: right; font-family: var(--display); font-weight: 400; }
.skills li small { color: var(--muted); text-align: right; }
.skills li.empty, .missed li.empty { display: block; color: var(--muted); }
.pbar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--flame), var(--sun) 50%, var(--lime)); background-size: 120px 100%; }
.missed li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: rgba(0,0,0,.2); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.missed li b { grid-column: 1 / -1; }
.missed li span { color: var(--lime); font-weight: 800; }
.missed li small { color: var(--muted); font-weight: 800; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; }
.week .day { display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; }
.week .barwrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.week .barwrap i { width: 70%; min-height: 2px; border-radius: 6px 6px 2px 2px; background: var(--sky); }
.week b { font-family: var(--display); font-weight: 400; }
.week small { color: var(--muted); font-weight: 800; font-size: 12px; }
.list-ed { display: flex; flex-direction: column; gap: 6px; }
.list-ed textarea { min-height: 150px; font-family: var(--body); font-size: 16px; line-height: 1.5; }
.list-ed textarea.zh { font-family: var(--zh); font-size: 20px; }
.list-ed code { background: rgba(0,0,0,.3); border-radius: 6px; padding: 1px 6px; }
.list-ed .bad { color: #ffb4a4; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 10px; padding: 8px 10px; min-height: 40px; background: #2a3a72; color: var(--cream); font-weight: 800; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sun); color: var(--ink); }
.panel.gate { width: min(380px, 100%); }
.panel.gate .keypad, .panel.gate .ans-box { margin: 0 auto; }
.gate-q { margin: 0; text-align: center; font: 400 30px var(--display); }
.break-emoji { font-size: 64px; text-align: center; animation: bob 1.6s ease-in-out infinite; }
.break-text { text-align: center; font-size: 17px; }
@media (max-width: 520px) { .skills li { grid-template-columns: minmax(0, 1fr) 70px 40px; } .skills li small { display: none; } }
