/* ═══════════════════════════════════════════════════════
   PONY QUEST — "Quiet Magic" edition
   WebGL canvas paints scene + ponies. HTML floats above as
   hairline chrome with type-as-breath philosophy.
   Cormorant Garamond + Inter, candle-gold accent.
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,500;1,600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --candle: #fdf6e8;
  --candle-dim: rgba(253, 246, 232, 0.7);
  --ink: #1a1530;
  --warm: #f4b87a;
  --warm-deep: #c4793d;
  --rose: #e85a8c;       /* Ivy */
  --sky:  #5fa4d9;       /* Oliver */
  --shadow-text: 0 1px 2px rgba(0,0,0,0.55), 0 2px 12px rgba(0,0,0,0.45);
  --shadow-text-hard: 0 1px 1px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.55), 0 4px 18px rgba(0,0,0,0.4);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; font-family: inherit; }

html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--ink);
  color: var(--candle);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

/* ═════ Vignette layer (over WebGL canvas, under HTML) ═════
   Strong radial: bright painted scene at center, fades to ink at edges.
   Replaces the previous top/bottom scrims — corner darkening is enough
   to keep HUD + dock + cards readable.
*/
body::before {
  content: ""; position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  background: radial-gradient(
    ellipse 66% 54% at center,
    transparent 0%,
    transparent 30%,
    rgba(13,10,28,0.44) 65%,
    rgba(13,10,28,0.78) 100%
  );
}

/* ═════ Screens ═════ */
.screen {
  display: none;
  position: fixed; inset: 0;
  padding:
    max(1rem, env(safe-area-inset-top))
    1rem
    max(1rem, env(safe-area-inset-bottom));
  z-index: 5;
}
.screen.active {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  overflow-y: auto;
}
/* Allow grid children to shrink below their natural size so overflow-y
   actually scrolls (otherwise center alignment can push content off-screen
   above the scrollable area). */
.screen.active > * { min-height: 0; min-width: 0; }
/* Welcome stacks tall — let it scroll from the top instead of centering
   an oversize box, which was causing the title to clip on phones. */
#screen-welcome.active { align-items: start; padding-top: 1.5rem; }

/* ═════ Top HUD (chapter context) ═════ */
.hud {
  width: 100%;
  max-width: 720px;
  padding-top: 0.25rem;
  text-align: center;
  color: var(--candle);
  text-shadow: var(--shadow-text-hard);
  z-index: 10;
}
.hud-eyebrow {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.625rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.85);
}
.hud-chapter {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1;
  margin-top: 0.25rem;
}
.hud-rule {
  margin: 0.6rem auto 0;
  max-width: 200px;
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  color: var(--warm);
  font-size: 0.6rem;
}
.hud-rule::before, .hud-rule::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
}
.hud-hearts-row {
  display: flex; gap: 0.25rem;
  justify-content: center;
  margin-top: 0.6rem;
}
.heart-glyph {
  width: 14px; height: 14px;
  background: var(--warm);
  clip-path: path("M12 21s-9-5.5-9-12a5 5 0 0 1 9-3 5 5 0 0 1 9 3c0 6.5-9 12-9 12z");
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.heart-glyph.empty { background: rgba(253,246,232,0.3); }

/* ═════ Content zone (story / puzzle / etc.) ═════ */
.content {
  width: 100%;
  max-width: 720px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  z-index: 5;
  /* Generous bottom padding so the last interactive element is never
     covered by the floating dock controls on phone viewports. */
  padding: 1rem 0.5rem 5.5rem;
  color: var(--candle);
}

/* ═════ Bottom dock (overlays canvas ponies + controls) ═════ */
.dock {
  width: 100%;
  max-width: 720px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.25rem;
  z-index: 10;
}
.dock-pony {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.35rem;
  flex: 0 0 auto;
  text-align: center;
  text-shadow: var(--shadow-text-hard);
  pointer-events: none; /* canvas pony art shows through */
}
.dock-pony.active .name {
  color: var(--warm);
  text-shadow: 0 0 14px rgba(244,184,122,0.55), var(--shadow-text-hard);
}
.dock-pony .name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--candle);
}
.dock-pony.ivy    .name { color: #ffb6cf; }
.dock-pony.oliver .name { color: #b8d8f5; }
.dock-pony .stars {
  display: flex; gap: 3px;
}
.star-glyph {
  width: 10px; height: 10px;
  background: var(--warm);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.star-glyph.empty { background: rgba(253,246,232,0.28); }

/* ═════ Center cluster (music, read, pause) ═════ */
.dock-controls {
  display: flex; gap: 0.5rem;
  align-items: center;
  padding-bottom: 1rem;
  flex: 0 0 auto;
}
.ctrl-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(253,246,232,0.7);
  background: rgba(26,21,48,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--candle);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: all 0.18s ease;
  pointer-events: auto;
}
.ctrl-btn:hover { border-color: var(--candle); background: rgba(26,21,48,0.7); transform: translateY(-2px); }
.ctrl-btn:active { transform: scale(0.94); }
.ctrl-btn svg { width: 18px; height: 18px; }
.ctrl-btn.read {
  width: 54px; height: 54px;
  border-color: var(--warm);
  background: rgba(244,184,122,0.18);
  color: var(--warm);
}
.ctrl-btn.read svg { width: 22px; height: 22px; }
.ctrl-btn.muted { opacity: 0.45; }
.ctrl-btn.speaking {
  border-color: var(--warm);
  background: rgba(244,184,122,0.32);
  color: var(--warm);
  animation: pulse-warm 0.9s ease-in-out infinite alternate;
}
@keyframes pulse-warm {
  from { box-shadow: 0 0 6px rgba(244,184,122,0.35); }
  to   { box-shadow: 0 0 22px rgba(244,184,122,0.65); }
}

/* ═════ Type atoms ═════ */
.smallcaps {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}
.gold { color: var(--warm); }

/* ═════ Buttons ═════ */
.btn-primary {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--candle);
  border: none;
  padding: 0.95rem 1.75rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(253,246,232,0.18), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 48px;
  margin-top: 0.5rem;
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(253,246,232,0.25), 0 3px 10px rgba(0,0,0,0.35); }
.btn-primary:active { transform: scale(0.97); }

.btn-hairline {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--candle);
  background: rgba(26,21,48,0.42);
  border: 1px solid rgba(253,246,232,0.75);
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.18s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  min-height: 44px;
  margin-top: 0.4rem;
}
.btn-hairline:hover  { border-color: var(--candle); background: rgba(26,21,48,0.6); }
.btn-hairline:active { transform: scale(0.97); }

