/* ---------- Theme tokens: Explorer (Gr 5–7) and Challenger (Gr 8–10) ---------- */
body[data-mode="junior"] {
  --bg: #e9f6ff;
  --bg-art: linear-gradient(180deg, #bfe6ff 0%, #e9f6ff 35%, #fff6e2 100%);
  --surface: #ffffff;
  --surface-2: #f1f7ff;
  --text: #1f2a44;
  --muted: #5b6b88;
  --line: #d4e3f5;
  --primary: #ff6b4a;
  --primary-ink: #ffffff;
  --primary-soft: #ffe4dc;
  --accent: #2bb3a3;
  --gold: #ffb800;
  --good: #188a55;
  --good-bg: #dff7ea;
  --warn: #9a5b00;
  --warn-bg: #fff1d1;
  --bad: #c2362b;
  --bad-bg: #ffe2df;
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  --shadow: 0 5px 0 rgba(31, 42, 68, .07), 0 12px 28px rgba(31, 42, 68, .08);
  --x: #7c5cff;
}
body[data-mode="senior"] {
  --bg: #0b1020;
  --bg-art: radial-gradient(1100px 600px at 85% -10%, #1d2c5c 0%, transparent 60%),
            radial-gradient(800px 500px at -10% 110%, #2a1b4f 0%, transparent 60%), #0b1020;
  --surface: #121a30;
  --surface-2: #19233f;
  --text: #e8edf8;
  --muted: #94a2c0;
  --line: #27345a;
  --primary: #22d3ee;
  --primary-ink: #03222b;
  --primary-soft: rgba(34, 211, 238, .14);
  --accent: #a78bfa;
  --gold: #fbbf24;
  --good: #34d399;
  --good-bg: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .1);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 30px rgba(0, 0, 0, .35);
  --x: #a78bfa;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-art);
  background-color: var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
body[data-mode="senior"] h1 { letter-spacing: -.02em; font-weight: 800; }
a { color: var(--primary); }
body[data-mode="junior"] a { color: #e0472a; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.center-text { text-align: center; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.row.center { justify-content: center; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 64px; outline: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: inherit; font-weight: 600; font-size: 1rem;
  padding: .65em 1.15em;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, background .15s, box-shadow .15s;
}
body[data-mode="senior"] .btn { border-radius: var(--radius-sm); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
body[data-mode="senior"] .btn.primary { box-shadow: 0 0 0 1px rgba(34, 211, 238, .4), 0 8px 24px rgba(34, 211, 238, .25); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.small { font-size: .875rem; padding: .45em .9em; }
.btn.big { font-size: 1.15rem; padding: .8em 1.6em; }
.btn.danger { color: var(--bad); }
body[data-mode="junior"] a.btn.ghost { color: var(--text); }

.chip {
  display: inline-block; font-size: .78rem; font-weight: 600;
  padding: .2em .7em; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.gold { background: var(--gold); color: #3a2a00; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }

.stars span { color: var(--line); font-size: 1.1rem; }
.stars span.on { color: var(--gold); }
.stars.big span { font-size: 2.6rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hud { max-width: 1040px; margin: 0 auto; padding: 10px 16px 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text) !important; white-space: nowrap; }
.hud-stats { display: flex; align-items: center; gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .2em .7em; white-space: nowrap; font-size: .95rem; }
.grade-sel select {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: .3em .6em; border-radius: 999px;
  background: var(--primary-soft); color: var(--text); border: 1px solid var(--line);
}
.grade-sel option { background: var(--surface); color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.avatar { font-size: 1.6rem; text-decoration: none; line-height: 1; }
.nav { max-width: 1040px; margin: 0 auto; padding: 4px 12px 8px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; text-decoration: none; color: var(--muted) !important; font-weight: 600; font-size: .92rem;
  padding: .35em .8em; border-radius: 999px;
}
.nav a.active { background: var(--primary); color: var(--primary-ink) !important; }
.nav a:not(.active):hover { background: var(--surface-2); }

@media (max-width: 560px) {
  .brand { font-size: 1rem; }
  .stat { padding: .15em .5em; font-size: .85rem; }
}

/* ---------- Page heads, welcome ---------- */
.page-head { margin: 8px 0 18px; }
.page-head h1 { margin-bottom: .2em; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem 1rem; }
.suggest { width: 100%; margin: 0; color: var(--muted); }
.big-emoji { font-size: 3.5rem; line-height: 1.1; margin-bottom: .2em; }

.welcome { max-width: 520px; margin: 24px auto; text-align: center; }
.welcome-form { display: grid; gap: 16px; margin: 18px 0 8px; text-align: left; }
.field { display: grid; gap: 6px; font-weight: 600; }
input:not([type="range"]):not([type="radio"]) {
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: .55em .8em; min-width: 0;
}
input:focus { border-color: var(--primary); outline: none; }
.grade-pick { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.grade-pick legend { font-weight: 600; margin-bottom: 6px; }
.grade-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.grade-opt { cursor: pointer; }
.grade-opt input { position: absolute; opacity: 0; }
.grade-opt span {
  display: grid; justify-items: center; padding: 8px 0; line-height: 1.1;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.grade-opt b { font-size: 1.4rem; }
.grade-opt small { font-size: .68rem; color: var(--muted); }
.grade-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.grade-opt input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (max-width: 420px) { .grade-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Island map ---------- */
.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.island {
  --hue: #5b8def;
  display: flex; gap: 14px; align-items: flex-start;
  text-decoration: none; color: var(--text) !important;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
  transition: transform .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.island::before {
  content: ''; position: absolute; inset: auto -20% -60% auto; width: 180px; height: 180px; border-radius: 50%;
  background: var(--hue); opacity: .12; pointer-events: none;
}
.island:hover { transform: translateY(-3px); border-color: var(--hue); }
.island-art {
  flex: none; width: 72px; height: 72px; display: grid; place-items: center; font-size: 2.4rem;
  border-radius: 50% 50% 46% 54% / 60% 55% 45% 40%;
  background: color-mix(in srgb, var(--hue) 22%, var(--surface));
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--hue) 35%, transparent);
}
body[data-mode="senior"] .island-art { border-radius: 14px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--hue) 50%, transparent), 0 0 24px color-mix(in srgb, var(--hue) 30%, transparent); }
.island-name { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--hue); }
.island-game { font-size: 1.25rem; font-weight: 700; }
.island-blurb { color: var(--muted); font-size: .92rem; margin: .2em 0; }
.island-pizza { --hue: #ff7a45; }
.island-elevator { --hue: #3b9cff; }
.island-balance { --hue: #8b5cf6; }
.island-line { --hue: #14b8a6; }
.island-daily { --hue: #eab308; }
.island-boss { --hue: #ef4444; }

/* ---------- Round shell ---------- */
.round { display: grid; gap: 14px; }
.round-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.round-title { display: grid; flex: 1; font-weight: 700; font-size: 1.2rem; line-height: 1.2; }
.round-title small { font-weight: 500; font-size: .8rem; color: var(--muted); }
.pips { display: flex; gap: 6px; }
.pip { width: 14px; height: 14px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.pip.current { box-shadow: 0 0 0 3px var(--primary-soft), 0 0 0 1px var(--primary); }
.pip.good { background: var(--good); }
.pip.ok { background: var(--gold); }
.pip.miss { background: var(--bad); opacity: .6; }

.patience { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.patience-fill { height: 100%; width: 100%; background: var(--accent); border-radius: 99px; transition: width .1s linear, background .3s; }
.patience-fill.low { background: var(--bad); }

.prompt .lead { font-size: 1.15rem; margin: 0 0 .3em; }
.expr { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; margin: .2em 0; letter-spacing: .02em; }
.feedback { min-height: 1.6em; font-size: 1.08rem; font-weight: 600; text-align: center; border-radius: var(--radius-sm); padding: 0 12px; }
.feedback.good { color: var(--good); background: var(--good-bg); padding: 10px 12px; }
.feedback.try { color: var(--warn); background: var(--warn-bg); padding: 10px 12px; }
.feedback:empty { padding: 0; }
.coin-pop { display: inline-block; animation: pop .5s ease; }
.hint-box { display: grid; gap: 10px; }
.hint { background: var(--primary-soft); border: 1px dashed var(--primary); border-radius: var(--radius-sm); padding: 10px 14px; }
.hint b { display: block; margin-bottom: 4px; }
.round-foot { display: flex; justify-content: center; }
.round-end { text-align: center; max-width: 520px; margin: 20px auto; }

.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; font-weight: 700; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 .2em; }
.frac > span:last-child { padding: 0 .2em; }
.xchip, .unitchip {
  display: inline-grid; place-items: center; font-style: normal; font-weight: 700; color: #fff;
  width: 1.4em; height: 1.4em; font-size: .85em; vertical-align: middle;
}
.xchip { background: var(--x); border-radius: 4px; }
.unitchip { background: var(--gold); border-radius: 50%; color: #3a2a00; }

/* ---------- Pizza Shop ---------- */
.customer { display: flex; gap: 14px; align-items: center; }
.cust-face { font-size: 3rem; animation: bob 2.4s ease-in-out infinite; }
.bubble { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 10px 16px; font-size: 1.15rem; }
.bubble small { display: block; color: var(--muted); font-size: .8rem; }
.order { font-size: 1.4rem; white-space: nowrap; }
.order .op { margin: 0 .2em; font-weight: 700; }
.pizza-area { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pizza { width: min(320px, 84vw); height: auto; touch-action: manipulation; }
.pizza .board { fill: #c58b52; opacity: .35; }
.slice { cursor: pointer; transition: transform .18s; outline: none; }
.slice path { fill: #ffd98a; stroke: #e2a447; stroke-width: 3; stroke-linejoin: round; }
.slice .pep { fill: #d6452f; opacity: 0; transition: opacity .15s; }
.slice:hover path { fill: #ffe3a6; }
.slice.on { transform: translate(var(--dx), var(--dy)); }
.slice.on path { fill: #ffc24d; }
.slice.on .pep { opacity: 1; }
.slice:focus-visible path { stroke: var(--primary); stroke-width: 5; }
.pizza-side { display: grid; gap: 8px; justify-items: center; text-align: center; }
.serving { font-size: 1.05rem; }
.serving-frac { font-size: 2.4rem; }

/* ---------- Elevator ---------- */
.elevator { display: grid; justify-items: center; }
.elev-tip { color: var(--muted); margin: 0 0 8px; }
.shaft {
  --row: 26px;
  position: relative; display: grid; grid-template-rows: repeat(21, var(--row));
  width: min(280px, 100%); border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid var(--line); background: var(--surface);
}
.floor {
  font: inherit; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--surface); border: 0; border-bottom: 1px solid var(--line);
  color: var(--text); cursor: pointer; text-align: left;
}
.floor:hover { background: var(--primary-soft); }
.floor.basement { background: color-mix(in srgb, #5b6b88 10%, var(--surface)); }
.floor.basement:hover { background: var(--primary-soft); }
.floor.ground { border-top: 3px solid var(--good); border-bottom: 3px solid var(--good); font-weight: 700; }
.floor.start .fl-num { color: var(--primary); font-weight: 700; }
.fl-num { width: 2.2em; font-variant-numeric: tabular-nums; }
.fl-tag { font-size: .72rem; color: var(--good); text-transform: uppercase; letter-spacing: .06em; }
.pin { font-size: .9rem; }
.car {
  position: absolute; right: 8px; width: 46px; height: var(--row);
  top: calc(var(--f, 10) * var(--row));
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--primary); border-radius: 6px; pointer-events: none;
  transition: top .55s cubic-bezier(.5, 0, .3, 1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
@media (max-width: 560px) { .shaft { --row: 23px; } .floor { font-size: .9rem; } }

/* ---------- Balance Scale ---------- */
.balance { display: grid; gap: 12px; justify-items: center; }
.eq-now { font-size: 1.2rem; text-align: center; }
.scale { width: min(460px, 100%); height: auto; }
.scale .stand { fill: var(--muted); opacity: .5; }
.scale .base { fill: var(--muted); opacity: .6; }
.scale .beam { fill: var(--accent); }
.scale .pivot { fill: var(--text); }
.scale .string { stroke: var(--muted); stroke-width: 1.5; opacity: .6; }
.scale .pan { fill: var(--muted); }
.scale .xbox { fill: var(--x); }
.scale .unit { fill: var(--gold); }
.scale .xt, .scale .ut { text-anchor: middle; font-weight: 700; font-family: var(--font); }
.scale .xt { fill: #fff; font-size: 13px; }
.scale .ut { fill: #3a2a00; font-size: 9px; }
.beam-g { transform-origin: 180px 50px; transition: transform .5s cubic-bezier(.4, 1.6, .5, 1); }
.beam-g.wobble { animation: wobble .6s ease; }
.moves { display: grid; gap: 8px; width: min(560px, 100%); }
.move { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; }
.move input { width: 4.2em; text-align: center; padding: .3em .4em; }
.move-msg { color: var(--warn); font-weight: 600; font-size: .92rem; }
.answer { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: 1.2rem; font-weight: 700; }
.answer input { width: 5em; font-size: 1.2rem; text-align: center; }

/* ---------- Star Laser ---------- */
.line-game { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.plane { width: min(420px, 100%); height: auto; }
.plane .plane-bg { fill: var(--surface); stroke: var(--line); }
body[data-mode="senior"] .plane .plane-bg { fill: #0d1428; }
.plane .grid { stroke: var(--line); stroke-width: 1; }
.plane .axis { stroke: var(--muted); stroke-width: 2; }
.plane .tick, .plane .axis-label { fill: var(--muted); font-size: 10px; text-anchor: middle; font-family: var(--font); }
.plane .axis-label { font-size: 13px; font-weight: 700; font-style: italic; }
.plane .laser { stroke: var(--primary); stroke-width: 3.5; stroke-linecap: round; }
body[data-mode="senior"] .plane .laser { filter: drop-shadow(0 0 4px var(--primary)); }
.plane .star polygon { fill: var(--surface); stroke: var(--gold); stroke-width: 2; transition: fill .2s; }
.plane .star.hit polygon { fill: var(--gold); filter: drop-shadow(0 0 6px var(--gold)); }
.plane .star-label { font-size: 10px; fill: var(--text); font-weight: 600; font-family: var(--font); }
.line-controls { display: grid; gap: 14px; width: min(320px, 100%); }
.eq-big { font-size: 1.6rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.slider { display: grid; gap: 4px; }
.slider span { display: flex; justify-content: space-between; }
.slider output { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--primary); height: 28px; }

/* ---------- Daily 24 ---------- */
.daily { max-width: 620px; margin: 0 auto; display: grid; gap: 10px; }
.streak-box { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3em .9em; }
.tag { justify-self: start; font-size: .9rem; background: var(--primary-soft); padding: .3em .8em; border-radius: 999px; }
.cards24 { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; min-height: 96px; }
.c24 {
  font: inherit; font-size: 2rem; font-weight: 700; color: var(--text);
  min-width: 84px; height: 96px; padding: 0 12px;
  background: var(--surface); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, border-color .15s;
}
.c24:hover { transform: translateY(-2px); }
.c24.sel { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-4px); }
.c24.fresh { animation: pop .35s ease; }
.c24.won { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.ops24 { display: flex; justify-content: center; gap: 10px; }
.op24 {
  font: inherit; font-size: 1.6rem; font-weight: 700; width: 58px; height: 58px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); border: 2px solid var(--line); cursor: pointer;
}
body[data-mode="senior"] .op24 { border-radius: var(--radius-sm); }
.op24.sel { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.steps24 { margin: 0 auto; padding-left: 1.4em; font-weight: 600; color: var(--muted); }

/* ---------- Boss ---------- */
.boss { max-width: 560px; margin: 0 auto; }
.boss-face { font-size: 3rem; display: inline-block; }
.boss-face.big { font-size: 5rem; animation: bob 2s ease-in-out infinite; }
.boss-top { display: flex; align-items: center; gap: 14px; }
.boss-meta { flex: 1; }
.boss-name { font-weight: 700; }
.hp { height: 16px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.hp-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #f97316); transition: width .35s; }
.boss-status { display: flex; justify-content: space-between; margin: 12px 0; font-size: 1.15rem; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; }
.clock.low { color: var(--bad); }
.boss-q { font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 700; text-align: center; padding: 18px 8px; min-height: 3.2em; }
.boss-form { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.boss-in { width: 8em; font-size: 1.3rem !important; text-align: center; }
.sign { padding: .5em .8em; }

/* ---------- Cards, shop, progress ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.mcard {
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 25%, var(--surface)), var(--surface) 60%);
  border: 2px solid var(--gold); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.mcard h3 { margin: .2em 0 0; }
.mcard .years { color: var(--muted); font-size: .85rem; margin-bottom: .4em; }
.mcard p { font-size: .92rem; margin: 0; }
.mcard-emoji { font-size: 2.6rem; }
.mcard { display: flex; flex-direction: column; }
.mcard-goal { margin-top: auto; padding-top: 10px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.mcard-goal.earned { color: var(--good); }
.mcard.pop { animation: pop .5s ease; box-shadow: none; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.shop-item {
  font: inherit; color: var(--text); cursor: pointer;
  display: grid; justify-items: center; gap: 6px; padding: 16px 8px;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.shop-item:hover { border-color: var(--primary); }
.shop-item.wearing { border-color: var(--good); background: var(--good-bg); }
.shop-item.poor { opacity: .55; }
.shop-emoji { font-size: 2.6rem; }
.shop-label { font-weight: 600; font-size: .9rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; display: grid; }
.tile b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }
.callout { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 10px 14px; }
.table-wrap { overflow-x: auto; padding: 6px; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-size: .78rem; }

/* ---------- Overlays ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(10, 16, 32, .55); animation: fade .2s; }
.modal { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 22px; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); text-align: center; animation: pop .3s ease; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: var(--text); color: var(--bg); padding: .7em 1.2em; border-radius: 999px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: opacity .4s, transform .4s; max-width: calc(100% - 32px);
}
.toast.out { opacity: 0; transform: translate(-50%, 10px); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 80; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 13px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }

/* ---------- Motion ---------- */
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes pop { 0% { transform: scale(.7); opacity: .4; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes wobble { 25% { transform: rotate(-4deg); } 60% { transform: rotate(3deg); } 85% { transform: rotate(-1deg); } }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
