/* IQ Brain — IQ Bonkers Flagship shell styles
   Galaxy theme. Vanilla CSS, system font stack only, no external resources.
   Polish pass 2026-11-17: centered masthead, fluid type/spacing (clamp),
   layered starfield depth, unified card surfaces, liquid motion throughout.
   Masthead promotion 2026-11-17 (from the iq-brain-test variant, on Andy's
   approval): logo mark right of the wordmark + larger Adults · Kids ·
   Seniors switcher. Presentation only. */

:root {
  --pink: #FF00C6;
  --pink2: #FF5CDB;
  --navy: #070B1E;
  --navy2: #0D1430;
  --card: #131B3D;
  --card2: #18234C;
  --ink: #F4F6FF;
  --muted: #9AA7D4;
  --good: #2EE6A8;
  --bad: #FF5C7A;
  --gold: #FFD166;

  --radius: 18px;
  --radius-sm: 12px;
  --tap: 48px; /* minimum tap target */
  --wm-size: clamp(2.5rem, 11vw, 3.8rem); /* wordmark fluid size — logo + switcher scale from it */
  --maxw: 980px;

  /* Fluid scale — type and spacing glide with the viewport, no jumpy steps. */
  --pad-x: clamp(1rem, 4.5vw, 1.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.2, 1.45, 0.36, 1);
}

* { box-sizing: border-box; }

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

/* Seniors mode: larger base font (everything below is in rem where it matters). */
body.mode-seniors { font-size: 118%; }
/* Kids mode: slightly larger tap targets (see .mode-kids rules below). */
body.mode-kids { --tap: 60px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.45;
  /* Deep-space navy + layered radial-gradient starfield. */
  background-color: var(--navy);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 8%, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 16%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 76% 30%, rgba(255, 92, 219, 0.8) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 10%, rgba(255, 255, 255, 0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 48%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 62%, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 52%, rgba(255, 255, 255, 0.65) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 92% 58%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 76%, rgba(255, 92, 219, 0.55) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 88%, rgba(255, 255, 255, 0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 80%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 92%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 96% 84%, rgba(255, 255, 255, 0.6) 50%, transparent 51%),
    radial-gradient(ellipse 90% 55% at 85% -10%, rgba(255, 0, 198, 0.16), transparent 60%),
    radial-gradient(ellipse 80% 50% at 5% 105%, rgba(46, 80, 230, 0.20), transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy2) 100%);
  background-attachment: fixed;
}

/* Living starfield: two parallax layers over the painted sky — a far field
   that drifts slowly and a near field that twinkles — for real depth. */