.btn-text {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.8);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.btn-text:hover { color: var(--candle); }

.btn-startover {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.55);
  background: transparent;
  border: 1px solid rgba(253,246,232,0.3);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: all 0.18s;
}
.btn-startover:hover { border-color: rgba(232,90,140,0.7); color: rgba(232,90,140,0.95); }
.btn-startover.primed { border-color: rgba(232,90,140,0.95); color: rgba(232,90,140,1); }

/* ═════ WELCOME ═════ */
#screen-welcome.active { grid-template-rows: 1fr auto; }
.welcome-box {
  display: flex; flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 520px;
  margin: auto;
  padding: 1rem;
  text-shadow: var(--shadow-text-hard);
}
.welcome-eyebrow {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--warm);
  margin-bottom: 1rem;
}
.welcome-box h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: 0.005em;
  color: var(--candle);
}
.welcome-box h1 .accent {
  display: block;
  font-style: italic;
  font-weight: 500;
  color: var(--warm);
  margin-top: -0.05em;
}
.welcome-subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  color: rgba(253,246,232,0.85);
  margin-top: 1rem;
  letter-spacing: 0.01em;
}
.welcome-intro {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  line-height: 1.55;
  color: var(--candle);
  margin-top: 1.25rem;
  max-width: 32ch;
  text-wrap: pretty;
}
.welcome-intro strong { color: var(--warm); font-weight: 600; }

/* hide the legacy banner emoji row */
.welcome-banner { display: none; }

/* ═════ PONY SELECT ═════ */
#screen-pony-select.active { grid-template-rows: auto 1fr auto; }
#pony-select-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  color: var(--candle);
  text-align: center;
  margin: 1rem 0 1.5rem;
  text-shadow: var(--shadow-text-hard);
  background: none; padding: 0; border-radius: 0; box-shadow: none; max-width: none;
  letter-spacing: 0.005em;
}
#pony-select-title::before {
  content: "✦";
  display: block;
  font-style: normal;
  color: var(--warm);
  font-size: 0.55em;
  letter-spacing: 0.5em;
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.3em;
}
.pony-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  width: 100%; max-width: 720px;
  align-self: center;
}
.pony-card {
  background: rgba(26,21,48,0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(253,246,232,0.55);
  border-radius: 18px;
  padding: 1rem 0.6rem 0.85rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  text-shadow: var(--shadow-text);
}
.pony-card:hover {
  border-color: var(--warm);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.35), 0 0 0 1px var(--warm);
}
.pony-card:active { transform: scale(0.97); }
.pony-card.taken  { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.6); }
.pony-card-img {
  width: 72%; max-height: 92px; object-fit: contain;
  margin: 0 auto 0.5rem; display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}
