/* ==========================================================================
   MUSEUM GUARDIANS — PROTOTYPE STYLESHEET
   Design tokens below implement the "bright, warm, rounded, never-scary"
   direction from PROJECT_VISION.md / GAME_DESIGN_DOCUMENT.md Ch.13.
   Signature element: the "Guardian Bubble" speech-bubble-with-tail used
   for every companion line, tying every screen together visually.
   ========================================================================== */

:root {
  /* --- Color (named palette) --- */
  --color-bg: #EAF6F7;          /* pale museum-atrium sky-blue */
  --color-bg-deep: #DCEEF0;      /* slightly deeper variant for depth/cards */
  --color-surface: #FFFFFF;
  --color-ink: #2B2A4C;          /* warm deep indigo-plum — used instead of pure black */
  --color-ink-soft: #5C5A82;
  --color-gold: #E8A33D;         /* Guardian signature / badges / primary CTA */
  --color-gold-deep: #C97F1E;
  --color-teal: #3FA796;         /* staff / secondary interactive accent */
  --color-teal-deep: #2C7F71;
  --color-coral: #F2785C;        /* gentle warm highlight — never used as a "wrong" signal */
  --color-pink: #F28CB6;         /* playful kid-friendly accent */
  --color-sky: #9BD4E8;          /* bright supplementary sky accent */

  /* --- Radius (rounded-friendly, per approved art direction) --- */
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* --- Type --- */
  --font-display: "Trebuchet MS", "Segoe UI Rounded", "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* --- Shadow --- */
  --shadow-soft: 0 8px 24px rgba(43, 42, 76, 0.12);
  --shadow-lift: 0 14px 34px rgba(43, 42, 76, 0.18);

  /* --- Motion (respects Reduced Motion toggle via .reduced-motion class on body) --- */
  --dur-fast: 160ms;
  --dur-med: 320ms;
  --dur-slow: 560ms;
}

* { box-sizing: border-box; }

/* Several elements below (HUD, screen footer, badge overlay, modals) are
   toggled via the plain HTML `hidden` attribute in JS, but also carry a
   CSS class that sets `display: flex` for when they ARE visible. Without
   this rule, the class-based `display` declaration wins over the
   attribute's default `display: none` (a CSS-specificity gotcha), so
   those elements would stay visible at all times regardless of the
   `hidden` attribute actually being set. This single rule makes `hidden`
   always win, everywhere, no matter what other display value a class
   later declares. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: linear-gradient(180deg, #EAF6F7 0%, #F7F3E6 55%, #FDEBD9 100%);
  color: var(--color-ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.reduced-motion * {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--color-bg-deep);
  flex-shrink: 0;
  z-index: 20;
}
.hud-zone-label {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-ink-soft);
  font-size: 0.9rem;
  text-transform: uppercase;
}
.hud-badge-tray {
  display: flex;
  gap: 6px;
}
.badge-slot {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-deep);
  border: 2px solid rgba(43,42,76,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: transparent;
  transition: all var(--dur-med) ease;
}
.badge-slot.filled {
  background: linear-gradient(145deg, #FFD98A, var(--color-gold));
  border-color: var(--color-gold-deep);
  color: var(--color-ink);
  box-shadow: 0 0 0 3px rgba(232,163,61,0.25);
  transform: scale(1.05);
  animation: badgeShine 2.6s linear infinite;
}
@keyframes badgeShine {
  0%, 100% { box-shadow: 0 0 0 3px rgba(232,163,61,0.28), 0 0 0 0 rgba(242,140,182,0); }
  50% { box-shadow: 0 0 0 3px rgba(232,163,61,0.28), 0 0 0 6px rgba(242,140,182,0.18); }
}

/* ---------- Screen shell ---------- */
.screen-root {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  justify-content: safe center;
  text-align: center;
}
.screen-content > * {
  flex-shrink: 0;
}
.screen-content.screen-enter { animation: screenFadeIn var(--dur-med) ease; }
@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-footer {
  flex-shrink: 0;
  padding: 14px 20px 22px;
  display: flex;
  justify-content: center;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 30px;
  cursor: pointer;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  min-height: 48px;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible {
  outline: 3px solid var(--color-teal-deep);
  outline-offset: 3px;
}
.btn-primary {
  background: linear-gradient(145deg, #FFD98A, var(--color-gold));
  color: var(--color-ink);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { box-shadow: var(--shadow-lift); }
.btn-secondary {
  background: var(--color-teal);
  color: white;
  box-shadow: var(--shadow-soft);
}
.btn-ghost {
  background: transparent;
  color: var(--color-ink);
  border: 2px solid var(--color-ink-soft);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--color-coral);
  border: 2px solid var(--color-coral);
  font-size: 0.85rem;
  padding: 10px 20px;
}
.btn-danger {
  background: var(--color-coral);
  color: white;
}
.btn-block { width: 100%; max-width: 340px; }
.btn-stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; }

/* ---------- Menu screen ---------- */
.menu-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}
.game-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  color: var(--color-ink);
  margin: 0;
}
.game-logo span { color: var(--color-gold-deep); }
.build-pill {
  margin-top: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(43,42,76,0.07);
  color: rgba(43,42,76,0.55);
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.game-tagline {
  color: var(--color-ink-soft);
  margin-top: -12px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

/* ---------- Placeholder scenery ---------- */
/* Every ".scene-art" block is a stand-in for a full illustrated background.
   Swap the placeholder emoji/shape for the matching Asset Bible ID
   (Phase 7) when final art is produced — see inline comments per screen. */
.scene-art {
  width: min(94vw, 540px);
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--color-bg-deep), var(--color-surface));
  border: 3px dashed rgba(43,42,76,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.scene-art-label {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 0.65rem;
  color: rgba(43,42,76,0.35);
  font-family: var(--font-body);
  letter-spacing: 0.03em;
}

/* ---------- Guardian bubble (signature element) ---------- */
.guardian-bubble {
  position: relative;
  max-width: 420px;
  width: 92vw;
  background: var(--color-surface);
  border: 3px solid var(--color-gold);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 10px 0 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.guardian-bubble::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: -14px;
  width: 22px;
  height: 22px;
  background: var(--color-surface);
  border-right: 3px solid var(--color-gold);
  border-bottom: 3px solid var(--color-gold);
  transform: rotate(45deg);
  border-radius: 0 0 4px 0;
}
.guardian-avatar {
  font-size: 2.2rem;
  flex-shrink: 0;
  /* PLACEHOLDER: swap for CHAR-GUARDIAN idle sprite, Character Bible Section 2 */
}
.guardian-line {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.35;
}

/* ---------- Story/heading text ---------- */
.screen-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  margin: 0 0 6px;
}
.screen-sub {
  color: var(--color-ink-soft);
  font-size: 0.95rem;
  margin: 0 0 14px;
  max-width: 460px;
}

/* ---------- Decision mechanic ---------- */
.decision-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.decision-card {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 3px solid var(--color-bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-size: 2.6rem;
  transition: transform var(--dur-fast) ease, border-color var(--dur-fast) ease;
  box-shadow: var(--shadow-soft);
}
.decision-card:hover { transform: translateY(-4px); border-color: var(--color-teal); }
.decision-card:active { transform: scale(0.97); }
.decision-card-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-ink-soft);
}
.decision-card.shake { animation: shakeCard 0.5s ease; }
@keyframes shakeCard {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------- Drag & drop (Locker) ---------- */
.dragdrop-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}
.dropzone {
  width: 130px;
  height: 90px;
  border-radius: var(--radius-md);
  border: 3px dashed var(--color-teal);
  background: rgba(63,167,150,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--color-teal-deep);
}
/* Locker with a real environment backdrop: the backpack drop target sits
   centered on the scene image instead of in a separate card below. */