.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 18px 26px, rgba(255, 255, 255, 0.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 130px 90px, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 205px 160px, rgba(255, 182, 235, 0.65) 50%, transparent 51%),
    radial-gradient(1px 1px at 70px 200px, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 250px 40px, rgba(255, 255, 255, 0.6) 50%, transparent 51%);
  background-size: 280px 240px;
  animation: starDrift 160s linear infinite alternate;
}
.starfield::after {
  content: "";
  position: absolute;
  inset: -60px;
  background-image:
    radial-gradient(2px 2px at 60px 70px, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 300px 210px, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 470px 120px, rgba(255, 92, 219, 0.75) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 180px 330px, rgba(255, 255, 255, 0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 540px 300px, rgba(255, 255, 255, 0.8) 50%, transparent 51%);
  background-size: 620px 420px;
  animation: starTwinkle 7s ease-in-out infinite alternate, starDrift 240s linear infinite alternate-reverse;
}
@keyframes starDrift {
  from { background-position: 0 0; }
  to   { background-position: 140px 70px; }
}
@keyframes starTwinkle {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

/* Content floats above the starfield layers. */
.app-header, .app-main, .app-footer { position: relative; z-index: 1; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus-visible, a:focus-visible {
  outline: 3px solid var(--pink2);
  outline-offset: 2px;
}

/* ---------- Header — centered masthead ---------- */

.app-header {
  overflow: hidden;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 3.2rem) var(--pad-x) clamp(0.7rem, 2.5vw, 1.1rem);
  text-align: center;
}

/* Milky Way band: a wide diagonal soft gradient band centered behind the
   wordmark — layered core glow + star specks, breathing very slowly. */
.milky-way {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 170%;
  height: clamp(120px, 27vw, 200px);
  transform: translate(-50%, -50%) rotate(-14deg);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.10) 22%,
    rgba(255, 182, 235, 0.22) 46%,
    rgba(255, 255, 255, 0.28) 52%,
    rgba(255, 92, 219, 0.16) 62%,
    rgba(255, 255, 255, 0.08) 78%,
    transparent 100%
  );
  filter: blur(14px);
  opacity: 0.8;
  pointer-events: none;
  animation: mwBreathe 9s ease-in-out infinite alternate;
}
.milky-way::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 22px 30px, rgba(255, 255, 255, 0.95) 50%, transparent 51%),
    radial-gradient(1px 1px at 64px 58px, rgba(255, 255, 255, 0.8) 50%, transparent 51%),
    radial-gradient(2px 2px at 105px 22px, rgba(255, 255, 255, 0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 140px 66px, rgba(255, 214, 245, 0.9) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40px 78px, rgba(255, 255, 255, 0.7) 50%, transparent 51%);
  background-size: 170px 96px;
  opacity: 0.85;
}
.milky-way::after {
  content: "";
  position: absolute;
  left: 30%;
  right: 30%;
  top: 18%;
  bottom: 18%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(255, 255, 255, 0.30), rgba(255, 92, 219, 0.12) 55%, transparent 75%);
  filter: blur(10px);
}
@keyframes mwBreathe {
  from { opacity: 0.65; }
  to   { opacity: 0.9; }
}

.header-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.95rem, 3vw, 1.35rem);
  text-align: center;
}

/* Wordmark + logo lockup: one centered unit, logo on the RIGHT of the
   wordmark (Andy's pick, promoted from the test variant 2026-11-17). */
.wordmark-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.7rem, 2.5vw, 1.1rem);
}

.wordmark {
  margin: 0;
  font-size: var(--wm-size);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* Logo height ≈ 2.2× the wordmark cap height (cap ≈ 0.716 × font size),
   scaling on the same fluid clamp as the wordmark itself.
   Optical alignment (Andy's note, 2026-11-17 — "a little bit larger and
   align better"): the V32 PNG carries transparent headroom (artwork bbox
   starts 31% down the canvas), so the artwork's alpha-weighted centroid
   sits at 59.8% of the image box — below its geometric center — and plain
   flex centering leaves the mark riding low beside the wordmark. The
   translateY lifts the box by (centroid − cap-band center) so the
   artwork's visual center rides the wordmark's cap-height center. */
.masthead-logo {
  display: block;
  width: auto;
  height: calc(var(--wm-size) * 1.58);
  transform: translateY(calc(var(--wm-size) * -0.18));
  filter: drop-shadow(0 0 14px rgba(255, 0, 198, 0.35));
}
.wordmark-iq {
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 0, 198, 0.65), 0 0 46px rgba(255, 0, 198, 0.3);
}
.wordmark-brain { color: var(--ink); }

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 0.72rem + 0.4vw, 0.9rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.tagline {
  position: relative;
  margin: clamp(0.85rem, 3vw, 1.15rem) 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 0.9rem + 0.5vw, 1.08rem);
  text-align: center;
}

/* Segmented mode switcher — enlarged (promoted from the test variant,
   2026-11-17): bigger pills, larger labels, generous tap targets,
   still centered. */
