/* ================= Tokens ================= */
:root {
  --road-h: 24vh;
  --walk-h: 3.6vh;
  --bus-w: min(80vw, 1040px, calc((100vh - 220px) * 2));
  --bus-h: calc(var(--bus-w) / 3);
  --bus-left: 5vw;
  --bus-bottom: 4vh;
  --ink: #0f2a4a;
  --navy: #1e3a5f;
  --navy-70: rgba(30, 58, 95, .7);
  --navy-60: rgba(30, 58, 95, .6);
  --shadow-soft: 0 6px 0 rgba(15, 42, 74, .08), 0 10px 24px rgba(15, 42, 74, .12);
  --bus-main: #ef4444;
  --bus-dark: #b91c1c;
  --bus-light: #fecaca;
}
.theme-integer {
  --bus-main: #ef4444; --bus-dark: #b91c1c; --bus-light: #fecaca;
  --accent: #ef4444; --accent-dark: #b91c1c; --accent-text: #dc2626; --glow: rgba(239, 68, 68, .25);
}
.theme-decimal {
  --bus-main: #22c55e; --bus-dark: #15803d; --bus-light: #bbf7d0;
  --accent: #22c55e; --accent-dark: #15803d; --accent-text: #16a34a; --glow: rgba(34, 197, 94, .25);
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  background: #bfe6ff;
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
h1, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
kbd { font-family: 'Fredoka', system-ui, sans-serif; background: #f1f5f9; border-radius: 6px; padding: 1px 7px; margin: 0 2px; }
.font-display { font-family: 'Fredoka', system-ui, sans-serif; }
.hidden { display: none !important; }
.pill { background: rgba(255, 255, 255, .92); border-radius: 999px; box-shadow: var(--shadow-soft); }

/* ================= Screens ================= */
.screen { position: fixed; inset: 0; transition: opacity .45s ease, visibility .45s ease; }
.screen.off { opacity: 0; visibility: hidden; pointer-events: none; }
.sky { background: linear-gradient(180deg, #74c3f5 0%, #b3e0fb 55%, #e3f5ff 100%); }

.clouds { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cloud { position: absolute; left: 0; animation: drift linear infinite; opacity: .95; }
@keyframes drift { from { transform: translateX(110vw); } to { transform: translateX(-40vw); } }

/* ================= Bus SVG ================= */
.bus-svg { display: block; width: 100%; height: auto; }
.b-main { fill: var(--bus-main); }
.b-dark { fill: var(--bus-dark); }
.b-light { fill: var(--bus-light); }

/* ================= Start screen ================= */
.start-skyline { bottom: 14vh; height: 30vh; opacity: .55; }
.start-grass { position: absolute; left: 0; right: 0; bottom: 0; height: 14vh; background: linear-gradient(#8fd694, #6cc57a); }
.start-scroll { position: relative; z-index: 10; height: 100%; overflow-y: auto; }
.start-inner {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(24px, 4vh, 40px);
  padding: 76px 16px 32px;
}
.lang-switch { position: absolute; top: 16px; right: 16px; z-index: 20; display: flex; gap: 4px; padding: 5px; }
.lang-btn {
  min-width: 46px; height: 38px; padding: 0 10px; border-radius: 999px;
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 15px; color: var(--navy);
  transition: background-color .2s ease, color .2s ease;
}
.lang-btn:hover { background: #e0f2fe; }
.lang-btn[aria-pressed="true"] { background: var(--navy); color: #fff; }
.lang-btn:focus-visible { outline: 3px solid #0ea5e9; outline-offset: 2px; }

.start-header { text-align: center; }
.brand-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; margin-bottom: 16px;
  font-size: 14px; font-weight: 800; letter-spacing: .05em; color: rgba(30, 58, 95, .8);
}
.title {
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700;
  font-size: clamp(44px, 8vw, 76px); line-height: 1.05; color: var(--navy);
  text-shadow: 0 4px 0 rgba(255, 255, 255, .8);
}
.subtitle { margin: 12px auto 0; max-width: 32rem; font-size: clamp(16px, 2vw, 18px); color: var(--navy-70); }

.cards { display: grid; grid-template-columns: 1fr; gap: clamp(20px, 3vw, 40px); width: 100%; max-width: 1040px; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }

.line-card {
  display: flex; flex-direction: column; text-align: left;
  padding: clamp(20px, 2.4vw, 28px);
  border-radius: 32px;
  background: rgba(255, 255, 255, .72);
  border: 4px solid rgba(255, 255, 255, .9);
  box-shadow: 0 10px 0 rgba(15, 42, 74, .08), 0 24px 48px rgba(15, 42, 74, .12);
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease, border-color .3s ease, background-color .3s ease;
  outline: none;
}
.line-card:hover, .line-card:focus-visible {
  transform: translateY(-8px) scale(1.04);
  border-color: var(--accent);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 12px 0 rgba(15, 42, 74, .08), 0 0 0 8px var(--glow), 0 30px 60px var(--glow);
}
.line-card:active { transform: translateY(-2px) scale(.99); }
.badge {
  align-self: flex-start; border-radius: 999px; padding: 4px 12px;
  background: var(--accent); color: #fff;
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 14px;
}
.bus-art { margin: clamp(18px, 3.5vh, 32px) 0; animation: bob 2.4s ease-in-out infinite; }
.line-card:hover .bus-art { animation-duration: .5s; }
.line-card .wheel { transform-box: fill-box; transform-origin: center; }
.line-card:hover .wheel { animation: spin .6s linear infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.card-name {
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700;
  font-size: clamp(28px, 3.2vw, 38px); line-height: 1.1; color: var(--accent-text);
}
.card-hint { font-size: clamp(14px, 1.5vw, 16px); color: var(--navy-60); }
.go-btn {
  flex-shrink: 0; width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--accent); box-shadow: 0 5px 0 var(--accent-dark);
}

/* ================= Parallax world ================= */
.layer { position: absolute; left: 0; right: 0; background-repeat: repeat-x; background-size: auto 100%; will-change: background-position; }
#skyFar  { bottom: calc(var(--road-h) + var(--walk-h)); height: 40vh; opacity: .9; }
#skyNear { bottom: calc(var(--road-h) + var(--walk-h)); height: 29vh; }
#trees   { bottom: calc(var(--road-h) + var(--walk-h) - 2px); height: 17vh; }
#walk {
  bottom: var(--road-h); height: var(--walk-h);
  background-color: #d5dde7;
  background-image: repeating-linear-gradient(90deg, transparent 0 86px, #bfc9d6 86px 90px);
  background-size: auto;
  border-top: 4px solid #eef2f7;
  border-bottom: 6px solid #8f9cad;
}
#road { bottom: 0; height: var(--road-h); background: linear-gradient(180deg, #3a404b 0%, #474e5b 12%, #434a56 100%); }
#lane {
  position: absolute; left: 0; right: 0; top: 46%; height: max(6px, 1.1vh);
  background-image: repeating-linear-gradient(90deg, #f8fafc 0 72px, transparent 72px 132px);
  border-radius: 4px; opacity: .92;
}
#roadEdge { position: absolute; left: 0; right: 0; bottom: 10%; height: 4px; background: rgba(248, 250, 252, .35); }

/* ================= Bus (game) ================= */
.bus {
  position: absolute; left: var(--bus-left); bottom: var(--bus-bottom); width: var(--bus-w); z-index: 10;
  transform: translateX(-130vw);
  container-type: inline-size;
}
.bus-inner { position: relative; }
.bus.driving .bus-inner { animation: bump .28s ease-in-out infinite alternate; }
.bus.idle .bus-inner { animation: idle .12s linear infinite alternate; }
.bus.hop .bus-inner { animation: hop .6s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes bump { from { transform: translateY(0); } to { transform: translateY(-.3cqw); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-2.2cqw); } 60% { transform: translateY(0); } 80% { transform: translateY(-.8cqw); } }
@keyframes idle { from { transform: translateY(0); } to { transform: translateY(.1cqw); } }

.win {
  position: absolute;
  display: grid; place-items: center;
  border-radius: 1cqw; cursor: default;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.win .num {
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700;
  font-size: max(17px, 4.4cqw); line-height: 1; color: var(--ink);
  background: #fff; border-radius: max(8px, 1.2cqw);
  padding: max(5px, .8cqw) max(8px, 1.3cqw) max(6px, .95cqw);
  min-width: max(34px, 7cqw); text-align: center;
  box-shadow: 0 max(3px, .5cqw) 0 rgba(15, 42, 74, .35);
  transform: scale(0);
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), background-color .2s, color .2s, box-shadow .2s, opacity .3s;
}
.win.show .num { transform: scale(1); }
.bus.ready .win { cursor: pointer; }
.bus.ready .win:hover { background: rgba(253, 224, 71, .35); box-shadow: inset 0 0 0 max(3px, .5cqw) #facc15; }
.bus.ready .win:hover .num { transform: scale(1.12) translateY(-.3cqw); }
.win:focus-visible { outline: max(3px, .4cqw) solid #facc15; outline-offset: 2px; }
.win.correct { animation: flashGreen .45s ease-in-out 3; }
.win.wrong { animation: shake .5s ease, flashRed .45s ease-in-out 3; }
.win.correct .num { background: #22c55e; color: #fff; transform: scale(1.12); }
.win.wrong .num { background: #f43f5e; color: #fff; }
/* ✓ / ✗ badge on the window corner */
.win::after {
  content: ''; position: absolute; top: -1.4cqw; right: -1.4cqw;
  width: max(22px, 3.4cqw); height: max(22px, 3.4cqw); border-radius: 50%;
  border: max(2px, .35cqw) solid #fff; background: #22c55e center / 62% no-repeat;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transform: scale(0); transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); pointer-events: none;
}
.win.correct::after {
  transform: scale(1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.win.wrong::after {
  transform: scale(1); background-color: #f43f5e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 7l10 10M17 7L7 17' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
@keyframes shake { 0%, 100% { translate: 0 0; } 20% { translate: -1.2cqw 0; } 40% { translate: 1.2cqw 0; } 60% { translate: -.8cqw 0; } 80% { translate: .5cqw 0; } }
.win.dim .num { opacity: .45; }
@keyframes flashGreen { 0%, 100% { background: rgba(34, 197, 94, .15); } 50% { background: rgba(34, 197, 94, .9); box-shadow: 0 0 2.5cqw rgba(34, 197, 94, .9); } }
@keyframes flashRed { 0%, 100% { background: rgba(239, 68, 68, .15); } 50% { background: rgba(239, 68, 68, .9); box-shadow: 0 0 2.5cqw rgba(239, 68, 68, .9); } }

/* ================= Station ================= */
.station-wrap {
  position: absolute; right: 3vw; bottom: calc(var(--road-h) + var(--walk-h) * .3);
  width: min(400px, 34vw); z-index: 5; pointer-events: none;
}
.station {
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(140%); opacity: 0;
  transition: transform .65s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease;
}
.station.up { transform: none; opacity: 1; }
.station.leaving { transition: transform .45s cubic-bezier(.5, 0, .75, 0), opacity .4s ease; }
.board {
  width: 100%; background: #fff; border-radius: 24px; overflow: hidden;
  border: 5px solid var(--navy);
  box-shadow: 0 10px 0 rgba(15, 42, 74, .14), 0 24px 44px rgba(15, 42, 74, .2);
}
.board-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px 10px; background: var(--navy); color: #fff;
}
.board-title { display: inline-flex; align-items: center; gap: 8px; font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 18px; }
.line-tag { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; letter-spacing: .04em; background: var(--accent); }
.equation {
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700;
  font-size: clamp(30px, 3.8vw, 52px); line-height: 1.1;
  padding: 16px 12px 20px; text-align: center; color: var(--ink); white-space: nowrap; overflow: hidden;
}
.eq-inner { display: inline-block; }
.op { color: #64748b; margin: 0 .24em; }
.revealed { color: #16a34a; }
.qmark {
  display: inline-grid; place-items: center; min-width: 1.25em; height: 1.2em; padding: 0 .08em;
  border: 4px dashed #f59e0b; border-radius: .28em; background: #fef3c7; color: #d97706;
  vertical-align: middle; animation: wiggle 1.6s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(0); } }
/* Pole is tall enough to lift the board just above the bus roof */
.pole {
  position: relative; width: 14px;
  height: max(10vh, calc(var(--bus-bottom) + var(--bus-h) + 18px - var(--road-h) - var(--walk-h) * .3 - 10px));
  background: linear-gradient(90deg, #7c8a9c, #d3dbe5, #7c8a9c);
}
.stop-sign {
  position: absolute; top: 2vh; left: 50%; transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #facc15; border: 4px solid var(--navy); box-shadow: 0 4px 0 rgba(15, 42, 74, .2);
}
.pole-base { width: 64px; height: 10px; border-radius: 6px; background: #5b6778; }

/* ================= HUD ================= */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: clamp(12px, 2vw, 20px);
}
.hud-left { display: flex; gap: 12px; flex-shrink: 0; }
.hud-center { flex: 1; min-width: 0; max-width: 36rem; display: flex; flex-direction: column; gap: 10px; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 18px;
  display: grid; place-items: center;
  background: #fff; color: var(--navy); box-shadow: var(--shadow-soft);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}
.icon-btn:hover { transform: translateY(-2px) scale(1.06); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(15, 42, 74, .12); }
.banner-wrap { position: relative; }
.banner { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 18px; }
.banner p { flex: 1; min-width: 0; font-weight: 800; font-size: 16px; line-height: 1.25; color: var(--navy); }
.info-btn {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #0ea5e9; color: #fff;
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 18px;
  transition: background-color .2s;
}
.info-btn:hover { background: #0284c7; }
.help-pop {
  position: absolute; top: calc(100% + 12px); left: 50%; width: min(380px, 88vw);
  padding: 16px; border-radius: 24px;
  font-size: 14px; line-height: 1.6; color: rgba(30, 58, 95, .85);
  transform: translate(-50%, -6px) scale(.96); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.help-pop.open { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.help-title { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 18px; color: var(--navy); margin-bottom: 4px; }
.help-tip { margin-top: 8px; color: var(--navy-60); }
.timer-row { display: flex; align-items: center; gap: 10px; }
.timer-track {
  flex: 1; height: 16px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, .85);
  box-shadow: inset 0 2px 4px rgba(15, 42, 74, .15), 0 4px 12px rgba(15, 42, 74, .1);
}
.timer-fill { height: 100%; width: 100%; border-radius: 999px; background: hsl(215 85% 55%); transform-origin: left center; }
.timer-fill.low { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
.timer-text { min-width: 48px; text-align: right; font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
.score-pill { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 8px; }
.score { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 24px; color: var(--navy); font-variant-numeric: tabular-nums; }
.score-bump { animation: scoreBump .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes scoreBump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.streak-pill { padding: 4px 12px; font-size: 14px; font-weight: 800; color: #ea580c; opacity: 0; transition: opacity .3s; }

/* ================= Trip progress ================= */
.trip { display: flex; justify-content: center; gap: 6px; }
.trip span {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255, 255, 255, .75); box-shadow: inset 0 0 0 2px rgba(30, 58, 95, .15);
  transition: background-color .3s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease;
}
.trip span.current { background: #fff; box-shadow: inset 0 0 0 3px var(--accent); transform: scale(1.3); }
.trip span.good { background: #22c55e; box-shadow: none; }
.trip span.bad { background: #f43f5e; box-shadow: none; }

/* ================= Feedback card ================= */
.fb-layer { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.fb-card {
  --fb-c: #16a34a; --fb-soft: #dcfce7;
  /* centred in the open sky between the HUD and the bus, left of the station board */
  --fb-x: calc((100vw - 3vw - min(400px, 34vw)) / 2);
  --fb-y: calc((118px + 100vh - var(--bus-bottom) - var(--bus-h)) / 2);
  position: absolute; left: var(--fb-x); top: var(--fb-y);
  width: min(400px, calc(100vw - 32px));
  padding: 46px 22px 18px;
  border-radius: 28px; border: 4px solid var(--fb-c);
  background: #fff; text-align: center;
  box-shadow: 0 10px 0 rgba(15, 42, 74, .12), 0 26px 50px rgba(15, 42, 74, .22);
  transform: translate(-50%, -50%) scale(.8);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .2s ease, opacity .2s ease, visibility .2s;
}
.fb-card::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 60px; z-index: -1;
  border-radius: 24px 24px 0 0; background: var(--fb-soft);
}
.fb-card.show {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  animation: cardIn .6s cubic-bezier(.34, 1.56, .64, 1);
}
.fb-card.good { --fb-c: #16a34a; --fb-soft: #dcfce7; }
.fb-card.bad  { --fb-c: #f43f5e; --fb-soft: #ffe4e6; }
.fb-card.late { --fb-c: #f59e0b; --fb-soft: #fef3c7; }
@keyframes cardIn {
  0% { transform: translate(-50%, -38%) scale(.6) rotate(-4deg); opacity: 0; }
  60% { transform: translate(-50%, -52%) scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}
.fb-icon {
  position: absolute; top: 0; left: 50%; width: 76px; height: 76px;
  display: grid; place-items: center;
  border-radius: 50%; border: 5px solid #fff; background: var(--fb-c);
  box-shadow: 0 6px 0 rgba(15, 42, 74, .12), 0 10px 24px rgba(15, 42, 74, .18);
  transform: translate(-50%, -50%);
}
.fb-card.show .fb-icon { animation: iconPop .6s .05s cubic-bezier(.34, 1.56, .64, 1) both; }
.fb-icon svg { width: 44px; height: 44px; }
.fb-icon .draw { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .45s .3s ease-out forwards; }
@keyframes iconPop { from { transform: translate(-50%, -50%) scale(0) rotate(-35deg); } to { transform: translate(-50%, -50%) scale(1) rotate(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.fb-title { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: clamp(30px, 4vw, 42px); line-height: 1.05; color: var(--fb-c); }
.fb-eq {
  display: inline-block; margin-top: 12px; padding: 6px 16px; border-radius: 14px;
  background: #f1f5f9; color: var(--ink); white-space: nowrap;
  font-weight: 700; font-size: clamp(22px, 2.6vw, 30px);
}
.fb-eq .revealed { display: inline-block; padding: 0 .25em; border-radius: .3em; background: #22c55e; color: #fff; }
.fb-hint { margin-top: 12px; font-size: 16px; line-height: 1.4; color: var(--navy-70); }
.fb-hint strong { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 1.15em; color: var(--navy); white-space: nowrap; }
.fb-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.fb-hint:empty, .fb-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 800; }
.chip svg { width: 16px; height: 16px; }
.chip-points { background: #fef9c3; color: #a16207; }
.chip-streak { background: #ffedd5; color: #c2410c; }
.fb-next {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 16px; padding: 10px 22px 13px; border-radius: 999px;
  background: var(--fb-c); color: #fff; box-shadow: 0 4px 0 rgba(15, 42, 74, .18);
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 17px;
  transition: transform .15s ease;
}
.fb-next:hover { transform: translateY(-1px) scale(1.03); }
.fb-next:active { transform: translateY(2px); }
.fb-next:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.fb-next-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .3); }
.fb-next-bar span { display: block; width: 100%; height: 100%; background: #fff; transform-origin: left center; }

.fx { position: fixed; inset: 0; z-index: 45; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; width: 12px; height: 16px; border-radius: 3px; }
.fly-star { position: fixed; left: 0; top: 0; z-index: 60; width: 36px; height: 36px; pointer-events: none; }

/* ================= Results ================= */
.results-layer {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(15, 42, 74, .35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility .35s ease;
}
.results-layer.open { opacity: 1; visibility: visible; }
.results-card {
  width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 26px 24px 24px; border-radius: 32px; background: #fff; text-align: center;
  box-shadow: 0 12px 0 rgba(15, 42, 74, .12), 0 30px 60px rgba(15, 42, 74, .3);
  transform: translateY(30px) scale(.92); transition: transform .5s cubic-bezier(.34, 1.56, .64, 1);
}
.results-layer.open .results-card { transform: none; }
.res-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin-bottom: 6px; }
.res-star { width: 64px; height: 64px; transform: scale(0); }
.res-star:nth-child(2) { width: 84px; height: 84px; }
.res-star path { fill: #e2e8f0; stroke: #cbd5e1; }
.res-star.on path { fill: #facc15; stroke: #eab308; }
.results-layer.open .res-star { animation: starPop .55s cubic-bezier(.34, 1.56, .64, 1) forwards; }
@keyframes starPop { from { transform: scale(0) rotate(-45deg); } to { transform: scale(1) rotate(0); } }
.res-title { margin: 0; font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: clamp(28px, 4vw, 36px); line-height: 1.1; color: var(--navy); }
.res-correct { margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--accent-text); }
.res-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.res-stat { padding: 12px 8px; border-radius: 18px; background: #f1f5f9; }
.res-stat-val { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 28px; color: var(--navy); }
.res-stat-label { font-size: 13px; color: var(--navy-60); }
.res-new {
  display: none; width: max-content; margin: 14px auto 0; padding: 5px 14px; border-radius: 999px;
  background: #fef9c3; color: #a16207; font-size: 14px; font-weight: 800;
}
.res-new.show { display: block; animation: wiggle 1.6s ease-in-out infinite; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1 1 160px; padding: 13px 18px 15px; border-radius: 18px;
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; font-size: 18px;
  transition: transform .15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); }
.btn:focus-visible { outline: 3px solid #0ea5e9; outline-offset: 3px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-dark); }
.btn-ghost { background: #f1f5f9; color: var(--navy); box-shadow: 0 5px 0 #cbd5e1; }

/* ================= Small screens ================= */
@media (max-width: 719px) {
  :root { --bus-w: 96vw; --bus-left: 2vw; --bus-bottom: 3vh; --road-h: 22vh; }
  .hud { flex-wrap: wrap; gap: 10px; }
  .hud-center { order: 3; flex-basis: 100%; max-width: none; }
  .banner p { font-size: 14px; }
  .icon-btn { width: 44px; height: 44px; border-radius: 14px; }
  .station-wrap { left: 4vw; right: 4vw; width: auto; top: 190px; bottom: auto; }
  .station { transform: translateY(-30px) scale(.9); }
  .station .pole, .station .pole-base { display: none; }
  .equation { font-size: clamp(34px, 11vw, 52px); }
  .lang-switch { left: 50%; right: auto; transform: translateX(-50%); }
  .fb-card { --fb-x: 50vw; --fb-y: calc((340px + 100vh - var(--bus-bottom) - var(--bus-h)) / 2); }
  .trip span { width: 10px; height: 10px; }
}
@media (max-height: 640px) {
  .fb-card { padding: 38px 16px 14px; }
  .fb-icon { width: 60px; height: 60px; }
  .fb-icon svg { width: 34px; height: 34px; }
  .fb-title { font-size: 28px; }
  .fb-eq { font-size: 20px; margin-top: 8px; }
  .fb-hint { font-size: 14px; margin-top: 8px; }
  .fb-next { margin-top: 10px; padding: 8px 18px 10px; }
  .res-star { width: 48px; height: 48px; }
  .res-star:nth-child(2) { width: 62px; height: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  .cloud, .bus-art, .qmark, .res-new.show { animation: none !important; }
}