.pony-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--candle);
  margin-bottom: 0.25rem;
  letter-spacing: 0.005em;
}
.pony-element {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.6rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
  margin-bottom: 0.5rem;
}
.pony-power {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.9);
  margin-bottom: 0.2rem;
}
.pony-power-desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.4;
  color: rgba(253,246,232,0.75);
}
.taken-label {
  position: absolute; top: 8px; right: 8px;
  background: rgba(244,184,122,0.95);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}

/* ═════ Dark text card (map-style) ═════
   Used wherever significant copy needs a solid reading surface over the
   painted scene. Picks up the same ink + hairline + ✦ vocabulary as the
   map screen.
*/
.text-card,
.story-text,
.gameover-box,
.cc-box,
.dig-box {
  background: rgba(13,10,28,0.78);
  border: 1px solid rgba(253,246,232,0.18);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(253,246,232,0.06);
  position: relative;
}
.text-card::before,
.story-text::before,
.gameover-box::before,
.cc-box::before,
.dig-box::before {
  content: "✦";
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: rgba(13,10,28,0.95);
  color: var(--warm);
  font-size: 0.8rem;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(244,184,122,0.4);
}

/* ═════ STORY ═════ */
.story-text {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  line-height: 1.45;
  letter-spacing: 0.005em;
  color: var(--candle);
  text-wrap: pretty;
  max-width: 320px;
  padding: 1.5rem 1.5rem 1.25rem;
  margin: 0 auto 1rem;
}
.story-text em { font-style: italic; color: var(--warm); }

/* ═════ PUZZLE ═════ */
.puzzle-header {
  display: flex; align-items: center; justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  text-shadow: var(--shadow-text-hard);
}
.puzzle-header .dot {
  width: 3px; height: 3px; border-radius: 50%; background: var(--warm);
}
.puzzle-type-badge {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.85);
  background: none; padding: 0; border-radius: 0;
}
.puzzle-turn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--warm);
  background: none; padding: 0; border-radius: 0;
}
.ivy-turn, .oliver-turn, .both-turn { color: var(--warm); }

.puzzle-art {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  margin: 0.5rem 0 1rem;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.4));
  min-height: 3rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.puzzle-art-img {
  width: 96px; height: 96px;
  object-fit: contain;
  display: block; margin: 0 auto;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.4));
}

.puzzle-question {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  line-height: 1.4;
  color: var(--candle);
  text-wrap: pretty;
  max-width: 320px;
  margin: 0 auto 1rem;
  /* Dark card */
  background: rgba(13,10,28,0.78);
  border: 1px solid rgba(253,246,232,0.18);
  border-radius: 22px;
  padding: 1.25rem 1.5rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(253,246,232,0.06);
  position: relative;
}
.puzzle-question::before {
  content: "✦";
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: rgba(13,10,28,0.95);
  color: var(--warm);
  font-size: 0.8rem;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(244,184,122,0.4);
}