.mode-switcher {
  display: inline-flex;
  background: rgba(13, 20, 48, 0.82);
  border: 1px solid rgba(154, 167, 212, 0.35);
  border-radius: 999px;
  padding: 6px;
  gap: 4px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  min-height: 56px;
  padding: 0.7rem clamp(1.15rem, 4.5vw, 1.65rem);
  font-size: clamp(1.06rem, 1rem + 0.55vw, 1.28rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    box-shadow 0.25s var(--ease), transform 0.15s var(--ease);
}
.mode-btn:active { transform: scale(0.95); }
.mode-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--pink), var(--pink2));
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 0, 198, 0.45);
}

/* ---------- Layout ---------- */

.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(0.6rem, 2vw, 1rem) var(--pad-x) clamp(2rem, 6vw, 3rem);
}

.app-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad-x) 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- BrainScore card ---------- */

.brainscore-card {
  background: linear-gradient(160deg, var(--card), var(--navy2));
  border: 1px solid rgba(154, 167, 212, 0.28);
  border-radius: var(--radius);
  padding: clamp(1.15rem, 4vw, 1.6rem);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.brainscore-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
}
.brainscore-title { margin: 0; font-size: clamp(1.25rem, 1.1rem + 1vw, 1.45rem); }
.brainscore-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; max-width: 34rem; }
.brainscore-overall {
  margin-top: 0.35rem;
  font-size: clamp(2.6rem, 9vw, 3.8rem);
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 209, 102, 0.35);
  min-width: 2ch;
  text-align: center;
}
.brainscore-bars {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 0.55rem clamp(1rem, 3vw, 1.5rem);
}
.bs-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.6rem;
  align-items: baseline;
}
.bs-name { font-size: 0.9rem; color: var(--ink); }
.bs-value { font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.bs-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: rgba(154, 167, 212, 0.22);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.bs-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--pink2));
  transform-origin: left center;
  animation: bsGrow 0.9s var(--ease) both;
}
@keyframes bsGrow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ---------- Category tiles & game rows ---------- */

.category-grid {
  margin-top: clamp(1rem, 3.5vw, 1.4rem);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: clamp(0.9rem, 2.5vw, 1.25rem);
}
.category-tile {
  background: linear-gradient(165deg, var(--card), var(--navy2));
  border: 1px solid rgba(154, 167, 212, 0.24);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.25rem);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: tileIn 0.55s var(--ease) both;
}
.category-tile:nth-child(2) { animation-delay: 0.05s; }
.category-tile:nth-child(3) { animation-delay: 0.10s; }
.category-tile:nth-child(4) { animation-delay: 0.15s; }
.category-tile:nth-child(5) { animation-delay: 0.20s; }
.category-tile:nth-child(6) { animation-delay: 0.25s; }
@keyframes tileIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.category-name {
  position: relative;
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  font-size: clamp(1.05rem, 1rem + 0.6vw, 1.2rem);
  letter-spacing: 0.02em;
}
.category-name::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.4rem;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), rgba(255, 0, 198, 0));
}
.game-list { display: flex; flex-direction: column; gap: 0.5rem; }