.scene-art-real.backdrop-lg .dropzone.on-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.82);
  border: 3px dashed var(--color-teal);
  box-shadow: var(--shadow-soft);
  border-radius: 16px;
}
.dropzone.drag-over { background: rgba(63,167,150,0.22); }
.item-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
}
.drag-item {
  width: 66px;
  height: 66px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: grab;
  box-shadow: var(--shadow-soft);
  touch-action: none;
  user-select: none;
}
.drag-item.placed { opacity: 0.25; pointer-events: none; }
.drag-item.selected { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(232,163,61,0.35); transform: translateY(-3px); }
.drag-item.bounce { animation: bounceBack 0.4s ease; }
@keyframes bounceBack {
  0% { transform: scale(1); }
  40% { transform: scale(0.85) rotate(-6deg); }
  100% { transform: scale(1) rotate(0); }
}
.progress-pills { display: flex; gap: 6px; margin-top: 8px; }
.progress-pill {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--color-bg-deep);
  border: 2px solid rgba(43,42,76,0.15);
}
.progress-pill.filled { background: var(--color-gold); border-color: var(--color-gold-deep); }

/* ---------- Hidden object ---------- */
.hidden-object-scene {
  position: relative;
  width: min(94vw, 480px);
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--color-bg-deep), var(--color-surface));
  border: 3px dashed rgba(43,42,76,0.2);
  overflow: hidden;
  -webkit-background-size: cover;
  background-size: cover;
  background-position: center;
}
.hotspot {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  cursor: pointer;
  background: rgba(255,255,255,0.6);
  border: 2px solid rgba(43,42,76,0.15);
  transition: transform var(--dur-fast) ease;
}
.hotspot:hover { transform: scale(1.08); }
.hotspot.found { opacity: 0.3; pointer-events: none; transform: scale(0.85); }
.hotspot.shrug { animation: shrugPop 0.4s ease; }
@keyframes shrugPop {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.1) rotate(-4deg); }
}
.timer-bar-wrap {
  width: min(94vw, 480px);
  height: 14px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-deep);
  overflow: hidden;
  margin-bottom: 10px;
}
.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-teal), var(--color-gold));
  width: 100%;
  transition: width 1s linear;
}

/* ---------- Follow mechanic ---------- */
.follow-track {
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
}
.follow-step {
  width: 34px; height: 8px; border-radius: var(--radius-pill);
  background: var(--color-bg-deep);
}
.follow-step.done { background: var(--color-teal); }
.follow-step.current { background: var(--color-gold); animation: glowPulse 1.4s ease-in-out infinite; }

/* ---------- Puzzle ---------- */
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  grid-template-rows: repeat(3, 78px);
  gap: 6px;
  margin-bottom: 16px;
}
.puzzle-stage {
  aspect-ratio: auto;
  height: auto;
  padding: 12px;
  margin-bottom: 16px;
  overflow: visible;
}
.puzzle-stage .puzzle-grid {
  background: rgba(255,255,255,0.88);
  padding: 10px;
  border-radius: var(--radius-md);
  margin-bottom: 0;
}
.puzzle-slot {
  border-radius: var(--radius-sm);
  border: 2px dashed rgba(43,42,76,0.2);
  background: rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.puzzle-slot.filled { border-style: solid; border-color: var(--color-gold); background: var(--color-surface); }
.puzzle-tray {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 420px;
}
.puzzle-piece {
  width: 60px; height: 60px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  cursor: grab;
  box-shadow: var(--shadow-soft);
  touch-action: none;
}
.puzzle-piece.placed { opacity: 0.15; pointer-events: none; }
.puzzle-piece.selected { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(232,163,61,0.35); transform: translateY(-3px); }

/* ---------- NPC Assist / Memory challenge ---------- */
.npc-list { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 420px; }
.npc-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color var(--dur-fast) ease;
  text-align: left;
}
.npc-card:hover { border-color: var(--color-teal); }
.npc-card.resolved { opacity: 0.35; pointer-events: none; }
.npc-card.action-ready { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(232,163,61,0.18); transform: translateY(-2px); }
.npc-action-btn { margin-top: 8px; animation: popIn 0.25s ease; }

.npc-emoji { font-size: 2rem; flex-shrink: 0; }
.npc-text { font-size: 0.92rem; }
.candidate-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.candidate-card {
  width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
}
.candidate-card:hover { border-color: var(--color-teal); }
.candidate-emoji { font-size: 1.8rem; }
.candidate-detail { font-size: 0.7rem; color: var(--color-ink-soft); }
.clue-box {
  background: rgba(232,163,61,0.12);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  max-width: 400px;
  font-size: 0.9rem;
}
/* Full-view museum map overlay (Family Area "show map") — the real map
   photo deserves to be read at size, not squeezed into a medallion. */