.puzzle-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  width: 100%;
  max-width: 380px;
  margin: 0.5rem auto 0.5rem;
}
.choice-btn {
  background: rgba(26,21,48,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(253,246,232,0.7);
  border-radius: 18px;
  padding: 0.95rem 0.5rem;
  color: var(--candle);
  font-family: var(--serif);
  font-weight: 600;
  /* Bigger, denser font for kid readability */
  font-size: clamp(1.4rem, 4vw, 1.7rem);
  cursor: pointer;
  transition: all 0.18s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  min-height: 70px;
  line-height: 1.1;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--candle);
  background: rgba(26,21,48,0.7);
}
.choice-btn:disabled { cursor: default; }
.choice-btn.correct {
  border-color: var(--warm);
  background: rgba(244,184,122,0.28);
  color: var(--warm);
  box-shadow: 0 0 24px rgba(244,184,122,0.45), inset 0 0 0 1px rgba(244,184,122,0.55);
}
.choice-btn.wrong {
  border-color: rgba(232,90,140,0.85);
  background: rgba(232,90,140,0.18);
  color: #ff9fbb;
}
.choice-btn.magic-peek {
  border-color: var(--warm);
  background: rgba(244,184,122,0.18);
  animation: pulse-gold 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-gold {
  from { box-shadow: 0 0 6px rgba(244,184,122,0.45); }
  to   { box-shadow: 0 0 24px rgba(244,184,122,0.65), 0 0 40px rgba(244,184,122,0.3); }
}

.btn-hint, .btn-magic {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--candle);
  background: rgba(26,21,48,0.45);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(253,246,232,0.55);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  margin: 0.2rem;
  transition: all 0.18s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn-hint:hover { border-color: var(--warm); }
.btn-magic {
  border-color: var(--warm);
  color: var(--warm);
  background: rgba(244,184,122,0.12);
}
.btn-magic:hover { background: rgba(244,184,122,0.22); }

.hint-box {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--warm);
  background: rgba(244,184,122,0.10);
  border: 1px solid rgba(244,184,122,0.4);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin: 0.5rem auto;
  max-width: 380px;
  backdrop-filter: blur(8px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Team clues */
.team-clues {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.75rem;
  background: rgba(26,21,48,0.4);
  border: 1px solid rgba(253,246,232,0.3);
  border-radius: 18px;
  padding: 1rem;
  margin: 0.5rem auto;
  max-width: 480px;
  backdrop-filter: blur(10px);
}
.clue-instruction {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--candle);
  text-align: center;
  text-shadow: var(--shadow-text);
}
.clue-cards { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; }
.clue-card {
  background: rgba(26,21,48,0.55);
  border: 1px solid rgba(253,246,232,0.4);
  border-top-width: 2px;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  min-width: 180px; max-width: 220px;
  backdrop-filter: blur(8px);
}
.clue-card.clue-ivy    { border-top-color: var(--rose); }
.clue-card.clue-oliver { border-top-color: var(--sky); }
.clue-player-header {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.clue-card.clue-ivy    .clue-player-header { color: #ffb6cf; }
.clue-card.clue-oliver .clue-player-header { color: #b8d8f5; }
.clue-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--candle);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.feedback-box {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
  background: rgba(26,21,48,0.55);
  border: 1px solid rgba(244,184,122,0.4);
  border-radius: 18px;
  padding: 1rem 1.25rem;
  /* Bottom margin keeps the "Keep going" button clear of the dock controls
     on short phone viewports. */
  margin: 0.5rem auto 5rem;
  max-width: 420px;
  backdrop-filter: blur(10px);
  text-shadow: var(--shadow-text);
  position: relative;
  z-index: 12;   /* sits above the dock so the button is never covered */
}
.feedback-icon { font-size: 2rem; filter: drop-shadow(0 2px 8px rgba(244,184,122,0.5)); }
.feedback-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--candle);
  text-align: center;
}

@keyframes shake {
  0%,100%{transform:translateX(0)}
  20%,60%{transform:translateX(-6px)}
  40%,80%{transform:translateX(6px)}
}
.shake { animation: shake 0.45s ease-in-out; }

/* Mini dig grid (inline puzzle) */
.mini-dig-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0.75rem auto;
  max-width: 320px;
}
.mini-dig-status {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
  text-align: center;
  margin: 0.5rem 0;
  text-shadow: var(--shadow-text);
}

/* ═════ DIG SCREEN ═════ */
.dig-box {
  width: 100%;
  max-width: 420px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
  padding: 1.5rem 1.25rem 1.25rem;
  margin: 0 auto;
}
.dig-box h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--candle);
  letter-spacing: 0.005em;
  text-shadow: var(--shadow-text-hard);
}
.dig-item-preview { font-size: 3rem; min-height: 3rem; filter: drop-shadow(0 4px 14px rgba(0,0,0,0.5)); }
.dig-item-img {
  width: 120px; height: 120px;
  object-fit: contain; display: block; margin: 0.25rem auto;
  filter: drop-shadow(0 4px 16px rgba(244,184,122,0.5));
}
#dig-message {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--candle);
}
.dig-shovel-count {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--warm);
}
.dig-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin: 0.5rem 0;
  width: 100%;
  max-width: 380px;
}
.dig-tile {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #4a2818, #2e1808);
  border: 1px solid rgba(244,184,122,0.25);
  border-radius: 10px;
  font-size: 1.2rem;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.dig-tile:hover:not(.dug) {
  background: linear-gradient(135deg, #6a3a20, #4a2410);
  transform: scale(1.04);
  border-color: rgba(244,184,122,0.5);
}
.dig-tile.dug {
  background: rgba(244,184,122,0.18);
  border-color: var(--warm);
  cursor: default;
  box-shadow: 0 0 14px rgba(244,184,122,0.5);
  animation: unearth 0.3s ease-out;
}
@keyframes unearth { from{transform:scale(.7);opacity:.5} to{transform:scale(1);opacity:1} }
.dig-progress-wrap {
  width: 100%;
  background: rgba(26,21,48,0.6);
  border: 1px solid rgba(253,246,232,0.25);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.dig-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--warm), var(--candle));
  border-radius: 999px;
  transition: width 0.35s ease;
}
#dig-found-text {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--warm);
  margin: 0.4rem 0;
  text-shadow: var(--shadow-text);
}
.dig-box p {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: rgba(253,246,232,0.85);
  text-shadow: var(--shadow-text);
}
.dig-box p strong {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  color: var(--warm);
  font-size: 1rem;
  letter-spacing: 0;
}

