/* ==========================================================================
   Grammar Quest — UI stylesheet
   Gameplay = whack-a-mole: mascots pop out of holes with sentence bubbles.
   Design: purple/blue brand, gold rewards, green success, red/pink mistakes,
   clean fantasy scene, compact HUD, light feedback. Boston English Center.
   ========================================================================== */

/* ------------------------------ 1. Tokens ------------------------------ */
:root {
  --brand-900: #241A4A;
  --brand-800: #32255E;
  --brand-700: #4B3596;
  --brand-600: #5B41BE;
  --brand-500: #7C5CFF;
  --brand-300: #B9A5FF;
  --blue-500: #4FA3FF;
  --blue-300: #9CCBFF;
  --gold-500: #FFC531;
  --gold-600: #F0A81C;
  --green-700: #3E9D5C;
  --green-600: #2F8F4E;
  --green-500: #35C46E;
  --green-300: #8FDB8F;
  --red-500: #FF5D73;
  --red-600: #E8445C;
  --ink-900: #2A2140;
  --ink-600: #4E4570;
  --ink-300: #8B84A8;
  --paper: #FFFFFF;
  --paper-soft: #F4F1FF;

  --grad-brand: linear-gradient(135deg, #5B41BE 0%, #4B3596 55%, #37287A 100%);
  --grad-gold: linear-gradient(180deg, #FFDE7A 0%, #FFC531 55%, #F0A81C 100%);
  --grad-green: linear-gradient(180deg, #4CD986 0%, #35C46E 60%, #23A657 100%);
  --grad-danger: linear-gradient(180deg, #FF8296 0%, #FF5D73 60%, #E8445C 100%);

  --shadow-soft: 0 4px 14px rgba(43, 27, 96, 0.14);
  --shadow-card: 0 10px 30px rgba(43, 27, 96, 0.18);
  --shadow-pop: 0 14px 34px rgba(43, 27, 96, 0.28);
  --glow-gold: 0 0 0 4px rgba(255, 197, 49, 0.45);

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --radius-pill: 999px;

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  --tap: 44px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* ------------------------------ 2. Reset ------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The hidden attribute must ALWAYS win. Component classes that set their own
   `display` (feedback card, binary paddles, streak chip…) would otherwise
   override the browser's default [hidden] { display: none } and keep
   "hidden" elements painted on screen — e.g. the verdict card showing up
   before the player has answered. Every show/hide in ui.js drives this
   attribute, so it has to stay authoritative. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html {
  height: 100%;
}

/* App shell: pin the body to the viewport so no webview dvh/ICB rounding
   can ever make the page taller than the visible area. */
body {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink-900);
  background: var(--grad-brand);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Touch ergonomics: no double-tap-zoom delay on controls, no iOS tap flash,
 * no accidental text-selection drags during gameplay. Pinch zoom itself is
 * left enabled for accessibility. */
button,
.mole,
.paddle,
.intro__start,
.challenge-card__start,
.pause-pill,
.icon-btn,
.btn-home-primary,
.btn-home-secondary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

/* Game screens must never rubber-band or scroll-chain on mobile webviews;
   the map viewport keeps its own controlled scrolling. */
.app {
  overscroll-behavior: none;
}

/* --------------------- 2B. SVG icon system (sprite) --------------------
 * Every icon references a <symbol> in the index.html sprite. Stroke icons
 * inherit currentColor; filled symbols use fill="currentColor". Size comes
 * from the width/height attributes set at render time or from context CSS. */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;
  pointer-events: none;
}

.icon--gold { color: var(--gold-500); }
.icon--red { color: var(--red-500); }
.star--empty { opacity: 0.45; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

ul { list-style: none; }

:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------- 3. Screen system -------------------------- */
.app {
  position: relative;
  width: min(100%, 1400px);
  margin-inline: auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100%; /* guards against webview dvh rounding on fractional DPRs */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Let the illustrated map and play field reach both edges on desktop.
   Smaller breakpoints keep their existing viewport-specific layouts. */
@media (min-width: 1025px) {
  .app {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--sat);
  padding-bottom: var(--sab);
  animation: screen-in 260ms ease both;
}

.screen[hidden] { display: none; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Shared screen header */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: clamp(10px, 2vh, 18px) clamp(14px, 3vw, 24px);
  color: #fff;
}

.screen-header__titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.screen-header__title {
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen-header__subtitle {
  font-size: clamp(0.8rem, 1.8vw, 0.95rem);
  color: var(--blue-300);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-total {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.star-total .icon { width: 22px; height: 22px; }

/* ------------------------------ 4. Buttons ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 1rem;
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
  text-align: center;
}

.btn:active { transform: translateY(2px) scale(0.98); }

.btn--primary {
  background: var(--grad-gold);
  color: var(--brand-900);
  box-shadow: 0 6px 18px rgba(240, 168, 28, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.btn--primary:hover { filter: brightness(1.05); }

.btn--secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.55);
}
.btn--secondary:hover { background: rgba(255, 255, 255, 0.2); }

.btn--danger { background: var(--grad-danger); color: #fff; }
.btn--danger-ghost { color: var(--red-500); border: 2px solid currentColor; }
.btn--ghost { color: rgba(255, 255, 255, 0.85); border: 2px solid rgba(255, 255, 255, 0.35); }

.btn--xl {
  min-height: 58px;
  font-size: clamp(1.05rem, 2.4vw, 1.2rem);
  padding: 12px 30px;
}

.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(20, 12, 48, 0.35);
}
.icon-btn:active { transform: translateY(0) scale(0.92); }
.icon-btn .icon { width: 24px; height: 24px; transition: transform 320ms cubic-bezier(0.34, 1.3, 0.64, 1); }
.icon-btn--gear:hover .icon { transform: rotate(45deg); }
.icon-btn--solid { background: var(--brand-700); border-color: var(--brand-500); }
.icon-flip-x { transform: scaleX(-1); }
.icon-btn__glyph { font-size: 1.2rem; font-weight: 800; color: #fff; }

/* Switch */
.switch {
  width: 56px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--ink-300);
  position: relative;
  transition: background 160ms ease;
  flex-shrink: 0;
}

.switch[aria-checked="true"] { background: var(--green-500); }

.switch__knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease;
}

.switch[aria-checked="true"] .switch__knob { transform: translateX(24px); }

/* --------------------------- 5. Loading / error ------------------------ */
.screen--loading,
.screen--error {
  align-items: center;
  justify-content: center;
  background: var(--grad-brand);
  color: #fff;
  text-align: center;
  padding: 24px;
}

/* Soft fantasy artwork behind the loader (non-blocking, dimmed + blurred
 * so text always wins). WebP first via image-set, JPEG fallback. */
.loading__scene {
  position: absolute;
  inset: 0;
  background: url("../assets/images/loading-scene.jpg") center / cover no-repeat;
  opacity: 0.28;
  filter: saturate(0.9) blur(1.5px);
  pointer-events: none;
}
@supports (background-image: image-set("a.webp" type("image/webp"))) {
  .loading__scene {
    background-image: image-set(
      url("../assets/images/loading-scene.webp") type("image/webp"),
      url("../assets/images/loading-scene.jpg") type("image/jpeg")
    );
  }
}
/* vignette keeps the centered content readable over the artwork */
.screen--loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(75% 60% at 50% 42%, rgba(24, 14, 66, 0.1), rgba(24, 14, 66, 0.78) 100%),
    linear-gradient(180deg, rgba(24, 14, 66, 0.35), rgba(24, 14, 66, 0.6));
  pointer-events: none;
}

.loading {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92%, 420px);
}

/* Prairie dog mascot popping out of its hole while the game loads */
.loading__mascot {
  position: relative;
  width: 132px;
  height: 132px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: loading-bob 2.6s ease-in-out infinite;
  will-change: transform;
}
.loading__mascot img {
  width: 118px;
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 18px rgba(6, 3, 24, 0.55));
  animation: loading-peek 2.6s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.loading__hole {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(8, 4, 26, 0.85), rgba(8, 4, 26, 0) 72%);
}
@keyframes loading-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
@keyframes loading-peek {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.loading__title {
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-top: 18px;
  text-shadow: 0 3px 0 rgba(11, 6, 35, 0.55), 0 10px 28px rgba(6, 3, 24, 0.6);
}
.loading__status {
  color: var(--blue-300);
  margin-top: 6px;
  font-weight: 600;
  min-height: 1.4em; /* reserve the line so retry text never shifts layout */
}

.loading__progress {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 300px);
  margin-top: 18px;
}
.loading__bar {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 2px 4px rgba(6, 3, 24, 0.45);
  overflow: hidden;
}
.loading__bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-400, #9B7BFF), var(--gold-400, #FFC531));
  box-shadow: 0 0 12px rgba(255, 197, 49, 0.55);
  transition: width 260ms ease-out;
}
/* moving shine keeps the bar alive even between file settles */
.loading__bar-fill::after {
  content: "";
  display: block;
  height: 100%;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.5) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: loading-shine 1.6s linear infinite;
  border-radius: inherit;
}
@keyframes loading-shine {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.loading__pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  min-width: 3.2em;
  text-align: right;
  color: #FFE9B8;
}

.loading__retry { margin-top: 20px; }
.loading__retry[hidden] { display: none; }

.loading__brand {
  margin-top: 26px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* Fade-out beat when loading completes (ui.js adds .is-done). */
.screen--loading.is-done { animation: loading-out 340ms ease forwards; }
@keyframes loading-out {
  to { opacity: 0; transform: scale(1.03); }
}
/* Failure state: gentle shake so the Retry button draws the eye. */
.screen--loading.is-failed .loading__bar {
  background: rgba(255, 93, 115, 0.25);
}
.screen--loading.is-failed .loading { animation: loading-nudge 420ms ease; }
@keyframes loading-nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-7px); }
  60% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .loading__mascot,
  .loading__mascot img,
  .loading__bar-fill::after { animation: none; }
}
body.reduce-motion .loading__mascot,
body.reduce-motion .loading__mascot img,
body.reduce-motion .loading__bar-fill::after { animation: none; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.error-box { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.error-box__mascot { width: clamp(90px, 18vw, 130px); }
.error-box__title { font-size: clamp(1.3rem, 4vw, 1.6rem); font-weight: 800; }
.error-box__text { color: var(--blue-300); margin-bottom: 8px; overflow-wrap: break-word; }

/* ------------------------------- 6. Home ------------------------------- */

/* ========================= HOME / ENTRY SCREEN =========================
 * Premium fantasy-academy landing. Two-column hero on desktop:
 * text + progress + CTAs left, large transparent Prairie Dog right.
 * Background is layered CSS gradients (castle-atmosphere mood), NOT an
 * embedded screenshot. All progress values come from the game engine.
 * ====================================================================== */

.screen--home {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* The mascot bleeds off the true bottom edge (artwork is bottom-cropped);
     safe-area insets are handled per-element (brand) instead of as a band. */
  padding-bottom: 0;
}

/* ---- Painted fantasy-landscape background (supplied artwork) ---- */
.home-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: #8FBFE8; /* base while the artwork loads */
}

.home-scene__art {
  position: absolute;
  inset: 0;
  background: url("../assets/images/home-bg.jpg") center / cover no-repeat;
}
@supports (background-image: image-set("a.webp" type("image/webp"))) {
  .home-scene__art {
    background-image: image-set(
      url("../assets/images/home-bg.webp") type("image/webp"),
      url("../assets/images/home-bg.jpg") type("image/jpeg")
    );
  }
}

/* Soft navy scrims keep the copy readable over the busy painting: a gentle
   top+bottom veil by default (stacked phone layout), and a left-side veil on
   wide screens where the text column sits. */
.home-scene__scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(12, 26, 50, 0.42) 0%,
      rgba(12, 26, 50, 0.16) 26%,
      rgba(12, 26, 50, 0) 52%,
      rgba(12, 26, 50, 0.38) 100%);
}

@media (min-width: 901px) {
  .home-scene__scrim {
    background:
      linear-gradient(90deg,
        rgba(12, 26, 50, 0.52) 0%,
        rgba(12, 26, 50, 0.32) 30%,
        rgba(12, 26, 50, 0.04) 62%,
        rgba(12, 26, 50, 0.3) 100%),
      linear-gradient(180deg,
        rgba(12, 26, 50, 0.22) 0%,
        rgba(12, 26, 50, 0) 24%,
        rgba(12, 26, 50, 0) 66%,
        rgba(12, 26, 50, 0.4) 100%);
  }
}

/* Two-column hero via grid: copy + actions share the left column, the
   Prairie Dog owns the right column and spans both rows. Phone/tablet-port
   stacks copy -> mascot -> actions in one column (see media queries). */
.home-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 1.12fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "copy masc"
    "side masc";
  align-items: center;
  column-gap: clamp(16px, 3.5vw, 56px);
  width: min(100%, 1320px);
  margin-inline: auto;
  padding: clamp(12px, 2.5vh, 24px) clamp(16px, 4vw, 48px) 0; /* no dead band under the mascot */
  overflow-y: auto;
  overflow-x: clip;
}

.home-copy {
  grid-area: copy;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(8px, 1.6vh, 16px);
  text-align: left;
}

.home-side {
  grid-area: side;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(10px, 1.8vh, 18px);
}

/* RIGHT column: the hero Prairie Dog — large, transparent, anchored to the
   very bottom edge. The artwork is hard-cropped at its own bottom (no feet),
   so the character must BLEED a few px past the fold and get clipped there:
   the crop line then always sits below the visible edge and the dog reads as
   standing at the bottom of the scene instead of floating above it. */
.home-mascot-area {
  grid-area: masc;
  position: relative;
  min-width: 0;
  min-height: 0;
  align-self: stretch; /* always fill both grid rows so height caps resolve */
  display: flex;
  align-items: flex-end;   /* grounded: no air below the character */
  justify-content: flex-end; /* bottom-right anchor on desktop */
  padding-bottom: 0; /* the bleed handles idle swing; keep the fold flush */
  overflow: clip; /* the bleed + decorative glow/shadow never expand the page */
}

/* soft magical glow behind the character — subtle, never a visible circle */
.home-mascot-area__aura {
  position: absolute;
  right: clamp(0px, 1vw, 16px);
  bottom: 0;
  width: 92%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(147, 93, 255, 0.32),
    rgba(147, 93, 255, 0.1) 46%,
    transparent 72%);
  animation: aura-breathe 5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes aura-breathe {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.045); }
}

/* soft contact shadow right at the floor line — no offset, no gap */
.home-mascot-area::after {
  content: "";
  position: absolute;
  right: clamp(0px, 2vw, 24px);
  bottom: 0;
  width: 52%;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(8, 16, 34, 0.6), rgba(8, 16, 34, 0.26) 55%, transparent 78%);
  filter: blur(2px);
  animation: home-shadow-breathe 4.5s ease-in-out infinite;
}

@keyframes home-shadow-breathe {
  0%, 100% { transform: scaleX(1); opacity: 0.9; }
  50% { transform: scaleX(0.86); opacity: 0.65; }
}