.map-overlay {
  position: fixed; inset: 0;
  background: rgba(43,42,76,0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 80;
  cursor: pointer;
  animation: overlayFade var(--dur-med) ease;
}
.map-overlay img {
  max-width: 88vw;
  max-height: 72vh;
  border-radius: 12px;
  border: 4px solid var(--color-gold);
  box-shadow: var(--shadow-lift);
  pointer-events: none;
}

/* ---------- Free play (Exit Hall) ---------- */
.freeplay-hotspots { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin: 14px 0; }
.freeplay-hotspot {
  width: 100px; height: 100px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 2rem;
  cursor: pointer;
}
.freeplay-hotspot span.lbl { font-size: 0.65rem; color: var(--color-ink-soft); font-family: var(--font-display); }
.freeplay-hotspot.done { opacity: 0.4; }



/* ---------- Gameplay depth upgrades ---------- */
.hidden-object-clue {
  position: absolute;
  left: 12px; right: 12px; top: 10px;
  z-index: 3;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(43,42,76,0.14);
  font-size: .72rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.hotspot.mistake-hotspot {
  background: rgba(255,255,255,.86);
  border-color: rgba(232,163,61,.5);
  box-shadow: 0 4px 12px rgba(43,42,76,.12);
}
.hotspot.decoy-hotspot {
  opacity: .7;
  background: rgba(255,255,255,.42);
}
.hidden-response-panel {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  width: min(92%, 390px);
  z-index: 5;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255,253,248,.97);
  border: 2px solid var(--color-gold);
  box-shadow: var(--shadow-lift);
}
.hidden-response-title { font-weight: 700; font-size: .86rem; margin-bottom: 8px; text-align:center; }
.hidden-response-choices { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
.hidden-response-btn { flex:1 1 145px; min-height:44px; }
.hidden-response-feedback {
  position:absolute; left:50%; bottom:12px; transform:translateX(-50%);
  width:min(90%,360px); z-index:6; padding:10px 12px; border-radius:var(--radius-md);
  background:rgba(255,253,248,.96); text-align:center; font-size:.82rem; box-shadow:var(--shadow-soft);
}
.puzzle-instruction {
  width:min(94vw,500px); margin:0 auto 10px; padding:9px 12px;
  border-radius:var(--radius-md); background:rgba(232,163,61,.10);
  border:1px solid rgba(232,163,61,.35); font-size:.78rem; text-align:center;
}
.puzzle-slot { position:relative; }
.puzzle-slot-direction {
  position:absolute; top:4px; right:6px; font-size:.7rem; opacity:.35;
  pointer-events:none;
}
.puzzle-slot-ghost {
  transition: transform .25s ease, opacity .25s ease, filter .25s ease;
  opacity:.62;
  filter: grayscale(.35) saturate(.8);
  pointer-events:none;
}
.puzzle-slot.filled .puzzle-slot-ghost {
  opacity:1;
  filter:none;
}
.puzzle-piece { position:relative; }
.puzzle-piece-icon { transition:transform .25s ease; }
.puzzle-rotate {
  position:absolute; right:3px; bottom:3px; width:22px; height:22px;
  border:1px solid rgba(43,42,76,.18); border-radius:50%; background:var(--color-surface);
  font-size:.8rem; cursor:pointer; line-height:18px; padding:0;
}
.memory-details {
  display:flex; gap:8px; flex-wrap:wrap; justify-content:center; max-width:420px; margin:0 0 8px;
}
.memory-details span {
  padding:7px 10px; border-radius:var(--radius-pill);
  background:rgba(23,111,114,.08); border:1px solid rgba(23,111,114,.2); font-size:.75rem;
}
.memory-details.memory-fade { animation: fadeOut .45s ease forwards; }
.memory-candidates { transition:opacity .45s ease; }
.candidate-details-icons { font-size:1.2rem; letter-spacing:3px; }

/* ---------- Certificate ---------- */
.certificate {
  width: min(94vw, 420px);
  background: var(--color-surface);
  border: 4px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  box-shadow: var(--shadow-lift);
}
.certificate h2 { font-family: var(--font-display); margin: 4px 0; }
.certificate-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.certificate-badges .badge-slot { width: 34px; height: 34px; }
.name-input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-bg-deep);
  width: 100%;
  max-width: 260px;
  margin: 10px 0;
  text-align: center;
}
.star-count { font-size: 1.6rem; margin: 6px 0; }
.certificate-art { position: relative; width: min(94vw, 460px); margin: 20px auto 0; container-type: inline-size; }
.certificate-art img { width: 100%; height: auto; display: block; border-radius: 12px; box-shadow: var(--shadow-soft); }
.certificate-fields { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
.certificate-field-line { position: absolute; left: 6%; right: 6%; text-align: center; padding: 0 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.4); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); color: #26243F; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: Georgia, "Times New Roman", serif; font-size: 12px; }
.certificate-field-line.cf-name { top: 44%; font-size: 3.5cqw; font-weight: 800; }
.certificate-field-line.cf-museum { top: 60%; font-size: 3cqw; font-weight: 700; }
.certificate-field-line.cf-date { top: 69.6%; left: 27%; right: auto; width: 15%; font-size: 2.4cqw; font-weight: 600; color: #4a4a66; font-family: "Segoe UI", Tahoma, sans-serif; padding-left: 0; padding-right: 0; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(43,42,76,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(92vw, 380px);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lift);
}
.modal-panel-small { text-align: center; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
.slider-row, .toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.9rem; margin: 12px 0;
  gap: 12px;
}
.slider-row input[type=range] { flex: 1; margin-left: 12px; }