.game-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  background: var(--navy2);
  border: 1px solid rgba(154, 167, 212, 0.22);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 0.65rem 0.8rem;
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease),
    box-shadow 0.22s var(--ease), background 0.22s var(--ease);
}
.game-row:hover {
  border-color: var(--pink2);
  background: var(--card2);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.game-row:active {
  border-color: var(--pink2);
  transform: scale(0.98);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.game-icon {
  font-size: 1.7rem;
  line-height: 1;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.game-text { flex: 1 1 auto; min-width: 0; }
.game-name { display: block; font-weight: 800; }
.game-tagline { display: block; color: var(--muted); font-size: 0.88rem; }
.best-chip {
  flex: 0 0 auto;
  background: rgba(255, 209, 102, 0.16);
  color: var(--gold);
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}
.coming-soon { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0; }

/* Kids: larger tap targets & roomier rows. */
body.mode-kids .game-row { padding: 0.95rem 1rem; gap: 1rem; }
body.mode-kids .game-icon { font-size: 2rem; }
body.mode-kids .btn, body.mode-kids .back-btn { min-height: 60px; padding-left: 1.4rem; padding-right: 1.4rem; }

/* ---------- Game screen ---------- */

.game-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.game-title {
  margin: 0;
  font-size: clamp(1.25rem, 1.1rem + 1vw, 1.45rem);
  flex: 1 1 auto;
  text-align: center;
}
.game-topbar-spacer { flex: 0 0 5.5rem; }
.back-btn {
  flex: 0 0 auto;
  min-height: var(--tap);
  background: var(--card);
  border: 1px solid rgba(154, 167, 212, 0.35);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-weight: 700;
  transition: border-color 0.22s var(--ease), transform 0.15s var(--ease),
    box-shadow 0.22s var(--ease);
}
.back-btn:hover { border-color: var(--pink2); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
.back-btn:active { transform: scale(0.96); }

#game-mount {
  background: linear-gradient(165deg, var(--card), var(--navy2));
  border: 1px solid rgba(154, 167, 212, 0.24);
  border-radius: var(--radius);
  padding: clamp(0.9rem, 3.5vw, 1.4rem);
  min-height: 320px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.game-error { color: var(--bad); }

/* ---------- Result overlay ---------- */

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 11, 30, 0.82);
  animation: overlayIn 0.28s ease both;
}
.result-overlay[hidden] { display: none; }
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.result-card {
  background: linear-gradient(165deg, var(--card2), var(--card));
  border: 1px solid rgba(255, 92, 219, 0.45);
  border-radius: var(--radius);
  box-shadow: 0 0 44px rgba(255, 0, 198, 0.28);
  padding: clamp(1.3rem, 5vw, 1.8rem);
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.result-eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
}
.result-score {
  font-size: clamp(3.2rem, 14vw, 4.4rem);
  font-weight: 900;
  line-height: 1.05;
  color: var(--pink2);
  text-shadow: 0 0 26px rgba(255, 0, 198, 0.5);
}
.result-label { margin: 0.4rem 0 0; font-size: 1.1rem; font-weight: 700; }
.result-accuracy { margin: 0.35rem 0 0; color: var(--muted); }
.result-actions {
  margin-top: 1.3rem;
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Shell juice (quality gate, Nov 17): transitions + celebration ---------- */

@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
#home-screen:not([hidden]),
#game-screen:not([hidden]) { animation: screenIn 0.45s var(--ease) both; }

@keyframes resultPop {
  0%   { transform: scale(0.82); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.result-card {
  position: relative;
  overflow: visible;
  animation: resultPop 0.45s var(--ease-spring) both;
}

.result-burst {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 2;
}
.result-burst i {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--pink));
  box-shadow: 0 0 10px var(--c, var(--pink));
  opacity: 0;
  animation: burstFly 1.15s cubic-bezier(0.15, 0.6, 0.4, 1) forwards;
}
.result-burst i:nth-child(3n) { border-radius: 2px; width: 7px; height: 7px; }
.result-burst i:nth-child(4n) { width: 5px; height: 5px; }
@keyframes burstFly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

.btn {
  min-height: var(--tap);
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-weight: 800;
  border: 1px solid transparent;
  transition: transform 0.15s var(--ease), box-shadow 0.25s var(--ease),
    filter 0.25s var(--ease), border-color 0.25s var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--pink2));
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 0, 198, 0.4);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(154, 167, 212, 0.45);
}
.btn-ghost:hover { border-color: var(--pink2); }

/* Utility states used by games via the shell (optional helpers). */
.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.text-gold { color: var(--gold); }

@media (max-width: 560px) {
  .game-topbar-spacer { display: none; }
}

/* Respect users who prefer stillness: keep the layout, drop the motion. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Sound toggle (masthead corner; centered column untouched) ---------- */
.sound-toggle {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(154, 167, 212, 0.35);
  background: rgba(13, 20, 48, 0.82);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease), border-color 0.25s var(--ease), opacity 0.25s var(--ease);
}
.sound-toggle:active { transform: scale(0.92); }
.sound-toggle[aria-pressed="false"] { opacity: 0.55; border-color: rgba(154, 167, 212, 0.2); }