.home-mascot {
  position: relative;
  /* Grounded hero sizing: the box is the full column height PLUS a 16px bleed
   * that margin-bottom pushes past the fold, so the artwork's hard bottom
   * crop is always clipped below the visible edge — even mid idle-lift
   * (−8px) and micro-rotation. object-position pins the contained art to the
   * box bottom so letterbox slack can never open a gap under the character.
   * The 780px cap (was 680) gives a stronger presence on tall screens. */
  width: auto;
  height: calc(100% + 16px);
  max-height: 780px;
  max-width: 100%;
  margin-bottom: -16px; /* park the crop line below the fold */
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 24px 36px rgba(0, 0, 0, 0.5));
  animation: mascot-idle 4.5s ease-in-out infinite, mascot-hero-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* subtle idle: tiny lift + micro rotation, never a bounce */
@keyframes mascot-idle {
  0%, 100% { transform: translateY(0) rotate(-0.3deg); }
  50% { transform: translateY(-8px) rotate(0.5deg); }
}

@keyframes mascot-hero-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Badge ---- */
.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(0.68rem, 1.4vw, 0.8rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1E5AA8;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(30, 90, 168, 0.18);
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  box-shadow: 0 3px 8px rgba(70, 120, 165, 0.18);
}

/* ---- Title: cartoon white lettering with a thick navy outline ---- */
.home-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0.01em;
  color: #ffffff;
  -webkit-text-stroke: 7px #1E5AA8;
  paint-order: stroke fill;
  text-shadow:
    0 6px 0 rgba(30, 90, 168, 0.35),
    0 14px 30px rgba(30, 90, 168, 0.3);
}

/* ---- Subtitle ---- */
.home-sub {
  font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  font-weight: 600;
  color: #D9DEFF; /* light lavender — readable over the dark scrim */
  text-shadow: 0 1px 6px rgba(8, 16, 34, 0.55);
  max-width: 38ch;
  line-height: 1.45;
}

/* ---- Stats ---- */
.home-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Base chip for the purple screens (intro). */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
}
.stat-chip img { width: 18px; height: 18px; object-fit: contain; }
.stat-chip__value { font-weight: 800; color: var(--gold-500); }
.stat-chip svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--gold-500); }

/* Home chips sit on the bright sky, so they are white cards with navy text. */
.home-stats .stat-chip {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(30, 90, 168, 0.12);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #33507E;
  box-shadow: 0 3px 8px rgba(70, 120, 165, 0.16);
}
.home-stats .stat-chip img { width: 18px; height: 18px; object-fit: contain; }
.home-stats .stat-chip__value { font-weight: 800; color: #E8930C; }
.home-stats .stat-chip svg { width: 16px; height: 16px; flex-shrink: 0; color: #E8930C; }

/* ---- CTA buttons: chunky cartoon pills with a solid 3D base ---- */
.home-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
}

.btn-home-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 32px;
  border-radius: var(--radius-pill);
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #3A2492;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  background: linear-gradient(180deg, #FFDE7A 0%, #FFC531 45%, #F0A81C 78%, #E0910D 100%);
  border: 2px solid #C9820A;
  box-shadow:
    0 6px 0 #B36F08,
    0 14px 30px rgba(240, 168, 28, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.btn-home-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 8px 0 #B36F08,
    0 18px 38px rgba(240, 168, 28, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.btn-home-primary:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #B36F08,
    0 6px 16px rgba(240, 168, 28, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.btn-home-primary__icon { width: 24px; height: 24px; }

.btn-home-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 28px;
  border-radius: var(--radius-pill);
  font-size: clamp(0.95rem, 1.8vw, 1.05rem);
  font-weight: 800;
  color: #7A4E12;
  background: linear-gradient(180deg, #FFFDF4 0%, #FFF3CE 100%);
  border: 2px solid #E8CE8C;
  box-shadow:
    0 4px 0 rgba(200, 160, 70, 0.55),
    0 8px 20px rgba(200, 160, 70, 0.22);
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.btn-home-secondary:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow:
    0 5px 0 rgba(200, 160, 70, 0.55),
    0 10px 24px rgba(200, 160, 70, 0.28);
}

.btn-home-secondary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(200, 160, 70, 0.55); }
.btn-home-secondary__icon { width: 18px; height: 18px; opacity: 0.85; }

/* ---- Tools + brand ---- */
.home-tools { display: flex; gap: 10px; margin-top: 4px; }

/* Cream round tool buttons for the sky scene (other screens keep the
   translucent purple .icon-btn). */
.home-tools .icon-btn {
  background: rgba(255, 253, 244, 0.95);
  border: 2px solid rgba(122, 78, 18, 0.22);
  color: #7A4E12;
  box-shadow: 0 4px 0 rgba(200, 160, 70, 0.45), 0 6px 14px rgba(70, 120, 165, 0.18);
}
.home-tools .icon-btn:hover {
  background: #fff;
  transform: translateY(-2px);
}
.home-tools .icon-btn:active { transform: translateY(1px); }

/* Brand wordmark: absolutely pinned to the bottom edge, centered. It used to
   be a flow grid row, which reserved a dead band under the mascot column.
   Light watermark treatment — the scene's bottom scrim is dark, so navy text
   would disappear; white + soft halo reads cleanly over grass and hoodie. */
.home-brand {
  position: absolute;
  left: 50%;
  bottom: calc(6px + var(--sab));
  transform: translateX(-50%);
  z-index: 2;
  width: max-content;
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.08em;
  text-shadow: 0 1px 5px rgba(8, 16, 34, 0.65);
}

/* ---- RESPONSIVE ---- */

/* Tablet portrait / phone: stack copy -> actions -> mascot. The mascot row is
   last and takes all remaining height, so the character is bottom-anchored
   and bleeds off the fold — no dead space below it, no mid-air crop line. */
@media (max-width: 900px) {
  .home-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(170px, 1fr);
    grid-template-areas: "copy" "side" "masc";
    row-gap: clamp(8px, 2vh, 16px);
    text-align: center;
  }
  .home-copy { align-items: center; text-align: center; }
  .home-side { align-items: center; }
  .home-mascot-area {
    justify-content: center; /* centered in the stacked layout */
    padding: 0;
  }
  .home-mascot-area__aura,
  .home-mascot-area::after { right: auto; left: 50%; transform: translateX(-50%); }
  .home-mascot-area__aura { animation: none; }
  .home-mascot-area::after { animation: none; width: 46%; }
  /* Height-driven like desktop (bleed + bottom object-position inherit);
     max-width keeps the dog elegant on wide tablets and phones. */
  .home-mascot { max-height: none; max-width: min(86vw, 400px); }
  .home-cta { max-width: 340px; }
}

/* Phone: badge/title/sub -> stats/buttons -> mascot (bottom, centered) */
@media (max-width: 560px) {
  .home-shell {
    padding: clamp(10px, 2vh, 20px) 16px 0;
    row-gap: 6px;
  }
  .home-copy { gap: 6px; }
  .home-badge { font-size: 0.62rem; padding: 4px 10px; }
  .home-title { font-size: clamp(1.9rem, 8vw, 2.6rem); -webkit-text-stroke: 5px #1E5AA8; }
  .home-sub { font-size: 0.86rem; max-width: 26ch; }
  .home-mascot { max-width: min(80vw, 350px); }
  .home-cta { max-width: 100%; }
  .btn-home-primary { min-height: 54px; font-size: 1rem; padding: 0 24px; }
  .btn-home-secondary { min-height: 44px; font-size: 0.92rem; }
  .home-stats { justify-content: center; }
  .home-stats .stat-chip { font-size: 0.78rem; padding: 5px 11px; }
}

/* Short screens (landscape phones): same stack, compact mascot */
@media (max-height: 560px) {
  .home-shell { padding: 8px 16px 0; grid-template-rows: auto auto minmax(120px, 1fr); }
  .home-mascot { max-height: 200px; }
  .home-sub { display: none; }
  .home-cta { flex-direction: row; }
  .home-cta .btn-home-primary { flex: 1; min-height: 46px; }
  .home-cta .btn-home-secondary { flex: 0 0 auto; min-height: 46px; padding: 0 16px; }
  .home-brand { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .home-mascot,
  .home-mascot-area__aura,
  .home-mascot-area::after {
    animation: none !important;
  }
}




/* ------------------------------- 7. Map -------------------------------- */
.screen--map {
  background:
    radial-gradient(1100px 460px at 50% -10%, rgba(124, 92, 255, 0.35), transparent 60%),
    var(--grad-brand);
}

/* Compact premium header bar (no sound controls — the Boston English Center
   platform owns audio). */
.screen-header--map {
  background: linear-gradient(180deg, rgba(36, 26, 74, 0.97), rgba(50, 37, 94, 0.88));
  border-radius: 0 0 18px 18px;
  box-shadow: 0 6px 18px rgba(20, 12, 48, 0.35);
  padding: clamp(8px, 1.6vh, 14px) 14px;
  gap: 10px;
  z-index: 10;
}
.screen-header--map .screen-header__title { font-size: 1.12rem; }

/* The map scroller: full-bleed vertical journey on phones; on tablet and
   desktop the tier classes below frame each composition. */
.map-viewport {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.map-viewport::-webkit-scrollbar { display: none; }

.map-canvas {
  position: relative;
  width: 100%;
}

/* --------------- 7B. Journey map over the fantasy artworks ---------------
 * THREE SEPARATE COMPOSITIONS, one per device class — never one image for
 * all screens:
 *   desktop (>1024px)  -> map-desktop.webp|jpg   (1672x941 panorama)
 *   tablet  (<=1024px) -> map-tablet.webp|jpg    (1086x1448 portrait)
 *   phone   (<=600px)  -> bg-map-journey.webp|jpg (941x1672 vertical)
 * The media queries are the static defaults; ui.js additionally sets
 * .map-canvas--desktop|tablet|mobile from the MEASURED map viewport, so the
 * right artwork also wins inside a narrow platform container whose window
 * is wide. Nodes are positioned in percent and (on the panorama) through
 * the real cover-crop math, so they stay on their painted islands.
 * ---------------------------------------------------------------------- */

.map-canvas--journey {
  position: relative;
  width: 100%;
  margin-inline: auto;
  background-image: url("../assets/images/map-desktop.jpg"); /* wide default */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #241A4A;     /* shows only while the artwork loads */
}

@media (max-width: 1024px) {
  .map-canvas--journey { background-image: url("../assets/images/map-tablet.jpg"); }
}
@media (max-width: 600px) {
  .map-canvas--journey { background-image: url("../assets/images/bg-map-journey.jpg"); }
}

/* JS tier classes (set from the measured map container) — kept last so the
   container-aware choice always wins over the viewport media queries. */
.map-canvas--mobile  { background-image: url("../assets/images/bg-map-journey.jpg"); }
.map-canvas--tablet  { background-image: url("../assets/images/map-tablet.jpg"); }
.map-canvas--desktop { background-image: url("../assets/images/map-desktop.jpg"); }

@supports (background-image: image-set("a.webp" type("image/webp"))) {
  .map-canvas--journey {
    background-image: image-set(
      url("../assets/images/map-desktop.webp") type("image/webp"),
      url("../assets/images/map-desktop.jpg") type("image/jpeg")
    );
  }
  @media (max-width: 1024px) {
    .map-canvas--journey {
      background-image: image-set(
        url("../assets/images/map-tablet.webp") type("image/webp"),
        url("../assets/images/map-tablet.jpg") type("image/jpeg")
      );
    }
  }
  @media (max-width: 600px) {
    .map-canvas--journey {
      background-image: image-set(
        url("../assets/images/bg-map-journey.webp") type("image/webp"),
        url("../assets/images/bg-map-journey.jpg") type("image/jpeg")
      );
    }
  }
  .map-canvas--mobile {
    background-image: image-set(
      url("../assets/images/bg-map-journey.webp") type("image/webp"),
      url("../assets/images/bg-map-journey.jpg") type("image/jpeg")
    );
  }
  .map-canvas--tablet {
    background-image: image-set(
      url("../assets/images/map-tablet.webp") type("image/webp"),
      url("../assets/images/map-tablet.jpg") type("image/jpeg")
    );
  }
  .map-canvas--desktop {
    background-image: image-set(
      url("../assets/images/map-desktop.webp") type("image/webp"),
      url("../assets/images/map-desktop.jpg") type("image/jpeg")
    );
  }
}

/* Hidden for one frame so nodes never flash in unpositioned. */
.map-canvas--journey.is-positioning { visibility: hidden; }

/* --- dotted, softly glowing trail over the painted pathways -------------
 * Colors and caps live here; stroke widths / dash arrays are set as SVG
 * attributes by drawJourneyPath() so the trail scales with the stage. */

.map-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-path__glow {
  fill: none;
  stroke: rgba(255, 224, 138, 0.22);
  stroke-linecap: round;
}
.map-path__dash {
  fill: none;
  stroke: #fff;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 3px rgba(20, 12, 48, 0.55));
}
.map-path__stub {
  fill: none;
  stroke: rgba(255, 255, 255, 0.78);
  stroke-linecap: round;
  opacity: 0.66;
}

/* --- journey nodes (real buttons over the artwork) ---------------------- */

.map-jnode {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 68px;
  padding: 0;
  color: #fff;
}
.map-jnode--soon { cursor: default; }

/* the level disc itself — always a comfortable touch target */
.map-jnode__disc {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 50%;
  font-weight: 800;
  color: #fff;
  background: var(--grad-brand);
  border: 4px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 20px rgba(10, 5, 30, 0.38);
  transition: transform 140ms ease;
}
.map-jnode:not(.map-jnode--soon):not(.map-jnode--locked):active .map-jnode__disc { transform: scale(0.94); }

.map-jnode--unlocked .map-jnode__disc,
.map-jnode--completed .map-jnode__disc {
  width: clamp(70px, 20vw, 88px);
  font-size: clamp(1.5rem, 5vw, 1.95rem);
}
.map-jnode--completed .map-jnode__disc { background: var(--grad-green); }

.map-jnode--perfect .map-jnode__disc {
  width: clamp(70px, 20vw, 88px);
  font-size: clamp(1.5rem, 5vw, 1.95rem);
  background: var(--grad-gold);
  color: var(--brand-900);
  box-shadow: 0 0 0 4px rgba(255, 197, 49, 0.4), 0 8px 20px rgba(10, 5, 30, 0.38);
}
.map-jnode--perfect .map-jnode__disc::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid rgba(255, 222, 122, 0.5);
}

.map-jnode--locked .map-jnode__disc,
.map-jnode--soon .map-jnode__disc {
  width: clamp(64px, 18vw, 80px);
  background: linear-gradient(180deg, #A6ACC4 0%, #7D84A3 58%, #676E90 100%);
  border-color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 16px rgba(10, 5, 30, 0.35);
}
.map-jnode--locked .map-jnode__disc .icon,
.map-jnode--soon .map-jnode__disc .icon {
  width: 44%;
  height: 44%;
  color: #E7EAF6;
  filter: drop-shadow(0 1px 2px rgba(10, 5, 30, 0.4));
}

/* the current level is the strongest element on the screen */
.map-jnode--current .map-jnode__disc {
  width: clamp(92px, 26vw, 112px);
  font-size: clamp(2.1rem, 7.2vw, 2.8rem);
  background: var(--grad-gold);
  color: var(--brand-900);
  border-width: 5px;
  border-color: #fff;
  animation: jnode-glow 2.2s ease-in-out infinite;
}
.map-jnode--current .map-jnode__disc::before {
  content: "";
  position: absolute;
  inset: -13px;
  border-radius: 50%;
  border: 3px solid rgba(255, 222, 122, 0.35);
}

@keyframes jnode-glow {
  0%, 100% { box-shadow: 0 0 0 6px rgba(255, 197, 49, 0.42), 0 10px 26px rgba(10, 5, 30, 0.45); }
  50% { box-shadow: 0 0 0 14px rgba(255, 197, 49, 0.15), 0 10px 26px rgba(10, 5, 30, 0.45); }
}

/* one-time pop for an island that just became unlocked */
@keyframes jnode-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.07); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.map-jnode--newly { animation: jnode-pop 450ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.map-jnode__stars {
  display: flex;
  gap: 3px;
  margin-top: -1px;
  filter: drop-shadow(0 2px 3px rgba(10, 5, 30, 0.5));
}
.map-jnode__stars .icon { width: 17px; height: 17px; }

/* cream pill keeps titles readable over busy scenery; long titles wrap to a
   second line instead of overflowing toward the screen edge */
.map-jnode__label {
  max-width: 122px;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(255, 248, 229, 0.94);
  border: 1px solid rgba(122, 96, 190, 0.35);
  color: var(--ink-900);
  font-size: clamp(0.76rem, 3vw, 0.9rem);
  font-weight: 700;
  line-height: 1.18;
  text-align: center;
  overflow-wrap: break-word;
  text-wrap: balance;
  box-shadow: 0 3px 10px rgba(15, 8, 40, 0.35);
}
.map-jnode--locked .map-jnode__label,
.map-jnode--soon .map-jnode__label {
  background: rgba(243, 240, 233, 0.82);
  opacity: 0.85;
}

/* --- tier node scales ----------------------------------------------------
 * The rules above are the phone scale (kept untouched). The desktop
 * panorama spreads bigger islands (90-120px current) across a wide stage;
 * the tablet composition sits between the two. Sized with clamp() so the
 * discs stay inside each tier's spec at every tested viewport. */

.map-tier-desktop .map-jnode--current .map-jnode__disc {
  width: clamp(96px, 8vw, 124px);
  font-size: clamp(2.2rem, 2.4vw, 2.9rem);
}
.map-tier-desktop .map-jnode--unlocked .map-jnode__disc,
.map-tier-desktop .map-jnode--completed .map-jnode__disc,
.map-tier-desktop .map-jnode--perfect .map-jnode__disc {
  width: clamp(84px, 6.4vw, 108px);
  font-size: clamp(1.7rem, 1.9vw, 2.2rem);
}
.map-tier-desktop .map-jnode--locked .map-jnode__disc,
.map-tier-desktop .map-jnode--soon .map-jnode__disc { width: clamp(76px, 5.6vw, 98px); }
.map-tier-desktop .map-jnode__label {
  max-width: 168px;
  font-size: clamp(0.88rem, 0.8vw, 1rem);
}
.map-tier-desktop .map-jnode__stars .icon { width: 20px; height: 20px; }

.map-tier-tablet .map-jnode--current .map-jnode__disc {
  width: clamp(84px, 11vw, 106px);
  font-size: clamp(2rem, 4.2vw, 2.5rem);
}
.map-tier-tablet .map-jnode--unlocked .map-jnode__disc,
.map-tier-tablet .map-jnode--completed .map-jnode__disc,
.map-tier-tablet .map-jnode--perfect .map-jnode__disc {
  width: clamp(74px, 9.4vw, 94px);
  font-size: clamp(1.6rem, 3.4vw, 2rem);
}
.map-tier-tablet .map-jnode--locked .map-jnode__disc,
.map-tier-tablet .map-jnode--soon .map-jnode__disc { width: clamp(66px, 8.4vw, 84px); }
.map-tier-tablet .map-jnode__label {
  max-width: 140px;
  font-size: clamp(0.82rem, 2.2vw, 0.94rem);
}

/* Map header brand — hidden on small phones, eyebrow on tablets, inline on
   desktop ("Grammar Quest | Adventure Map"). */
.screen-header__brand {
  display: none;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-500);
  line-height: 1.1;
  white-space: nowrap;
}
@media (min-width: 520px) {
  .screen-header__brand { display: block; }
}
@media (min-width: 1024px) {
  .screen-header--map .screen-header__titles {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }
  .screen-header--map .screen-header__brand { display: block; }
  .screen-header--map .screen-header__brand::after {
    content: "|";
    margin-left: 10px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0;
  }
}

/* ---------------------------- 8. Level detail -------------------------- */
.screen--level { background: var(--grad-brand); }

.level-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px clamp(14px, 3vw, 28px) calc(20px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.level-desc {
  color: var(--blue-300);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  max-width: 68ch;
}

.challenge-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 14px;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}

.challenge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper);
  border-radius: var(--radius-l);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-soft);
  border: 2px solid transparent;
  transition: transform 140ms ease, box-shadow 160ms ease;
  text-align: left;
  min-height: 128px;
}

.challenge-card:not(.challenge-card--locked):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.challenge-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.challenge-card__num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--brand-500);
  background: var(--paper-soft);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.challenge-card__badge .icon { width: 26px; height: 26px; }