/* ---------- Badge Moment overlay ---------- */
.badge-overlay {
  position: fixed; inset: 0;
  background: rgba(43,42,76,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  animation: overlayFade var(--dur-med) ease;
}
@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }
.badge-overlay-panel {
  background: linear-gradient(170deg, var(--color-surface) 0%, #FFF6E5 60%, #FFEDDA 100%);
  border-radius: var(--radius-lg);
  padding: 26px 24px 30px;
  width: min(92vw, 380px);
  text-align: center;
  box-shadow: var(--shadow-lift);
  border: 4px solid var(--color-gold);
}
.badge-overlay-icon {
  font-size: 4rem;
  margin-bottom: 10px;
  animation: badgePop var(--dur-slow) ease;
}
.badge-overlay-icon img {
  animation: badgePop var(--dur-slow) ease;
}
.badge-overlay-icon .char-portrait {
  width: 96px;
  height: 96px;
  border-width: 4px;
}
@keyframes badgePop {
  0% { transform: scale(0.4) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.badge-overlay-name {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--color-gold-deep);
  margin-bottom: 6px;
}
.badge-overlay-line {
  font-size: 0.9rem;
  color: var(--color-ink-soft);
  margin-bottom: 18px;
}

/* ---------- Pause button ---------- */
.pause-btn {
  position: fixed;
  top: 64px;
  right: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-bg-deep);
  box-shadow: var(--shadow-soft);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 30;
}

/* ==========================================================================
   PROTOTYPE v2 — ANIMATION & INTERACTION LAYER
   Added on top of v1's design tokens. Nothing above this point was removed
   or restructured — v2 only extends the system. All animations below
   respect body.reduced-motion (see the global rule near the top of this
   file that zeroes animation/transition durations).
   ========================================================================== */

/* ---------- Character animation ---------- */
@keyframes charBreathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.03) translateY(-2px); }
}
@keyframes charBlink {
  0%, 92%, 100% { filter: none; }
  94%, 97% { filter: brightness(0.75) contrast(1.1); transform-origin: center; }
}
@keyframes charLookAround {
  0%, 100% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-2px) scale(1.03); }
  75% { transform: translateX(2px) scale(1.03); }
}
@keyframes charWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}
@keyframes charBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-10px) scale(1.08); }
  50% { transform: translateY(0) scale(0.96); }
  70% { transform: translateY(-4px) scale(1.03); }
}
@keyframes charWalkBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes charShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-6px) rotate(-4deg); }
  40% { transform: translateX(6px) rotate(4deg); }
  60% { transform: translateX(-4px) rotate(-2deg); }
  80% { transform: translateX(4px) rotate(2deg); }
}

.guardian-avatar {
  animation: charBreathe 3.2s ease-in-out infinite, charBlink 5.5s ease-in-out infinite;
  transform-origin: center;
  display: inline-block;
}
/* Real Canva-produced character portraits (v2.3): rendered as a rounded
   medallion since the connected Canva account is on the Free plan and
   can't export transparent PNGs — the solid background becomes an
   intentional framed-portrait look instead of a stray box. */
.char-portrait {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-gold);
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
  display: block;
}
.char-portrait.player-portrait { border-color: var(--color-teal); }
.guardian-avatar.talking { animation: charLookAround 1.6s ease-in-out infinite; }
.guardian-avatar.celebrating { animation: charBounce 0.9s ease-in-out infinite; }
.guardian-avatar.waving { animation: charWave 1.2s ease-in-out infinite; }
.guardian-avatar.concerned { animation: charShake 0.5s ease-in-out 1; }

/* ---------- Large Guardian portrait hero (intro welcome + ceremony) ---------- */
.guardian-hero {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--color-gold);
  box-shadow: 0 8px 22px rgba(43,42,76,.25);
  display: block;
  flex-shrink: 0;
}
.guardian-hero-ceremony {
  width: 108px;
  height: 108px;
  border-width: 4px;
  animation: charBounce 1.1s ease-in-out infinite;
}
.scene-art.scene-welcome {
  border-style: none;
  background: radial-gradient(circle at 50% 34%, rgba(232,163,61,0.30), rgba(43,42,76,0.60) 78%);
}
.scene-art.scene-welcome .guardian-hero {
  animation: charBreathe 3.2s ease-in-out infinite, charBlink 5.5s ease-in-out infinite;
}
.ceremony-guardian { display: flex; justify-content: center; }

/* ---------- Environmental animation (scene-art placeholders) ---------- */
.scene-art { position: relative; overflow: hidden; }
.scene-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(232,163,61,0.15), transparent 55%),
              radial-gradient(circle at 75% 70%, rgba(63,167,150,0.14), transparent 50%);
  animation: sceneGlow 6s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes sceneGlow {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}
.scene-art .sparkle {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-gold);
  opacity: 0.7;
  animation: sparkleFloat 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sparkleFloat {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  30% { opacity: 0.9; }
  100% { transform: translateY(-40px) scale(1); opacity: 0; }
}
.scene-art > div:first-child:not(.sparkle):not(.scene-art-label) {
  position: relative;
  z-index: 1;
  animation: charBreathe 4s ease-in-out infinite;
}

/* ---------- Floating interaction affordance ---------- */
@keyframes floatHint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,163,61,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(232,163,61,0); }
}
.affordance-hint {
  animation: floatHint 1.8s ease-in-out infinite, glowPulse 2.2s ease-in-out infinite;
}

/* ---------- Discovery / success burst ---------- */
@keyframes discoveryBurst {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
.discovery-burst {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--color-gold);
  pointer-events: none;
  animation: discoveryBurst 0.6s ease-out forwards;
}

/* ---------- Enhanced button micro-interactions ---------- */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 70%);
  opacity: 0; transform: scale(0.5);
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.btn:active::after { opacity: 1; transform: scale(1.2); transition-duration: 60ms; }
.btn-primary:hover { transform: translateY(-2px); }

/* ---------- Card pop-in ---------- */
@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  70% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}
.decision-card, .drag-item, .puzzle-piece, .npc-card, .candidate-card, .freeplay-hotspot, .hotspot {
  animation: popIn var(--dur-med) ease backwards;
}
.decision-card.correct-pulse { animation: glowPulse 0.6s ease 2; border-color: var(--color-gold); }

/* ---------- Drag feedback ---------- */
.drag-item.lifted, .puzzle-piece.lifted { box-shadow: var(--shadow-lift); transform: scale(1.08) rotate(-2deg); }
.dropzone.drag-over, .puzzle-slot.drag-over { background: rgba(63,167,150,0.28); border-color: var(--color-gold); transform: scale(1.04); }
@keyframes snapPlace {
  0% { transform: scale(1.2); }
  60% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.drag-item.placed, .puzzle-slot.filled { animation: snapPlace 0.35s ease; }

/* ---------- Timer urgency ---------- */
.timer-bar-fill.urgent { background: linear-gradient(90deg, var(--color-coral), var(--color-gold)); animation: glowPulse 0.8s ease-in-out infinite; }

/* ---------- Screen transition wrapper ---------- */
.screen-content.transitioning-out { animation: screenFadeOut var(--dur-fast) ease forwards; }
@keyframes screenFadeOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-6px) scale(0.99); }
}

/* ---------- Badge SVG icon shell ---------- */
.badge-icon-svg { width: 44px; height: 44px; display: block; }
.badge-slot .badge-icon-svg { width: 20px; height: 20px; }
.badge-overlay-icon .badge-icon-svg { width: 72px; height: 72px; margin: 0 auto; }