/* ---------- Feel layer (feel.js: particles, flash, floating text) ---------- */
#iqf-canvas {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
#iqf-float {
  position: fixed;
  inset: 0;
  z-index: 31;
  pointer-events: none;
  overflow: hidden;
}
.iqf-flash {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--iqf-flash-c, rgba(255, 255, 255, 0.85)) 0%, rgba(255, 0, 198, 0.25) 55%, transparent 72%);
  animation: iqfFlash 0.32s ease-out forwards;
}
@keyframes iqfFlash {
  from { opacity: 0.9; transform: scale(0.6); }
  to   { opacity: 0; transform: scale(1.25); }
}
.iqf-float-text {
  position: absolute;
  transform: translate(-50%, -100%);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--pink);
  text-shadow: 0 2px 14px rgba(255, 0, 198, 0.55), 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  animation: iqfFloatUp 1.1s var(--ease) forwards;
}
.iqf-float-text.iqf-gold { color: var(--gold); text-shadow: 0 2px 14px rgba(255, 209, 102, 0.55), 0 1px 3px rgba(0, 0, 0, 0.6); }
@keyframes iqfFloatUp {
  0%   { opacity: 0; transform: translate(-50%, -80%) scale(0.8); }
  18%  { opacity: 1; transform: translate(-50%, -110%) scale(1.08); }
  32%  { transform: translate(-50%, -118%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}
/* Hit-stop: freeze in-container CSS animation for the impact frame. */
.iqf-hitstop *, .iqf-hitstop *::before, .iqf-hitstop *::after {
  animation-play-state: paused !important;
}

/* ---------- Combo meter (feel.js shared component) ---------- */
.iqf-combo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto 10px;
  font-size: 0.9rem;
}
.iqf-combo-label {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
.iqf-combo-track {
  flex: 0 1 180px;
  height: 8px;
  border-radius: 99px;
  background: rgba(154, 167, 212, 0.22);
  overflow: hidden;
}
.iqf-combo-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--pink2));
  transition: width 0.18s var(--ease);
}
.iqf-combo.iqf-combo-hot .iqf-combo-fill {
  background: linear-gradient(90deg, var(--pink), var(--gold));
  box-shadow: 0 0 10px rgba(255, 0, 198, 0.6);
}
.iqf-combo-x { font-weight: 900; color: var(--ink); min-width: 2.4em; text-align: left; }
.iqf-combo.iqf-combo-hot .iqf-combo-x { color: var(--gold); }
.iqf-combo-banked {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.iqf-combo-banked.iqf-show { opacity: 1; }

/* ---------- Quick how-to layer (howto.js, 2026-11-17) ----------
 * Galaxy shell styling, ~10-second read. The panel is an overlay:
 * the mounted game underneath is never touched, so closing the panel
 * returns to the round exactly as it was. Mode rules follow the
 * shell's existing mode system (body.mode-kids / .mode-seniors). */
.howto-btn {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.howto-btn:hover { border-color: var(--pink); }
.howto-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 11, 30, 0.84);
  animation: overlayIn 0.28s ease both;
}
.howto-overlay[hidden] { display: none; }
.howto-card {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.4rem 1.4rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55), 0 0 44px rgba(255, 0, 198, 0.14);
  text-align: left;
  animation: resultPop 0.38s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.howto-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pink2);
}
.howto-name { margin: 0 0 0.55rem; font-size: 1.45rem; line-height: 1.15; }
.howto-goal { margin: 0 0 0.7rem; font-weight: 700; font-size: 1.02rem; }
.howto-goal::before { content: "🎯 "; }
.howto-list { margin: 0 0 0.8rem; padding-left: 1.25rem; }
.howto-list li { margin: 0.3rem 0; line-height: 1.45; }
.howto-list li::marker { color: var(--pink2); }
.howto-win {
  margin: 0 0 1.05rem;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: rgba(255, 209, 102, 0.08);
  line-height: 1.45;
}
.howto-win::before { content: "🏁 "; }
.howto-play-btn {
  width: 100%;
  min-height: 56px;
  font-size: 1.18rem;
  font-weight: 800;
}
/* Kids: bigger words, bigger button, roomier lines. */
body.mode-kids .howto-card { font-size: 1.1rem; }
body.mode-kids .howto-name { font-size: 1.6rem; }
body.mode-kids .howto-goal { font-size: 1.14rem; }
body.mode-kids .howto-list li { line-height: 1.55; }
body.mode-kids .howto-play-btn { min-height: 64px; font-size: 1.3rem; }
body.mode-kids .howto-btn { min-height: var(--tap); }
/* Seniors: larger type, calm spacing, tall button. */
body.mode-seniors .howto-card { font-size: 1.12rem; line-height: 1.6; }
body.mode-seniors .howto-name { font-size: 1.6rem; }
body.mode-seniors .howto-goal { font-size: 1.16rem; }
body.mode-seniors .howto-list li { line-height: 1.65; }
body.mode-seniors .howto-play-btn { min-height: 64px; font-size: 1.28rem; }
@media (max-width: 560px) {
  .howto-btn { font-size: 0.8rem; padding: 0.4rem 0.65rem; }
  .howto-card { padding: 1.15rem 1.1rem 1.05rem; }
}