.challenge-card__title {
  font-size: clamp(1.02rem, 2.2vw, 1.15rem);
  font-weight: 800;
  color: var(--ink-900);
  line-height: 1.25;
}

.challenge-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.8rem;
    min-height: 40px;
  color: var(--ink-600);
  font-weight: 600;
}

.challenge-card__meta .pos { color: var(--green-600); }
.challenge-card__stars { display: flex; gap: 3px; margin-top: auto; }
.challenge-card__stars .icon { width: 20px; height: 20px; }

.challenge-card__start {
  margin-top: 10px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  transition: transform 140ms ease, box-shadow 160ms ease, filter 160ms ease;
  box-shadow: 0 4px 12px rgba(43, 27, 96, 0.25);
}

.challenge-card__start:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 8px 18px rgba(43, 27, 96, 0.3); }
.challenge-card__start:active { transform: translateY(1px) scale(0.98); }

.challenge-card--available { border-color: var(--brand-300); }
.challenge-card--available .challenge-card__start { background: var(--grad-brand); color: #fff; }

.challenge-card--current { border-color: var(--gold-500); box-shadow: var(--glow-gold), var(--shadow-card); }
.challenge-card--current .challenge-card__start { background: var(--grad-gold); color: var(--brand-900); }
/* The next-up challenge glows so students always know where to continue */
.challenge-card--current { animation: card-current-pulse 2.2s ease-in-out infinite; }

@keyframes card-current-pulse {
  0%, 100% { box-shadow: var(--glow-gold), var(--shadow-card); }
  50%      { box-shadow: 0 0 0 5px rgba(255, 197, 49, 0.35), var(--glow-gold), var(--shadow-card); }
}

.challenge-card--completed { border-color: var(--green-500); }
.challenge-card--completed .challenge-card__start { background: var(--grad-green); color: #fff; }

.challenge-card--locked {
  opacity: 0.62;
  filter: saturate(0.5);
  pointer-events: none;
}
.challenge-card--locked .challenge-card__title::after {
  content: "Locked";
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.challenge-card--final {
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    linear-gradient(135deg, var(--gold-500), var(--brand-500)) border-box;
  border: 3px solid transparent;
}

.challenge-card--final .challenge-card__num { background: rgba(255, 197, 49, 0.25); color: var(--gold-600); }

/* ------------------------------ 9. Intro -------------------------------
 * Premium challenge splash: a 16:9-style landscape composition — challenge
 * information on the left ~58%, an oversized Prairie Dog close-up on the
 * right ~42%, over a blurred castle-academy backdrop with glows, sparkles
 * and faint floating grammar cards. All copy is still set dynamically by
 * openIntro() from engine data.
 * ---------------------------------------------------------------------- */
.screen--intro { background: var(--grad-brand); }

.intro-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- backdrop ---------------------------------------------------------- */

.intro-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.intro-bg__art {
  position: absolute;
  inset: -5%;
  background: url("../assets/images/map-desktop.jpg") center 38% / cover no-repeat;
  filter: blur(7px) saturate(1.02) brightness(0.7);
  opacity: 0.55;
  transform: scale(1.05);
}
@supports (background-image: image-set("a.webp" type("image/webp"))) {
  .intro-bg__art {
    background-image: image-set(
      url("../assets/images/map-desktop.webp") type("image/webp"),
      url("../assets/images/map-desktop.jpg") type("image/jpeg")
    );
  }
}
.intro-bg__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  mix-blend-mode: screen;
  pointer-events: none;
}
.intro-bg__glow--blue {
  width: 46vw;
  height: 46vw;
  left: -10vw;
  top: -14vw;
  background: radial-gradient(closest-side, rgba(79, 163, 255, 0.5), transparent 70%);
}
.intro-bg__glow--pink {
  width: 40vw;
  height: 40vw;
  right: -8vw;
  top: 6vw;
  background: radial-gradient(closest-side, rgba(255, 122, 182, 0.34), transparent 70%);
}
/* readability: keep the left text zone dark and the whole frame cinematic */
.intro-bg__shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 95% at 20% 45%, rgba(28, 18, 64, 0.92), rgba(28, 18, 64, 0.42) 55%, rgba(28, 18, 64, 0.08) 78%),
    linear-gradient(90deg, rgba(24, 15, 56, 0.94) 0%, rgba(24, 15, 56, 0.6) 36%, rgba(24, 15, 56, 0.12) 62%, rgba(24, 15, 56, 0.55) 100%),
    linear-gradient(180deg, rgba(18, 11, 46, 0.6), transparent 28%, transparent 72%, rgba(14, 8, 38, 0.7));
}

/* --- sparkles ----------------------------------------------------------- */