/* Real render badge (full-color PNG) — shown large on the Badge Moment
   overlay. `object-fit: contain` keeps the artwork intact on its own
   background rather than cropping it into a tiny square. */
.badge-icon-img {
  display: block;
  width: min(280px, 84vw);
  max-height: 170px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #FFF7E8, #FFEFD6);
  border: 3px solid var(--color-gold);
  box-shadow: var(--shadow-lift);
  transition: transform var(--dur-med) ease;
}

/* ---------- Confetti (Badge Moment celebration) ---------- */
.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  top: -10px;
  animation: confettiFall 1.1s ease-in forwards;
  pointer-events: none;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(160px) rotate(360deg); opacity: 0; }
}
@media (min-width: 640px) {
  .screen-content { padding: 36px 20px 16px; }
}
@media (max-width: 380px) {
  .decision-card { width: 118px; height: 118px; font-size: 2.1rem; }
  .puzzle-grid { grid-template-columns: repeat(3, 66px); grid-template-rows: repeat(3, 66px); }
  .freeplay-hotspot { width: 86px; height: 86px; font-size: 1.7rem; }
  .freeplay-hotspots { gap: 10px; }
}

/* ==========================================================================
   PROTOTYPE v2.1 — RTL / LTR ADAPTATION
   Most layouts here use flexbox `row`/`column` without an explicit
   `flex-direction: row-reverse`, which means they already follow the
   document's `dir` attribute automatically per the CSS spec — no override
   needed for the majority of the UI. The rules below cover the specific
   spots that use directional properties (text-align: left, left:, margin-
   left:) instead of logical ones, where a real visual mirror is wanted.
   Per the brief: exhibits, illustrations, and decorative art are NOT
   mirrored — only navigation/UI chrome and text alignment.
   ========================================================================== */

/* Font stack: the existing --font-display/--font-body already fall back
   through system UI fonts, which on every modern OS include a paired
   Arabic-capable face (Segoe UI / San Francisco / Roboto all ship Arabic
   glyphs). No separate @font-face is introduced, keeping the prototype
   dependency-free per the Performance section of the brief. */
body.rtl {
  font-family: "Segoe UI", "Tahoma", var(--font-body);
}
body.rtl .guardian-line,
body.rtl .npc-text,
body.rtl .screen-sub,
body.rtl .certificate p {
  text-align: right;
}

/* Guardian speech bubble: mirror the tail and text alignment */
body.rtl .guardian-bubble {
  text-align: right;
}
body.rtl .guardian-bubble::after {
  left: auto;
  right: 34px;
  border-right: none;
  border-left: 3px solid var(--color-gold);
}

/* NPC cards: mirror text alignment (icon stays visually first on the
   inline-start side automatically via flexbox's dir-aware row axis) */
body.rtl .npc-card { text-align: right; }

/* Corner-positioned chrome: mirror to the opposite corner rather than
   overlapping content that has now flowed the other way */
body.rtl .scene-art-label { right: auto; left: 10px; }
body.rtl .pause-btn { right: auto; left: 14px; }

/* Settings slider rows: the label now reads on the right, so the slider's
   spacing flips to match */
body.rtl .slider-row input[type=range] { margin-left: 0; margin-right: 12px; }

/* Language switcher pills */
.language-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.language-switch-label { font-weight: 600; font-size: 0.9rem; color: var(--color-ink-soft); }
.language-switch-buttons { display: flex; gap: 6px; }
.lang-pill {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-bg-deep);
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}
.lang-pill:hover { border-color: var(--color-teal); }
.lang-pill.active {
  background: linear-gradient(145deg, #FFD98A, var(--color-gold));
  border-color: var(--color-gold-deep);
}

/* Exhibits, illustration content, and any element explicitly marked
   .no-mirror stay untouched in RTL — the shape-language of the museum
   itself doesn't flip just because the UI language does. */
.scene-art, .hidden-object-scene, .badge-icon-svg { direction: ltr; }

/* ---------- Character selection ---------- */
.character-select-screen {
  width: min(94vw, 820px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.character-select-hero { text-align: center; }
.character-select-badge {
  width: 52px; height: 52px; margin: 0 auto 8px;
  border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg,#FFE6A8,#F5C45E);
  color: var(--color-ink); box-shadow: var(--shadow-soft);
}
.character-select-badge .char-portrait { width: 40px; height: 40px; }
.character-select-tip .char-portrait { width: 30px; height: 30px; border-width: 2px; }
.character-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 22px;
  width: 100%;
  max-width: 680px;
}
.character-card {
  position: relative;
  padding: 10px;
  border: 3px solid transparent;
  border-radius: 28px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: var(--color-ink);
  transition: transform var(--dur-med) ease, box-shadow var(--dur-med) ease, border-color var(--dur-med) ease;
}
.character-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lift); }
.character-card.selected { border-color: var(--color-gold); box-shadow: 0 0 0 5px rgba(232,163,61,.18), var(--shadow-lift); }
.character-art { border-radius: 22px; overflow: hidden; }
.character-art-boy { background: linear-gradient(145deg,#D9F0FF,#A9D5EF); }
.character-art-girl { background: linear-gradient(145deg,#FFE0EA,#F5B5CC); }
.character-svg { display: block; width: 100%; height: auto; }
.character-card-body { padding: 12px 10px 14px; position: relative; }
.character-card-name { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; }
.character-card-trait { color: var(--color-ink-soft); font-size: .9rem; margin-top: 4px; }
.character-select-mark {
  position: absolute; right: 4px; top: 6px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--color-teal); color: white;
  opacity: 0; transform: scale(.7); transition: .2s ease;
}
.character-card.selected .character-select-mark { opacity: 1; transform: scale(1); }
.character-select-tip {
  display: flex; align-items: center; gap: 8px; color: var(--color-ink-soft);
  background: rgba(255,255,255,.8); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-soft);
}
@media (max-width: 620px) {
  .character-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .character-card { border-radius: 20px; }
  .character-card-name { font-size: 1rem; }
  .character-card-trait { font-size: .78rem; }
  .character-select-tip { font-size: .8rem; }
}

/* ---------- Gameplay feedback upgrade ---------- */
.decision-feedback{width:min(92vw,520px);display:flex;align-items:flex-start;gap:12px;margin:14px auto 0;padding:14px 16px;border-radius:18px;background:rgba(255,255,255,.94);border:2px solid var(--color-bg-deep);box-shadow:var(--shadow-soft);text-align:start;animation:feedbackIn .3s ease}
.decision-feedback.positive{border-color:var(--color-teal)}
.decision-feedback.retry{border-color:var(--color-gold)}
.decision-feedback-icon{width:34px;height:34px;flex:0 0 34px;border-radius:50%;display:grid;place-items:center;background:var(--color-gold);font-weight:900}
.decision-feedback strong{font-family:var(--font-display);font-size:1rem}.decision-feedback p{margin:3px 0 0;color:var(--color-ink-soft);font-size:.9rem;line-height:1.35}
.decision-next{margin-top:12px;animation:feedbackIn .3s ease}
@keyframes feedbackIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.puzzle-grid{grid-template-columns:repeat(4,78px);grid-template-rows:repeat(3,78px)}
@media(max-width:380px){.puzzle-grid{grid-template-columns:repeat(4,58px);grid-template-rows:repeat(3,58px);gap:4px}.puzzle-slot{font-size:1.15rem}.puzzle-piece{width:50px;height:50px;font-size:1.2rem}}


/* Gameplay Upgrade Pass — contextual feedback and interaction clarity */
.mechanic-feedback {
  min-height: 28px; margin: 10px auto; max-width: 760px; padding: 9px 14px;
  border-radius: 14px; text-align: center; font-weight: 700; opacity: .95;
}
.mechanic-feedback.positive { border: 2px solid var(--color-gold); background: rgba(255,215,100,.14); }
.mechanic-feedback.retry { border: 2px solid rgba(220,100,100,.55); background: rgba(220,100,100,.08); }
.feedbackPop { animation: feedbackPop .35s ease; }
@keyframes feedbackPop { 0%{transform:scale(.96);opacity:.2} 100%{transform:scale(1);opacity:1} }
@keyframes wrongPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(.96)} }
.wrong-pulse { animation: wrongPulse .35s ease; }
.puzzle-progress { font-weight: 800; }
.follow-step-note { font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .feedbackPop, .wrong-pulse { animation: none !important; }
}