/* ═════ CHAPTER COMPLETE ═════ */
.cc-box {
  width: 100%; max-width: 420px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.6rem;
  padding: 1.5rem 1.25rem 1.25rem;
  margin: 0 auto;
}
.cc-art {
  font-size: 3.5rem;
  min-height: 3.5rem;
  filter: drop-shadow(0 6px 18px rgba(244,184,122,0.4));
}
.cc-item-img {
  width: 200px; height: 200px;
  object-fit: contain; display: block; margin: 0 auto;
  filter: drop-shadow(0 0 28px rgba(244,184,122,0.65)) drop-shadow(0 0 56px rgba(244,184,122,0.35));
  animation: item-reveal 0.7s cubic-bezier(0.34,1.56,0.64,1) forwards, float 2.5s 0.7s ease-in-out infinite;
}
@keyframes item-reveal {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  70%  { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.cc-box h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  color: var(--candle);
  letter-spacing: 0.005em;
  text-shadow: var(--shadow-text-hard);
}
.cc-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.55;
  color: var(--candle);
  max-width: 32ch;
  text-wrap: pretty;
}
.cc-powerup {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
}
.cc-scores { display: flex; justify-content: center; gap: 2.5rem; margin: 0.5rem 0; }
.cc-score-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.4rem;
}
.cc-pony { font-size: 2.2rem; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5)); }
.cc-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.9);
}

/* ═════ GAME OVER ═════ */
#screen-gameover.active { grid-template-rows: 1fr auto; }
.gameover-box {
  width: 100%; max-width: 420px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.6rem;
  padding: 1.5rem 1.25rem 1.25rem;
  margin: auto;
}
.gameover-art { font-size: 3.5rem; filter: drop-shadow(0 4px 14px rgba(0,0,0,0.5)); }
.gameover-box h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--candle);
  text-shadow: var(--shadow-text-hard);
  letter-spacing: 0.005em;
}
#gameover-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.55;
  color: var(--candle);
  max-width: 32ch;
  text-wrap: pretty;
}

/* ═════ VICTORY ═════ */
#screen-victory.active { grid-template-rows: 1fr auto; }
.victory-box {
  width: 100%; max-width: 520px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
  margin: auto;
  padding: 1rem;
  text-shadow: var(--shadow-text-hard);
}
.victory-ponies {
  font-size: 2.5rem;
  filter: drop-shadow(0 4px 14px rgba(244,184,122,0.5));
  display: flex; align-items: center; gap: 0.5rem;
  justify-content: center;
}
.victory-ponies::before {
  content: "✦";
  font-size: 0.6em;
  color: var(--warm);
  font-family: var(--sans);
  font-weight: 600;
}
.victory-ponies::after {
  content: "✦";
  font-size: 0.6em;
  color: var(--warm);
  font-family: var(--sans);
  font-weight: 600;
}
.victory-box h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  line-height: 0.95;
  color: var(--candle);
  letter-spacing: 0.005em;
}
.victory-sub {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  color: rgba(253,246,232,0.9);
  max-width: 32ch;
  text-wrap: pretty;
  margin-top: 0.5rem;
}
.final-scores {
  display: flex; justify-content: center; gap: 2.5rem;
  margin: 1rem 0;
}
.final-score-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.35rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.9);
}
.final-score-pony {
  font-size: 2rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}
.final-score-card span:not(.final-score-pony) {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--warm);
  letter-spacing: 0;
  text-transform: none;
  text-shadow: var(--shadow-text-hard);
}