.intro-sparks { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.intro-sparks i {
  position: absolute;
  border-radius: 50%;
  background: #FFE9AD;
  box-shadow: 0 0 10px 2px rgba(255, 214, 92, 0.55);
  opacity: 0;
  animation: intro-twinkle 3.6s ease-in-out infinite;
}
.intro-sparks i:nth-child(1) { left: 8%;  top: 22%; width: 5px; height: 5px; animation-delay: 0s; }
.intro-sparks i:nth-child(2) { left: 21%; top: 12%; width: 3px; height: 3px; background: #BFD7FF; box-shadow: 0 0 10px 2px rgba(124, 178, 255, 0.6); animation-delay: 0.8s; }
.intro-sparks i:nth-child(3) { left: 34%; top: 72%; width: 4px; height: 4px; animation-delay: 1.6s; }
.intro-sparks i:nth-child(4) { left: 46%; top: 16%; width: 3px; height: 3px; background: #BFD7FF; box-shadow: 0 0 10px 2px rgba(124, 178, 255, 0.6); animation-delay: 2.4s; }
.intro-sparks i:nth-child(5) { left: 55%; top: 55%; width: 5px; height: 5px; animation-delay: 0.4s; }
.intro-sparks i:nth-child(6) { left: 66%; top: 26%; width: 4px; height: 4px; background: #FFC7DD; box-shadow: 0 0 10px 2px rgba(255, 150, 190, 0.55); animation-delay: 1.2s; }
.intro-sparks i:nth-child(7) { left: 76%; top: 68%; width: 3px; height: 3px; animation-delay: 2s; }
.intro-sparks i:nth-child(8) { left: 87%; top: 34%; width: 5px; height: 5px; animation-delay: 2.8s; }
.intro-sparks i:nth-child(9) { left: 93%; top: 62%; width: 3px; height: 3px; background: #BFD7FF; box-shadow: 0 0 10px 2px rgba(124, 178, 255, 0.6); animation-delay: 0.6s; }
.intro-sparks i:nth-child(10) { left: 15%; top: 82%; width: 4px; height: 4px; animation-delay: 3.1s; }

@keyframes intro-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.4); }
  50% { opacity: 0.95; transform: scale(1); }
}

/* --- floating grammar cards (decorative, faded) ------------------------- */

.intro-card {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 10px 18px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 26px rgba(8, 4, 26, 0.4);
  color: #E4EBFF;
  filter: blur(1.3px);
  opacity: 0.5;
  animation: intro-card-float 7s ease-in-out infinite;
}
.intro-card b { font-weight: 800; font-size: 0.95rem; letter-spacing: 0.05em; }
.intro-card--he { left: 4.5%; top: 15%; transform: rotate(-5deg); }
.intro-card--ido { left: 47%; bottom: 11%; transform: rotate(4deg); animation-delay: 1.8s; }

@keyframes intro-card-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

/* --- top-left navigation pill ------------------------------------------- */

.intro-nav {
  position: absolute;
  z-index: 6;
  left: clamp(14px, 3vw, 42px);
  top: clamp(12px, 2.6vh, 30px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 18px 5px 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(75, 53, 150, 0.66), rgba(48, 34, 108, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 20px rgba(8, 4, 26, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.82rem, 1.2vw, 0.98rem);
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: min(58vw, 430px);
  overflow: hidden;
  animation: intro-drop-in 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.intro-nav:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(8, 4, 26, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.intro-nav:active { transform: translateY(0) scale(0.98); }
.intro-nav__back {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #4CD986, #23A657);
  box-shadow: 0 3px 10px rgba(35, 166, 87, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: #fff;
  flex-shrink: 0;
}
.intro-nav__back .icon { width: 18px; height: 18px; }
.intro-nav__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- top-right branding -------------------------------------------------- */

.intro-brand {
  position: absolute;
  z-index: 6;
  right: clamp(14px, 3vw, 42px);
  top: clamp(10px, 2.4vh, 26px);
  text-align: right;
  animation: intro-drop-in 460ms cubic-bezier(0.22, 1, 0.36, 1) 80ms both;
  pointer-events: none;
}
.intro-brand__logo {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-size: clamp(1.2rem, 2.1vw, 1.6rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(38, 22, 88, 0.95), 0 5px 16px rgba(10, 5, 32, 0.55);
}
.intro-brand__g { color: #fff; }
.intro-brand__q { color: var(--gold-500); }
.intro-brand__cap {
  position: absolute;
  left: -0.62em;
  top: -0.52em;
  width: 1.35em;
  height: auto;
  transform: rotate(-10deg);
  filter: drop-shadow(0 2px 4px rgba(10, 5, 32, 0.5));
}
.intro-brand__sub {
  display: block;
  margin-top: 5px;
  font-size: clamp(0.5rem, 0.85vw, 0.62rem);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(208, 218, 255, 0.78);
}

/* --- main split ----------------------------------------------------------- */

.intro-main {
  position: relative;
  z-index: 4;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
  align-items: center;
  padding: clamp(72px, 10vh, 108px) clamp(18px, 4.5vw, 64px) clamp(16px, 3.5vh, 40px);
}

.intro-info {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: clamp(10px, 2.1vh, 18px);
}
.intro-info > * { animation: intro-rise 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.intro-info > *:nth-child(1) { animation-delay: 60ms; }
.intro-info > *:nth-child(2) { animation-delay: 130ms; }
.intro-info > *:nth-child(3) { animation-delay: 200ms; }
.intro-info > *:nth-child(4) { animation-delay: 270ms; }
.intro-info > *:nth-child(5) { animation-delay: 340ms; }

/* challenge label with side rays */
.intro__kicker {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #FFD65C;
  font-weight: 800;
  font-size: clamp(0.8rem, 1.3vw, 0.98rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(255, 197, 49, 0.4);
}
.intro__kicker::before,
.intro__kicker::after {
  content: "";
  height: 2px;
  width: clamp(20px, 3.2vw, 44px);
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 214, 92, 0.85));
}
.intro__kicker::after { background: linear-gradient(90deg, rgba(255, 214, 92, 0.85), transparent); }

/* headline: white -> pale blue gradient with purple depth */
.intro__title {
  position: relative;
  font-size: clamp(1.9rem, 4.4vw, 3.3rem);
  line-height: 1.07;
  font-weight: 900;
  letter-spacing: -0.01em;
  max-width: 16ch;
  text-wrap: balance;
  background: linear-gradient(180deg, #FFFFFF 16%, #DEE8FF 58%, #BCCAF2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(38, 22, 88, 0.5)) drop-shadow(0 12px 28px rgba(8, 4, 26, 0.5));
}
/* golden underline swoosh */
.intro__title::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: -0.24em;
  width: min(58%, 210px);
  height: 0.16em;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFDF7E, #FFB63E 62%, rgba(255, 182, 62, 0));
  transform: skewX(-16deg);
  filter: drop-shadow(0 3px 8px rgba(255, 197, 49, 0.5));
}

.intro__instruction {
  margin-top: 0.35em;
  color: #C7D4FF;
  font-size: clamp(0.98rem, 1.7vw, 1.16rem);
  line-height: 1.55;
  max-width: 38ch;
  text-wrap: balance;
}

/* --- HUD information pills ------------------------------------------------ */

.intro__chips {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 1.2vw, 14px);
  margin-top: clamp(2px, 0.8vh, 8px);
}
.intro-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: clamp(38px, 5.4vh, 46px);
  padding: 0 clamp(13px, 1.5vw, 19px);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(99, 73, 190, 0.48), rgba(52, 38, 118, 0.48));
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -10px 18px rgba(16, 9, 46, 0.22),
    0 6px 18px rgba(8, 4, 26, 0.42);
  backdrop-filter: blur(4px);
  color: #fff;
  font-weight: 700;
  font-size: clamp(0.84rem, 1.25vw, 1rem);
  white-space: nowrap;
}
.intro-chip .icon { width: 19px; height: 19px; flex-shrink: 0; }
.intro-chip--time .icon { color: #6FBCFF; filter: drop-shadow(0 0 6px rgba(111, 188, 255, 0.65)); }
.intro-chip--lives .icon { color: #FF7A93; filter: drop-shadow(0 0 6px rgba(255, 122, 147, 0.65)); }
.intro-chip--pass .icon { color: #FFD65C; filter: drop-shadow(0 0 6px rgba(255, 214, 92, 0.65)); }
.intro-chip--count .icon { color: #C3A9FF; filter: drop-shadow(0 0 6px rgba(195, 169, 255, 0.65)); }

/* --- Start CTA -------------------------------------------------------------- */

.intro__start {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  margin-top: clamp(8px, 2.2vh, 20px);
  min-height: clamp(52px, 7.4vh, 66px);
  padding: 0 clamp(20px, 2vw, 28px) 0 clamp(26px, 2.6vw, 34px);
  border-radius: 999px;
  border: none;
  font-weight: 900;
  font-size: clamp(1.02rem, 1.8vw, 1.28rem);
  letter-spacing: 0.01em;
  color: #2A1A5E;
  background: linear-gradient(180deg, #FFE9AC 0%, #FFC531 46%, #F2A71D 100%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow:
    0 10px 26px rgba(255, 182, 62, 0.45),
    0 22px 50px rgba(255, 160, 40, 0.22),
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    inset 0 -3px 0 rgba(146, 88, 12, 0.4);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.intro__start:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 14px 32px rgba(255, 182, 62, 0.55),
    0 26px 60px rgba(255, 160, 40, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -3px 0 rgba(146, 88, 12, 0.4);
}
.intro__start:active { transform: translateY(1px) scale(0.98); }
.intro__start:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.intro__start-arrow {
  width: clamp(24px, 2.2vw, 30px);
  height: clamp(24px, 2.2vw, 30px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(42, 26, 94, 0.16);
  color: #2A1A5E;
  transition: transform 140ms ease;
}
.intro__start-arrow .icon { width: 60%; height: 60%; }
.intro__start:hover .intro__start-arrow { transform: translateX(3px); }

/* --- mascot close-up --------------------------------------------------------- */

.intro-hero {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  animation: intro-hero-in 640ms cubic-bezier(0.22, 1, 0.36, 1) 90ms both;
}
/* aura behind the character */
.intro-hero::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -14%;
  top: 8%;
  bottom: -10%;
  background:
    radial-gradient(42% 38% at 55% 42%, rgba(124, 92, 255, 0.38), transparent 70%),
    radial-gradient(50% 42% at 60% 62%, rgba(255, 197, 49, 0.16), transparent 72%);
  filter: blur(16px);
  pointer-events: none;
}
.intro-hero img {
  display: block;
  height: min(116%, 108vh);
  max-height: none;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom center;
  transform: translateY(7%);
  filter: drop-shadow(0 26px 46px rgba(6, 3, 20, 0.6));
  animation: intro-hero-float 4.6s ease-in-out infinite;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes intro-hero-float {
  0%, 100% { transform: translateY(9%) rotate(-1.1deg); }
  50% { transform: translateY(5%) rotate(0.9deg); }
}
@keyframes intro-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes intro-drop-in {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes intro-hero-in {
  from { opacity: 0; transform: translateX(40px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* --- portrait / narrow adaptation ------------------------------------------ */

@media (max-width: 880px) {
  .intro-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    align-items: end;
    padding: clamp(64px, 11vh, 96px) clamp(16px, 5vw, 30px) calc(14px + var(--sab));
  }
  /* the mascot becomes a generous close-up band above the info stack */
  .intro-hero { align-self: stretch; justify-content: flex-end; }
  .intro-hero img {
    height: clamp(210px, 34vh, 330px);
    max-width: 128%;
    margin-right: -6%;
    transform: translateY(10%);
  }
  .intro-info {
    align-items: center;
    text-align: center;
    gap: clamp(8px, 1.6vh, 14px);
  }
  .intro__title { max-width: 14ch; }
  .intro__instruction { max-width: 34ch; }
  .intro__chips { justify-content: center; }
  .intro__start { width: min(100%, 340px); justify-content: center; }
  .intro-card--he { left: 5%; top: 13%; }
  .intro-card--ido { display: none; } /* avoid crowding on narrow frames */
}

/* --- short landscape (phones on their side) --------------------------------- */

@media (max-height: 480px) {
  .intro-main { padding: clamp(52px, 12vh, 70px) clamp(14px, 3vw, 30px) 10px; }
  .intro-hero { display: none; }
  .intro-info { gap: 6px; }
  .intro__title { font-size: clamp(1.15rem, 5.4vh, 1.7rem); }
  .intro__instruction { font-size: 0.9rem; }
  .intro-chip { min-height: 34px; }
  .intro__start { min-height: 44px; margin-top: 4px; }
  .intro-card { display: none; }
}

/* ====================================================================== */
/* ======================= 10. GAMEPLAY: WHACK-A-MOLE ==================== */
/* ====================================================================== */

.screen--game {
  background: var(--brand-900);
  gap: 8px;
  padding: calc(8px + var(--sat)) clamp(10px, 1.8vw, 20px) calc(10px + var(--sab));
}

/* ---- Top HUD: level chip | green progress | hearts timer score ---- */
.gamebar {
  position: relative;   /* above the whole .whack stack — the pause veil must
                           never reach the HUD with its grayscale backdrop */
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 22px);
  min-height: clamp(52px, 6.5vh, 66px);
  padding: 8px clamp(12px, 2vw, 22px);
  border-radius: 18px;
  background: linear-gradient(90deg, #372A73 0%, #453391 55%, #372A73 100%);
  border: 2px solid rgba(124, 92, 255, 0.45);
  box-shadow: 0 6px 18px rgba(20, 12, 48, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.08);
  color: #fff;
}

.gamebar__level { display: flex; align-items: center; gap: 10px; min-width: 0; }

.gamebar__shield {
  width: clamp(34px, 4.5vh, 42px);
  height: clamp(34px, 4.5vh, 42px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #FFDE7A, #F0A81C);
  border-radius: 12px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.gamebar__shield .icon { width: 55%; height: 55%; color: var(--brand-900); }

.gamebar__title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  font-size: clamp(0.85rem, 1.5vw, 1.02rem);
  white-space: nowrap;
}

.gamebar__title strong { color: var(--gold-500); font-weight: 800; flex-shrink: 0; }
.gamebar__sep { opacity: 0.6; }
.gamebar__title #hud-challenge { overflow: hidden; text-overflow: ellipsis; }

.gamebar__finaltag {
  flex-shrink: 0;
  background: var(--grad-gold);
  color: var(--brand-900);
  font-size: 0.64rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.gamebar__progress { flex: 1; min-width: 90px; display: flex; align-items: center; gap: 10px; }

.gamebar__qlabel {
  font-size: 0.8rem;
    min-height: 40px;
  font-weight: 800;
  color: #DFF7E7;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.gamebar__bar {
  flex: 1;
  height: 14px;
  min-width: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.gamebar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4CD986, #23A657);
  box-shadow: 0 0 8px rgba(76, 217, 134, 0.55);
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gamebar__stats { display: flex; align-items: center; gap: clamp(6px, 1.2vw, 12px); flex-shrink: 0; }

.gamebar__hearts {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 5px 11px;
}

.gamebar__hearts .icon { width: 22px; height: 22px; }
.gamebar__hearts .heart--full { color: var(--red-500); }
.gamebar__hearts .heart--empty { color: rgba(255, 255, 255, 0.3); }
.gamebar__hearts .icon.heart--lost { animation: heart-lose 500ms ease both; }
.gamebar__hearts.is-low .icon.heart--full { animation: heart-low 1.4s ease-in-out infinite; }

@keyframes heart-lose {
  0% { transform: scale(1); }
  35% { transform: scale(1.3) rotate(-8deg); }
  100% { transform: scale(1); }
}

@keyframes heart-low {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.gamebar__timer {
  display: none; /* countdown lives in the question card ring — one timer on screen */
}

/* Kept for the warn/danger classes the JS still toggles on the wrap. */
.gamebar__timer .icon { width: 17px; height: 17px; }

.gamebar__timer--warn { color: var(--gold-500); }

.gamebar__timer--danger {
  color: #FF8296;
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.gamebar__score {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 5px 13px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--gold-500);
  font-variant-numeric: tabular-nums;
}

.gamebar__score .icon { width: 16px; height: 16px; }
.gamebar__score #hud-score { display: inline-block; }
.gamebar__score #hud-score.bump { animation: score-bump 320ms ease; }

@keyframes score-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---- The play field uses the supplied fantasy artwork ---- */
/* (cursor: the big fantasy hammer overlay owns the pointer while
   .hammer-mode is live — see the hammer cursor section below. Outside
   hammer-mode the native cursor is deliberately restored for real
   controls like Pause and the feedback card's Next button.) */
.whack {
  position: relative;
  z-index: 0;          /* own stacking context: confines the field's internal
                          layers so the purple header always paints above them */
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-card), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  background: #2E4A2B;
}

/* The supplied artwork already contains the holes — one dedicated painting
   per device class, swapped at the same thresholds ui.js uses for the
   hole-position maps (mobile <= 600, tablet <= 1024, desktop > 1024). */
.whack__bg {
  position: absolute;
  inset: 0;
  background: url("../assets/images/game-bg-desktop.jpg") center / cover no-repeat;
}

@media (max-width: 1024px) {
  .whack__bg { background-image: url("../assets/images/game-bg-tablet.jpg"); }
}

@media (max-width: 600px) {
  .whack__bg {
    background-image: url("../assets/images/game-bg-mobile.jpg");
    /* Phone fields stack Pause + the instruction card over the TOP of this
       portrait artwork; anchoring the painting to the top keeps the painted
       holes at their in-image depth instead of center-cropping them up under
       the cards. ui.js mapHole() mirrors this anchor for the mobile tier. */
    background-position: top center;
  }
}

/* Tall fields (portrait tablets) also use the portrait artwork — same top
   anchor so the hole map stays aligned with the painting */
.whack.whack--tall .whack__bg {
  background-image: url("../assets/images/game-bg-mobile.jpg");
  background-position: top center;
}

/* JS artwork tiers (syncFieldArtwork in ui.js): the MEASURED field aspect
   decides which painting is displayed, so the background and the hole map
   used for animal placement are always the same artwork — the window-width
   media queries above are only the first-paint guess. Kept after them on
   purpose so these always win. */
.whack.whack--art-desktop .whack__bg {
  background-image: url("../assets/images/game-bg-desktop.jpg");
  background-position: center;
}
.whack.whack--art-tablet .whack__bg {
  background-image: url("../assets/images/game-bg-tablet.jpg");
  background-position: center;
}
.whack.whack--art-mobile .whack__bg {
  background-image: url("../assets/images/game-bg-mobile.jpg");
  background-position: top center;
}

/* WebP variants (~40% lighter) wherever the browser supports them */
@supports (background-image: image-set("a.webp" type("image/webp"))) {
  .whack__bg {
    background-image: image-set(
      url("../assets/images/game-bg-desktop.webp") type("image/webp"),
      url("../assets/images/game-bg-desktop.jpg") type("image/jpeg")
    );
  }
  @media (max-width: 1024px) {
    .whack__bg {
      background-image: image-set(
        url("../assets/images/game-bg-tablet.webp") type("image/webp"),
        url("../assets/images/game-bg-tablet.jpg") type("image/jpeg")
      );
    }
  }
  @media (max-width: 600px) {
    .whack__bg {
      background-image: image-set(
        url("../assets/images/game-bg-mobile.webp") type("image/webp"),
        url("../assets/images/game-bg-mobile.jpg") type("image/jpeg")
      );
    }
  }
  .whack.whack--tall .whack__bg {
    background-image: image-set(
      url("../assets/images/game-bg-mobile.webp") type("image/webp"),
      url("../assets/images/game-bg-mobile.jpg") type("image/jpeg")
    );
  }
  .whack.whack--art-desktop .whack__bg {
    background-image: image-set(
      url("../assets/images/game-bg-desktop.webp") type("image/webp"),
      url("../assets/images/game-bg-desktop.jpg") type("image/jpeg")
    );
  }
  .whack.whack--art-tablet .whack__bg {
    background-image: image-set(
      url("../assets/images/game-bg-tablet.webp") type("image/webp"),
      url("../assets/images/game-bg-tablet.jpg") type("image/jpeg")
    );
  }
  .whack.whack--art-mobile .whack__bg {
    background-image: image-set(
      url("../assets/images/game-bg-mobile.webp") type("image/webp"),
      url("../assets/images/game-bg-mobile.jpg") type("image/jpeg")
    );
  }
}

.whack--speed .whack__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 4px rgba(255, 93, 115, 0.5);
  animation: speed-edge 1.6s ease-in-out infinite;
}

@keyframes speed-edge {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ---- Instruction card: cream-and-gold game card (matches the bubbles) ----
 * Pure CSS: ivory face, double gold trim, dark navy text, star ornaments,
 * number badge left, countdown ring right. Same family as the speech
 * bubbles so the whole field reads as one design. */
.instruction {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(94%, 560px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  background: linear-gradient(180deg, #FFFDF6 0%, #FBF2D8 100%);
  border: 2.5px solid #DCAB3C;
  border-radius: 22px;
  padding: 26px 66px 26px 66px;     /* generous height like a game card */
  text-align: center;
  box-shadow:
    0 12px 26px rgba(15, 9, 44, 0.32),
    inset 0 0 0 2px rgba(255, 255, 255, 0.6),
    inset 0 0 0 3.5px rgba(217, 169, 59, 0.45);
  will-change: transform;
  transition: transform 300ms cubic-bezier(0.5, 0.1, 0.3, 1), box-shadow 300ms ease;
}

/* Question number badge — gold-ringed circle at the pill's left end */
.instruction__badge {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 252, 240, 0.55);
  border: 3px solid var(--gold-600);
  color: #2F2B60;
  font-weight: 900;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 5px rgba(122, 89, 12, 0.18);
}


/* Question read beat: every question first holds CENTER STAGE for ~2s so the
   learner reads it, then the card docks to the top and the animals come out.
   ui.js flies it with a measured transform (works for the absolutely
   positioned desktop layout AND the in-flow stacked phone layout). */
.instruction.is-center {
  z-index: 30;            /* above the pause pill and popups while reading */
  box-shadow:
    0 20px 44px rgba(15, 9, 44, 0.4),
    0 0 0 6px rgba(255, 197, 49, 0.32),
    inset 0 0 0 2px rgba(255, 255, 255, 0.6),
    inset 0 0 0 3.5px rgba(217, 169, 59, 0.45);
}

/* The flight is decorative: with reduced motion the card still holds center
   for the same ~2s (ui.js timing), just without the travel animation. */
@media (prefers-reduced-motion: reduce) {
  .instruction { transition: none; }
}

body.reduce-motion .instruction { transition: none; }

/* Countdown ring (right side of the card): shows the seconds left for the
   whole challenge, draining as the clock runs. */
.instruction__timer {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}

.instruction__ring { width: 50px; height: 50px; transform: rotate(-90deg); }

.instruction__ring-track,
.instruction__ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.instruction__ring-track { stroke: rgba(47, 43, 96, 0.18); }

.instruction__ring-fill {
  stroke: #E8A81C;
  stroke-dasharray: 119.38;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear, stroke 300ms ease;
}

.instruction__seconds {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  font-weight: 800;
  color: #2F2B60;
  font-variant-numeric: tabular-nums;
}

.instruction__timer--warn .instruction__ring-fill { stroke: #C97A12; }
.instruction__timer--warn .instruction__seconds { color: #9A5E0C; }

.instruction__timer--danger .instruction__ring-fill { stroke: var(--red-500); }
.instruction__timer--danger .instruction__seconds { color: #C22742; }
.instruction__timer--danger .instruction__ring { animation: ring-pulse 640ms ease-in-out infinite; }

@keyframes ring-pulse {
  0%, 100% { transform: rotate(-90deg) scale(1); }
  50%      { transform: rotate(-90deg) scale(1.09); }
}

/* Golden ornaments flanking the instruction text: small star + thin line,
 * like the reference card. Pure CSS — no animation cost. */
.instruction__orn {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 20px;
  align-self: center;
}

.instruction__orn-star {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  color: #D9A93B;
}

.instruction__orn-line {
  display: block;
  height: 2px;
  flex: 1 1 auto;
  min-width: 12px;
  max-width: 54px;
  border-radius: 2px;
  background: linear-gradient(to right, rgba(217, 169, 59, 0), #D9A93B);
}

.instruction__orn:last-of-type .instruction__orn-line,
.instruction__orn--right .instruction__orn-line {
  background: linear-gradient(to left, rgba(217, 169, 59, 0), #D9A93B);
}

.instruction__text {
  font-weight: 800;
  font-size: clamp(1.12rem, 2.5vw, 1.42rem);
  color: #2F2B60;
}

.instruction__hint {
  flex-basis: 100%;
  font-size: 0.78rem;
  color: #7A7494;
  font-weight: 600;
}

.instruction__sentence {
  flex-basis: 100%;
  font-size: clamp(1rem, 2.4vw, 1.32rem);
  font-weight: 800;
  color: #2F2B60;
  overflow-wrap: anywhere;
}

.instruction__sentence .blank {
  color: #B07800;
  border-bottom: 3px dotted rgba(176, 120, 0, 0.8);
  padding-inline: 4px;
}

/* ---- Yard: target moles sit directly on the painted holes ---- */
.yard { position: absolute; inset: 0; z-index: 2; }

.mole {
  position: absolute;
  left: 50%;
  /* inline style sets left:x% and bottom:(100-y)% so the button's BOTTOM
     sits inside the painted hole (y includes the rim sink); the in-flow clip
     rises upward from it. --mole-w/--mole-clip-h come from the layout engine,
     which sizes the mascot to the painted hole it stands in. */
  transform: translateX(-50%);
  width: var(--mole-w, clamp(116px, 14.5vw, 200px));
  z-index: 3;
  padding: 0;
  background: none;
  border: none;
  display: block;
}

.mole__clip {
  display: block;
  position: relative;
  width: 100%;
  /* full body when no explicit clip height is given (aspect fallback) */
  aspect-ratio: 1 / 1.04;
  height: var(--mole-clip-h, auto);
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}

.mole__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  transform: translateY(106%);
  animation: mole-rise 230ms cubic-bezier(0.3, 1.5, 0.5, 1) forwards;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.3));
  transition: transform 140ms ease;
  will-change: transform;
}

@media (hover: hover) {
  .mole:not(.is-dim):not(.is-down):hover .mole__img { transform: translateY(-2%) scale(1.04); }
}

@keyframes mole-rise {
  0%   { transform: translateY(106%); }
  55%  { transform: translateY(-8%); }
  75%  { transform: translateY(3%); }
  90%  { transform: translateY(-1.5%); }
  100% { transform: translateY(0); }
}

.mole.is-down .mole__img { animation: mole-duck 180ms ease-in forwards; }

@keyframes mole-duck {
  to { transform: translateY(108%); }
}

.mole.is-idle .mole__img { animation: mole-idle 2.4s ease-in-out infinite 380ms; }

@keyframes mole-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3%) scale(1.015); }
}

/* speech bubble appears just after the mascot */
.mole__bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  min-width: 92px;
  max-width: min(320px, 27vw);
  background: #FFFCF1;
  border: 2.5px solid #E8D48A;
  border-radius: 14px;
  padding: 9px 13px;
  font-size: clamp(15px, 1.25vw, 22px);
  font-weight: 700;
  line-height: 1.3;
  color: #22335C;
  text-align: center;
  box-shadow: 0 5px 14px rgba(20, 12, 48, 0.3);
  opacity: 0;
  animation: bubble-in 200ms ease 110ms forwards;
  overflow-wrap: break-word;
  cursor: pointer;
  text-wrap: balance;
}

.mole__bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: #E8D48A;
  border-bottom: 0;
}

/* Word chips the layout engine hangs BESIDE the animal (stacked phone hole
   rows leave no room above both dogs): the bubble sits at muzzle height on
   the assigned side with its tail touching the animal. Sentence bubbles
   always stay above their animal. */
.mole__bubble--side-l,
.mole__bubble--side-r {
  bottom: auto;
  top: var(--chip-top, 16%);
  transform: none;
  max-width: 46vw;
  text-align: left;
  animation: bubble-side-in 200ms ease 110ms forwards;
}
.mole__bubble--side-l { left: auto; right: 100%; }
.mole__bubble--side-r { left: 100%; transform: none; }

.mole__bubble--side-l::after,
.mole__bubble--side-r::after {
  bottom: auto;
  left: auto;
  right: auto;
  top: 50%;
}
.mole__bubble--side-l::after {
  right: -8px;
  transform: translateY(-50%) rotate(-90deg);
}
.mole__bubble--side-r::after {
  left: -8px;
  transform: translateY(-50%) rotate(90deg);
}

@keyframes bubble-side-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Readability floor on small phones: bubbles never shrink below this even
   when the layout ladder compresses the wave. */
@media (max-width: 460px) {
  .mole__bubble { font-size: max(13px, 3.4vw); padding: 7px 10px; }
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ---- Tap-to-hear: speaker badge pinned to each animal's bubble ---------
 * Tap the badge to hear the sentence — it stops the click from reaching
 * the mole, so listening NEVER submits an answer. The visual circle is
 * 28px but the hit box is a generous 40px (transparent padding is still
 * tappable), matching comfortable touch ergonomics. Animations use only
 * transform/opacity — no repaint cost during gameplay.
 * Rendered only when the browser supports speechSynthesis (ui.js). */
.mole__speak {
  position: absolute;
  top: -14px;
  right: -12px;
  width: 40px;
  height: 40px;
  padding: 6px;                 /* transparent, still clickable */
  box-sizing: border-box;
  border-radius: 50%;
  background: linear-gradient(180deg, #3A2E7E, #241A5C) content-box;
  border: 2px solid rgba(255, 216, 107, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFE9B8;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  animation: speak-badge-in 220ms cubic-bezier(0.3, 1.5, 0.5, 1) forwards;
  transition: transform 120ms ease, filter 120ms ease;
}

.mole__speak .icon { width: 14px; height: 14px; pointer-events: none; }

/* The WHOLE speech bubble is a native-cursor zone (use-default-cursor on
 * .mole__bubble in ui.js): being close to the text swaps the hammer for the
 * normal pointer. Clicking the text still whacks; clicking the speaker
 * badge hears. The badge itself also enlarges its own hit ring slightly so
 * the speaker stays easy to land on. */
.mole__speak::before {
  content: "";
  position: absolute;
  inset: -6px;               /* small comfort ring, kept clear of the text */
  border-radius: 50%;
  clip-path: polygon(50% -30%, 140% -30%, 140% 140%, -30% 140%);
}

@media (hover: hover) {
  .mole__speak:hover { transform: scale(1.12); filter: brightness(1.15); }
}
.mole__speak:active { transform: scale(0.9); }

/* speaking: gold fill + sonar ring (transform/opacity only — cheap) */
.mole__speak.is-speaking {
  background: linear-gradient(180deg, #FFD66B, #FFB238) content-box;
  color: #2F2B60;
  border-color: #fff;
}
.mole__speak.is-speaking::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 197, 49, 0.8);
  animation: speak-sonar 900ms ease-out infinite;
}

@keyframes speak-sonar {
  from { transform: scale(0.8); opacity: 0.9; }
  to   { transform: scale(2.1); opacity: 0; }
}

@keyframes speak-badge-in {
  from { opacity: 0; transform: scale(0.3); }
  to   { opacity: 1; transform: scale(1); }
}

/* dimmed/reaction states inherit the mole's visual hierarchy */
.mole.is-faded .mole__speak,
.mole.is-dim .mole__speak { opacity: 0.55; }

/* ---- "Listen" pill (question card, feedback card, review items) ------- */
.speech-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms ease, transform 140ms ease, color 140ms ease;
}

.speech-btn .icon { width: 16px; height: 16px; }
.speech-btn:hover { background: rgba(255, 255, 255, 0.24); }
.speech-btn:active { transform: scale(0.94); }
.speech-btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.speech-btn[hidden] { display: none; }

.speech-btn.is-speaking {
  background: var(--grad-gold, linear-gradient(90deg, #ffd66b, #ffb238));
  border-color: transparent;
  color: var(--brand-900, #2F2B60);
}

/* question card: inline chip under the missing-word sentence */
.instruction__speak { margin-top: 5px; background: rgba(255, 255, 255, 0.16); }

/* feedback card: the same pill, re-cut for the cream surface — dark navy
 * copy on a light gold wash, and a rose outline in the wrong state so the
 * "hear the right sentence" affordance is the only pink thing on the card. */
.feedback-card__speak {
  min-height: 40px;
  padding: 6px 16px;
  font-size: 0.86rem;
  background: rgba(47, 43, 96, 0.07);
  color: #2F2B60;
  border-color: rgba(47, 43, 96, 0.28);
}
.feedback-card__speak .icon { width: 18px; height: 18px; }
.feedback-card__speak:hover { background: rgba(47, 43, 96, 0.16); }
.feedback-card.is-wrong .feedback-card__speak {
  color: #C22742;
  border-color: rgba(208, 39, 66, 0.45);
  background: rgba(208, 39, 66, 0.08);
}
.feedback-card.is-wrong .feedback-card__speak:hover { background: rgba(208, 39, 66, 0.16); }
/* Speaking state: the shared .speech-btn rule already flips to the gold
 * gradient, which reads correctly on cream too — only lift the shadow. */
.feedback-card__speak.is-speaking { color: var(--brand-900, #2F2B60); }
.feedback-card__speak:focus-visible { outline: 2px solid #2F2B60; outline-offset: 2px; }

/* review items: light chip on the cream card */
.review-item__speak {
  margin-top: 7px;
  background: rgba(47, 43, 96, 0.08);
  color: #2F2B60;
  border-color: rgba(47, 43, 96, 0.3);
}
.review-item__speak:hover { background: rgba(47, 43, 96, 0.15); }

@media (prefers-reduced-motion: reduce) {
  .mole__speak { animation: speak-badge-in 1ms forwards; }
  .mole__speak.is-speaking::after { animation: none; }
}
body.reduce-motion .mole__speak { animation: speak-badge-in 1ms forwards; }
body.reduce-motion .mole__speak.is-speaking::after { animation: none; }

/* entrance for elements that are NOT anchored with translateX(-50%) */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}

/* hit / answer states */
.mole.is-hit::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: 135%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 5px solid rgba(255, 197, 49, 0.95);
  opacity: 0;
  animation: hit-ring 480ms ease-out forwards;
  pointer-events: none;
}

@keyframes hit-ring {
  from { opacity: 0.95; transform: translateX(-50%) scale(0.4); }
  to   { opacity: 0; transform: translateX(-50%) scale(1.15); }
}

.mole.is-hit .mole__img { animation: mole-hit 320ms ease; }

@keyframes mole-hit {
  0%   { transform: translateY(0) scale(1, 1); }
  25%  { transform: translateY(12%) scale(1.22, 0.76); }
  50%  { transform: translateY(-4%) scale(0.92, 1.1); }
  75%  { transform: translateY(2%) scale(1.03, 0.98); }
  100% { transform: translateY(0) scale(1, 1); }
}

.mole.is-correct .mole__bubble {
  border-color: var(--green-500);
  background: #EDFFF3;
  box-shadow: 0 0 0 4px rgba(53, 196, 110, 0.35), 0 5px 14px rgba(20, 12, 48, 0.3);
}

.mole.is-correct .mole__bubble::after { border-top-color: var(--green-500); }

.mole.is-wrong .mole__bubble { border-color: var(--red-500); background: #FFEDF0; }
.mole.is-wrong .mole__bubble::after { border-top-color: var(--red-500); }
/* opacity stays pinned: bubble-shake REPLACES the bubble-in animation, so
   its `forwards` fill no longer holds — without this the shaken bubble
   would fall back to its base opacity 0 and the learner's pick would
   vanish right after the verdict. */
.mole.is-wrong .mole__bubble { opacity: 1; animation: bubble-shake 380ms ease 120ms; }

@keyframes bubble-shake {
  0%, 100% { transform: translateX(-50%) translateX(0); }
  25% { transform: translateX(-50%) translateX(-6px); }
  50% { transform: translateX(-50%) translateX(6px); }
  75% { transform: translateX(-50%) translateX(-4px); }
}

.mole.is-dim .mole__img { filter: saturate(0.45) brightness(0.92); }
.mole.is-dim .mole__bubble { opacity: 0.55; }

/* ---- Wrong-answer reveal hierarchy ---------------------------------------
 * After a wrong hit the field must answer three questions at a glance:
 *   1. strongest — the CORRECT target: green ring, glowing bubble, happy
 *      Prairie Dog, check badge, "Correct answer" label
 *   2. the learner's MISTAKE: red ring, X badge, smashed/dizzy Prairie Dog
 *   3. unrelated targets: grayscale + dimmed, still visible — never hidden
 * The eye should travel: my mistake -> the correct answer -> the rule card.
 * ------------------------------------------------------------------------ */
.mole.is-wrong { opacity: 1; }

/* the gold hit ring turns red on the learner's wrong pick */
.mole.is-wrong.is-hit::before { border-color: var(--red-500); }

.mole.is-wrong .mole__img {
  filter: drop-shadow(0 0 7px rgba(232, 68, 92, 0.6)) drop-shadow(0 5px 5px rgba(0, 0, 0, 0.3));
}

/* the revealed correct target: the strongest element on the field */
.mole.is-revealed-correct {
  z-index: 5;
  opacity: 1;
  filter: none;
  transform: translateX(-50%) scale(1.04);
  transition: transform 180ms cubic-bezier(0.34, 1.68, 0.64, 1);
}

.mole.is-revealed-correct .mole__bubble {
  border-color: var(--green-500);
  background: #F0FFF6;
  box-shadow:
    0 0 0 3px rgba(46, 204, 113, 0.16),
    0 8px 22px rgba(46, 204, 113, 0.3);
}

.mole.is-revealed-correct .mole__bubble::after { border-top-color: var(--green-500); }

/* unrelated targets: clearly secondary, still readable */
.mole.is-faded {
  filter: grayscale(0.85);
  opacity: 0.45;
  transition: filter 260ms ease, opacity 260ms ease;
}

/* Word-chip targets (missing-word options): single words render smaller than
 * sentence dogs so every option always fits on the field together — never
 * drop an option, or the wrong-answer reveal could lose its target. The
 * layout engine sizes every mascot to its painted hole via --mole-w; the
 * clamps are only the fallback when no hole size was computed. */
.mole.mole--word { width: var(--mole-w, clamp(82px, 24vw, 118px)); }

/* The full-width desktop artwork has large painted holes, so the characters
 * need a stronger scale than the phone-first defaults. Sentence animals stay
 * largest; short word-option animals are only slightly smaller so they remain
 * the main targets instead of looking like tiny decorations in the holes. */
@media (min-width: 601px) {
  .mole.mole--word { width: var(--mole-w, clamp(110px, 15vw, 150px)); }
}

@media (min-width: 1025px) and (min-height: 641px) {
  .mole { width: var(--mole-w, clamp(180px, 12vw, 240px)); }
  .mole.mole--word { width: var(--mole-w, clamp(150px, 9vw, 190px)); }
}

@media (max-height: 640px) {
  .mole.mole--word { width: var(--mole-w, clamp(82px, 16.5vh, 118px)); }
}

.mole.mole--word .mole__bubble {
  min-width: 64px;
  padding: 7px 11px;
  font-size: clamp(14px, 3.6vw, 19px);
}

/* X / check badges riding on the Prairie Dog's head */
.mole__mark {
  position: absolute;
  top: 1%;
  left: 50%;
  width: clamp(26px, 3.2vw, 34px);
  aspect-ratio: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 3px 8px rgba(20, 12, 48, 0.35);
  animation: mark-pop 260ms cubic-bezier(0.34, 1.68, 0.64, 1) both;
}

.mole__mark--x { background: var(--red-500); }
.mole__mark--check { background: var(--green-500); }

@keyframes mark-pop {
  0%   { transform: translate(-50%, 8px) scale(0); }
  65%  { transform: translate(-50%, 0) scale(1.16); }
  100% { transform: translate(-50%, 0) scale(1); }
}

/* small label pinned above the revealed bubble */
.mole__tag {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-500);
  color: #fff;
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 800;
  line-height: 1;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(46, 204, 113, 0.38);
  animation: rise-in 220ms ease both;
}

@media (max-width: 600px), (max-height: 480px) {
  .mole__mark { width: 26px; }
  .mole__tag { font-size: 11px; padding: 4px 9px; }
}

/* ---- Prairie Dog reaction states (image swaps keep the same box) ---- */

/* correct: quick happy bounce */
.mole.is-bounce .mole__img { animation: pd-bounce 380ms cubic-bezier(0.34, 1.68, 0.64, 1) both; }

@keyframes pd-bounce {
  0%   { transform: translateY(0) scale(1, 1); }
  20%  { transform: translateY(4%) scale(0.92, 1.08); }
  50%  { transform: translateY(-18%) scale(1.06, 0.96); }
  75%  { transform: translateY(3%) scale(0.97, 1.03); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* smashed: the artwork is wider — scale the box up but keep it centered
   on the hole and inside the field */
.mole.is-smashed .mole__clip { width: 135%; left: 50%; transform: translateX(-50%); }

/* dizzy: gentle wobble after the smash */
.mole.is-dizzy .mole__img { animation: pd-dizzy 500ms ease-in-out infinite; }

@keyframes pd-dizzy {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(4deg); }
}

/* results screens: celebrate prairie dog beside the medal */
.results__celebrate { width: clamp(96px, 16vh, 150px); animation: float 3s ease-in-out infinite; }
.results__celebrate img { width: 100%; filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.35)); }



/* ---- Binary answer paddles ---- */
.binary {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 4%, 24px);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: clamp(10px, 2vw, 16px);
  width: min(94%, 520px);
}

.paddle {
  flex: 1;
  min-height: 56px;
  border-radius: var(--radius-m);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 800;
  color: #fff;
  transition: transform 110ms ease, filter 140ms ease;
  animation: rise-in 220ms ease both;
}

.paddle:nth-child(2) { animation-delay: 60ms; }
.paddle:active { transform: translateY(2px) scale(0.97); }
.paddle__mark { width: 1.2em; height: 1.2em; flex-shrink: 0; }

.paddle--good {
  background: var(--grad-green);
  box-shadow: 0 5px 16px rgba(35, 166, 87, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.paddle--bad {
  background: var(--grad-danger);
  box-shadow: 0 5px 16px rgba(232, 68, 92, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.paddle:hover { filter: brightness(1.06); transform: translateY(-2px); }

.paddle.is-picked-good { animation: paddle-good-flash 450ms ease both; }
.paddle.is-picked-bad { animation: paddle-bad-shake 380ms ease both; filter: saturate(0.85); }
.paddle.is-dim { opacity: 0.45; }

@keyframes paddle-good-flash {
  40% { transform: scale(1.05); box-shadow: 0 0 0 9px rgba(53, 196, 110, 0.35); }
}

@keyframes paddle-bad-shake {
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
}

.score-popups { position: absolute; inset: 0; z-index: 8; pointer-events: none; }

.score-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: clamp(1.15rem, 2.8vw, 1.5rem);
  color: var(--gold-600);
  text-shadow: 0 2px 0 #fff, 0 4px 10px rgba(0, 0, 0, 0.25);
  animation: popup-rise 900ms ease-out both;
  white-space: nowrap;
}

.score-popup--life { color: var(--red-500); font-size: clamp(0.95rem, 2.2vw, 1.2rem); }

@keyframes popup-rise {
  from { opacity: 0; transform: translate(-50%, -30%); }
  25% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -170%); }
}

/* ---- Fantasy hammer: the custom gameplay cursor ------------------------
 * DESKTOP-ONLY, by pointer capability — never by viewport width. Everything
 * hammer-related (cursor hiding, the overlay itself) lives inside
 * @media (hover: hover) and (pointer: fine), so touch phones/tablets can
 * never show a hammer, hide the native cursor, or scroll-fight an overlay,
 * even in landscape or after resize. While .hammer-mode is on (set by
 * ui.js under the same capability query during a live question), the native
 * cursor disappears across the ENTIRE whack arena — Prairie Dog buttons,
 * images, sentence bubbles, bubble text and the fallback paddles — and the
 * hammer overlay becomes the pointer. Real controls inside the arena
 * (.use-default-cursor: Pause, feedback card) keep a native cursor, and
 * the overlay hides while they are hovered.
 * ---------------------------------------------------------------------- */

/* Belt-and-braces: no cursor hiding and no overlay outside fine pointers,
 * even if a .hammer-mode class ever leaked onto a touch device. */
.whack.hammer-mode,
.whack.hammer-mode * { cursor: auto; }
.hammer-cursor { display: none; }

@media (hover: hover) and (pointer: fine) {
  .whack.hammer-mode,
  .whack.hammer-mode * { cursor: none !important; }
  .whack.hammer-mode .use-default-cursor,
  .whack.hammer-mode .use-default-cursor * { cursor: pointer !important; }

  /* Persistent desktop overlay: position layer only (transform set by JS in
   * a rAF loop); rotation lives on the inner <img> so the keyframes never
   * fight pointer tracking. Fixed to the viewport: clipped at edges, never
   * part of document flow, can never create scrollbars. */
  .hammer-cursor {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: clamp(72px, 6vw, 105px);
    aspect-ratio: 1 / 1;
    z-index: 40; /* above the arena layers (z 2-8), below modals (50)/toast */
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    will-change: transform;
  }
  .hammer-cursor.is-visible { opacity: 1; visibility: visible; }

  .hammer-cursor__img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 7px 10px rgba(10, 5, 30, 0.45));
    /* artwork: head upper-left, handle to bottom-right — the strike face is
     * the hotspot and the swing pivots around it */
    transform-origin: 33% 56%;
    transform: rotate(-24deg); /* idle ready pose */
  }

  /* hovering a real target: a tiny wind-up cue (never an answer hint) */
  .hammer-cursor.is-aim .hammer-cursor__img { transform: rotate(-31deg) scale(1.05); }

  /* lift -> slam -> recoil -> ready; the head contacts at ~50% of 300ms,
   * which is HAMMER_IMPACT_MS in ui.js where engine reactions are revealed */
  .hammer-cursor.is-whacking .hammer-cursor__img {
    animation: hammer-whack 300ms cubic-bezier(0.3, 0.75, 0.4, 1) both;
  }
}

@keyframes hammer-whack {
  0%   { transform: rotate(-24deg) translateY(0); }
  18%  { transform: rotate(-46deg) translateY(-8%); }
  50%  { transform: rotate(15deg)  translateY(5%); }
  66%  { transform: rotate(1deg)   translateY(2%); }
  100% { transform: rotate(-24deg) translateY(0); }
}

/* Reduced motion (user preference or the in-game setting): keep the hammer
 * and the impact beat, replace the big swing with a short snap. These
 * selectors out-specify the global animation kill-switch at the file end. */
@media (prefers-reduced-motion: reduce) {
  .hammer-cursor.is-whacking .hammer-cursor__img {
    animation-name: hammer-snap !important;
    animation-duration: 200ms !important;
  }
}
body.reduce-motion .hammer-cursor.is-whacking .hammer-cursor__img {
  animation-name: hammer-snap !important;
  animation-duration: 200ms !important;
}

@keyframes hammer-snap {
  0%   { transform: rotate(-24deg) scale(1); }
  55%  { transform: rotate(-7deg) scale(0.92) translateY(3%); }
  100% { transform: rotate(-24deg) scale(1); }
}

/* ---- Pause control: top-left of the field, clear of the feedback zone ---- */
.pause-pill {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px 8px 13px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #43318F, #372A73);
  border: 2px solid rgba(124, 92, 255, 0.5);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 5px 12px rgba(20, 12, 48, 0.45);
}

.pause-pill:active { transform: translateY(1px) scale(0.98); }
.pause-pill .icon { width: 15px; height: 15px; }

/* ---- Cinematic pause -----------------------------------------------------
   One layer, one filter pass: the veil sits on top of the field and treats
   everything already painted under it as its backdrop, so the whole scene
   (background art, instruction card, animals, paddles, feedback) is drained
   to grayscale, softened and dimmed by ONE backdrop-filter — no per-element
   filters, no extra layers, no blur animation loop. The Play button is a
   sibling painted above the veil, so it stays sharp, gold and colorful.
   The purple header lives in .gamebar, which paints above .whack's whole
   stacking context and is therefore not part of the veil's backdrop. */
.pause-veil {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(8px + var(--sat)) 8px calc(8px + var(--sab));
  -webkit-backdrop-filter: grayscale(100%) blur(4px) brightness(0.86);
  backdrop-filter: grayscale(100%) blur(4px) brightness(0.86);
  /* Swallow every tap/click aimed at the frozen field underneath. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
  animation: pause-veil-in 200ms ease both;
}

/* No backdrop-filter support: fall back to a plain dim so the frozen scene
   still reads as "paused" instead of staying fully interactive-looking. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pause-veil { background: rgba(28, 22, 44, 0.55); }
}

.pause-veil[hidden] { display: none; }

@keyframes pause-veil-in { from { opacity: 0; } to { opacity: 1; } }

/* The one control on the pause screen: a big golden arcade coin. */
.pause-play {
  --play-size: min(clamp(92px, 26vmin, 156px), 34vh); /* comfortable thumb
                                                       target on phones, still
                                                       tamed on short landscape */
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--play-size);
  height: var(--play-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
  animation: pause-play-in 320ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

/* Coin face: gold rim, domed gradient, lit from the top-left. */
.pause-play__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(68% 62% at 30% 22%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 58%),
    radial-gradient(96% 96% at 50% 30%, #FFE07A 0%, #FFC531 46%, #F0A81C 78%, #D98A0B 100%);
  border: 3px solid #E8A81E;
  box-shadow:
    inset 0 0 0 2.5px rgba(255, 238, 176, 0.8),  /* warm inner ring */
    inset 0 -10px 20px rgba(163, 96, 0, 0.35),   /* bottom shading    */
    0 10px 24px rgba(20, 12, 48, 0.45),          /* drop shadow       */
    0 0 26px 6px rgba(255, 197, 49, 0.55);       /* soft golden glow  */
  transition: transform 140ms ease;
}

.pause-play__icon {
  width: 47%;
  height: 47%;
  /* The Lucide #i-play path spans x 8..20.5 inside its 0 0 24 24 viewBox, so
     the glyph itself is 2.25u (9.375%) right of the box centre. Nudge it back
     to land the visible triangle — not just its box — on the coin's centre. */
  transform: translateX(-9.375%);
  fill: #2A1A5E;          /* dark purple play mark */
  filter: drop-shadow(0 2px 2px rgba(90, 50, 0, 0.35));
}

/* Halo pulse: transform/opacity only, no filter, no repaint of the backdrop. */
.pause-play::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 214, 102, 0.55);
  opacity: 0.9;
  animation: pause-play-pulse 2.6s ease-in-out infinite;
}

.pause-play:active .pause-play__face { transform: scale(0.94); }

@keyframes pause-play-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pause-play-pulse {
  0%   { transform: scale(1);    opacity: 0.75; }
  70%  { transform: scale(1.28); opacity: 0; }
  100% { transform: scale(1.28); opacity: 0; }
}

/* Freeze every animation in the field while paused. animation-play-state keeps
   each keyframe's current time, so lifting the freeze continues the idle
   breathing / dizzy spin exactly where it stopped — no restart, no jump.
   `!important` is deliberate: the per-element `animation:` shorthands would
   otherwise reset play-state back to running at a higher specificity. */
.whack.is-paused > *:not(.pause-veil),
.whack.is-paused > *:not(.pause-veil)::before,
.whack.is-paused > *:not(.pause-veil)::after,
.whack.is-paused > *:not(.pause-veil) *,
.whack.is-paused > *:not(.pause-veil) *::before,
.whack.is-paused > *:not(.pause-veil) *::after {
  animation-play-state: paused !important;
}

/* (Score popups are defined once above, next to the paddle styles.) */

/* Streak milestone burst: one quick flame flourish at 3 / 5 / 10 in a row,
   anchored under the HUD streak chip. Transform/opacity only. */
.streak-burst {
  position: absolute;
  top: 14%;
  left: 50%;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 122, 46, 0.95), rgba(232, 74, 56, 0.92));
  border: 2px solid rgba(255, 224, 138, 0.9);
  box-shadow: 0 8px 22px rgba(232, 74, 56, 0.45);
  color: #fff;
  font-weight: 900;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  pointer-events: none;
  animation: streak-burst 1s cubic-bezier(0.3, 1.4, 0.5, 1) both;
  will-change: transform, opacity;
}

.streak-burst .icon { width: 20px; height: 20px; color: #FFE28A; }

@keyframes streak-burst {
  0%   { opacity: 0; transform: translate(-50%, 14px) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  30%  { transform: translate(-50%, 0) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(0.94); }
}

/* ---- HUD streak chip (hidden until streak >= 2) ---- */
.gamebar__streak {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 5px 11px;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gold-500);
  font-variant-numeric: tabular-nums;
}

.gamebar__streak .icon { width: 15px; height: 15px; color: #FF9D45; }
.gamebar__streak.bump { animation: score-bump 320ms ease; }

/* ---- Feedback: the cream-and-gold VERDICT CARD --------------------------
 * One panel over the bottom of the field, hidden (and space-free) until the
 * engine grades an answer. Three zones in a single row on desktop:
 *   status (badge + verdict word) | gold divider | explanation | Next.
 * Everything decorative — the crest on the top edge and the four corner
 * flourishes — is pure CSS, so the whole panel costs no image request. */
.feedback-card {
  /* Local palette for this light surface (the cream cards elsewhere in the
   * game hard-code the same family rather than reusing the dark-screen
   * tokens, which are tuned for a purple backdrop). */
  --fc-cream-top: #FFFDF4;
  --fc-cream-mid: #FBF2D8;
  --fc-cream-end: #F6E7BE;
  --fc-gold: #DCAB3C;
  --fc-gold-deep: #B9820A;
  --fc-ink: #2F2B60;       /* dark navy body text on cream */
  --fc-ink-soft: #6A6590;  /* rule / secondary copy */
  --fc-good: #1B7F3F;      /* deep green — AA on cream at body size */
  --fc-bad: #D02742;       /* deep crimson — AA on cream at body size */

  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 9;
  box-sizing: border-box;
  /* Inset by the safe-area on notched phones so the panel never runs under
   * a rounded corner or a home indicator. Capped wide enough that a normal
   * sentence clears the fixed zones and stays on ONE line, like the design
   * reference — longer sentences simply wrap and the card grows. */
  width: min(960px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 26px;
  color: var(--fc-ink);
  border: 2px solid rgba(220, 171, 60, 0.9);
  border-radius: 26px;
  background:
    radial-gradient(130% 150% at 50% 0%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, var(--fc-cream-top) 0%, var(--fc-cream-mid) 58%, var(--fc-cream-end) 100%);
  box-shadow:
    0 16px 36px rgba(15, 9, 44, 0.42),      /* warm drop onto the field */
    0 3px 0 rgba(255, 255, 255, 0.7) inset, /* lit top edge of the cream */
    0 0 0 4px rgba(255, 197, 49, 0.16);     /* soft gold halo */
  animation: feedback-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes feedback-in {
  from { opacity: 0; transform: translateX(-50%) translateY(22px) scale(0.97); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Gold crest straddling the top edge: a fading hairline with a diamond on
 * the centre. Decorative only — pointer events stay off so it can never
 * swallow a tap meant for the card. */
.feedback-card__crest {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 148px;
  height: 22px;
  transform: translateX(-50%);
  pointer-events: none;
  background:
    linear-gradient(to right,
      rgba(220, 171, 60, 0) 0%,
      var(--fc-gold) 26%,
      var(--fc-gold) 74%,
      rgba(220, 171, 60, 0) 100%) center 11px / 100% 2px no-repeat;
}

.feedback-card__crest::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 6px;
  background: linear-gradient(135deg, #FFF3CC 0%, #FFC531 46%, #DF9A10 100%);
  box-shadow:
    0 2px 7px rgba(94, 58, 4, 0.45),
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.75);
}

/* Corner flourishes: a thin gold L-bracket with a diamond on its vertex,
 * tucked inside each corner. One shape, positioned per corner and rotated —
 * rotation about the box centre is an isometry, so it turns the L to face
 * the right corner AND keeps the diamond exactly on the vertex. */
.feedback-card__corner {
  position: absolute;
  width: 26px;
  height: 26px;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--fc-gold-deep), rgba(220, 171, 60, 0)) left top / 100% 2.5px no-repeat,
    linear-gradient(to bottom, var(--fc-gold-deep), rgba(220, 171, 60, 0)) left top / 2.5px 100% no-repeat;
}

.feedback-card__corner::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #FFE9A8 0%, var(--fc-gold) 100%);
  box-shadow:
    0 0 0 2px rgba(255, 253, 244, 0.92), /* cream halo: reads clear of the bracket */
    0 1px 4px rgba(120, 76, 8, 0.4);
}

.feedback-card__corner--tl { top: 9px; left: 9px; }
.feedback-card__corner--tr { top: 9px; right: 9px; transform: rotate(90deg); }
.feedback-card__corner--br { right: 9px; bottom: 9px; transform: rotate(180deg); }
.feedback-card__corner--bl { bottom: 9px; left: 9px; transform: rotate(270deg); }

/* --- Zone 1 · verdict ------------------------------------------------- */
.feedback-card__status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.feedback-card__badge {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 50%;
  color: #fff;
  box-shadow:
    0 6px 14px rgba(94, 20, 34, 0.32),
    inset 0 0 0 3px rgba(255, 255, 255, 0.55),
    inset 0 -4px 9px rgba(0, 0, 0, 0.16);
}

.feedback-card.is-wrong .feedback-card__badge { background: var(--grad-danger); }
.feedback-card.is-correct .feedback-card__badge { background: var(--grad-green); }

.feedback-card__mark { width: 34px; height: 34px; }

.feedback-card__title {
  font-size: clamp(1.3rem, 2.6vw, 1.8rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--fc-good);
}

.feedback-card.is-wrong .feedback-card__title { color: var(--fc-bad); }

/* Thin gold rule between the verdict and the explanation, with a diamond
 * riding its middle. Hidden once the card stacks (the zones get their own
 * rows there and the rule would just float). */
.feedback-card__divider {
  flex: 0 0 auto;
  align-self: stretch;
  width: 2px;
  margin-block: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to bottom,
    rgba(220, 171, 60, 0) 0%,
    rgba(220, 171, 60, 0.85) 22%,
    rgba(220, 171, 60, 0.85) 78%,
    rgba(220, 171, 60, 0) 100%);
  position: relative;
}

.feedback-card__divider::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 2px;
  background: var(--fc-gold);
  box-shadow: 0 0 0 2px var(--fc-cream-mid), 0 0 7px rgba(240, 168, 28, 0.6);
}

/* --- Zone 2 · explanation -------------------------------------------- */
.feedback-card__detail {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.feedback-card__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.32;
}

.feedback-card__line {
  font-size: clamp(0.95rem, 2vw, 1.06rem);
  color: var(--fc-ink);
  overflow-wrap: break-word; /* long sentences wrap, never spill sideways */
}

.feedback-card__line--answer { font-weight: 800; }

.feedback-card__label {
  font-weight: 900;
  color: var(--fc-good); /* "Correct:" stays green in BOTH states */
}

.feedback-card__line--rule {
  font-size: clamp(0.84rem, 1.8vw, 0.96rem);
  font-weight: 600;
  color: var(--fc-ink-soft);
}

.feedback-card__line--rule .feedback-card__label {
  font-weight: 800;
  color: var(--fc-ink);
}

/* Correct answers stay lighter than a correction: one calm confirmation
 * line, no rule, no label. */
.feedback-card__line--note {
  font-weight: 600;
  color: var(--fc-ink-soft);
}

/* --- Zone 3 · next action -------------------------------------------- */
.feedback-card__next {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  min-width: 132px;
  padding: 0 26px;
  border: 2px solid rgba(160, 104, 6, 0.45);
  border-radius: var(--radius-pill);
  background: var(--grad-gold);
  color: var(--brand-900);
  font-family: inherit;
  font-size: 1.06rem;
  font-weight: 900;
  /* Chunky gold "puck" with a solid bottom lip: the lip is what sells the
   * press, so the :active state slides the button down into it. */
  box-shadow:
    0 6px 0 #D18F0C,
    0 12px 20px rgba(240, 168, 28, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 160ms ease;
}

.feedback-card__next-arrow {
  width: 18px;
  height: 18px;
  transition: transform 160ms ease;
}

.feedback-card__next:focus-visible {
  outline: 3px solid var(--fc-ink);
  outline-offset: 3px;
}

.feedback-card__next:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #D18F0C,
    0 4px 10px rgba(240, 168, 28, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

@media (hover: hover) and (pointer: fine) {
  .feedback-card__next:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow:
      0 7px 0 #D18F0C,
      0 16px 24px rgba(240, 168, 28, 0.48),
      inset 0 1px 0 rgba(255, 255, 255, 0.65);
  }
  .feedback-card__next:hover .feedback-card__next-arrow { transform: translateX(4px); }
}

/* --- Phones & portrait tablets ----------------------------------------
 * Too narrow for one row: the zones stack in reading order — verdict on
 * top, the sentence and rule under it, and a full-width Next as the last
 * row (the biggest, easiest thumb target in the card). Nothing overlaps
 * and nothing overflows: every zone claims a full row and the card simply
 * grows taller as the explanation wraps. */
@media (max-width: 700px) {
  .feedback-card {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 22px;
  }

  .feedback-card__divider { display: none; }
  .feedback-card__status { flex: 1 1 100%; }
  .feedback-card__detail {
    flex: 1 1 100%;
    flex-wrap: wrap;   /* Listen drops below the text only if the row is tight */
    gap: 10px 12px;
  }
  .feedback-card__speak { align-self: flex-start; }
  .feedback-card__body { flex: 1 1 200px; }
  .feedback-card__next { flex: 1 1 100%; min-height: 56px; font-size: 1.12rem; }
  .feedback-card__corner { width: 20px; height: 20px; }
  .feedback-card__crest { width: 104px; }
}

/* Landscape phones / short windows: the single row survives, so everything
 * tightens instead of stacking — flourishes are the first thing to go. */
@media (max-height: 480px) {
  .feedback-card {
    bottom: 8px;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 18px;
  }
  .feedback-card__corner,
  .feedback-card__crest { display: none; }
  .feedback-card__badge { width: 42px; height: 42px; }
  .feedback-card__mark { width: 24px; height: 24px; }
  .feedback-card__title { font-size: 1.15rem; }
  .feedback-card__next { min-height: 42px; min-width: 108px; padding: 0 18px; font-size: 0.95rem; }
}

/* Narrow phones: trim the chrome again so the verdict lines stay readable
 * without the learner zooming. */
@media (max-width: 380px) {
  .feedback-card { padding: 14px 14px; gap: 10px; }
  .feedback-card__badge { width: 48px; height: 48px; }
  .feedback-card__mark { width: 28px; height: 28px; }
  .feedback-card__status { gap: 10px; }
}

/* Home mascot sizing for the same phones (unrelated to the verdict card —
 * kept at its original 560px breakpoint). */
@media (max-width: 560px) {
  .home__mascot-glow { display: none; }
  .home__mascot-ring { width: 106%; }
}


/* ------------------------------ 11. Results ---------------------------- */
.screen--results {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 460px at 50% -10%, rgba(255, 197, 49, 0.25), transparent 60%),
    var(--grad-brand);
  color: #fff;
  padding: 20px;
}

.results {
  width: min(100%, 620px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(10px, 2vh, 18px);
}

.results__medal { width: clamp(110px, 20vh, 170px); animation: medal-drop 520ms cubic-bezier(0.34, 1.5, 0.64, 1) both; }
.results__medal img { width: 100%; filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.4)); }

@keyframes medal-drop {
  from { opacity: 0; transform: translateY(-40px) scale(0.6); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.results__title { font-size: clamp(1.5rem, 4.4vw, 2.1rem); font-weight: 800; text-wrap: balance; }

.results__stars { display: flex; gap: 6px; }
.results__stars .icon { width: clamp(34px, 7vw, 48px); height: clamp(34px, 7vw, 48px); }
.results__stars .icon.star--empty { color: #fff; opacity: 0.5; }
.results__stars .icon.star--earn { animation: star-earn 520ms cubic-bezier(0.34, 1.6, 0.64, 1) both; }
.results__stars .icon.star--earn:nth-child(2) { animation-delay: 180ms; }
.results__stars .icon.star--earn:nth-child(3) { animation-delay: 360ms; }

@keyframes star-earn {
  from { opacity: 0; transform: scale(0) rotate(-40deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.results__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  width: 100%;
}

.result-tile {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-m);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-tile__label { font-size: 0.74rem; font-weight: 700; color: var(--blue-300); }
.result-tile__value { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 800; font-variant-numeric: tabular-nums; }

.results__required { color: var(--blue-300); font-size: 0.9rem; font-weight: 600; }

.results__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; padding-bottom: 4px; }
.results__actions .btn { flex: 1 1 150px; max-width: 230px; }
.results__mascot { width: clamp(110px, 18vh, 160px); animation: float 3s ease-in-out infinite; }

/* --------------------------- 12. Review screen ------------------------- */
.screen--review { background: var(--grad-brand); }

.review-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px clamp(14px, 3vw, 28px) calc(20px + var(--sab));
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  margin-inline: auto;
  padding-bottom: 12px;
}

.review-item {
  background: var(--paper);
  border-radius: var(--radius-m);
  border-left: 6px solid var(--red-500);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-soft);
}

.review-item__question { font-weight: 700; font-size: clamp(0.98rem, 2.2vw, 1.1rem); overflow-wrap: anywhere; }
.review-item__question .blank {
  color: var(--brand-500);
  border-bottom: 3px dotted var(--brand-500);
  font-weight: 800;
  padding-inline: 3px;
}

.review-item__row { font-size: 0.92rem; overflow-wrap: anywhere; }
.review-item__row span { font-weight: 700; }
.review-item__row--you span { color: var(--red-600); }
.review-item__row--correct span { color: var(--green-600); }

.review-item__rule {
  font-size: 0.88rem;
  color: var(--ink-600);
  background: var(--paper-soft);
  border-radius: var(--radius-s);
  padding: 6px 10px;
}

.review-empty { color: var(--blue-300); text-align: center; padding: 40px 16px; font-weight: 600; }

/* -------------------------- 13. Level complete ------------------------- */
.screen--level-complete {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 460px at 50% -10%, rgba(255, 197, 49, 0.3), transparent 60%),
    var(--grad-brand);
  color: #fff;
  padding: 20px;
}

.level-complete {
  width: min(100%, 620px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(10px, 2vh, 16px);
}

.level-complete__banner { width: min(78%, 340px); animation: banner-wave 1.4s ease-in-out infinite; }
.level-complete__banner img { width: 100%; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.4)); }

@keyframes banner-wave {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

.level-complete__title { font-size: clamp(1.6rem, 5vw, 2.3rem); font-weight: 800; text-wrap: balance; }
.level-complete__subtitle { color: var(--blue-300); font-weight: 600; }

.level-complete__chest { width: clamp(120px, 20vh, 180px); animation: float 2.6s ease-in-out infinite; }
.level-complete__chest img { width: 100%; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.42)); }

.level-complete__sparkles { width: clamp(90px, 14vw, 130px); animation: sparkle-twinkle 1.8s ease-in-out infinite; }

@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0.65; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.08); }
}

.level-complete__stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.level-complete__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; padding-bottom: 6px; }
.level-complete__actions .btn { flex: 1 1 160px; max-width: 240px; }

/* ------------------------------ 14. Modals ----------------------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--sat));
  padding-bottom: calc(16px + var(--sab));
  background: rgba(20, 12, 48, 0.6);
  backdrop-filter: blur(4px);
  animation: fade-in 180ms ease both;
}

.modal-root[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(100%, 420px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius-l);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  animation: modal-in 240ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.modal[hidden] { display: none; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__title { font-size: 1.35rem; font-weight: 800; color: var(--ink-900); }
.modal__text { color: var(--ink-600); font-size: 0.95rem; }
.modal__mascot { width: 90px; margin-inline: auto; }
.modal__actions { display: flex; flex-direction: column; gap: 10px; }
.modal__actions--row { flex-direction: row; }
.modal__actions--row .btn { flex: 1; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--paper-soft);
}

.setting-row__label { font-weight: 700; color: var(--ink-900); }

.help-list { text-align: left; display: flex; flex-direction: column; gap: 8px; color: var(--ink-600); font-size: 0.95rem; }
.help-list li { padding-left: 20px; position: relative; }
.help-list li::before { content: "★"; position: absolute; left: 0; color: var(--gold-500); }

/* ------------------------------ 15. Toast ------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--sab));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 420px);
  background: var(--paper);
  color: var(--ink-900);
  font-weight: 700;
  border-radius: var(--radius-pill);
  border: 2px solid var(--gold-500);
  box-shadow: var(--shadow-pop);
  padding: 10px 18px;
  animation: toast-in 260ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.toast .icon { width: 22px; height: 22px; flex-shrink: 0; }
.toast[hidden] { display: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --------------------------- 16. Media queries ------------------------- */

/* Phone: intentionally redesigned, not shrunk */
@media (max-width: 560px) {
  .screen--game { padding: 4px 5px calc(6px + var(--sab)); gap: 5px; }

  /* HUD: row 1 = level + stats, row 2 = progress (pause lives in the field) */
  .gamebar { flex-wrap: wrap; gap: 6px 10px; padding: 6px 10px; min-height: 0; border-radius: 14px; }
  .gamebar__level { order: 0; flex: 1; min-width: 0; }
  .gamebar__shield { width: 30px; height: 30px; border-radius: 9px; }
  .gamebar__title { font-size: 0.78rem; gap: 5px; }
  .gamebar__stats { order: 1; gap: 5px; }
  .gamebar__timer { font-size: 0.8rem;
    min-height: 40px; padding: 3px 9px; }
  .gamebar__timer .icon { width: 14px; height: 14px; }
  .gamebar__score { font-size: 0.8rem;
    min-height: 40px; padding: 3px 10px; }
  .gamebar__score .icon { width: 13px; height: 13px; }
  .gamebar__hearts { padding: 4px 8px; }
  .gamebar__hearts .icon { width: 17px; height: 17px; }
  .gamebar__progress { order: 2; flex-basis: 100%; min-width: 0; gap: 8px; }
  .gamebar__bar { height: 11px; }

  /* Instruction card + Pause pill: restyled by the dedicated phone field-top
     block below (max-width: 600px) — they stack in normal flow there. */

  .mole { width: clamp(98px, 30vw, 138px); }
  .mole__bubble { max-width: 38vw; min-width: 76px; font-size: 15px; padding: 7px 10px; }

  .paddle { min-height: 52px; font-size: 0.95rem; }

  .home__actions .btn,
  .results__actions .btn,
  .level-complete__actions .btn { flex: 1 1 100%; max-width: none; }
  .modal { padding: 18px 14px 14px; }
}

/* ---- Narrow field top (≤820px: phones and portrait tablets): Pause and the
 * instruction card stack in NORMAL FLOW. Pause owns a small row ABOVE the
 * card, so the two can never overlap and no control is absolutely positioned
 * over sentence text. (The centered-card + corner-pill layout only becomes
 * overlap-free around 800px of width, so everything below 820px stacks.)
 * Only the Prairie Dog yard keeps absolute positioning; the other absolutely
 * positioned field layers (background, yard, score popups, paddles, feedback
 * card) ignore the flex layout. Landscape tablets and desktop are unchanged. */
@media (max-width: 820px) {
  .whack { display: flex; flex-direction: column; gap: 8px; }

  .pause-pill {
    position: static;            /* leave the absolute overlay stack */
    order: -1;                   /* own row above the instruction */
    align-self: flex-start;
    flex-shrink: 0;
    margin: 8px 0 0 8px;         /* safe spacing from the field edge */
    min-height: 44px;            /* comfortable touch target */
  }

  .instruction {
    position: static;            /* in flow below Pause — never under it */
    transform: none;
    flex-shrink: 0;
    box-sizing: border-box;
    min-width: 0;
    width: calc(100% - 24px);
    max-width: min(100%, 560px); /* keep the desktop card cap */
    margin-inline: auto;
    padding: 18px 56px 18px 60px; /* taller card, badge left, ring right */
  }

  /* Stacked center stage: the card STAYS in flow (its row keeps the field
     layout stable — nothing jumps when it flies) and ui.js measures the
     distance to the field's center and animates it with an inline transform,
     because top/left cannot animate a static element. transform:none is only
     the no-JS fallback; the inline style wins whenever the beat runs. */
  .instruction.is-center {
    transform: none;
  }
}

/* Phone-sized refinements inside the stacked layout. sizing applies to
   narrow phones (width <= 600) AND short/landscape phones (height <= 480):
   both must keep the instruction card compact so sentence bubbles always
   clear it. */
@media (max-width: 600px), (max-height: 480px) {
  .pause-pill { padding: 0 12px; gap: 6px; font-size: 0.8rem; }

  /* Compact card: ~40-60px for plain instructions, ~90-110px when the
     missing-word sentence row is present. Same cream-and-gold family —
     just sized for small screens. The hint line is dropped: it only
     restates the instruction text already shown between badge and ring. */
  .instruction {
    padding: 9px 42px;
    gap: 2px 6px;
    border-radius: 16px;
  }
  .instruction__text {
    font-size: 0.98rem;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .instruction__hint { display: none; }
  .instruction__sentence { font-size: 0.92rem; line-height: 1.25; overflow-wrap: anywhere; }

  /* narrow phones: ornaments shrink to stars only so the text keeps its room */
  .instruction__orn-line { display: none; }
  .instruction__orn { min-width: 8px; }
  .instruction__orn-star { width: 9px; height: 9px; }

  .instruction__badge { width: 32px; height: 32px; left: 7px; border-width: 2.5px; font-size: 0.92rem; }
  .instruction__timer { width: 36px; height: 36px; right: 6px; }
  .instruction__ring { width: 36px; height: 36px; }
  .instruction__seconds { font-size: 0.8rem; }
  .instruction__speak { min-height: 30px; padding: 3px 10px; font-size: 0.72rem; margin-top: 2px; }
}

/* Extra-tight card for VERY short fields (landscape phones): the sentence
   stays (the question needs it) but the Listen pill is dropped — every
   bubble keeps its own tap-to-hear badge — and everything shrinks a notch
   so a whole bubble+animal stack fits below the card. */
@media (max-height: 480px) {
  .instruction { padding: 5px 38px; }
  .instruction__text { font-size: 0.82rem; }
  .instruction__sentence { font-size: 0.85rem; line-height: 1.2; }
  .instruction__speak { display: none; }
  .instruction__badge { width: 28px; height: 28px; font-size: 0.82rem; }
  .instruction__timer { width: 30px; height: 30px; }
  .instruction__ring { width: 30px; height: 30px; }
  .instruction__seconds { font-size: 0.72rem; }
  .instruction__orn { display: none; }
}

/* Journey map fades: on phones the full-bleed artwork eases under the header
   and the bottom edge via sticky gradient masks. */
.map-fade { position: sticky; height: 0; z-index: 6; pointer-events: none; }
.map-fade::after { content: ""; position: absolute; left: 0; right: 0; height: 46px; }
.map-fade--top { top: 0; }
.map-fade--top::after {
  top: 0;
  background: linear-gradient(180deg, rgba(30, 20, 66, 0.9), rgba(30, 20, 66, 0));
}
.map-fade--bottom { bottom: 0; }
.map-fade--bottom::after {
  bottom: 0;
  height: 38px;
  background: linear-gradient(0deg, rgba(30, 20, 66, 0.8), rgba(30, 20, 66, 0));
}

/* Tablet tier: the portrait tablet painting fills the available width as a
   framed journey column; the header shares the same side insets as the map. */
.map-tier-tablet .map-fade { display: none; }
.map-tier-tablet .map-viewport {
  padding: 6px clamp(14px, 3vw, 28px) calc(18px + var(--sab));
}
.map-tier-tablet .screen-header--map { margin-inline: clamp(14px, 3vw, 28px); }
.map-tier-tablet .map-canvas--journey {
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-pop);
}

/* Desktop tier: the panorama occupies the full content area below the
   header — no narrow centered column, no empty purple sides. On very tall
   windows the stage caps its height (ui.js) so the cover crop can never
   hide the edge islands; the canvas then centers vertically like a matted
   frame. The header matches the map's width. */
.map-tier-desktop .map-fade { display: none; }
.map-tier-desktop .map-viewport {
  padding: 8px 14px 14px;
  overflow-y: hidden; /* the panorama is sized to fit; nothing to scroll */
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.map-tier-desktop .screen-header--map { margin-inline: 14px; }
.map-tier-desktop .map-canvas--journey {
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-pop);
}

/* Short screens (landscape phones): fit content, keep game playable */
@media (max-height: 640px) {
  .home { gap: 8px; }
  .home__kicker { padding: 3px 12px; font-size: 0.66rem; }
  .home__brand { gap: 5px; }
  .home__title { font-size: clamp(1.6rem, 6vw, 2.2rem); }
  .home__mascot img { width: clamp(110px, 20vh, 180px); }
  .home__actions .btn--xl { min-height: 50px; }
}

@media (max-height: 480px) {
  .home { gap: 6px; padding-block: 8px; }
  .home__mascot img { width: clamp(70px, 16vh, 110px); }
  .home__mascot { margin-top: 8px; }
  .home__subtitle, .home__kicker, .home__footer,
  .home__sky, .home__mascot-glow, .home__mascot-ring, .home__mascot-shadow { display: none; }
  .home__actions { flex-wrap: nowrap; }
  .home__actions .btn { flex: 1 1 auto; }

  .intro-info { gap: 6px; }
  .intro-hero { display: none; }
  .intro__title { font-size: clamp(1.2rem, 4vh, 1.6rem); }
  .intro__instruction { font-size: 0.92rem; }
  .intro__start { min-height: 46px; margin-top: 2px; }
  .intro-card { display: none; }

  .loading__mascot { width: 104px; height: 104px; }
  .loading__mascot img { width: 92px; }
  .loading__hole { width: 96px; }
  .error-box__mascot { width: 70px; }

  .gamebar { min-height: 42px; }
  /* Short fields: tighten the phone flow stack (see the compact-card block
     above for the card itself — sizing is handled there, not here). */
  .whack { gap: 4px; }
  .pause-pill { margin: 4px 0 0 6px; padding: 0 10px; font-size: 0.76rem; min-height: 40px; }
  .mole { width: clamp(70px, 16.5vh, 124px); }
  .mole__bubble { font-size: 15px; }
  .paddle { min-height: 46px; }
  .binary { bottom: 6px; }
}

/* Reduced motion: user preference or in-game setting */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@media (hover: hover) {
  .btn--primary:hover,
  .btn--secondary:hover { transform: translateY(-2px); }
  .map-jnode:not(.map-jnode--soon):not(.map-jnode--locked):hover .map-jnode__disc { transform: scale(1.06); }
}

/* Touch devices: never show any custom or pointer cursor in the arena */
@media (pointer: coarse) {
  .whack, .whack * { cursor: default !important; }
  .hammer-cursor { display: none !important; }
}

@media (max-width: 560px) {
  .home { gap: 6px; padding-top: clamp(12px, 2vh, 24px); }
  .home__title { font-size: clamp(1.8rem, 6.5vw, 2.4rem); }
  .home__hero img { width: clamp(120px, 24vh, 190px); }
  .home__actions .btn { flex: 1 1 100%; max-width: none; min-height: 50px; }
}
@media (max-height: 640px) {
  .home { gap: 4px; }
  .home__hero img { width: clamp(100px, 18vh, 160px); }
  .home__subtitle { display: none; }
  .home__actions { flex-wrap: nowrap; }
  .home__actions .btn { flex: 1 1 auto; min-height: 46px; }
}