/* ---------- Gameplay HUD upgrade ---------- */
.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid rgba(43,42,76,.1);
  box-shadow: 0 4px 18px rgba(43,42,76,.08);
  position: relative;
  z-index: 10;
}
.hud-player {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--color-bg-deep);
  border: 2px solid rgba(43,42,76,.1);
  overflow: hidden;
}
.hud-player svg { width: 38px; height: 38px; }
.hud-center { min-width: 0; text-align: center; }
.hud-zone-label { font-weight: 800; font-size: .95rem; color: var(--color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-progress { font-size: .72rem; color: var(--color-ink-soft); margin-top: 2px; }
.hud-stats { display: flex; align-items: center; gap: 7px; }
.hud-stars, .hud-badge-count {
  font-weight: 800;
  font-size: .78rem;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--color-bg-deep);
  white-space: nowrap;
}
.hud-stars { color: var(--color-gold-deep); }
.hud-badge-tray { display: flex; gap: 4px; }
.hud .badge-slot { width: 28px; height: 28px; border-radius: 9px; }
.hud .badge-slot svg { width: 22px; height: 22px; }
.objective-card {
  width: min(92vw, 520px);
  margin: 0 auto 12px;
  padding: 10px 13px;
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: start;
  border-radius: 15px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(43,42,76,.1);
  box-shadow: 0 5px 16px rgba(43,42,76,.06);
}
.objective-icon {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--color-gold);
  color: var(--color-ink);
  font-size: .7rem;
}
.objective-card div { display: flex; flex-direction: column; gap: 2px; }
.objective-card strong { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-teal-deep); }
.objective-card span:last-child { font-size: .86rem; color: var(--color-ink); }
@media (max-width: 620px) {
  .hud { padding: 8px 9px; gap: 6px; }
  .hud-player { width: 38px; height: 38px; border-radius: 12px; }
  .hud-player svg { width: 32px; height: 32px; }
  .hud-badge-tray { display: none; }
  .hud-stars, .hud-badge-count { font-size: .7rem; padding: 5px 7px; }
}

/* ---------- Free Exploration gameplay expansion ---------- */
.freeplay-scene { position: relative; min-height: 150px; }
.freeplay-character { font-size: 3.2rem; animation: charBreathe 2.2s ease-in-out infinite; }
.freeplay-scene-label { margin-top: 6px; }
.freeplay-progress { margin: 8px auto; font-weight: 800; color: var(--color-teal-deep); }
.freeplay-hotspots-expanded { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.freeplay-hotspot-icon { display:block; font-size: 2rem; line-height: 1.1; margin-bottom: 4px; }
.freeplay-hotspot-icon img { width: 40px; height: 40px; object-fit: contain; margin: 0 auto; display: block; border-radius: 10px; }
.freeplay-hotspot.done { opacity: .88; }
@media (max-width: 620px) {
  .freeplay-hotspots-expanded { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* ==========================================================================
   v2.9 — INTERACTION MOTION PASS
   Motion is feedback, not decoration: interactive objects respond at the
   moment the child acts. All rules inherit the global reduced-motion switch.
   ========================================================================== */

/* Character SVGs now have a calm idle loop. The animation is on the complete
   portrait so it remains stable when real art replaces the prototype art. */
.character-svg.character-idle {
  transform-origin: 50% 92%;
  animation: characterIdle 3.2s ease-in-out infinite;
}
@keyframes characterIdle {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-0.35deg); }
}
.character-card:hover .character-svg,
.character-card:focus-visible .character-svg {
  animation: characterInspect 700ms ease-out;
}
@keyframes characterInspect {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-5px) scale(1.025); }
  100% { transform: translateY(0) scale(1); }
}

/* Decision cards get a physical press response and a distinct, friendly
   confirmation state. */
.decision-card {
  will-change: transform;
}
.decision-card.decision-tap {
  animation: decisionTap 180ms ease-out;
}
@keyframes decisionTap {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(2px) scale(.97); }
  100% { transform: translateY(0) scale(1); }
}
.decision-card.decision-success {
  box-shadow: 0 0 0 4px rgba(63,167,150,.20), var(--shadow-lift);
}
.decision-card.decision-retry {
  box-shadow: 0 0 0 4px rgba(232,163,61,.18), var(--shadow-soft);
}

/* Puzzle placement: the piece and its destination acknowledge a successful
   fit together instead of simply changing state. */