/* ═════ MAP SCREEN ═════ */
#screen-map .hud { display: block; }
#screen-map.active {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(244,184,122,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(95,164,217,0.06) 0%, transparent 55%),
    linear-gradient(180deg, #1a1530 0%, #0d0a1c 100%);
}
#screen-map.active::before {
  content: ""; position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(253,246,232,0.5) 0, transparent 1.2px),
    radial-gradient(circle at 80% 12%, rgba(253,246,232,0.4) 0, transparent 1.2px),
    radial-gradient(circle at 22% 60%, rgba(253,246,232,0.3) 0, transparent 1.2px),
    radial-gradient(circle at 88% 55%, rgba(253,246,232,0.4) 0, transparent 1.2px),
    radial-gradient(circle at 50% 38%, rgba(253,246,232,0.3) 0, transparent 1.2px),
    radial-gradient(circle at 65% 78%, rgba(253,246,232,0.5) 0, transparent 1.2px);
  opacity: 0.6;
  z-index: 0;
}
#screen-map > * { position: relative; z-index: 1; }
.map-canvas {
  position: relative;
  width: 100%;
  max-width: 520px;
  flex: 1;
  min-height: 360px;
  margin: 0.5rem auto 0.5rem;
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 90px; text-align: center;
  pointer-events: none;
}
.node-disc {
  width: 64px; height: 64px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid rgba(253,246,232,0.4);
  background: var(--ink);
  margin: 0 auto;
  position: relative;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  transition: width 0.4s ease, height 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}
.node-disc img { width: 100%; height: 100%; object-fit: cover; }

.map-node.locked .node-disc {
  border-style: dashed;
  border-color: rgba(253,246,232,0.22);
  box-shadow: none;
}
.map-node.locked .node-disc img { filter: grayscale(1) brightness(0.35); }
.map-node.locked .node-disc::after {
  content: "✦";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(244,184,122,0.5);
  font-size: 1.4rem;
}
.map-node.locked .node-label,
.map-node.locked .node-num { opacity: 0.45; }

.map-node.complete .node-disc {
  border-color: var(--warm);
  border-width: 1px;
}
.map-node.complete .node-disc::after {
  content: "✦";
  position: absolute; top: -3px; right: -3px;
  width: 18px; height: 18px;
  background: var(--warm);
  color: var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.55rem;
  font-weight: 700;
}

.map-node.current .node-disc {
  width: 78px; height: 78px;
  border-color: var(--warm);
  border-width: 2px;
  box-shadow: 0 0 28px rgba(244,184,122,0.55), 0 6px 18px rgba(0,0,0,0.4);
  animation: pulse-warm 1.6s ease-in-out infinite alternate;
}

.node-num {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.55rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.node-label {
  margin-top: 0.1rem;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--candle);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.map-ponies {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 5;
  display: flex; align-items: flex-end;
  transition: left 1.6s cubic-bezier(0.4, 0, 0.2, 1), top 1.6s cubic-bezier(0.4, 0, 0.2, 1);
  animation: pony-bob 1.4s ease-in-out infinite alternate;
}
@keyframes pony-bob {
  from { translate: 0 0; }
  to   { translate: 0 -4px; }
}
.map-pony {
  width: 56px; height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.55));
}
.map-pony + .map-pony { margin-left: -16px; }
.map-pony.flip { transform: scaleX(-1); }

.map-caption { text-align: center; margin-top: 0.5rem; }
.caption-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--candle);
  text-shadow: var(--shadow-text-hard);
  max-width: 28ch;
  margin: 0 auto 1rem;
}
.caption-text em { color: var(--warm); }