/* ---------- Standalone additions: how-to overlay (flagship shipped it unstyled) ---------- */
.howto-btn{flex:0 0 auto;min-height:var(--tap);background:var(--card);border:1px solid rgba(154,167,212,.35);border-radius:999px;padding:.5rem 1rem;font-weight:700}
.howto-btn:hover{border-color:var(--pink2)}
.howto-overlay{position:fixed;inset:0;z-index:45;display:flex;align-items:center;justify-content:center;padding:1rem;background:rgba(7,11,30,.85)}
.howto-overlay[hidden]{display:none}
.howto-card{background:linear-gradient(165deg,var(--card2),var(--card));border:1px solid rgba(255,92,219,.45);border-radius:var(--radius);box-shadow:0 0 44px rgba(255,0,198,.28);padding:clamp(1.3rem,5vw,1.8rem);max-width:460px;width:100%;text-align:left}
.howto-eyebrow{margin:0;color:var(--muted);text-transform:uppercase;letter-spacing:.14em;font-size:.8rem}
.howto-name{margin:.3rem 0 .4rem;font-size:1.5rem}
.howto-goal{margin:0 0 .6rem;font-weight:700;font-size:1.05rem}
.howto-list{margin:0 0 .7rem;padding-left:1.25rem;color:var(--ink)}
.howto-list li{margin:.35rem 0}
.howto-win{margin:0 0 1.1rem;color:var(--gold);font-weight:700}
.howto-play-btn{width:100%}
.mode-badge{display:inline-block;margin-top:.6rem;background:rgba(255,0,198,.14);border:1px solid rgba(255,92,219,.5);color:var(--ink);border-radius:999px;padding:.3rem .9rem;font-size:.85rem;font-weight:800;letter-spacing:.06em}
.grownups-note,.calm-note{margin-top:1.25rem;background:linear-gradient(160deg,var(--card),var(--navy2));border:1px solid rgba(154,167,212,.28);border-radius:var(--radius);padding:1.1rem 1.25rem}
.grownups-note h2,.calm-note h2{margin:0 0 .45rem;font-size:1.1rem}
.grownups-note p,.calm-note p{margin:.3rem 0;color:var(--muted)}
.grownups-note strong,.calm-note strong{color:var(--ink)}

/* Kids standalone: roomier, brighter, zero-fail framing */
body.mode-kids .game-name{font-size:1.12rem}
body.mode-kids .brainscore-sub{font-size:1rem}
