/* =================================================================
   MathVille — style.css
   Blockville Workshop theme: wood brown + cherry red + gold, a town
   built from numbered blocks that visibly grows as chapters complete.
   ================================================================= */

:root {
  --wood: #C1793E;
  --wood-dark: #A8632F;
  --cherry: #E4572E;
  --cherry-dark: #C6431F;
  --gold: #F7C548;
  --taupe: #D8C7AE;
  --cream: #F7EEE0;
  --ink: #3B2A1A;
  --ink-soft: #7A6A56;
  --card: #ffffff;
  --good: #3F8F5F;
  --bad: #D64545;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--cream);
  font-family: "Fredoka", system-ui, sans-serif;
  color: var(--ink);
  color-scheme: light;
}

button { font-family: inherit; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,.08);
  padding-bottom: 24px;
}

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--taupe);
  max-width: 480px;
  margin: 0 auto;
}
.topbar-spacer { flex: 1; }
.icon-btn {
  background: none; border: none; font-size: 22px; cursor: pointer;
  padding: 4px 6px; border-radius: 10px; line-height: 1;
}
.icon-btn:hover { background: var(--cream); }
.xp-badge {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 13px; color: var(--ink-soft);
  background: var(--cream); padding: 6px 12px; border-radius: 20px;
}

/* ---------- Screens ---------- */
.screen { display: none; padding: 20px; }
.screen.active { display: block; }

/* ---------- Landing ---------- */
.hero { text-align: center; padding: 24px 0 8px; }
.hero-icon { font-size: 56px; display: inline-block; animation: heroFloat 3.2s ease-in-out infinite; }
@keyframes heroFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}
.title-xl { font: 800 30px "Baloo 2", sans-serif; color: var(--wood-dark); margin: 6px 0 2px; }
.subtitle { font-size: 15px; color: var(--ink-soft); margin: 0; }
.title-lg { font: 800 22px "Baloo 2", sans-serif; color: var(--ink); margin: 4px 0 12px; }
.subtitle-sm { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: none; border-radius: 20px; padding: 20px 10px; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.mode-solo { background: var(--wood); box-shadow: 0 6px 0 var(--wood-dark); }
.mode-mp { background: var(--cherry); box-shadow: 0 6px 0 var(--cherry-dark); }
.mode-card:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.mode-icon {
  width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.28);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  animation: modeIconWiggle 2.6s ease-in-out infinite;
}
.mode-mp .mode-icon { animation-delay: .3s; }
@keyframes modeIconWiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  15% { transform: rotate(-12deg) scale(1.05); }
  30% { transform: rotate(10deg) scale(1.05); }
  45% { transform: rotate(-6deg) scale(1.02); }
  60%, 100% { transform: rotate(0deg) scale(1); }
}
.mode-title { font: 700 17px "Baloo 2", sans-serif; color: #fff; }
.mode-sub { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.9); text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; padding: 15px; border: none; border-radius: 16px;
  font: 700 16px "Baloo 2", sans-serif; cursor: pointer; margin-top: 12px;
}
.btn-primary { background: var(--wood); color: #fff; }
.btn-primary:active { background: var(--wood-dark); }
.btn-secondary { background: var(--card); color: var(--wood-dark); border: 2px solid var(--taupe); }
.btn-cta { background: var(--cherry); }
.btn-cta:active { background: var(--cherry-dark); }
.btn-copy { width: auto; padding: 8px 14px; font-size: 13px; margin: 0; }

/* ---------- Pairing ---------- */
.players-seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg-btn {
  flex: 1; padding: 10px; border: 2px solid var(--taupe); border-radius: 14px;
  background: var(--card); font: 700 14px "Fredoka", sans-serif; color: var(--ink-soft); cursor: pointer;
}
.seg-btn.active { background: var(--wood); border-color: var(--wood); color: #fff; }
.pair-divider { text-align: center; color: var(--ink-soft); font-size: 13px; margin: 14px 0; }
.pair-input {
  width: 100%; padding: 14px; border: 2px solid var(--taupe); border-radius: 14px;
  font: 700 18px "Fredoka", sans-serif; text-align: center; letter-spacing: 3px; text-transform: uppercase;
}
.pair-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.code-display-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 16px 0; }
.code-display { font: 800 28px "Baloo 2", sans-serif; letter-spacing: 4px; color: var(--wood-dark); }
.qr-code { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- Town Map — winding road, like a little journey between stops ---------- */
.map-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 4px; text-align: left;
}
.map-header.drive-header {
  flex-direction: column; align-items: center;
  justify-content: center; text-align: center; margin-bottom: 2px;
}
.theme-toggle { display: flex; background: var(--cream); border-radius: 20px; padding: 3px; gap: 2px; flex: none; }
.theme-btn {
  padding: 7px 16px; border: none; border-radius: 16px; background: transparent;
  font: 700 12px "Fredoka", sans-serif; cursor: pointer;
}
#theme-btn-boy { color: #3B82C4; background: rgba(59,130,196,.12); }
#theme-btn-boy.active { background: #2E6BA3; color: #fff; }
#theme-btn-girl { color: #C23E82; background: rgba(224,70,138,.12); }
#theme-btn-girl.active { background: #C23E82; color: #fff; }

/* .town-map is the responsive VIEWPORT (real width, clips overflow);
   .town-map-inner is a fixed 440px-wide canvas that gets scaled down via
   JS (transform: scale) to fit whatever width is actually available —
   every child stays laid out in the same 440px coordinate space the road
   curve and traveler math already use, just visually shrunk to fit. */
.town-map {
  position: relative; width: 100%; margin: 12px auto 0; overflow: hidden;
}
.town-map-inner {
  position: relative; width: 440px; transform-origin: top left;
}
.map-stop {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 128px; text-align: center; cursor: pointer; z-index: 1;
}
.map-stop-node {
  width: 64px; height: 64px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  position: relative; box-shadow: 0 2px 6px rgba(59,42,26,.15);
}
.map-stop-node.open { background: var(--card); color: var(--ink); border: 3px solid var(--taupe); }
.map-stop-node.next {
  background: var(--card); color: var(--ink); border: 3px solid rgb(var(--pulse-color));
  animation: mapStopPulse 1.8s ease-in-out infinite;
}
.map-stop-node.complete { background: var(--wood); color: #fff; border: 3px solid var(--wood-dark); }
.map-stop-check {
  position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--wood); display: flex; align-items: center; justify-content: center;
  color: var(--wood); font-size: 12px; font-weight: 800;
}
@keyframes mapStopPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(var(--pulse-color), .22); }
  50% { box-shadow: 0 0 0 10px rgba(var(--pulse-color), .35); }
}
.map-stop-title {
  font: 700 12px "Fredoka", sans-serif; color: var(--ink-soft); line-height: 1.3;
  background: rgba(247,238,224,.92); padding: 2px 7px; border-radius: 8px;
}
.map-stop-stars { font-size: 12px; color: var(--gold); letter-spacing: 1px; }