/* ═════ WELCOME MAP PEEK ═════ */
.map-peek {
  width: 100%;
  max-width: 320px;
  margin: 1.25rem auto 0.5rem;
  padding: 0.85rem 0.75rem 0.5rem;
  border: 1px solid rgba(253,246,232,0.22);
  border-radius: 16px;
  background: rgba(13,10,28,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(253,246,232,0.06);
  position: relative;
}
.peek-eyebrow {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.55rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(253,246,232,0.7);
  text-align: center;
  margin-bottom: 0.5rem;
}
.peek-canvas { position: relative; height: 130px; }
.peek-canvas .map-node { width: 50px; }
.peek-canvas .node-disc { width: 38px; height: 38px; border-width: 1px; }
.peek-canvas .map-node.current .node-disc { width: 44px; height: 44px; }
.peek-canvas .node-disc::after { font-size: 0.85rem; }
.peek-canvas .map-node.complete .node-disc::after {
  width: 12px; height: 12px; font-size: 0.4rem; top: -2px; right: -2px;
}
.peek-canvas .node-num,
.peek-canvas .node-label { display: none; }

@media (max-width: 480px) {
  .map-canvas { min-height: 320px; }
  .node-disc { width: 56px; height: 56px; }
  .map-node.current .node-disc { width: 68px; height: 68px; }
  .map-pony { width: 48px; height: 48px; }
  .map-node { width: 78px; }
}

/* ═════ Legacy: convert HUD player blocks to dock format ═════
   The JS still writes to .hud-player elements for stars/pony/label. We
   re-style those into the bottom-dock pony rings instead of removing them.
*/
.hud { display: none; }  /* hide legacy HUD; replaced by .topbar */

/* legacy globals — keep these so JS references don't break */
.tts-toggle, .music-toggle { display: none !important; }

/* ═════ RESPONSIVE ═════ */
@media (min-width: 768px) {
  /* Tablet+ — more breathing room */
  .ctrl-btn { width: 52px; height: 52px; }
  .ctrl-btn.read { width: 64px; height: 64px; }
  .hud-chapter { font-size: 1.5rem; }
  .hud-eyebrow { font-size: 0.75rem; }
  .heart-glyph { width: 16px; height: 16px; }
}
@media (min-width: 1100px) {
  /* Desktop — even larger and more space */
  .ctrl-btn { width: 56px; height: 56px; }
  .ctrl-btn.read { width: 72px; height: 72px; }
  .hud { max-width: 900px; padding-top: 1.5rem; }
  .dock { max-width: 1100px; padding: 0 2rem 0.5rem; }
  .content { max-width: 900px; padding: 2rem; }
  .puzzle-choices { max-width: 480px; }
}
@media (max-width: 480px) {
  .pony-grid { grid-template-columns: repeat(2, 1fr); }
  .pony-card-img { max-height: 76px; }
  /* Keep 2-column (2x2) grid on phones — bigger tap targets, easier to
     read than a long vertical stack. */
  .puzzle-choices { grid-template-columns: 1fr 1fr; max-width: 320px; gap: 0.5rem; }
  .clue-cards { flex-direction: column; }
  .ctrl-btn { width: 40px; height: 40px; }
  .ctrl-btn.read { width: 48px; height: 48px; }
  .ctrl-btn svg { width: 16px; height: 16px; }
  .ctrl-btn.read svg { width: 20px; height: 20px; }
  .final-scores, .cc-scores { gap: 1.5rem; }
}
@media (max-height: 700px) {
  .hud-rule { margin-top: 0.4rem; }
  .hud-hearts-row { margin-top: 0.4rem; }
  .heart-glyph { width: 12px; height: 12px; }
}
/* ─── TRACE puzzle ─────────────────────────────────── */
.trace-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0.5rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.trace-canvas {
  width: 320px;
  height: 320px;
  max-width: 90vw;
  max-height: 50vh;
  background: rgba(13,10,28,0.78);
  border: 1px solid rgba(244,184,122,0.4);
  border-radius: 22px;
  touch-action: none;
  cursor: crosshair;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.trace-status {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
  margin-top: 0.25rem;
}
.trace-controls {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  justify-content: center; align-items: center;
}

/* ─── SHOOT puzzle ─────────────────────────────────── */
.shoot-wrap {
  width: 100%;
  max-width: 520px;
  margin: 0.5rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.shoot-hud {
  display: flex;
  justify-content: space-around;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--warm);
}
.shoot-stat {
  background: rgba(13,10,28,0.6);
  border: 1px solid rgba(244,184,122,0.3);
  border-radius: 10px;
  padding: 0.25rem 0.55rem;
}
.shoot-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 50vh;
  background: rgba(13,10,28,0.78);
  border: 1px solid rgba(244,184,122,0.35);
  border-radius: 22px;
  overflow: hidden;
  touch-action: manipulation;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.shoot-target {
  position: absolute;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2.4rem;
  color: var(--candle);
  /* Solid dark bg gives crisp contrast for the number/letter inside —
     against the cave/jungle scenes the previous translucent gold made
     the glyph nearly invisible. */
  background: rgba(13, 10, 28, 0.92);
  border: 3px solid var(--warm);
  border-radius: 50%;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.4),
    0 0 18px rgba(244,184,122,0.45);
}
.shoot-target.hit {
  animation: shoot-burst 0.32s ease-out forwards;
}
.shoot-target.miss {
  animation: shoot-shake 0.28s ease-out forwards;
  background: rgba(232,90,140,0.22);
  border-color: #ff9fbb;
}
@keyframes shoot-burst {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.6); background: rgba(244,222,140,0.6); }
  100% { transform: scale(2.0); opacity: 0; }
}
@keyframes shoot-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ─── MAZE puzzle ──────────────────────────────────── */
.maze-wrap {
  width: 100%;
  max-width: 380px;
  margin: 0.5rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.maze-grid {
  display: grid;
  grid-template-columns: repeat(var(--maze-cols, 5), 1fr);
  gap: 4px;
  width: 100%;
  max-width: 320px;
  padding: 8px;
  background: rgba(13,10,28,0.78);
  border: 1px solid rgba(244,184,122,0.35);
  border-radius: 18px;
  touch-action: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.maze-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(244,184,122,0.10);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  position: relative;
  transition: background 0.15s;
}
.maze-cell.wall {
  background: linear-gradient(135deg, #2a1a0a, #1a0d05);
  box-shadow: inset 0 0 6px rgba(0,0,0,0.6);
}
.maze-cell.goal {
  background: rgba(244,184,122,0.45);
  animation: pulse-warm 1.4s ease-in-out infinite alternate;
}
.maze-cell.goal::after {
  content: "👸";
  font-size: 1.5rem;
}
.maze-cell.player::after {
  content: var(--dino-emoji, "🦖");
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.maze-cell.player.goal::after {
  /* on goal cell, stack dino with princess */
  content: "🦖👸";
  font-size: 1.2rem;
}
.maze-cell.bump {
  animation: maze-bump 0.28s ease-out;
}
@keyframes maze-bump {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); background: rgba(232,90,140,0.35); }
}
.maze-controls {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.maze-row { display: flex; gap: 4px; }
.maze-btn {
  width: 56px; height: 56px;
  font-size: 1.3rem;
  border-radius: 12px;
  background: rgba(26,21,48,0.55);
  border: 1px solid rgba(253,246,232,0.7);
  color: var(--candle);
  cursor: pointer;
  font-family: var(--sans);
}
.maze-btn:active { background: rgba(244,184,122,0.25); transform: scale(0.95); }
.maze-status {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--warm);
  margin-top: 0.25rem;
}

/* small screens — shrink puzzle play areas */
@media (max-width: 480px) {
  .trace-canvas { width: 280px; height: 280px; }
  .maze-grid { max-width: 280px; }
  .maze-btn { width: 48px; height: 48px; font-size: 1.1rem; }
  .shoot-target { width: 76px; height: 76px; font-size: 2rem; }

/* Stars overflow guard — never let a tall stack push controls off center. */
.dock-pony { max-width: 30%; min-width: 0; }
.dock-pony .stars {
  flex-wrap: wrap;
  max-width: 100%;
  justify-content: center;
  font-size: 0.78rem;
}

/* Pause overlay (parity with dinorescue) */
.pause-overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(13,10,28,0.78);
  backdrop-filter: blur(6px);
  z-index: 100;
}
.pause-card {
  background: rgba(26,21,48,0.92);
  border: 1px solid var(--warm);
  border-radius: 22px;
  padding: 2rem 2.5rem;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.pause-icon { font-size: 3rem; color: var(--warm); }
.pause-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 2rem;
  color: var(--candle);
  text-shadow: var(--shadow-text-hard);
}
/* Stars overflow guard — applies to .dock-dino single-player block. */
.dock-dino { max-width: 30%; min-width: 0; }
.dock-dino .stars {
  flex-wrap: wrap;
  max-width: 100%;
  justify-content: center;
  font-size: 0.78rem;
}

/* Character interlude (Pirate Captain barging in mid-chapter, etc.) */
.character-interlude {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(13,10,28,0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  padding: 1.5rem;
}
.interlude-card {
  background: rgba(26,21,48,0.95);
  border: 2px solid var(--warm);
  border-radius: 22px;
  padding: 1.4rem 1.5rem 1.25rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7),
              inset 0 0 0 1px rgba(255,222,140,0.18);
  display: flex; flex-direction: column;
  align-items: center; gap: 0.85rem;
  animation: interlude-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes interlude-pop {
  0%   { transform: scale(0.7) translateY(20px); opacity: 0; }
  100% { transform: scale(1)   translateY(0);    opacity: 1; }
}
.interlude-img {
  max-width: 180px;
  max-height: 200px;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,0.7));
  animation: interlude-float 1.6s ease-in-out infinite alternate;
}
@keyframes interlude-float {
  from { transform: translateY(0); }
  to   { transform: translateY(-6px); }
}
.interlude-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--warm);
}
.interlude-label:empty { display: none; }
.interlude-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--candle);
  line-height: 1.45;
  text-shadow: var(--shadow-text-soft);
  margin-bottom: 0.25rem;
}