.puzzle-slot.snap-pop {
  animation: snapPop 420ms cubic-bezier(.2,1.5,.4,1);
}
.puzzle-piece.placed-pop {
  animation: placedPop 420ms ease-out;
}
@keyframes snapPop {
  0% { transform: scale(.86); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes placedPop {
  0% { transform: scale(.82); opacity:.5; }
  60% { transform: scale(1.08); opacity:1; }
  100% { transform: scale(1); opacity:1; }
}

/* Follow waypoints read as a moving journey. The active point breathes
   while completed points settle. */
.follow-step.current {
  animation: waypointBreathe 1.25s ease-in-out infinite;
}
@keyframes waypointBreathe {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(232,163,61,.15); }
  50% { transform: scale(1.13); box-shadow: 0 0 0 7px rgba(232,163,61,.12); }
}
.follow-step.done {
  animation: waypointDone 300ms ease-out;
}
@keyframes waypointDone {
  0% { transform: scale(.85); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Primary actions have a gentle invitation pulse only when they are waiting
   for the child; it stops as soon as the button is pressed. */
.btn.btn-primary:not(:disabled) {
  animation: ctaBreath 3.6s ease-in-out infinite;
}
.btn.btn-primary:active {
  animation: none;
}
@keyframes ctaBreath {
  0%,100% { box-shadow: 0 5px 14px rgba(43,42,76,.12); }
  50% { box-shadow: 0 8px 22px rgba(43,42,76,.18); }
}

/* Imported production-art portraits */
.character-raster {
  display: block;
  width: 100%;
  height: auto;
  max-height: 190px;
  object-fit: contain;
  object-position: center bottom;
}

/* ---------- Production art integration (v3.2) ---------- */
.scene-art.scene-art-real {
  background-repeat: no-repeat;
  -webkit-background-size: cover;
  background-size: cover;
  background-position: center;
  background-color: var(--color-bg-deep);
  border-style: solid;
  border-color: rgba(43,42,76,0.10);
  box-shadow: var(--shadow-soft);
  /* Real environment art is 16:9 (e.g. 1678x937); rendering the box at the
     same aspect shows the full photo instead of cover-cropping it. */
  width: min(94vw, 680px);
  aspect-ratio: 16 / 9;
  /* Slight contrast/saturation lift makes the photographic backgrounds
     read noticeably crisper on-screen without touching the source art. */
  -webkit-filter: contrast(1.07) saturate(1.06);
  filter: contrast(1.07) saturate(1.06);
}
.scene-art-real::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(43,42,76,0.08));
  pointer-events: none;
}
.scene-art-fallback {
  position: relative;
  z-index: 1;
  font-size: 3.4rem;
}
.scene-art-pending {
  position: relative;
  z-index: 1;
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: rgba(43,42,76,0.45);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.scene-art-real .scene-art-fallback {
  display: none;
}
.scene-art-real .scene-art-label {
  z-index: 2;
  background: rgba(255,255,255,0.78);
  padding: 3px 7px;
  border-radius: 8px;
}
/* Full-area backdrop for interactive mechanics (Locker, Family Area):
   the zone render fills the mechanic card instead of a small framed box,
   with gameplay UI layered on top. */
.scene-art-real.backdrop-lg {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
}
.character-art .character-raster {
  max-width: 100%;
  height: auto;
}


/* ---------- Universal Web / iframe embedding (v3.3) ---------- */
html.is-embedded,
html.is-embedded body {
  min-height: 100%;
  height: auto;
}
html.is-embedded #app {
  min-height: 640px;
  height: 100vh;
  height: 100dvh;
}
html[data-embed="true"] body {
  background: var(--color-bg);
}
@media (max-width: 720px) {
  .hud { padding: 8px 10px; gap: 8px; }
  .hud-zone-label { font-size: .72rem; }
  .hud-player { min-width: 34px; }
  .hud-badge-tray { gap: 3px; }
  .badge-slot { width: 26px; height: 26px; font-size: .82rem; }
  .screen-content { padding: 18px 12px 10px; }
  .screen-footer { padding: 10px 12px 16px; }
  .btn { min-height: 46px; padding: 12px 22px; }
}
@media (max-width: 420px) {
  .hud-stats { gap: 4px; }
  .hud-stars, .hud-badge-count { font-size: .78rem; }
  .hud-badge-tray { display: none; }
  .screen-heading { font-size: 1.55rem; }
}

/* Universal museum branding: supplied through query parameters without changing game logic. */
.museum-brand { display:flex; align-items:center; justify-content:center; gap:.55rem; margin:.35rem auto .8rem; min-height:32px; }
.museum-brand-logo { width:38px; height:38px; object-fit:contain; border-radius:8px; }
.museum-brand-name { font-weight:800; font-size:.95rem; color:var(--color-ink); max-width:70vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ---------- Free Exploration decision layer (v3.6) ---------- */
.freeplay-choice-panel {
  margin: 12px auto;
  padding: 14px;
  max-width: 720px;
  border: 2px solid rgba(43,42,76,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-soft);
  animation: feedbackPop .3s ease;
}
.freeplay-choice-title {
  font-family: var(--font-display);
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--color-ink);
}
.freeplay-choice-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.freeplay-choice-btn { min-width: 170px; }
@media (max-width: 520px) {
  .freeplay-choice-btn { width: 100%; min-width: 0; }
}

/* v3.9 celebration polish: replace ceremony emoji with reusable visual mark. */
.ceremony-burst{display:inline-flex;align-items:center;justify-content:center;margin-inline-start:10px;width:28px;height:28px;border-radius:50%;background:var(--color-gold);color:#fff;font-weight:900;animation:badgeCelebrate .9s ease-in-out infinite alternate}
@keyframes badgeCelebrate{from{transform:scale(.9) rotate(-8deg);opacity:.75}to{transform:scale(1.08) rotate(8deg);opacity:1}}
@media(prefers-reduced-motion:reduce){.ceremony-burst{animation:none}}


@media (max-width: 520px) {
  /* Mobile: keep the 4x3 grid (fits the room's 16:9 frame) with smaller
     cells so no slot row is clipped by the scene-art box (it clips because
     .scene-art has overflow:hidden and the old 3x4 grid was taller). */
  .puzzle-stage { padding: 8px; }
  .puzzle-grid {
    grid-template-columns: repeat(4, clamp(42px, 15vw, 52px));
    grid-template-rows: repeat(3, clamp(42px, 15vw, 52px));
    width: max-content;
    margin-inline: auto;
    padding: 6px;
    gap: 4px;
  }
  .puzzle-slot { font-size: 1.25rem; }
  .puzzle-piece { width: 50px; height: 50px; }
  .hidden-response-panel { bottom:8px; }
}

/* ==========================================================================
   v3-15 "Professional look & variety" pass
   Real photograph tiles inside mechanics, illustrated CSS-only scene
   backdrops, shuffled-choice ordering support, and brighter warm accents.
   ========================================================================== */

/* Image-tile primitive shared by hotspots, tray items, candidate/npc cards.
   Emoji fallback (swap when a file can't load) is handled by imgFail().
   `pointer-events: none` + `draggable=false` prevent the browser's native
   image drag from hijacking the game's Pointer Events drag logic (Locker). */
.img-tile { display: block; width: 100%; height: 100%; object-fit: cover; background: #fff; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.tile-fallback { font-size: 1.7rem; line-height: 1; }

.hotspot { overflow: hidden; padding: 0; width: 62px; height: 62px; }
.hotspot .img-tile { border-radius: 12px; object-fit: contain; }
.hotspot.mistake-hotspot { border-color: var(--color-gold); background: rgba(255,255,255,.95); box-shadow: 0 4px 14px rgba(43,42,76,.16); }
.hotspot.decoy-hotspot { border-color: rgba(63,167,150,.45); background: rgba(255,255,255,.72); }

/* Placeholder scenes become an illustrated museum-hall backdrop (pure CSS;
   real environments keep their photograph via .scene-art-real — untouched). */
.scene-art:not(.scene-art-real) {
  border-style: solid;
  border-color: rgba(43,42,76,.12);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.28) 0 30px, rgba(255,255,255,0) 30px 86px, rgba(255,255,255,.16) 86px 106px),
    radial-gradient(circle at 50% 30%, rgba(255,247,222,.9) 0%, rgba(255,247,222,0) 48%),
    linear-gradient(180deg, #A9D3E2 0%, #DCEFF3 52%, #F8F4E8 100%);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.35), var(--shadow-soft);
}
.scene-art:not(.scene-art-real)::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 32%;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.16) 0 30px, rgba(255,255,255,0) 30px 150px),
    linear-gradient(180deg, #F0E2C3 0%, #DFC28F 100%);
  border-top: 3px solid rgba(255,255,255,.5);
  pointer-events: none;
  z-index: 0;
}
.scene-art:not(.scene-art-real) .scene-art-fallback { position: relative; z-index: 2; filter: drop-shadow(0 4px 6px rgba(43,42,76,.18)); }
.scene-art:not(.scene-art-real) .scene-art-pending { position: relative; z-index: 2; }
.scene-art:not(.scene-art-real) .scene-art-label {
  position: absolute; bottom: 6px; right: 10px; z-index: 3;
  background: rgba(255,255,255,.6); padding: 2px 8px; border-radius: 8px;
  color: rgba(43,42,76,.6); font-weight: 700;
}
body.rtl .scene-art:not(.scene-art-real) .scene-art-label { right: auto; left: 10px; }