@keyframes mvDrift { 0% { transform: translateX(0); } 50% { transform: translateX(14px); } 100% { transform: translateX(0); } }
@keyframes mvSway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes mvBob { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-5px) scale(1.04); } }

.map-traveler {
  position: absolute; width: 40px; height: 40px; margin-left: -20px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 3px 4px rgba(59,42,26,.35)); z-index: 2; pointer-events: none;
  animation: mvIdleBob 1.6s ease-in-out infinite;
}
.map-traveler-truck { font-size: 30px; display: block; }
.map-traveler.facing-left .map-traveler-truck { transform: scaleX(-1); }
.map-traveler.walking { animation: mvWalkBounce .3s ease-in-out infinite; }
@keyframes mvIdleBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes mvWalkBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
/* Bo riding along with the traveler, same pattern as .drive-bo-face --
   .map-traveler above is pointer-events:none so it never blocks taps on
   chapter icons, so the face opts back in on its own. */
.map-traveler-bo-face {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 15px; height: 15px; border-radius: 50%; pointer-events: auto; cursor: pointer;
  animation: sc-badge-wiggle 1.8s ease-in-out infinite;
}
.map-traveler-bo-hint {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 2px;
  font: 800 8px "Baloo 2", sans-serif; color: #fff; white-space: nowrap;
  background: #FF8A3D; padding: 1px 5px; border-radius: 7px 7px 7px 2px;
  pointer-events: none; animation: driveBoHintPop 3.2s ease-out infinite;
}

/* ---------- Drive Mode ---------- */
.drive-hud { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.drive-hud-pill {
  font: 700 13px "Fredoka", sans-serif; color: var(--ink);
  background: var(--card); padding: 4px 10px; border-radius: 14px;
  box-shadow: 0 2px 4px rgba(59,42,26,.12);
}
.drive-world {
  position: relative; width: 100%; height: calc(100vh - 175px); min-height: 380px;
  margin-top: 8px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(180deg, #f2e9d8 0%, var(--cream) 100%);
  box-shadow: inset 0 0 0 3px var(--taupe);
}
.drive-scenery {
  position: absolute; transform: translate(-50%, -50%);
  z-index: 1; pointer-events: none; opacity: .85;
}
.drive-car {
  position: absolute; width: 38px; height: 38px; margin-left: -19px; margin-top: -19px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 3px 4px rgba(59,42,26,.35)); z-index: 5;
  transition: transform .12s ease-out;
}
.drive-car.bitten { animation: driveBitten .35s ease-in-out 3; }
@keyframes driveBitten {
  0%, 100% { filter: drop-shadow(0 3px 4px rgba(59,42,26,.35)); }
  50% { filter: drop-shadow(0 0 8px var(--bad)) brightness(1.3); }
}

/* MOCKUP ONLY — Bo riding in the windshield + tap hint, mirrors the
   hub landing page's Bo avatar + "RAWR!"-style popup. */
.drive-bo-face {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 13px; height: 13px; border-radius: 50%; pointer-events: none;
  animation: sc-badge-wiggle 1.8s ease-in-out infinite;
}
.drive-bo-hint {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 2px;
  font: 800 9px "Baloo 2", sans-serif; color: #fff; white-space: nowrap;
  background: #FF8A3D; padding: 1px 6px; border-radius: 8px 8px 8px 2px;
  pointer-events: none; animation: driveBoHintPop 3.2s ease-out infinite;
}
@keyframes sc-badge-wiggle {
  0%, 100% { transform: translateX(-50%) rotate(-8deg); }
  50% { transform: translateX(-50%) rotate(8deg); }
}
@keyframes driveBoHintPop {
  0% { opacity: 0; transform: translate(-50%, 10%) scale(.5); }
  10% { opacity: 1; transform: translate(-50%, -15%) scale(1.1); }
  15% { transform: translate(-50%, -10%) scale(1); }
  35% { opacity: 1; }
  45%, 100% { opacity: 0; transform: translate(-50%, -25%) scale(1); }
}

/* Persistent Bo on the question screen, same pattern as azkacraft's
   .game-bo -- tap opens the shared #drive-bo-chat panel. */
.game-bo {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  right: 14px;
  z-index: 50;
  width: 40px;
  height: 40px;
  cursor: pointer;
}
.game-bo-face {
  width: 100%; height: 100%; border-radius: 50%; display: block;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  animation: sc-badge-wiggle 1.8s ease-in-out infinite;
}
.game-bo-hint {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 2px;
  font: 800 9px "Baloo 2", sans-serif; color: #fff; white-space: nowrap;
  background: #FF8A3D; padding: 1px 6px; border-radius: 8px 8px 8px 2px;
  pointer-events: none; animation: driveBoHintPop 3.2s ease-out infinite;
}

.sc-bo-chat {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(92%, 320px);
  background: #fff; border-radius: 18px; box-shadow: 0 10px 28px rgba(0,0,0,.22);
  z-index: 200; overflow: hidden;
  animation: scBoChatPopIn .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes scBoChatPopIn {
  0% { opacity: 0; transform: translateX(-50%) scale(.9) translateY(10px); }
  100% { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}
.sc-bo-chat-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #f3ede1; }
.sc-bo-chat-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,.15);
  animation: sc-badge-wiggle 1.8s ease-in-out infinite;
}
.sc-bo-chat-close {
  margin-left: auto; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: rgba(0,0,0,.08);
  font-size: 11px; line-height: 1; cursor: pointer; color: #8a6d3a;
  display: flex; align-items: center; justify-content: center;
}
.sc-bo-chat-thread { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; max-height: 180px; overflow-y: auto; }
.sc-bo-msg {
  display: flex; align-items: flex-start; gap: 6px; max-width: 88%;
  font: 600 12.5px "Baloo 2", sans-serif; line-height: 1.3;
  animation: scBoMsgIn .2s ease;
}
@keyframes scBoMsgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.sc-bo-msg-bo { align-self: flex-start; color: #6b5a3e; }
.sc-bo-msg-avatar { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; margin-top: 1px; }
.sc-bo-msg-bo .sc-bo-msg-text { background: rgba(193,121,62,.1); border-radius: 10px; padding: 6px 9px; }
.sc-bo-msg-kid { align-self: flex-end; color: #fff; }
.sc-bo-msg-kid .sc-bo-msg-text { background: #8a6d3a; border-radius: 10px; padding: 6px 9px; }
.sc-bo-chat-loading { display: flex; gap: 3px; padding: 0 12px 8px; }
.sc-bo-chat-loading.hidden { display: none; }
.sc-bo-chat-loading span { width: 5px; height: 5px; border-radius: 50%; background: #b9a98a; animation: scBoDotBounce 1.2s ease-in-out infinite; }
.sc-bo-chat-loading span:nth-child(2) { animation-delay: .15s; }
.sc-bo-chat-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes scBoDotBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
.sc-bo-chat-form { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid rgba(0,0,0,.06); }
.sc-bo-chat-input {
  flex: 1; border: 1.5px solid #e5dcc8; border-radius: 999px; padding: 7px 12px;
  font: 600 12.5px "Baloo 2", sans-serif; color: #6b5a3e; outline: none; min-width: 0;
}
.sc-bo-chat-input:focus { border-color: #c1793e; }
.sc-bo-chat-send {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; border: none;
  background: #c1793e; color: #fff; font-size: 14px; cursor: pointer;
}
.drive-dino {
  position: absolute; width: 34px; height: 34px; margin-left: -17px; margin-top: -17px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 3px 4px rgba(59,42,26,.35)); z-index: 4;
  transition: transform .12s ease-out;
}
.dino-leg { transform-box: fill-box; transform-origin: top center; }
.drive-dino.walking .dino-leg-l { animation: dinoLegSwing .3s ease-in-out infinite; }
.drive-dino.walking .dino-leg-r { animation: dinoLegSwing .3s ease-in-out infinite reverse; }
.drive-dino.soaked {
  filter: drop-shadow(0 3px 4px rgba(59,42,26,.35)) saturate(1.6) brightness(0.9) hue-rotate(-10deg);
}
@keyframes dinoLegSwing {
  0%, 100% { transform: rotate(-20deg); }
  50% { transform: rotate(20deg); }
}
.drive-toast {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: var(--bad); color: #fff; font: 700 13px "Fredoka", sans-serif;
  padding: 6px 14px; border-radius: 14px; z-index: 9;
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
  animation: driveToastPop .3s ease-out;
}
@keyframes driveToastPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.drive-obstacle {
  position: absolute; width: 32px; height: 32px; margin-left: -16px; margin-top: -16px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; z-index: 3;
}
.drive-city {
  position: absolute; width: 58px; height: 58px; margin-left: -29px; margin-top: -29px;
  display: flex; align-items: center; justify-content: center; font-size: 36px; z-index: 2;
}
.drive-city::before {
  content: ""; position: absolute; inset: -8px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(247,197,72,.4) 0%, rgba(247,197,72,0) 70%);
  animation: driveCityGlowRing 2.4s ease-in-out infinite;
}
@keyframes driveCityGlowRing {
  0%, 100% { opacity: .55; transform: scale(.88); }
  50% { opacity: 1; transform: scale(1.18); }
}
.drive-city > span:first-child {
  animation: driveCityGlow 2.4s ease-in-out infinite;
}
@keyframes driveCityGlow {
  0%, 100% { filter: drop-shadow(0 2px 3px rgba(59,42,26,.3)) drop-shadow(0 0 3px rgba(247,197,72,.3)); }
  50% { filter: drop-shadow(0 2px 3px rgba(59,42,26,.3)) drop-shadow(0 0 15px rgba(247,197,72,1)); }
}
.drive-city-check {
  position: absolute; top: -4px; right: -4px; font-size: 15px;
}
.drive-city-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px;
  font: 700 9px "Fredoka", sans-serif; color: var(--ink-soft); white-space: nowrap;
  background: rgba(247,238,224,.92); padding: 1px 5px; border-radius: 6px;
}

.joystick {
  position: absolute; left: 10px; bottom: 14px; width: 92px; height: 92px;
  border-radius: 50%; background: rgba(247,238,224,.6); touch-action: none; user-select: none;
  box-shadow: 0 2px 4px rgba(59,42,26,.15), inset 0 0 0 3px rgba(216,199,174,.85); z-index: 8;
}
.joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; border-radius: 50%;
  background: var(--wood); box-shadow: 0 2px 5px rgba(59,42,26,.3);
  transform: translate(-50%, -50%); pointer-events: none;
}

/* Plane Mode's own steering stick only, +20% -- per feedback it felt too
   small/fiddly to control precisely. Drive Mode's joystick (same shared
   .joystick class) is untouched. */
#plane-joystick { width: 121px; height: 121px; }
#plane-joystick .joystick-knob { width: 55px; height: 55px; }

/* Right-side controls: aim stick (water gun) + nitro button, mirroring
   the steering joystick's bottom-left placement. */
.drive-right-controls {
  position: absolute; right: 10px; bottom: 14px; z-index: 8;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.drive-aim-joystick {
  position: static; /* .joystick sets position:absolute+left/bottom -- this stick sits in the flex column instead */
  overflow: hidden;
}
.drive-aim-joystick.cooling { opacity: .5; }
/* Radial water-tank gauge: a bottom-up fill clipped to the stick's circle. */
.drive-water-fill-track {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden; pointer-events: none;
}
.drive-water-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background: rgba(90,170,220,.35);
  transition: height .1s linear;
}

.drive-nitro-btn {
  position: relative; width: 56px; height: 56px; border-radius: 50%; border: none;
  background: rgba(247,238,224,.6); touch-action: none; user-select: none; cursor: pointer;
  box-shadow: 0 2px 4px rgba(59,42,26,.15), inset 0 0 0 3px rgba(216,199,174,.85);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.drive-nitro-btn:active { transform: scale(0.94); }
.drive-nitro-btn.empty { opacity: .5; }
.drive-nitro-icon { position: relative; font-size: 22px; z-index: 1; filter: drop-shadow(0 1px 2px rgba(59,42,26,.3)); }
.drive-nitro-fill-track {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden; pointer-events: none;
}
.drive-nitro-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background: rgba(247,197,72,.45);
  transition: height .1s linear;
}

/* Water stream: a narrow, long CSS triangle (fire-truck-hose jet, not a
   splash cone) tinted blue, anchored at the car and rotated to the aim
   angle each frame. Un-rotated, it points "down" the screen (see the
   rotation math in driveWaterTick, which is calibrated to that default
   rather than driveHeadingCss's nose-up convention). Size matches
   DRIVE_WATER_RANGE_PX/DRIVE_WATER_CONE_RAD in script.js -- keep both
   in sync if either changes. */
.drive-water-stream {
  position: absolute; width: 0; height: 0; z-index: 6; pointer-events: none;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 128px solid rgba(120, 200, 240, 0.4);
  transform-origin: 50% 0%;
  margin-left: -10px;
  animation: driveWaterFlow .25s linear infinite;
}
@keyframes driveWaterFlow {
  0%, 100% { opacity: .55; }
  50% { opacity: .85; }
}

.drive-question-overlay {
  position: fixed; inset: 0; background: rgba(59,42,26,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.drive-question-card {
  background: var(--card); border-radius: 20px; padding: 20px; max-width: 360px; width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.drive-question-prompt {
  font: 700 18px/1.35 "Baloo 2", sans-serif; color: var(--ink); margin-bottom: 16px; text-align: center;
}
.plane-respawn-title {
  font: 800 16px/1.35 "Baloo 2", sans-serif; color: var(--ink); margin-bottom: 6px; text-align: center;
}
.plane-respawn-progress {
  font: 700 14px "Baloo 2", sans-serif; color: var(--accent, #e8703a); margin-bottom: 14px; text-align: center;
}
.drive-countdown {
  position: fixed; inset: 0; background: rgba(59,42,26,.5); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.drive-countdown-number {
  font: 800 88px "Baloo 2", sans-serif; color: #fff;
  text-shadow: 0 4px 12px rgba(0,0,0,.35);
  animation: driveCountdownPop .7s ease;
}
.drive-countdown-number.go { color: var(--gold); }
@keyframes driveCountdownPop {
  0% { transform: scale(0.4); opacity: 0; }
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
/* Focus Round topic picker (cross-subject: mathville + azkacraft +
   azkauniverse, mirrors brain-box's "Box" builder). Deliberately does
   NOT use mathville's wood/cream Baloo2+Fredoka theme -- this feature
   reaches outside MathVille into the other 2 games, so it's styled
   after the HUB's own landing-page look (Baloo 2 + Nunito, soft
   pastel-card palette) instead, leaning into the lavender accent its
   own hub card uses. Nunito is loaded in index.html's font link
   specifically for this. */
.focus-round-full .focus-round-card { max-width: 420px; }
.focus-round-card {
  text-align: center; max-height: 88vh; display: flex; flex-direction: column;
  background: linear-gradient(165deg, #ffffff 0%, #faf6ff 100%);
}
.focus-round-card .drive-difficulty-title {
  font: 800 20px "Baloo 2", sans-serif; color: #6b3f9b;
}
.focus-round-subtitle {
  font: 600 13px "Nunito", sans-serif; color: #8c7aa8; margin: -8px 0 14px; text-align: left;
}

.focus-round-picked {
  border: 2px dashed #d9c4f2; background: #faf5ff; border-radius: 14px;
  padding: 10px 12px; margin-bottom: 14px; text-align: left;
}
.focus-round-picked-count { font: 800 12px "Nunito", sans-serif; color: #8c7aa8; margin-bottom: 8px; }
.focus-round-picked-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.focus-round-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font: 700 11px "Nunito", sans-serif; padding: 5px 6px 5px 10px; border-radius: 999px; white-space: nowrap;
}
.focus-round-pill-x {
  border: none; background: rgba(0,0,0,.1); color: inherit; width: 15px; height: 15px;
  border-radius: 50%; font-size: 9px; line-height: 1; cursor: pointer; padding: 0;
}
.focus-round-item.focus-round-item-hidden { display: none; }
.focus-round-pill-math { background: rgba(74,144,217,.16); color: #2E6BA3; }
.focus-round-pill-lang { background: rgba(194,62,130,.14); color: #C23E82; }
.focus-round-pill-sci { background: rgba(63,168,74,.16); color: #2A7A32; }

/* 2-per-row grid, same density as the brain-box reference -- group
   labels span both columns via grid-column: 1 / -1. */
.focus-round-list {
  overflow-y: auto; margin-bottom: 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 8px;
}
.focus-round-group-label {
  grid-column: 1 / -1;
  font: 800 11px "Nunito", sans-serif; letter-spacing: .04em; text-transform: uppercase;
  color: #8c7aa8; text-align: left; margin: 10px 0 0;
}
.focus-round-group-label:first-child { margin-top: 0; }
.focus-round-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border-radius: 12px; padding: 9px 10px; cursor: pointer; text-align: left;
  box-shadow: inset 0 0 0 2px transparent;
}
.focus-round-item-math { background: rgba(74,144,217,.14); }
.focus-round-item-lang { background: rgba(194,62,130,.12); }
.focus-round-item-sci { background: rgba(63,168,74,.14); }
.focus-round-item:has(input:checked) { box-shadow: inset 0 0 0 2px #9b6fd1; }
.focus-round-item input { display: none; }
.focus-round-emoji {
  font-size: 15px; width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(59,42,26,.12);
}
.focus-round-name { font: 700 12.5px "Nunito", sans-serif; color: #3d2e22; line-height: 1.2; }

/* Dedicated (smaller) CTA buttons instead of mathville's chunky global
   .btn -- those are sized for a full-screen "Continue"/"Check" action,
   way oversized next to this popup's compact 2-column topic grid.
   Press-shadow style matches the hub's own .sc-auth-submit button. */
.focus-round-start {
  width: 100%; margin-top: 14px; margin-bottom: 8px; border: none; cursor: pointer;
  font: 800 14px "Baloo 2", sans-serif; color: #4a2d70; background: #d9c4f2;
  padding: 12px 0; border-radius: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.08);
  transition: transform .15s ease;
}
.focus-round-start:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.focus-round-start:disabled { background: #ece4f7; color: #b3a3c9; box-shadow: none; cursor: default; }
.focus-round-cancel {
  width: 100%; border: 2px solid #e4d4f7; background: #fff; cursor: pointer;
  font: 700 13px "Nunito", sans-serif; color: #8c7aa8; padding: 10px 0; border-radius: 14px;
}
.focus-round-cancel:active { background: #faf5ff; }

.drive-difficulty-card { text-align: center; }
.drive-difficulty-title { font: 800 20px "Baloo 2", sans-serif; color: var(--ink); margin-bottom: 16px; }
.drive-difficulty-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: none; background: var(--cream); border-radius: 14px; padding: 12px 16px;
  margin-bottom: 10px; cursor: pointer; text-align: left;
  box-shadow: 0 3px 0 rgba(59,42,26,.1);
  transition: transform .12s ease;
}
.drive-difficulty-btn:last-child { margin-bottom: 0; }
.drive-difficulty-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(59,42,26,.1); }
.drive-difficulty-emoji { font-size: 26px; }
.drive-difficulty-name { font: 800 16px "Baloo 2", sans-serif; color: var(--ink); }
.drive-difficulty-desc { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.drive-end-card { text-align: center; }
.drive-end-emoji { font-size: 52px; margin-bottom: 6px; }
.drive-end-title { font: 800 22px "Baloo 2", sans-serif; color: var(--ink); margin-bottom: 6px; }
.drive-end-sub { font-size: 14px; color: var(--ink-soft); margin-bottom: 18px; }
#drive-end-overlay.lost .drive-end-title { color: var(--bad); }

/* Vehicle skin picker (step 2 of the vehicle overlay) -- 5-card grid per
   category, each previewing the real sprite with the same glow animation
   it'll have in-game. */
.vehicle-skin-back {
  display: block; border: none; background: none; cursor: pointer;
  font: 700 13px "Fredoka", sans-serif; color: var(--ink-soft); margin-bottom: 8px; padding: 0;
}
.vehicle-skin-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.vehicle-skin-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px solid transparent; background: var(--cream); border-radius: 14px;
  padding: 10px 6px; cursor: pointer; box-shadow: 0 3px 0 rgba(59,42,26,.1);
  transition: transform .12s ease;
}
.vehicle-skin-card:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(59,42,26,.1); }
.vehicle-skin-card.active { border-color: var(--vehicle-glow, var(--wood)); }
.vehicle-skin-thumb { display: flex; align-items: center; justify-content: center; height: 40px; }
.vehicle-skin-thumb svg { width: auto; height: 36px; }
.vehicle-skin-name { font: 700 11px "Fredoka", sans-serif; color: var(--ink); }

/* Signature glow, shared by both the picker thumbnails and the actual
   in-game sprite -- --vehicle-glow is set per-skin in JS (applyVehicleSkin/
   renderVehicleSkinGrid), so this one animation covers every skin. */
.vehicle-glow svg {
  animation: vehicleGlowPulse 1.8s ease-in-out infinite;
}
@keyframes vehicleGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 2px var(--vehicle-glow, transparent)); }
  50% { filter: drop-shadow(0 0 8px var(--vehicle-glow, transparent)); }
}

/* ---------- Chapter Intro ---------- */
.intro-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.intro-icon {
  flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--wood);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.intro-title { font: 800 19px "Baloo 2", sans-serif; color: var(--ink); }
.intro-location { font-size: 13px; color: var(--ink-soft); }
.intro-body { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.mascot-badge {
  flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--taupe);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
}
.intro-text {
  flex: 1; background: var(--card); border-radius: 16px; border-top-left-radius: 4px;
  padding: 16px; font-size: 15px; line-height: 1.5; box-shadow: 0 1px 4px rgba(59,42,26,.08);
}

.intro-demo {
  background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(59,42,26,.08);
}
.intro-demo-label { font: 700 12px "Fredoka", sans-serif; color: var(--ink-soft); margin-bottom: 10px; }
.intro-demo-row { display: flex; gap: 6px; justify-content: center; align-items: flex-start; }
.intro-demo-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.intro-demo-digit {
  width: 100%; aspect-ratio: 1; max-width: 44px; border-radius: 10px; background: var(--wood);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font: 800 20px "Baloo 2", sans-serif;
}
.intro-demo-place { font: 700 9px/1.2 "Fredoka", sans-serif; color: var(--ink); text-align: center; }
.intro-demo-sep { font: 800 24px "Baloo 2", sans-serif; color: var(--taupe); align-self: flex-start; margin-top: 6px; }

/* "steps" demo type: a short vertical worked-example walkthrough,
   used by every chapter except Place Value (which keeps its own
   digit/place-label grid above). */
.intro-demo-row-steps {
  display: flex; flex-direction: column; gap: 6px; align-items: stretch;
}
.intro-demo-step {
  font: 600 14px "Fredoka", sans-serif; color: var(--ink-soft);
  padding: 4px 2px;
}
.intro-demo-step-final {
  font-weight: 800; color: var(--wood-dark);
  border-top: 2px dashed var(--taupe); padding-top: 8px; margin-top: 2px;
}
/* Column arithmetic (addition/subtraction/multiplication/measurement)
   reads best right-aligned in a monospace font so the digits actually
   line up like they would on paper. */
.intro-demo-row-mono .intro-demo-step {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  text-align: right; white-space: pre; font-size: 15px;
}

/* ---------- Question screen ---------- */
.q-label { font: 700 12px "Fredoka", sans-serif; color: var(--ink-soft); margin-bottom: 14px; }
.q-prompt { font: 700 21px/1.4 "Baloo 2", sans-serif; color: var(--ink); margin-bottom: 20px; }
.q-image:empty { display: none; }
.q-image { margin-bottom: 16px; text-align: center; }
.q-image svg { max-width: 100%; width: 260px; height: auto; display: inline-block; }
.ui-block { }

/* typein */
.keypad-display {
  min-height: 48px; font: 800 30px "Baloo 2", sans-serif; text-align: center;
  background: var(--card); border-radius: 14px; padding: 10px; margin-bottom: 14px;
  box-shadow: inset 0 1px 4px rgba(59,42,26,.08);
}
.kd-placeholder { color: var(--taupe); }
.keypad-display.correct-flash { outline: 3px solid var(--good); }
.keypad-display.wrong-flash { outline: 3px solid var(--bad); }
#typein-reveal { min-height: 18px; font-size: 13px; color: var(--bad); text-align: center; margin-bottom: 8px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  padding: 16px; border: none; border-radius: 14px; background: var(--card);
  font: 700 20px "Fredoka", sans-serif; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 3px rgba(59,42,26,.08);
}
.key.back { background: var(--taupe); color: var(--ink); }
.key.ent { background: var(--wood); color: #fff; }

/* mc */
.mc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mc-btn {
  padding: 18px; border: 3px solid transparent; border-radius: 14px; background: var(--card);
  font: 700 16px "Fredoka", sans-serif; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 3px rgba(59,42,26,.08);
}
.mc-btn.correct { border-color: var(--good); background: #e9f6ee; color: #1f5c3a; }
.mc-btn.wrong { border-color: var(--bad); background: #fdeaea; color: #8c2a2a; }

/* tap */
.tap-markers { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.tap-marker {
  min-width: 64px; padding: 12px 16px; border-radius: 30px; border: 3px solid transparent;
  background: var(--card); font: 700 14px "Fredoka", sans-serif; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 3px rgba(59,42,26,.08);
}
.tap-marker.correct { border-color: var(--good); background: #e9f6ee; color: #1f5c3a; }
.tap-marker.wrong { border-color: var(--bad); background: #fdeaea; color: #8c2a2a; }

/* match (drag-line) */
.match-wrap { position: relative; width: 100%; touch-action: none; }
.match-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.match-col { position: absolute; top: 0; width: 62%; display: flex; flex-direction: column; }
.match-col-left { left: 0; }
.match-col-right { right: 0; align-items: flex-end; }
.match-item {
  position: absolute; display: flex; align-items: center; gap: 8px; width: 100%;
}
.match-col-right .match-item { justify-content: flex-end; }
.match-label {
  font: 700 13px "Fredoka", sans-serif; color: var(--ink); background: var(--card);
  padding: 8px 10px; border-radius: 10px; box-shadow: 0 1px 3px rgba(59,42,26,.08);
}
.match-dot {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--card);
  border: 3px solid var(--cherry); box-sizing: border-box; cursor: pointer; touch-action: none;
}
.match-col-left .match-dot { border-color: var(--wood); cursor: grab; }
.match-dot.connected { background: var(--wood); border-color: var(--wood); }
.match-col-right .match-dot.connected { background: var(--wood); border-color: var(--wood); }
.match-dot.wrong-flash { background: #fdeaea; border-color: var(--bad); }

/* ---------- Reward ---------- */
.reward-title { text-align: center; font: 800 22px "Baloo 2", sans-serif; margin-top: 20px; }
.reward-stars { text-align: center; font-size: 40px; letter-spacing: 8px; color: var(--gold); margin: 12px 0; }
.reward-xp { text-align: center; font: 700 15px "Fredoka", sans-serif; color: var(--wood-dark); margin-bottom: 12px; }

.ai-hint-card {
  background: linear-gradient(135deg, #fff 0%, var(--cream) 100%);
  border-radius: 16px; padding: 16px; margin: 12px 0; box-shadow: 0 1px 4px rgba(59,42,26,.08);
  cursor: pointer;
}
.ai-hint-card.chat-open { cursor: default; }
.ai-hint-badge { font: 700 12px "Fredoka", sans-serif; color: var(--cherry); margin-bottom: 8px; }
.ai-hint-tap-cue {
  font: 700 11px "Fredoka", sans-serif; color: var(--wood); opacity: .7;
  margin-top: 6px;
}
.ai-hint-card.chat-open .ai-hint-tap-cue { display: none; }
.ai-hint-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.ai-hint-dots { display: inline-flex; gap: 3px; }
.ai-hint-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--cherry);
  animation: aiHintBounce 1.2s ease-in-out infinite;
}
.ai-hint-dots span:nth-child(2) { animation-delay: .15s; }
.ai-hint-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes aiHintBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes aiHintFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.ai-hint-thread { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.ai-hint-msg {
  font-size: 14px; line-height: 1.5; margin: 0; padding: 8px 12px; border-radius: 12px;
  animation: aiHintFadeIn .3s ease; max-width: 88%;
}
.ai-hint-msg-ai {
  font-style: italic; color: var(--ink-soft); background: rgba(193,121,62,.08);
  border-bottom-left-radius: 4px; align-self: flex-start;
  display: flex; align-items: flex-start; gap: 8px;
}
.ai-hint-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: #fff; object-fit: contain; margin-top: 1px;
}
.ai-hint-msg-text { flex: 1; }
.ai-hint-msg-kid {
  color: #fff; background: var(--wood); font-weight: 600;
  border-bottom-right-radius: 4px; align-self: flex-end;
}

.ai-hint-followups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-hint-chip {
  border: 2px solid var(--taupe); background: var(--card); color: var(--wood-dark);
  font: 700 12px "Fredoka", sans-serif; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.ai-hint-chip:active { background: var(--cream); }

.ai-hint-form { display: flex; gap: 8px; margin-top: 10px; }
.ai-hint-input {
  flex: 1; padding: 10px 12px; border: 2px solid var(--taupe); border-radius: 14px;
  font: 600 13px "Fredoka", sans-serif; color: var(--ink);
}
.ai-hint-input:focus { outline: none; border-color: var(--wood); }
.ai-hint-send {
  width: 40px; height: 40px; border: none; border-radius: 50%; background: var(--wood);
  color: #fff; font-size: 16px; cursor: pointer; flex: none;
}
.ai-hint-send:active { background: var(--wood-dark); }

.mp-results { margin: 16px 0; }
.mp-result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--card); border-radius: 12px; margin-bottom: 8px;
  font: 700 14px "Fredoka", sans-serif; box-shadow: 0 1px 3px rgba(59,42,26,.06);
}

/* ---------- Plane Mode (Phase 1) — entirely separate from Drive Mode's
   .drive-world/.drive-car styling, on purpose. ---------- */
.plane-world {
  position: relative; width: 100%; height: calc(100vh - 175px); min-height: 380px;
  margin-top: 8px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(180deg, #1b2a52 0%, #3a5a8c 100%);
  box-shadow: inset 0 0 0 3px var(--taupe);
}
.plane-sky-layer {
  position: absolute; left: 0; width: 100%; height: 200%;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, rgba(255,255,255,.8), transparent),
    radial-gradient(1.5px 1.5px at 30% 60%, rgba(255,255,255,.6), transparent),
    radial-gradient(1px 1px at 50% 15%, rgba(255,255,255,.7), transparent),
    radial-gradient(2px 2px at 70% 45%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 85% 80%, rgba(255,255,255,.7), transparent),
    radial-gradient(1.5px 1.5px at 92% 30%, rgba(255,255,255,.6), transparent);
  background-repeat: repeat; background-size: 100% 50%;
}
.plane-sky-far { animation: planeSkyScroll 6s linear infinite; opacity: .5; }
.plane-sky-near { animation: planeSkyScroll 3s linear infinite; opacity: .85; }
@keyframes planeSkyScroll {
  from { transform: translateY(-50%); }
  to { transform: translateY(0%); }
}

.plane-ship {
  position: absolute; width: 32px; height: 32px; margin-left: -16px; margin-top: -16px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
  transition: transform .08s ease-out;
  z-index: 5;
}

.plane-bullet {
  position: absolute; width: 5px; height: 14px; margin-left: -2.5px; margin-top: -7px;
  background: linear-gradient(180deg, #fff6b0, #ffd93d);
  border-radius: 3px; box-shadow: 0 0 6px rgba(255,217,61,.8);
  z-index: 4;
}

.plane-enemy {
  position: absolute; width: 30px; height: 30px; margin-left: -15px; margin-top: -15px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
  z-index: 4;
}

.plane-enemy-bullet {
  position: absolute; width: 6px; height: 12px; margin-left: -3px; margin-top: -6px;
  background: linear-gradient(180deg, #ffb3c6, #e4572e);
  border-radius: 3px; box-shadow: 0 0 6px rgba(228,87,46,.8);
  z-index: 4;
}
/* Per-enemy-type bullet shapes (see PLANE_ENEMY_TYPES) so shots read as
   coming from different threats, not just the same pink rectangle every
   time. */
.plane-enemy-bullet.round {
  width: 10px; height: 10px; margin-left: -5px; margin-top: -5px; border-radius: 50%;
  background: radial-gradient(circle, #d9c1f6, #8a4fd6); box-shadow: 0 0 6px rgba(138,79,214,.8);
}
.plane-enemy-bullet.big {
  width: 11px; height: 18px; margin-left: -5.5px; margin-top: -9px;
  background: linear-gradient(180deg, #c1e8f6, #2e9ad9); box-shadow: 0 0 7px rgba(46,154,217,.8);
}
.plane-enemy-bullet.diamond {
  width: 10px; height: 10px; margin-left: -5px; margin-top: -5px;
  background: linear-gradient(180deg, #d9f6c1, #6db32e); box-shadow: 0 0 6px rgba(109,179,46,.8);
  transform: rotate(45deg); border-radius: 2px;
}
.plane-enemy-bullet.boss {
  width: 13px; height: 20px; margin-left: -6.5px; margin-top: -10px;
  background: linear-gradient(180deg, #ffe1a8, #ff5d8f); box-shadow: 0 0 9px rgba(255,93,143,.9);
}

.plane-ship.hit { animation: planeHit .35s ease-in-out 4; }

/* Wingmen power-up escorts -- smaller than the main ship, no hit/collision
   styling of their own since they're purely offensive (can't be shot). */
.plane-wingman {
  position: absolute; width: 20px; height: 20px; margin-left: -10px; margin-top: -10px;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.3));
  z-index: 5; opacity: .92;
}
@keyframes planeHit {
  0%, 100% { filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); opacity: 1; }
  50% { filter: drop-shadow(0 0 8px var(--bad)) brightness(1.4); opacity: .4; }
}

/* Phase 3 "juice" -- explosion burst + screen shake. */
.plane-explosion {
  position: absolute; width: 34px; height: 34px; margin-left: -17px; margin-top: -17px;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 6;
  animation: planeExplode .5s ease-out forwards;
}
.plane-explosion.big { width: 54px; height: 54px; margin-left: -27px; margin-top: -27px; font-size: 42px; }
@keyframes planeExplode {
  0% { transform: scale(.3); opacity: 1; }
  60% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1.7); opacity: 0; }
}

.plane-world.shake { animation: planeShake .3s ease-in-out; }
@keyframes planeShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 3px); }
}

/* Phase 5 -- power-ups + boss. */
.plane-powerup {
  position: absolute; width: 26px; height: 26px; margin-left: -13px; margin-top: -13px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  filter: drop-shadow(0 0 6px rgba(255,255,255,.7));
  z-index: 4;
}
.plane-boss {
  position: absolute; width: 56px; height: 56px; margin-left: -28px; margin-top: -28px;
  display: flex; align-items: center; justify-content: center; font-size: 42px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.4));
  z-index: 4;
}
.plane-boss-hp {
  width: 100%; height: 10px; border-radius: 6px; background: rgba(0,0,0,.25);
  margin-top: 8px; overflow: hidden;
}
.plane-boss-hp-fill {
  height: 100%; width: 100%; background: linear-gradient(90deg, #ff5d8f, #e4572e);
  transition: width .2s ease-out;
}

#plane-end-overlay.lost .drive-end-title { color: var(--bad); }

/* Positive-feeling variant of .drive-toast, used for the "Boss defeated!"
   milestone rather than Drive Mode's warning-red default. */
.plane-toast-good { background: var(--wood); }

.mp-result-row.me { border: 2px solid var(--wood); }