/* Hidden-object scene shares the illustrated hall so the photo tiles sit
   on an intentional backdrop instead of a flat box. */
.hidden-object-scene {
  border-style: solid;
  border-color: rgba(43,42,76,.12);
  background:
    radial-gradient(circle at 50% 28%, rgba(255,247,222,.92) 0%, rgba(255,247,222,0) 48%),
    linear-gradient(180deg, #A9D3E2 0%, #DCEFF3 52%, #F8F4E8 100%);
  -webkit-background-size: cover;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.35), var(--shadow-soft);
}
.hidden-object-scene::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 26%;
  background: linear-gradient(180deg, #F0E2C3 0%, #DFC28F 100%);
  border-top: 3px solid rgba(255,255,255,.5);
  pointer-events: none;
  z-index: 0;
}
/* When the scene carries a real environment photo, drop the hand-drawn floor
   overlay (it would hide the art) and keep the image sharp & filling. */
.hidden-object-scene.has-art {
  border-style: solid;
  border-color: rgba(43,42,76,.12);
  min-height: 320px;
}
.hidden-object-scene.has-art::after {
  display: none;
}
.hidden-object-scene > .hotspot { z-index: 2; }

/* Decision cards: distinct soft tint per card + a medallion for the icon. */
.decision-row { gap: 16px; }
.decision-card { gap: 12px; }
.decision-card > div:first-child {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem;
  background: rgba(255,255,255,.85);
  box-shadow: inset 0 0 0 3px rgba(43,42,76,.08), 0 4px 10px rgba(43,42,76,.10);
}
.decision-card:nth-child(1) { background: linear-gradient(180deg, var(--color-surface) 0%, #FFF1D9 100%); border-color: #F0C37A; }
.decision-card:nth-child(2) { background: linear-gradient(180deg, var(--color-surface) 0%, #DFF3EF 100%); border-color: #9BD8CC; }
.decision-card:nth-child(3) { background: linear-gradient(180deg, var(--color-surface) 0%, #F9E4EF 100%); border-color: #F2AFCB; }
.decision-card:nth-child(4) { background: linear-gradient(180deg, var(--color-surface) 0%, #E1EFFF 100%); border-color: #9FC6E8; }
.decision-card-label { font-size: .82rem; text-align: center; }

/* Heading pop: a warm gradient underline accent. */
.screen-heading { position: relative; padding-bottom: 10px; }
.screen-heading::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 64px; height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-gold), var(--color-coral), var(--color-teal));
}
body.rtl .screen-heading::after { left: auto; right: 0; }

/* Locker tray items sized to the tile. */
.drag-item { padding: 4px; }
.drag-item > .img-tile { width: 52px; height: 52px; object-fit: contain; }
.drag-item > .tile-fallback { font-size: 1.8rem; }

/* NPC & memory-candidate portraits shown as round photo medallions. */
.npc-emoji > .img-tile, .candidate-emoji > .img-tile {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid var(--color-bg-deep);
  box-shadow: 0 4px 10px rgba(43,42,76,.12);
}
.candidate-emoji > .tile-fallback { font-size: 1.6rem; }

/* Freeplay hotspot props stay crisp inside the tiles. */
.freeplay-hotspot-icon > .img-tile { width: 54px; height: 54px; object-fit: contain; border-radius: 12px; }
