/* ============================================================
   KINGS OF THE FIVE ROADS — DESIGN SYSTEM
   ----------------------------------------------------------
   Sections in this file (use Find / Cmd+F):
     TOKENS        — colors, spacing, radius, type, motion, z-index
     ANIMATIONS    — @keyframes
     UTILITIES     — visually-hidden, skip-link
     INPUT         — text fields
     EMPTY STATE   — placeholder for empty lists
     BASE          — body, page-frame, page-glow
     HERO + LAYOUT — hero copy, status card, layout grid, side column
     PARCHMENT     — card base used by hero/status/cards
     BUTTON        — primary / ghost / sm + states
     PILLS         — pill base + reward / zone / status / success / difficulty
     XP / METER    — progress bars (HUD)
     WORLD MAP BAND — map shell + city markers + routes + caravans
     SCENE BAND    — live canvas wrapper (full-width)
     BATTLEFIELD   — canvas frame with HUD overlay
     PORTRAIT      — CSS-only character portrait
     DIALOGUE      — speaker bubble + phrase pills
     ANSWER        — radiogroup of choices
     QUEST SUMMARY — side card with active-quest summary
     QUEST MODAL   — centered dialog with NPC + lesson
     CUSTOMIZE MODAL — character customization
     TOAST         — top-right notification stack
     RESPONSIVE    — mobile/tablet breakpoints
     REDUCED MOTION — accessibility guard
   ============================================================ */

:root {
  --bg-night: #120f19;
  --bg-stone: #221a29;
  --frame-dark: #3a2317;
  --frame-mid: #6f4627;
  --frame-light: #c8944c;
  --gold: #efc66b;
  --gold-soft: #ffe7ad;
  --ink: #2d1a11;
  --text: #f7efd8;
  --panel-top: #f5ddaa;
  --panel-bottom: #d0a05a;
  --panel-edge: #6a4222;
  --crimson: #b4372f;
  --leaf: #4d8b46;
  --sky: #2e4e83;
  --focus: #4ca7d5;
  --success: #24633c;
  --error: #902f2a;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --spring-soft: cubic-bezier(.34, 1.2, .64, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);

  --duration-instant: 120ms;
  --duration-fast: 180ms;
  --duration-base: 220ms;
  --duration-slow: 320ms;
  --duration-slower: 480ms;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;
  --space-10: 72px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-2xl: 28px;
  --radius-3xl: 32px;
  --radius-pill: 999px;

  --type-eyebrow: 0.78rem;
  --type-label: 0.83rem;
  --type-sm: 0.94rem;
  --type-body: 1rem;
  --type-md: 1.08rem;
  --type-lg: 1.18rem;
  --type-xl: 1.34rem;
  --type-h3: clamp(1.2rem, 1.8vw, 1.5rem);
  --type-h2: clamp(1.5rem, 2.6vw, 2rem);
  --type-h1: clamp(2.7rem, 6vw, 5rem);

  --z-base: 1;
  --z-overlay: 50;
  --z-modal: 100;
  --z-toast: 200;

  --bs-shadow-strong: 0 6px 0 rgba(20, 12, 6, 0.42), 0 14px 28px rgba(0, 0, 0, 0.32);
  --bs-shadow-pressed: 0 2px 0 rgba(20, 12, 6, 0.42), 0 6px 12px rgba(0, 0, 0, 0.32);
  --bs-shadow-card: 0 24px 46px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(255, 239, 199, 0.08);
  --bs-shadow-hero: 0 30px 56px rgba(0, 0, 0, 0.34), inset 0 0 0 2px rgba(255, 239, 199, 0.12);
  --bs-shadow-band: 0 36px 64px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 239, 199, 0.16), inset 0 -8px 0 rgba(120, 70, 30, 0.28);
  --bs-shadow-modal: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 0 8px rgba(28, 14, 6, 0.55), inset 0 0 0 2px rgba(255, 239, 199, 0.18), inset 0 -6px 0 rgba(120, 70, 30, 0.32);
  --bs-press-inset: inset 0 2px 0 rgba(255, 245, 214, 0.6), inset 0 -3px 0 rgba(110, 56, 18, 0.55);
  --bs-ring-focus: 0 0 0 3px rgba(255, 231, 173, 0.95), 0 0 0 6px rgba(28, 14, 6, 0.55);
}

@keyframes goldShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes pillBreathe {
  0%, 100% { transform: scale(1); box-shadow: inset 0 1px 0 rgba(255, 245, 214, 0.4), 0 0 0 0 rgba(239, 198, 107, 0.0); }
  50% { transform: scale(1.04); box-shadow: inset 0 1px 0 rgba(255, 245, 214, 0.6), 0 0 22px 4px rgba(239, 198, 107, 0.4); }
}

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

@keyframes mapPulseRing {
  0% { transform: scale(0.85); opacity: 0.85; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes lockedDim {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.78; }
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes crestShine {
  0%, 100% { box-shadow: inset 0 0 0 4px rgba(255, 237, 190, 0.18), 0 0 0 0 rgba(239, 198, 107, 0); }
  50% { box-shadow: inset 0 0 0 4px rgba(255, 237, 190, 0.35), 0 0 28px 6px rgba(239, 198, 107, 0.45); }
}

@keyframes rewardPop {
  0% { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes successFlash {
  0% { box-shadow: inset 0 0 0 0 rgba(120, 220, 140, 0.0), 0 24px 46px rgba(0, 0, 0, 0.3); }
  35% { box-shadow: inset 0 0 0 6px rgba(120, 220, 140, 0.55), 0 0 60px 12px rgba(120, 220, 140, 0.35); }
  100% { box-shadow: inset 0 0 0 0 rgba(120, 220, 140, 0), 0 24px 46px rgba(0, 0, 0, 0.3); }
}

@keyframes errorFlash {
  0% { box-shadow: inset 0 0 0 0 rgba(220, 80, 80, 0.0), 0 24px 46px rgba(0, 0, 0, 0.3); }
  35% { box-shadow: inset 0 0 0 6px rgba(220, 80, 80, 0.55), 0 0 60px 12px rgba(220, 80, 80, 0.4); }
  100% { box-shadow: inset 0 0 0 0 rgba(220, 80, 80, 0), 0 24px 46px rgba(0, 0, 0, 0.3); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes glowAccent {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(239, 198, 107, 0)); }
  50% { filter: drop-shadow(0 0 18px rgba(239, 198, 107, 0.65)); }
}

/* ============================================================
   UTILITIES — accessibility helpers, skip-link, screen-reader
   ============================================================ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: var(--space-3) var(--space-4);
  background: var(--gold-soft);
  color: var(--ink);
  font-weight: 800;
  border-radius: var(--radius-md);
  text-decoration: none;
  z-index: var(--z-toast);
  box-shadow: var(--bs-shadow-strong);
  transition: top var(--duration-base) var(--spring);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 16px;
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

#scene-main:focus {
  outline: none;
}

/* ============================================================
   INPUT — text fields, used in forms (customization, etc.)
   ============================================================ */

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 2px solid rgba(103, 62, 29, 0.3);
  background: rgba(255, 252, 240, 0.7);
  color: var(--ink);
  font-size: var(--type-md);
  font-family: inherit;
  font-weight: 600;
  transition: border-color var(--duration-base) ease, box-shadow var(--duration-base) ease;
}

.input::placeholder {
  color: rgba(45, 26, 17, 0.55);
}

.input:hover {
  border-color: rgba(103, 62, 29, 0.5);
}

.input:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 2px;
  border-color: rgba(180, 55, 47, 0.55);
}

.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.input--invalid {
  border-color: rgba(180, 55, 47, 0.8);
}

.input--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-sm);
  border-radius: var(--radius-sm);
}

.input--lg {
  padding: var(--space-4) var(--space-5);
  font-size: var(--type-lg);
  border-radius: var(--radius-lg);
  font-weight: 700;
}

textarea.input {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
  font-family: inherit;
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 12px) center;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: var(--space-7);
  cursor: pointer;
}

select.input:disabled {
  cursor: not-allowed;
}

/* ============================================================
   EMPTY STATE — placeholder for empty lists / cards
   ============================================================ */

.empty-state {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(105, 62, 28, 0.06);
  color: rgba(45, 26, 17, 0.62);
  font-style: italic;
  text-align: center;
  line-height: 1.45;
  border: 2px dashed rgba(103, 63, 28, 0.22);
}

.empty-state__icon {
  display: block;
  margin: 0 auto var(--space-2);
  font-size: 1.5rem;
  filter: grayscale(0.3);
}

/* ============================================================
   DIVIDER — horizontal section separator
   ============================================================ */

.divider {
  height: 2px;
  margin: var(--space-4) 0;
  border: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(120, 70, 30, 0.32) 18%,
    rgba(120, 70, 30, 0.32) 82%,
    transparent 100%);
  border-radius: var(--radius-pill);
  position: relative;
}

.divider--ornament::after {
  content: "✦";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-top);
  padding: 0 var(--space-3);
  color: rgba(120, 70, 30, 0.7);
  font-size: 0.9rem;
}

body.modal-open {
  overflow: hidden;
}

.quest-summary {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.quest-summary__speaker {
  margin: 0;
  font-weight: 700;
  font-size: 1.04rem;
  color: #8d2e24;
  font-family: "Cinzel", serif;
  letter-spacing: 0.02em;
}

.quest-summary__hint {
  margin: 0;
  color: rgba(45, 26, 17, 0.74);
  font-size: 1rem;
  line-height: 1.42;
}

.quest-summary__progress {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}

.quest-summary__state {
  color: rgba(45, 26, 17, 0.7);
}

.quest-dots {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.quest-dots__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(45, 26, 17, 0.18);
  box-shadow: inset 0 0 0 1px rgba(45, 26, 17, 0.25);
}

.quest-dots__dot.is-done {
  background: linear-gradient(180deg, #5fa572, #2e6440);
  box-shadow: inset 0 0 0 1px rgba(45, 26, 17, 0.4), 0 0 6px rgba(95, 165, 114, 0.6);
}

.quest-dots__dot.is-current {
  background: linear-gradient(180deg, #f8d8a3, #d8842f);
  box-shadow: inset 0 0 0 1px rgba(120, 60, 20, 0.5), 0 0 8px rgba(239, 198, 107, 0.7);
  animation: dotPulse 1.6s ease-in-out infinite;
}

.quest-dots--lg .quest-dots__dot {
  width: 14px;
  height: 14px;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.quest-summary__open {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  font-size: 1.05rem;
}

.quest-summary__open[data-near="true"] {
  animation: openCtaPulse 1.4s ease-in-out infinite;
}

.quest-summary__open[data-state="ready"] {
  background: linear-gradient(180deg, #ffd070 0%, #d8842f 100%);
}

.quest-summary__open[data-state="done"] {
  background: linear-gradient(180deg, #8acf9a 0%, #2e6440 100%);
  color: #0e2014;
}

.quest-summary__open-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(28, 14, 6, 0.78);
  color: #ffe7ad;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 245, 214, 0.18);
}

@keyframes openCtaPulse {
  0%, 100% { box-shadow: var(--bs-press-inset), var(--bs-shadow-strong), 0 0 0 0 rgba(239, 198, 107, 0); }
  50% { box-shadow: var(--bs-press-inset), var(--bs-shadow-strong), 0 0 0 8px rgba(239, 198, 107, 0.35); }
}

/* === MODAL === */

.quest-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
}

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

.quest-modal__backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(38, 24, 12, 0.6), rgba(8, 4, 2, 0.85));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdropIn 280ms ease-out forwards;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes backdropOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.quest-modal.is-closing .quest-modal__backdrop {
  animation: backdropOut 220ms ease-in forwards;
}

.quest-modal__frame {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 32px;
  border: 3px solid rgba(238, 198, 107, 0.55);
  background:
    linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%),
    radial-gradient(circle at top, rgba(255, 248, 226, 0.85), transparent 28%);
  color: var(--ink);
  box-shadow: var(--bs-shadow-modal);
  animation: modalIn 480ms cubic-bezier(.34, 1.66, .64, 1) both;
  overflow: hidden;
}

.quest-modal.is-closing .quest-modal__frame {
  animation: modalOut 200ms ease-in forwards;
}

@keyframes modalIn {
  0% { transform: translateY(40px) scale(0.86); opacity: 0; }
  60% { transform: translateY(0) scale(1.04); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes modalOut {
  to { transform: translateY(20px) scale(0.94); opacity: 0; }
}

.quest-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(28, 14, 6, 0.4);
  background: linear-gradient(180deg, #f5e0a8, #c89046);
  color: #2d1a11;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 0.6;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 rgba(28, 14, 6, 0.35), 0 8px 14px rgba(0, 0, 0, 0.3);
  transition: transform 200ms var(--spring), box-shadow 200ms var(--spring);
}

.quest-modal__close:hover,
.quest-modal__close:focus-visible {
  transform: rotate(90deg) scale(1.05);
}

.quest-modal__close:focus-visible {
  outline: 3px solid #ffe7ad;
  outline-offset: 4px;
}

.quest-modal__close:active {
  transform: rotate(90deg) scale(0.95);
  box-shadow: 0 1px 0 rgba(28, 14, 6, 0.35);
}

.quest-modal__hero {
  position: relative;
  height: 168px;
  background:
    linear-gradient(180deg, #6ea4ec 0%, #ffc781 56%, #77ab58 56%, #53733b 100%);
  overflow: hidden;
  flex-shrink: 0;
  border-bottom: 3px solid rgba(28, 14, 6, 0.45);
}

.quest-modal__hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 244, 196, 0.55), transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(0, 0, 0, 0.18), transparent 50%);
  pointer-events: none;
}

.quest-modal__hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -30% -10%;
  height: 60%;
  background: linear-gradient(180deg, #6da54b, #4c6f32);
  border-radius: 50% 50% 0 0;
}

.quest-modal__zone {
  position: absolute;
  top: 16px;
  left: 18px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(28, 14, 6, 0.7);
  color: #ffe7ad;
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  z-index: 2;
  animation: modalPiecePop 480ms 120ms cubic-bezier(.34, 1.66, .64, 1) both;
}

.quest-modal__portrait {
  position: absolute;
  bottom: -22px;
  left: 50%;
  width: 178px;
  height: 200px;
  transform: translateX(-50%) translateY(20px);
  z-index: 2;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.45));
  animation: portraitRise 600ms 80ms cubic-bezier(.34, 1.66, .64, 1) both;
}

@keyframes portraitRise {
  from { transform: translateX(-50%) translateY(60px); opacity: 0; }
  to { transform: translateX(-50%) translateY(20px); opacity: 1; }
}

.quest-modal__portrait .portrait {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  width: 178px;
  height: 200px;
}

.quest-modal__content {
  flex: 1;
  overflow-y: auto;
  padding: 56px 32px 24px;
  display: grid;
  gap: 16px;
  scrollbar-width: thin;
}

.quest-modal__content::-webkit-scrollbar {
  width: 8px;
}

.quest-modal__content::-webkit-scrollbar-track {
  background: rgba(45, 26, 17, 0.08);
  border-radius: 4px;
}

.quest-modal__content::-webkit-scrollbar-thumb {
  background: rgba(120, 70, 30, 0.5);
  border-radius: 4px;
}

.quest-modal__heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  color: #3a1d10;
  text-shadow: 0 1px 0 rgba(255, 245, 214, 0.4);
}

.quest-modal__heading .eyebrow {
  color: rgba(45, 26, 17, 0.65);
}

.quest-modal__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.quest-modal__content > * {
  animation: modalPiecePop 460ms cubic-bezier(.34, 1.66, .64, 1) both;
}

.quest-modal__content > *:nth-child(1) { animation-delay: 160ms; }
.quest-modal__content > *:nth-child(2) { animation-delay: 200ms; }
.quest-modal__content > *:nth-child(3) { animation-delay: 240ms; }
.quest-modal__content > *:nth-child(4) { animation-delay: 280ms; }
.quest-modal__content > *:nth-child(5) { animation-delay: 320ms; }
.quest-modal__content > *:nth-child(6) { animation-delay: 360ms; }

@keyframes modalPiecePop {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.phrase-pair {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.phrase-with-audio {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
}

.phrase-with-audio .phrase {
  flex: 1;
}

.audio-btn {
  width: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  border: 2px solid rgba(28, 14, 6, 0.6);
  background: linear-gradient(180deg, #f5e0a8, #c89046);
  color: #2d1a11;
  font-size: 1.4rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 rgba(20, 12, 6, 0.32);
  transition: transform 200ms var(--spring), box-shadow 200ms var(--spring);
}

.audio-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 5px 0 rgba(20, 12, 6, 0.32);
}

.audio-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(20, 12, 6, 0.32);
}

.audio-btn:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
}

.audio-btn.is-playing {
  background: linear-gradient(180deg, #8acf9a, #2e6440);
  color: #fff;
}

.audio-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.audio-btn--scene {
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
}

.audio-btn--scene[aria-pressed="true"] {
  background: linear-gradient(180deg, #5b3320, #3a2010);
  color: #f5e0a8;
}

@media (min-width: 600px) {
  .phrase-pair {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .phrase {
    display: flex;
    align-items: center;
    min-height: 56px;
  }
}

.answer-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
  max-width: 100%;
}

.feedback--modal {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(28, 14, 6, 0.06);
  min-height: 28px;
}

.feedback--modal.is-success {
  background: linear-gradient(90deg, rgba(36, 99, 60, 0.18), rgba(36, 99, 60, 0.06));
  box-shadow: inset 0 0 0 2px rgba(36, 99, 60, 0.4);
}

.feedback--modal.is-error {
  background: linear-gradient(90deg, rgba(180, 55, 47, 0.18), rgba(180, 55, 47, 0.06));
  box-shadow: inset 0 0 0 2px rgba(180, 55, 47, 0.4);
  animation: shake 0.36s linear;
}

.quest-modal__footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 22px;
  background: linear-gradient(180deg, transparent, rgba(120, 70, 30, 0.18));
  border-top: 2px solid rgba(120, 70, 30, 0.22);
  flex-wrap: wrap;
}

.quest-modal__footer .button {
  flex: 1;
  min-width: 160px;
}

.quest-modal__footer .button--primary[data-state="advance"] {
  background: linear-gradient(180deg, #8acf9a 0%, #2e6440 100%);
  color: #0e2014;
}

@media (max-width: 520px) {
  .quest-modal__hero {
    height: 140px;
  }
  .quest-modal__portrait {
    width: 138px;
    height: 156px;
  }
  .quest-modal__portrait .portrait {
    width: 138px;
    height: 156px;
  }
  .quest-modal__content {
    padding: 44px 20px 18px;
  }
  .quest-modal__footer {
    padding: 14px 18px 18px;
  }
}

/* ============================================================
   REDUCED MOTION — silence heavy animations for users who request it
   Honored both here (CSS) and in JS (reducedMotion variable)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  h1 {
    animation: none !important;
    background: linear-gradient(110deg, #ffe7ad, #efc66b);
    -webkit-background-clip: text;
    background-clip: text;
  }
  .crest::before {
    display: none;
  }
  .battlefield.is-success,
  .battlefield.is-error {
    animation: none !important;
  }
  .quest-modal__backdrop,
  .quest-modal__frame,
  .quest-modal__zone,
  .quest-modal__portrait,
  .quest-modal__content > *,
  .quest-summary__open[data-near="true"] {
    animation: none !important;
  }
  .quest-modal__frame {
    transform: none;
    opacity: 1;
  }
  .quest-modal__portrait {
    transform: translateX(-50%) translateY(20px);
    opacity: 1;
  }
  .route,
  .map-cloud,
  .marker-pulse,
  .here-pin,
  .lock-badge,
  .caravan animateMotion {
    animation: none !important;
  }
  .here-pin,
  .lock-badge {
    transition: none !important;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* ============================================================
   BASE — page background, body defaults, page frame
   ============================================================ */

body {
  margin: 0;
  min-height: 100vh;
  font-family: "EB Garamond", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(106, 148, 217, 0.18), transparent 30%),
    radial-gradient(circle at bottom, rgba(215, 144, 63, 0.16), transparent 25%),
    linear-gradient(180deg, #18131f 0%, #100d15 100%);
  position: relative;
  overflow-x: hidden;
}

.page-frame,
.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}

.page-frame {
  border: 18px solid rgba(118, 71, 39, 0.3);
  box-shadow: inset 0 0 0 2px rgba(255, 218, 149, 0.15), inset 0 0 48px rgba(0, 0, 0, 0.42);
}

.page-glow {
  background:
    radial-gradient(circle at 8% 18%, rgba(255, 216, 127, 0.12), transparent 26%),
    radial-gradient(circle at 90% 4%, rgba(113, 165, 255, 0.11), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(195, 85, 58, 0.12), transparent 24%);
}

button,
input,
textarea,
select {
  font: inherit;
}

/* ============================================================
   HERO + LAYOUT GRID — top of page, status card, side column
   ============================================================ */

.hero,
.layout {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  padding: 28px 0 24px;
}

.hero__copy,
.status-card,
.parchment {
  border-radius: 28px;
  border: 2px solid rgba(238, 198, 107, 0.28);
  box-shadow:
    0 24px 46px rgba(0, 0, 0, 0.3),
    inset 0 0 0 2px rgba(255, 239, 199, 0.08);
}

.hero__copy {
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(38, 32, 61, 0.95), rgba(26, 22, 37, 0.96)),
    radial-gradient(circle at 10% 18%, rgba(255, 208, 122, 0.15), transparent 26%);
  position: relative;
  overflow: hidden;
}

.hero__copy::after {
  content: "";
  position: absolute;
  inset: auto -6% -26% 42%;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 206, 98, 0.2), transparent 72%);
  transform: rotate(-10deg);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: rgba(255, 229, 171, 0.75);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Cinzel", serif;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2.7rem, 6vw, 5rem);
  max-width: 11ch;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.28), 0 1px 0 rgba(70, 38, 14, 0.5);
  background: linear-gradient(110deg, #ffe7ad 0%, #ffd070 28%, #efc66b 50%, #fff5d9 70%, #efc66b 100%);
  background-size: 220% 220%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px rgba(91, 50, 18, 0.35);
  animation: goldShimmer 8s ease-in-out infinite;
  letter-spacing: 0.01em;
}

.hero__lede {
  max-width: 58ch;
  margin: 18px 0 26px;
  font-size: 1.18rem;
  line-height: 1.5;
  color: rgba(247, 239, 216, 0.88);
}

.hero__actions,
.quest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ============================================================
   BUTTON — .button base + --primary / --ghost / --sm variants
   States: hover, focus-visible (gold ring), active (squash), disabled
   ============================================================ */

.button {
  border-radius: 999px;
  padding: 13px 24px;
  border: 2px solid rgba(28, 14, 6, 0.35);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  position: relative;
  transition: transform 220ms var(--spring), box-shadow 220ms var(--spring), filter 200ms ease;
  will-change: transform;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-3px) scale(1.03);
  filter: saturate(1.1) brightness(1.04);
}

.button:focus-visible {
  outline: 3px solid #ffe7ad;
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(28, 14, 6, 0.65), var(--bs-shadow-strong);
}

.button:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: var(--bs-shadow-pressed) !important;
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
  text-shadow: none !important;
}

.button.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 3px solid rgba(28, 14, 6, 0.25);
  border-top-color: rgba(28, 14, 6, 0.9);
  animation: buttonSpin 720ms linear infinite;
}

@keyframes buttonSpin {
  to { transform: rotate(360deg); }
}

.button--primary {
  background: linear-gradient(180deg, #f9d77a 0%, #f0a341 50%, #b35d21 100%);
  color: #23150c;
  text-shadow: 0 1px 0 rgba(255, 245, 214, 0.6);
  box-shadow: var(--bs-press-inset), var(--bs-shadow-strong);
}

.button--primary::after {
  content: "";
  position: absolute;
  inset: 4px 8px auto 8px;
  height: 30%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 247, 224, 0.55), rgba(255, 247, 224, 0));
  pointer-events: none;
}

.button--ghost {
  background: linear-gradient(180deg, rgba(79, 115, 181, 0.32), rgba(38, 56, 90, 0.42));
  color: var(--gold-soft);
  box-shadow: inset 0 2px 0 rgba(255, 245, 214, 0.18), inset 0 -3px 0 rgba(0, 0, 0, 0.4), 0 6px 0 rgba(20, 12, 6, 0.28), 0 12px 20px rgba(0, 0, 0, 0.28);
}

#auth-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.auth-note {
  margin: var(--space-2) 0 0;
  font-size: var(--type-sm);
  color: rgba(45, 26, 17, 0.7);
  font-style: italic;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-top: var(--space-3);
  border-bottom: 2px solid rgba(120, 70, 30, 0.32);
}

.auth-tab {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--type-md);
  font-weight: 700;
  color: rgba(45, 26, 17, 0.6);
  transition: color 200ms ease, border-color 200ms ease;
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--crimson);
}

.auth-tab:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 2px;
}

.auth-error {
  margin: 0;
  min-height: 22px;
  padding: var(--space-2) 0;
  color: var(--error);
  font-weight: 700;
  font-size: var(--type-sm);
}

.auth-error.is-success {
  color: var(--success);
}

/* === ZOO FLASHCARDS === */

.zoo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.zoo-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(28, 14, 6, 0.4);
  background: linear-gradient(180deg, #f5e0a8, #c89046);
  cursor: pointer;
  display: grid;
  place-items: center;
  text-align: center;
  padding: var(--space-3);
  transition: transform 220ms var(--spring), box-shadow 220ms var(--spring);
  box-shadow: 0 4px 0 rgba(28, 14, 6, 0.3);
  perspective: 1000px;
  transform-style: preserve-3d;
  font-family: inherit;
  color: var(--ink);
}

.zoo-card:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 8px 0 rgba(28, 14, 6, 0.32);
}

.zoo-card:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
}

.zoo-card.is-flipped {
  background: linear-gradient(180deg, #5fa572, #2e6440);
  color: #fff5e6;
}

.zoo-card__emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: var(--space-1);
  filter: drop-shadow(0 2px 0 rgba(28, 14, 6, 0.32));
}

.zoo-card__name {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: var(--type-md);
  line-height: 1.2;
}

.zoo-card__sub {
  font-size: var(--type-sm);
  font-weight: 600;
  opacity: 0.8;
  margin-top: var(--space-1);
}

.zoo-card.is-flipped .zoo-card__sub {
  opacity: 0.95;
}

/* === WORD BANK QUEST === */

.wordbank-zone {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.wordbank-constructed {
  min-height: 56px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  border: 2px dashed rgba(120, 70, 30, 0.4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.wordbank-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-height: 56px;
}

.wordbank-tile {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 2px solid rgba(28, 14, 6, 0.4);
  background: linear-gradient(180deg, #fffaef, #f5e0a8);
  color: var(--ink);
  font-size: var(--type-md);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 200ms var(--spring), box-shadow 200ms var(--spring);
  box-shadow: 0 3px 0 rgba(28, 14, 6, 0.28);
}

.wordbank-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(28, 14, 6, 0.32);
}

.wordbank-tile:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(28, 14, 6, 0.32);
}

.wordbank-tile:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
}

.wordbank-tile.is-placed {
  background: linear-gradient(180deg, #c4e6cf, #5fa572);
  color: #0e2014;
}

.wordbank-empty {
  color: rgba(45, 26, 17, 0.45);
  font-style: italic;
  padding: var(--space-2) var(--space-3);
}

#wordbank-reset {
  justify-self: start;
}

.status-card,
.parchment {
  background:
    linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%),
    radial-gradient(circle at top, rgba(255, 248, 226, 0.75), transparent 28%);
  color: var(--ink);
}

.status-card {
  padding: 24px;
}

.status-card__header,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.status-card__header {
  margin-bottom: 22px;
}

.crest {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "Cinzel", serif;
  font-size: 1.5rem;
  color: var(--gold-soft);
  background: radial-gradient(circle at 30% 25%, #efc66b, #8b3228 70%);
  box-shadow: inset 0 0 0 4px rgba(255, 237, 190, 0.18);
  position: relative;
  animation: crestShine 3.6s ease-in-out infinite;
}

.crest::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px dashed rgba(239, 198, 107, 0.4);
  animation: spinSlow 16s linear infinite;
  pointer-events: none;
}

.status-grid,
.city-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.label {
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.83rem;
  color: rgba(45, 26, 17, 0.66);
}

.xp-bar {
  margin-top: 18px;
  height: 15px;
  border-radius: 999px;
  background: rgba(79, 45, 21, 0.2);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(108, 64, 27, 0.18);
}

.xp-bar__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #b33a34 0%, #efc66b 100%);
  border-radius: inherit;
  transition: width 280ms ease;
}

.status-tags,
.map-legend,
.controls-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-tags {
  margin-top: 18px;
}

.pill,
.status-tag,
.reward-pill,
.difficulty-badge,
.zone-pill {
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-sm);
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 245, 214, 0.4);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.pill--reward { background: linear-gradient(180deg, #f8d8a3 0%, #d8842f 100%); color: #4a2110; }
.pill--zone { background: linear-gradient(180deg, #7b4fb2, #49306b); color: #fff0c9; }
.pill--status { background: rgba(180, 55, 47, 0.12); color: #7a271f; }
.pill--difficulty { background: rgba(180, 55, 47, 0.12); color: #7a271f; }
.pill--success { background: linear-gradient(180deg, #8acf9a 0%, #2e6440 100%); color: #0e2014; }

.status-tag,
.reward-pill,
.difficulty-badge {
  background: rgba(180, 55, 47, 0.12);
  color: #7a271f;
}

.zone-pill {
  background: linear-gradient(180deg, #7b4fb2, #49306b);
  color: #fff0c9;
  animation: pillBreathe 3.4s ease-in-out infinite;
  box-shadow: inset 0 1px 0 rgba(255, 245, 214, 0.4), 0 6px 14px rgba(73, 48, 107, 0.4);
}

.reward-pill {
  background: linear-gradient(180deg, #f8d8a3 0%, #d8842f 100%);
  color: #4a2110;
  animation: rewardPop 0.5s var(--spring) both;
  box-shadow: inset 0 1px 0 rgba(255, 245, 214, 0.6), 0 5px 12px rgba(120, 60, 20, 0.4);
}

.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  padding-bottom: 30px;
}

.world-column,
.side-column {
  display: grid;
  gap: 22px;
}

.live-panel,
.map-panel,
.city-card,
.quest-summary,
.panels-grid {
  padding: 20px;
}

/* === WORLD MAP BAND === */

.world-band {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto 24px;
  padding: 24px 28px;
  display: grid;
  gap: 18px;
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(238, 198, 107, 0.42);
  box-shadow: var(--bs-shadow-band);
}

.world-band::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 24px;
  border: 2px dashed rgba(120, 70, 30, 0.28);
  pointer-events: none;
}

.world-band__heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.world-band__heading h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  color: #3a1d10;
  text-shadow: 0 1px 0 rgba(255, 245, 214, 0.4);
}

.world-band__heading .section-note {
  max-width: 56ch;
  text-align: right;
}

.world-band__shell {
  position: relative;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(123, 73, 32, 0.18), rgba(62, 39, 20, 0.12));
  box-shadow:
    inset 0 0 0 2px rgba(87, 55, 27, 0.22),
    inset 0 0 90px rgba(40, 24, 12, 0.22);
  padding: 16px;
}

.world-band .world-map {
  width: 100%;
  height: auto;
  display: block;
  min-height: 360px;
}

@media (min-width: 760px) {
  .world-band .world-map { min-height: 480px; }
}

@media (min-width: 1100px) {
  .world-band .world-map { min-height: 620px; }
}

@media (min-width: 1400px) {
  .world-band .world-map { min-height: 720px; }
}

.world-band .map-legend {
  position: relative;
  z-index: 2;
  font-size: 1rem;
  font-weight: 600;
  color: #3d2113;
}

/* Route animation */

.route {
  fill: none;
  stroke: #926434;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 18 22;
  stroke-dashoffset: 0;
  animation: routeFlow 2.6s linear infinite;
}

.route--main {
  stroke-width: 18;
  stroke-dasharray: 22 24;
  filter: drop-shadow(0 2px 0 rgba(120, 70, 30, 0.4));
}

.route--minor {
  stroke-width: 11;
  stroke-dasharray: 14 18;
  opacity: 0.85;
}

@keyframes routeFlow {
  to { stroke-dashoffset: -40; }
}

/* Caravan along route */

.caravan {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

/* Cloud drift */

.map-cloud {
  animation: cloudDrift 32s ease-in-out infinite;
}

.map-cloud--a { animation-duration: 36s; }
.map-cloud--b { animation-duration: 44s; animation-delay: -8s; }
.map-cloud--c { animation-duration: 38s; animation-delay: -14s; }
.map-cloud--d { animation-duration: 50s; animation-delay: -22s; }

@keyframes cloudDrift {
  0% { transform: translateX(-30px); opacity: 0.55; }
  50% { transform: translateX(70px); opacity: 0.85; }
  100% { transform: translateX(-30px); opacity: 0.55; }
}

/* Marker pulse ring */

.marker-pulse {
  opacity: 0;
  transform-origin: center;
  transform-box: fill-box;
}

.city-marker.is-active .marker-pulse {
  animation: markerPulseRing 1.8s ease-out infinite;
}

@keyframes markerPulseRing {
  0% { opacity: 0.85; transform: scale(0.92); stroke-width: 4; }
  100% { opacity: 0; transform: scale(1.45); stroke-width: 1; }
}

/* "Тук си" pin — visible only on active city */

.here-pin {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  transform-origin: center bottom;
  transform-box: fill-box;
}

.city-marker.is-active .here-pin {
  opacity: 1;
  animation: herePinBob 2.4s ease-in-out infinite;
}

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

/* Lock badge — visible only on locked cities */

.lock-badge {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  transform-origin: center;
  transform-box: fill-box;
}

.city-marker.is-locked .lock-badge {
  opacity: 1;
  animation: lockJiggle 4s ease-in-out infinite;
}

@keyframes lockJiggle {
  0%, 90%, 100% { transform: rotate(0); }
  93% { transform: rotate(-8deg); }
  96% { transform: rotate(8deg); }
}

/* Layout: when world-band exists, .world-column gives canvas full breathing room */

@media (min-width: 1180px) {
  main.layout {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

/* === SCENE BAND (live canvas, promoted to full width) === */

.scene-band {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto 24px;
  padding: 22px;
  position: relative;
  border: 3px solid rgba(238, 198, 107, 0.42);
  box-shadow: var(--bs-shadow-band);
}

.scene-band .battlefield {
  margin-top: var(--space-4);
}

.scene-band__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.button--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--type-sm);
}

.button--lg {
  padding: var(--space-4) var(--space-7);
  font-size: var(--type-lg);
  border-radius: var(--radius-pill);
  font-weight: 800;
  letter-spacing: 0.03em;
}

/* Side panel grid below scene */
@media (min-width: 1180px) {
  main.layout {
    grid-template-columns: 1fr;
  }
  main.layout .side-column {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    align-items: start;
  }
  main.layout .side-column .panels-grid {
    grid-column: span 1;
  }
}

/* === TOAST === */

.toast-stack {
  position: fixed;
  top: clamp(12px, 2vw, 24px);
  right: clamp(12px, 2vw, 24px);
  display: grid;
  gap: var(--space-3);
  z-index: var(--z-toast);
  pointer-events: none;
  width: min(380px, calc(100vw - 24px));
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(28, 14, 6, 0.6);
  color: #fff5d9;
  background: linear-gradient(180deg, #4a3322, #2a1d12);
  box-shadow: var(--bs-shadow-strong);
  font-size: var(--type-md);
  line-height: 1.35;
  transform-origin: top right;
  animation: toastIn 360ms cubic-bezier(.34, 1.66, .64, 1) both;
}

.toast.is-leaving {
  animation: toastOut 220ms ease-in forwards;
}

@keyframes toastIn {
  0% { transform: translateX(40px) scale(0.92); opacity: 0; }
  60% { transform: translateX(-4px) scale(1.02); opacity: 1; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateX(40px) scale(0.94); opacity: 0; }
}

.toast--success {
  background: linear-gradient(180deg, #3f8a4d, #2e6440);
  border-color: rgba(28, 14, 6, 0.7);
}

.toast--error {
  background: linear-gradient(180deg, #c25149, #8a2624);
}

.toast--info {
  background: linear-gradient(180deg, #4a6cb5, #2d4581);
}

.toast__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-family: "Cinzel", serif;
  font-size: 1rem;
  background: rgba(255, 245, 214, 0.18);
  color: #fff5d9;
  flex-shrink: 0;
}

.toast--success .toast__icon::before { content: "✓"; }
.toast--error .toast__icon::before { content: "!"; }
.toast--info .toast__icon::before { content: "i"; }

.toast__body {
  min-width: 0;
}

.toast__close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 245, 214, 0.4);
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 200ms var(--spring), background 200ms ease;
}

.toast__close:hover { transform: scale(1.08); background: rgba(0, 0, 0, 0.32); }
.toast__close:focus-visible {
  outline: 2px solid #ffe7ad;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.is-leaving { animation: none; opacity: 0; }
}

/* === CUSTOMIZATION MODAL === */

.quest-modal__form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.customize-hero {
  height: 220px;
  background: linear-gradient(180deg, #6ea4ec 0%, #ffc781 56%, #77ab58 56%, #53733b 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid rgba(28, 14, 6, 0.45);
}

.customize-hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -30% -10%;
  height: 60%;
  background: linear-gradient(180deg, #6da54b, #4c6f32);
  border-radius: 50% 50% 0 0;
}

.customize-preview {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 178px;
  height: 200px;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.45));
}

.customize-preview .portrait {
  width: 178px;
  height: 200px;
  bottom: 0;
}

.customize-field {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

.customize-field .label {
  margin-bottom: 0;
}

/* customize input now uses .input base — no overrides needed */

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.swatch-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(28, 14, 6, 0.5);
  cursor: pointer;
  position: relative;
  transition: transform 200ms var(--spring), box-shadow 200ms ease;
  background: var(--swatch-color);
  color: transparent;
  font-size: 0;
}

.swatch-btn--label {
  width: auto;
  min-width: 56px;
  height: 44px;
  border-radius: var(--radius-pill);
  padding: 0 var(--space-3);
  background: linear-gradient(180deg, #f5e0a8, #c89046);
  color: #2d1a11;
  font-size: var(--type-sm);
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 245, 214, 0.6);
}

.swatch-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.swatch-btn[aria-checked="true"] {
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
  transform: scale(1.08);
  box-shadow: 0 0 0 4px rgba(28, 14, 6, 0.55);
}

.swatch-btn:focus-visible {
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
}

.live-panel {
  border: 3px solid rgba(238, 198, 107, 0.4);
  box-shadow:
    0 30px 56px rgba(0, 0, 0, 0.34),
    inset 0 0 0 2px rgba(255, 239, 199, 0.12),
    0 0 0 0 rgba(239, 198, 107, 0);
}

.section-note {
  margin: 6px 0 0;
  font-size: 0.98rem;
  color: rgba(45, 26, 17, 0.72);
}

/* ============================================================
   BATTLEFIELD — wrapper around the live canvas, with HUD overlay
   ============================================================ */

.battlefield {
  position: relative;
  margin-top: 18px;
  border-radius: 28px;
  padding: 14px;
  background:
    linear-gradient(180deg, #5b391f 0%, #3c2414 100%);
  border: 3px solid rgba(84, 51, 23, 0.6);
  box-shadow:
    inset 0 0 0 4px rgba(255, 223, 153, 0.2),
    inset 0 0 38px rgba(0, 0, 0, 0.28),
    0 24px 46px rgba(0, 0, 0, 0.36);
  transition: box-shadow 240ms ease, transform 240ms ease;
}

.battlefield::before,
.battlefield::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 223, 153, 0.5);
  pointer-events: none;
}

.battlefield::before {
  top: 6px;
  left: 6px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 12px;
}

.battlefield::after {
  bottom: 6px;
  right: 6px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 12px;
}

.battlefield.is-success {
  animation: successFlash 0.7s ease-out;
}

.battlefield.is-error {
  animation: errorFlash 0.7s ease-out, shake 0.36s linear;
}

.game-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 20px;
  background: linear-gradient(180deg, #4c7ecc 0%, #f3c27f 68%, #5f8d49 68%, #47653a 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 250, 232, 0.16);
  cursor: pointer;
}

.game-canvas:focus-visible {
  outline: 4px solid #ffe7ad;
  outline-offset: 4px;
}

.battlefield-overlay {
  position: absolute;
  inset: 24px 24px auto 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.hud-bars {
  display: grid;
  gap: 10px;
  width: min(340px, 50%);
}

.hud-bar {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(27, 21, 32, 0.58);
  color: #fef4d7;
  backdrop-filter: blur(6px);
}

.hud-bar span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.meter {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.meter__fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.meter--health .meter__fill {
  background: linear-gradient(90deg, #ffb375, #d44330);
}

.meter--focus .meter__fill {
  background: linear-gradient(90deg, #b9f4ff, #3386bf);
}

.world-tip-shell {
  max-width: 48%;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(27, 21, 32, 0.62);
  color: #fef4d7;
  backdrop-filter: blur(6px);
}

.world-tip,
.objective-line {
  margin: 0;
  line-height: 1.35;
  font-size: 1rem;
}

.objective-line {
  margin-top: 6px;
  color: #ffe19a;
}

.controls-strip {
  margin-top: 14px;
  color: rgba(45, 26, 17, 0.75);
  font-size: 0.98rem;
}

.map-shell {
  margin-top: 18px;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(123, 73, 32, 0.18), rgba(62, 39, 20, 0.12));
  box-shadow: inset 0 0 0 1px rgba(87, 55, 27, 0.18);
}

.world-map {
  width: 100%;
  height: auto;
  display: block;
}

.city-label {
  font-family: "Cinzel", serif;
  font-size: 24px;
  fill: #341d0f;
}

.city-marker {
  cursor: pointer;
  transition: transform 240ms var(--spring), filter 200ms ease;
  transform-origin: center;
  transform-box: fill-box;
}

.city-marker > * {
  transform-box: fill-box;
  transform-origin: center;
}

.city-marker > circle:first-of-type {
  animation: mapMarkerBob 2.6s ease-in-out infinite;
}

.city-marker:hover,
.city-marker:focus-visible {
  transform: translateY(-8px) scale(1.06);
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.45));
  outline: none;
}

.city-marker.is-active > circle:first-of-type {
  filter: drop-shadow(0 0 22px rgba(239, 198, 107, 0.95));
}

.city-marker.is-active::after {
  content: "";
}

.city-marker.is-locked {
  animation: lockedDim 3.4s ease-in-out infinite;
  cursor: not-allowed;
}

.city-marker.is-locked circle {
  fill: #8a7c68;
}

.city-marker.is-locked .city-label {
  fill: #5d4f3c;
}

.legend-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 8px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 244, 203, 0.42);
}

.legend-swatch--capital { background: #c04848; }
.legend-swatch--trade { background: #dd8e39; }
.legend-swatch--garden { background: #4d9c67; }
.legend-swatch--forge { background: #6887c8; }
.legend-swatch--zoo { background: #7ba74a; }

/* ============================================================
   TOUCH CONTROLS — virtual joystick + interaction button
   ============================================================ */

/* Hidden by default; shown only on coarse-pointer devices */
.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 4;
}

.touch-joystick {
  position: absolute;
  bottom: 18px;
  left: 18px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 245, 214, 0.32), rgba(28, 14, 6, 0.55));
  border: 3px solid rgba(255, 245, 214, 0.6);
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.touch-joystick__stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f9d77a, #b35d21);
  box-shadow: var(--bs-press-inset), 0 4px 0 rgba(20, 12, 6, 0.42);
  transition: transform 80ms ease;
  transform: translate(0, 0);
}

.touch-action {
  position: absolute;
  bottom: 36px;
  right: 24px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 3px solid rgba(28, 14, 6, 0.6);
  background: linear-gradient(180deg, #f9d77a 0%, #f0a341 50%, #b35d21 100%);
  color: #1d0f08;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 2rem;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: var(--bs-press-inset), var(--bs-shadow-strong);
  touch-action: none;
}

.touch-action[data-near="true"] {
  animation: openCtaPulse 1.4s ease-in-out infinite;
}

.touch-action:active {
  transform: translateY(2px);
  box-shadow: var(--bs-press-inset), var(--bs-shadow-pressed);
}

/* Show touch controls on coarse-pointer (phone/tablet) devices */
@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: block;
  }
  .control-hint--keyboard {
    display: none;
  }
  body.touch-active .game-canvas {
    cursor: default;
  }
}

@media (hover: hover) and (pointer: fine) {
  .control-hint--touch {
    display: none;
  }
}

/* Mobile (narrow viewport) modal + scene polish */

@media (max-width: 520px) {
  .scene-band {
    padding: 14px;
    border-radius: 18px;
  }
  .scene-band__meta {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .scene-band__meta .button,
  .scene-band__meta .audio-btn {
    font-size: 0.86rem;
    padding: 8px 12px;
  }
  .quest-modal {
    padding: 8px;
  }
  .quest-modal__frame {
    border-radius: 22px;
    width: 100%;
    max-height: calc(100vh - 16px);
  }
  .quest-modal__content {
    padding: 36px 16px 14px;
  }
  .quest-modal__footer {
    padding: 12px 16px 16px;
  }
  .battlefield {
    padding: 8px;
    border-radius: 22px;
  }
  .battlefield-overlay {
    inset: 14px 14px auto 14px;
  }
  .hud-bars {
    width: min(220px, 56%);
  }
  .answer-option {
    padding: 12px 14px;
    font-size: 0.96rem;
  }
  .wordbank-tile {
    padding: 8px 14px;
    font-size: 0.96rem;
  }
  /* Bigger touch targets on phone */
  .touch-joystick {
    width: 116px;
    height: 116px;
    bottom: 14px;
    left: 14px;
  }
  .touch-joystick__stick {
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
  }
  .touch-action {
    width: 72px;
    height: 72px;
    bottom: 22px;
    right: 16px;
    font-size: 1.6rem;
  }
}

/* ============================================================
   WELCOME MODAL — first-time tour
   ============================================================ */

.welcome-list {
  display: grid;
  gap: var(--space-3);
  padding: 0;
  margin: 0;
  list-style: none;
}

.welcome-list li {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  background: rgba(105, 62, 28, 0.08);
  border-radius: var(--radius-md);
  font-size: var(--type-md);
}

.welcome-list .welcome-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f9d77a, #c89046);
  color: #1d0f08;
  font-weight: 800;
  font-family: "Cinzel", serif;
  box-shadow: 0 2px 0 rgba(20, 12, 6, 0.32);
}

/* ============================================================
   STATS MODAL — per-city progress + accuracy
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.stats-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(105, 62, 28, 0.08);
  border: 2px solid rgba(103, 63, 28, 0.2);
}

.stats-card__title {
  font-family: "Cinzel", serif;
  font-weight: 700;
  margin: 0 0 var(--space-2);
  color: var(--ink);
}

.stats-card__value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #5a3a1c;
  font-family: "Cinzel", serif;
}

.stats-card__sub {
  margin: 4px 0 0;
  color: rgba(45, 26, 17, 0.7);
  font-size: var(--type-sm);
}

.stats-card .stats-bar {
  margin-top: var(--space-2);
  height: 8px;
  border-radius: 999px;
  background: rgba(45, 26, 17, 0.18);
  overflow: hidden;
}

.stats-card .stats-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #b33a34, #efc66b);
  border-radius: inherit;
}

.city-description,
.quest-description,
.dialogue-line,
.phrase-hint,
.feedback,
.inventory-list,
.progress-list {
  font-size: 1.08rem;
  line-height: 1.45;
}

.city-art {
  margin-top: 18px;
  min-height: 230px;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(180deg, #6ea4ec 0%, #ffc781 56%, #77ab58 56%, #53733b 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 203, 0.22);
}

.showcase {
  position: absolute;
  inset: 0;
}

.showcase__hill {
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: -8%;
  height: 46%;
  background: linear-gradient(180deg, #6da54b, #4c6f32);
  border-radius: 50% 50% 0 0;
}

/* ============================================================
   PORTRAIT — CSS-only character portrait (modal hero, customize preview)
   Reads --skin, --hair, --cloth, --cape, --crown CSS custom properties
   ============================================================ */

.portrait {
  position: absolute;
  bottom: 18px;
  width: 160px;
  height: 188px;
}

.portrait--player {
  left: 24px;
}

.portrait--npc {
  right: 24px;
}

.portrait__halo {
  position: absolute;
  left: 50%;
  top: 24px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 236, 174, 0.65), rgba(255, 236, 174, 0.06) 70%);
}

.portrait__shadow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 84px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(36, 22, 12, 0.26);
}

.portrait__head,
.portrait__body,
.portrait__cape,
.portrait__hair,
.portrait__crown {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.portrait__head {
  top: 44px;
  width: 74px;
  height: 74px;
  border-radius: 48% 48% 46% 46%;
  background: var(--skin, #945e3d);
  border: 3px solid rgba(28, 14, 6, 0.55);
  z-index: 3;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12), inset 0 6px 0 rgba(255, 255, 255, 0.12);
}

.portrait__hair {
  top: 34px;
  width: 86px;
  height: 54px;
  border-radius: 50% 50% 36% 36%;
  background: var(--hair, #5d3b22);
  z-index: 4;
}

.portrait__body {
  top: 104px;
  width: 104px;
  height: 70px;
  border-radius: 24px 24px 18px 18px;
  background: var(--cloth, #376fc5);
  border: 3px solid rgba(62, 34, 20, 0.42);
  z-index: 2;
}

.portrait__cape {
  top: 94px;
  width: 118px;
  height: 88px;
  border-radius: 24px 24px 30px 30px;
  background: var(--cape, #b4372f);
  clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%);
  z-index: 1;
}

.portrait__crown {
  top: 16px;
  width: 60px;
  height: 34px;
  background: var(--crown, #efc66b);
  clip-path: polygon(0 100%, 0 56%, 16% 56%, 26% 8%, 46% 56%, 56% 28%, 72% 56%, 84% 12%, 100% 56%, 100% 100%);
  z-index: 5;
}

.portrait__label {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(35, 22, 16, 0.7);
  color: #ffefc3;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 6;
}

.showcase__title {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(35, 22, 16, 0.68);
  color: #ffefc3;
  font-size: 0.92rem;
  font-weight: 700;
}

/* ============================================================
   DIALOGUE + PHRASE — speaker chat bubble, romani/bulgarian pills
   .phrase--locked hides the Bulgarian translation until correct
   ============================================================ */

.dialogue-box,
.phrase-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.82) 0%, rgba(255, 240, 200, 0.62) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(103, 63, 28, 0.22),
    inset 0 -3px 0 rgba(120, 70, 30, 0.18),
    0 4px 0 rgba(103, 63, 28, 0.18);
  position: relative;
}

.dialogue-box {
  border-top-left-radius: 6px;
}

.dialogue-box::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 24px;
  width: 22px;
  height: 22px;
  background: linear-gradient(180deg, rgba(255, 252, 240, 0.82), rgba(255, 240, 200, 0.62));
  border-left: 2px solid rgba(103, 63, 28, 0.22);
  border-top: 2px solid rgba(103, 63, 28, 0.22);
  transform: rotate(45deg);
  border-radius: 4px;
}

.dialogue-speaker {
  margin: 0 0 6px;
  font-family: "Cinzel", serif;
  font-size: 1rem;
  color: #8d2e24;
  letter-spacing: 0.04em;
}

.dialogue-line {
  margin: 0;
  font-style: italic;
}

.phrase {
  font-weight: 800;
  font-size: 1.34rem;
  padding: 8px 14px;
  border-radius: 14px;
  display: inline-block;
  position: relative;
  box-shadow: 0 3px 0 rgba(20, 12, 6, 0.18);
}

.phrase--romani {
  margin-top: 10px;
  color: #fff5d9;
  background: linear-gradient(180deg, #c45149, #8a2624);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
}

.phrase--bulgarian {
  margin-top: 8px;
  color: #fff5d9;
  background: linear-gradient(180deg, #5fa572, #2e6440);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.32);
}

.phrase--locked {
  background: linear-gradient(180deg, #6c5840, #3f2f20) !important;
  color: rgba(255, 245, 214, 0.85) !important;
  text-shadow: none !important;
  font-style: italic;
  font-weight: 600;
  font-size: 1rem !important;
  position: relative;
}

.phrase--locked::after {
  content: "🔒";
  margin-left: 6px;
  font-size: 0.92rem;
  opacity: 0.85;
}

.phrase--bulgarian:not(.phrase--locked) {
  animation: phraseReveal 600ms cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes phraseReveal {
  0% { transform: rotateY(90deg) scale(0.9); opacity: 0; filter: blur(6px); }
  60% { transform: rotateY(-8deg) scale(1.04); opacity: 1; filter: blur(0); }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; filter: blur(0); }
}

.phrase--romani::before,
.phrase--bulgarian::before {
  content: attr(data-tag);
  position: absolute;
  top: -8px;
  left: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1e120a;
  color: #ffe7ad;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
}

.phrase-hint {
  margin: 10px 0 0;
  color: rgba(45, 26, 17, 0.72);
}

.answer-options {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  min-width: 0;
  max-width: 100%;
}

/* ============================================================
   ANSWER OPTIONS — radiogroup with chunky press feel
   States: default, hover, focus-visible, selected, correct, disabled
   Keyboard: roving tabindex via JS in renderSwatchRow / renderOptions
   ============================================================ */

.answer-option {
  min-width: 0;
  max-width: 100%;
  text-align: left;
  padding: 14px 18px;
  border-radius: 18px;
  border: 2px solid rgba(103, 62, 29, 0.22);
  background: rgba(255, 248, 230, 0.62);
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
  cursor: pointer;
  position: relative;
  transition: transform 220ms var(--spring), box-shadow 220ms var(--spring), border-color 200ms ease, background 200ms ease;
  box-shadow: 0 4px 0 rgba(103, 62, 29, 0.18), 0 6px 12px rgba(0, 0, 0, 0.05);
}

.answer-option:hover,
.answer-option:focus-visible {
  transform: translateY(-3px) scale(1.012);
  border-color: rgba(180, 55, 47, 0.55);
  background: rgba(255, 252, 240, 0.85);
  box-shadow: 0 7px 0 rgba(103, 62, 29, 0.22), 0 14px 26px rgba(180, 55, 47, 0.18);
}

.answer-option:focus-visible {
  outline: 3px solid #b4372f;
  outline-offset: 3px;
}

.city-marker:focus-visible {
  outline: 3px solid #ffe7ad;
  outline-offset: 6px;
}

.answer-option:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: 0 1px 0 rgba(103, 62, 29, 0.22);
}

.answer-option.is-selected {
  background: linear-gradient(180deg, rgba(255, 230, 180, 0.85), rgba(240, 180, 100, 0.6));
  border-color: rgba(180, 55, 47, 0.7);
  box-shadow: 0 6px 0 rgba(120, 60, 20, 0.32), 0 10px 22px rgba(180, 55, 47, 0.22), inset 0 0 0 2px rgba(255, 245, 214, 0.4);
  transform: translateY(-2px);
}

.answer-option.is-correct {
  background: linear-gradient(180deg, rgba(140, 220, 160, 0.65), rgba(60, 130, 90, 0.5));
  border-color: rgba(36, 99, 60, 0.7);
  color: #0e2014;
}

.answer-option.is-correct::before {
  content: "✓";
  font-weight: 800;
  margin-right: 8px;
  color: #1f5a36;
}

.answer-option[disabled] {
  cursor: default;
  opacity: 0.85;
}

.feedback {
  min-height: 28px;
  margin: 14px 0 0;
  font-weight: 700;
}

.feedback.is-success { color: var(--success); }
.feedback.is-error { color: var(--error); }

.panels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.inventory-list,
.progress-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.inventory-list li,
.progress-list li {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(105, 62, 28, 0.08);
  box-shadow: inset 0 0 0 1px rgba(103, 63, 28, 0.16), 0 2px 0 rgba(103, 63, 28, 0.08);
  transition: transform 200ms var(--spring), box-shadow 200ms ease;
  position: relative;
  padding-left: 38px;
}

.inventory-list li::before,
.progress-list li::before {
  content: "✦";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #b35d21;
  font-size: 1.1rem;
}

.inventory-list li:hover,
.progress-list li:hover {
  transform: translateX(4px);
  box-shadow: inset 0 0 0 1px rgba(180, 55, 47, 0.3), 0 4px 10px rgba(180, 55, 47, 0.12);
}

.progress-list li.complete {
  background: linear-gradient(90deg, rgba(36, 99, 60, 0.18), rgba(36, 99, 60, 0.06));
  box-shadow: inset 0 0 0 1px rgba(36, 99, 60, 0.32), 0 2px 0 rgba(36, 99, 60, 0.18);
}

.progress-list li.complete::before {
  content: "✓";
  color: #2c7a4a;
  font-weight: 800;
}

.inventory-list li.empty,
.progress-list li.empty {
  color: rgba(45, 26, 17, 0.62);
}

/* ============================================================
   RESPONSIVE BREAKPOINTS — collapse columns + shrink padding
   ============================================================ */

@media (max-width: 1180px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .hero,
  .layout {
    width: min(100% - 18px, 1480px);
  }

  .hero {
    padding-top: 18px;
  }

  .hero__copy,
  .status-card,
  .live-panel,
  .map-panel,
  .city-card,
  .quest-summary,
  .panels-grid {
    padding: 16px;
  }

  .status-grid,
  .city-meta,
  .panels-grid {
    grid-template-columns: 1fr;
  }

  .battlefield-overlay {
    position: static;
    margin-top: 12px;
    flex-direction: column;
    inset: auto;
  }

  .hud-bars,
  .world-tip-shell {
    width: 100%;
    max-width: none;
  }

  .portrait {
    transform: scale(0.88);
    transform-origin: bottom center;
  }
}

/* ============================================================
   HIGH-ENERGY VISUAL OVERHAUL
   Saturated arcade-fantasy layer over the existing static app.
   ============================================================ */

:root {
  --arcade-blue: #1267ee;
  --arcade-cyan: #37ddff;
  --arcade-gold: #ffd45f;
  --arcade-red: #f0423c;
  --arcade-green: #32c85f;
  --arcade-ink: #171129;
  --panel-top: #fff1c5;
  --panel-bottom: #f0b34f;
  --bs-shadow-strong:
    0 7px 0 rgba(14, 9, 22, 0.62),
    0 20px 34px rgba(0, 0, 0, 0.38);
  --bs-shadow-card:
    0 11px 0 rgba(28, 16, 20, 0.32),
    0 24px 44px rgba(0, 0, 0, 0.32),
    inset 0 2px 0 rgba(255, 255, 255, 0.34);
  --bs-shadow-band:
    0 13px 0 rgba(18, 9, 18, 0.48),
    0 38px 70px rgba(0, 0, 0, 0.42),
    inset 0 3px 0 rgba(255, 255, 255, 0.24),
    inset 0 -8px 0 rgba(82, 37, 17, 0.28);
}

body {
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 212, 95, 0.18), transparent 18%),
    radial-gradient(circle at 84% 4%, rgba(55, 221, 255, 0.2), transparent 20%),
    radial-gradient(circle at 70% 92%, rgba(240, 66, 60, 0.16), transparent 24%),
    linear-gradient(180deg, #172c70 0%, #171129 52%, #0d0a17 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.15;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.5) 0 5px, transparent 6px),
    radial-gradient(circle, rgba(255, 212, 95, 0.6) 0 3px, transparent 4px);
  background-size: 112px 112px, 84px 84px;
  background-position: 0 0, 42px 32px;
}

.page-frame {
  border: 12px solid rgba(255, 212, 95, 0.34);
  box-shadow:
    inset 0 0 0 5px rgba(11, 7, 18, 0.42),
    inset 0 0 70px rgba(0, 0, 0, 0.48);
}

.page-glow {
  background:
    radial-gradient(circle at 14% 14%, rgba(255, 212, 95, 0.18), transparent 24%),
    radial-gradient(circle at 92% 8%, rgba(55, 221, 255, 0.22), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(50, 200, 95, 0.14), transparent 28%);
}

.hero__copy,
.status-card,
.parchment {
  border: 4px solid rgba(21, 13, 30, 0.88);
  box-shadow: var(--bs-shadow-card);
}

.hero__copy {
  min-height: 430px;
  background:
    linear-gradient(180deg, rgba(20, 116, 242, 0.96) 0%, rgba(57, 222, 255, 0.88) 48%, rgba(45, 184, 90, 0.9) 49%, rgba(34, 116, 64, 0.98) 100%);
  color: #fff9df;
}

.hero__copy > * {
  position: relative;
  z-index: 2;
}

.hero__copy::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 76% 28%, rgba(255, 255, 255, 0.24) 0 38px, transparent 40px),
    radial-gradient(circle at 66% 44%, rgba(255, 212, 95, 0.24) 0 70px, transparent 72px),
    radial-gradient(circle at 18% 72%, rgba(240, 66, 60, 0.22) 0 76px, transparent 78px);
  pointer-events: none;
  z-index: 0;
}

.hero__copy::after {
  inset: auto -8% -10% 46%;
  height: 300px;
  background:
    radial-gradient(ellipse at 20% 78%, rgba(20, 13, 30, 0.36) 0 22%, transparent 24%),
    linear-gradient(135deg, #f0423c 0 32%, transparent 33%),
    linear-gradient(45deg, #ffd45f 0 30%, transparent 31%),
    radial-gradient(circle at 58% 30%, rgba(255, 255, 255, 0.28), transparent 18%);
  border-radius: 40% 40% 0 0;
  opacity: 0.86;
  transform: rotate(-5deg);
  z-index: 1;
}

h1 {
  font-family: "Cinzel", serif;
  font-size: clamp(2.7rem, 5.2vw, 4.8rem);
  letter-spacing: 0;
  line-height: 1;
  max-width: 10.5ch;
  color: #ffe65c;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-stroke: 1.6px #16101f;
  text-shadow:
    0 3px 0 #f0423c,
    0 7px 0 #761d2e,
    0 14px 24px rgba(0, 0, 0, 0.42);
  animation: none;
  overflow-wrap: normal;
}

h2,
h3,
.section-heading h2,
.quest-modal__heading h2,
.world-band__heading h2 {
  letter-spacing: 0;
}

.hero__lede {
  position: relative;
  max-width: 62ch;
  color: #fff9df;
  text-shadow: 0 2px 0 rgba(16, 9, 24, 0.46);
  font-weight: 800;
}

.eyebrow {
  color: rgba(255, 245, 214, 0.9);
  font-weight: 900;
}

.button,
.audio-btn,
.touch-action {
  border: 4px solid rgba(21, 13, 30, 0.88);
  text-transform: none;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.36),
    inset 0 -5px 0 rgba(91, 37, 15, 0.4),
    var(--bs-shadow-strong);
}

.button--primary,
.touch-action {
  background: linear-gradient(180deg, #fff16e 0%, #ffb83f 48%, #d45b1f 100%);
  color: #20121a;
}

.button--ghost,
.audio-btn {
  background: linear-gradient(180deg, #3a91ff 0%, #2559c9 58%, #172d7b 100%);
  color: #fff4c4;
}

.button:hover,
.button:focus-visible,
.audio-btn:hover,
.audio-btn:focus-visible {
  transform: translateY(-4px) scale(1.035);
  filter: saturate(1.18) brightness(1.06);
}

.status-card,
.parchment {
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%);
}

.status-card__header h2,
.city-card h2,
.quest-summary h2,
.panels-grid h3 {
  color: #271521;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
}

.crest {
  color: #16101f;
  background:
    radial-gradient(circle at 32% 24%, #fff99b 0%, #ffd45f 40%, #f0423c 72%);
  border: 4px solid #16101f;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.42),
    0 6px 0 rgba(22, 16, 31, 0.44),
    0 12px 22px rgba(0, 0, 0, 0.26);
}

.status-grid > div,
.city-meta > div,
.stats-card,
.inventory-list li,
.progress-list li,
.dialogue-box,
.phrase-box,
.wordbank-constructed,
.wordbank-tile,
.answer-option {
  border: 3px solid rgba(21, 13, 30, 0.78);
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.42), transparent 25%),
    linear-gradient(180deg, rgba(255, 248, 221, 0.96), rgba(245, 203, 113, 0.86));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 5px 0 rgba(91, 54, 22, 0.34);
}

.xp-bar,
.meter,
.stats-card .stats-bar {
  border: 3px solid rgba(21, 13, 30, 0.8);
  background: rgba(21, 13, 30, 0.38);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
}

.xp-bar__fill,
.stats-card .stats-bar__fill {
  background: linear-gradient(90deg, #f0423c 0%, #ffd45f 52%, #32c85f 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.38);
}

.pill,
.status-tag,
.reward-pill,
.difficulty-badge,
.zone-pill {
  border: 3px solid rgba(21, 13, 30, 0.82);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.38),
    0 4px 0 rgba(21, 13, 30, 0.32);
}

.zone-pill {
  background: linear-gradient(180deg, #a85cff, #4a2cb3);
}

.reward-pill {
  background: linear-gradient(180deg, #fff16e 0%, #ff9c2f 100%);
}

.world-band,
.scene-band {
  background:
    linear-gradient(180deg, rgba(255, 241, 197, 0.98), rgba(241, 172, 75, 0.98)),
    radial-gradient(circle at top, rgba(255, 255, 255, 0.56), transparent 32%);
  border: 5px solid rgba(21, 13, 30, 0.9);
  box-shadow: var(--bs-shadow-band);
}

.world-band::before {
  border: 3px solid rgba(255, 255, 255, 0.32);
  border-radius: 18px;
}

.world-band__shell {
  border: 4px solid rgba(21, 13, 30, 0.86);
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.38), transparent 22%),
    linear-gradient(180deg, #3fbdf9, #4faf61 58%, #c99248 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.38),
    inset 0 -8px 0 rgba(30, 20, 16, 0.22),
    0 8px 0 rgba(21, 13, 30, 0.34);
}

.world-band .world-map {
  filter: saturate(1.24) contrast(1.05) drop-shadow(0 12px 16px rgba(0, 0, 0, 0.22));
}

.route {
  stroke: #6b3c24;
  stroke-width: 17;
  filter: drop-shadow(0 4px 0 rgba(255, 245, 214, 0.34));
}

.city-marker > circle:nth-of-type(2) {
  stroke: #16101f;
  stroke-width: 9;
}

.city-label {
  font-family: "Bangers", "Cinzel", serif;
  font-size: 31px;
  letter-spacing: 0;
  fill: #fff4c4;
  stroke: #16101f;
  stroke-width: 4px;
  paint-order: stroke fill;
}

.battlefield {
  padding: 18px;
  border-radius: 22px;
  border: 5px solid #16101f;
  background:
    linear-gradient(180deg, #ffd45f 0%, #f08b2c 48%, #7d2f20 100%);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.34),
    inset 0 -10px 0 rgba(89, 32, 18, 0.34),
    0 12px 0 rgba(16, 10, 22, 0.52),
    0 34px 60px rgba(0, 0, 0, 0.46);
}

.battlefield::before,
.battlefield::after {
  width: 42px;
  height: 42px;
  border-width: 5px;
  border-color: rgba(255, 246, 190, 0.8);
}

.game-canvas {
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.18),
    inset 0 0 80px rgba(0, 0, 0, 0.15);
  image-rendering: auto;
}

.hud-bar,
.world-tip-shell {
  border: 3px solid rgba(255, 245, 214, 0.46);
  background: rgba(15, 12, 29, 0.72);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 5px 0 rgba(0, 0, 0, 0.28);
}

.controls-strip {
  padding: 12px 14px;
  border: 3px solid rgba(21, 13, 30, 0.72);
  border-radius: 12px;
  background: rgba(255, 244, 207, 0.72);
  color: #2c1722;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(21, 13, 30, 0.18);
}

.city-art,
.quest-modal__hero,
.customize-hero {
  background:
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, 0.32), transparent 20%),
    linear-gradient(180deg, #1279f2 0%, #40dbff 54%, #63d951 55%, #287a40 100%);
  border: 4px solid rgba(21, 13, 30, 0.82);
}

.showcase__hill,
.quest-modal__hero::after,
.customize-hero::before {
  background: linear-gradient(180deg, #70f06a, #258043);
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.18);
}

.showcase__title,
.portrait__label,
.quest-modal__zone {
  border: 3px solid rgba(21, 13, 30, 0.78);
  background: linear-gradient(180deg, rgba(56, 37, 27, 0.94), rgba(18, 12, 20, 0.92));
  color: #fff4c4;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.portrait {
  filter: drop-shadow(0 10px 0 rgba(12, 8, 18, 0.28)) drop-shadow(0 18px 20px rgba(0, 0, 0, 0.38));
}

.portrait__head {
  border-width: 4px;
  border-color: rgba(21, 13, 30, 0.92);
  box-shadow:
    inset -10px -8px 0 rgba(0, 0, 0, 0.16),
    inset 8px 8px 0 rgba(255, 255, 255, 0.16);
}

.portrait__head::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 25px;
  width: 10px;
  height: 13px;
  border-radius: 50%;
  background: #fff8ef;
  box-shadow:
    28px 0 0 #fff8ef,
    2px 2px 0 3px rgba(16, 9, 24, 0.92),
    30px 2px 0 3px rgba(16, 9, 24, 0.92);
}

.portrait__head::after {
  content: "";
  position: absolute;
  left: 29px;
  top: 50px;
  width: 18px;
  height: 8px;
  border-bottom: 4px solid rgba(91, 30, 36, 0.85);
  border-radius: 0 0 18px 18px;
}

.portrait__hair {
  border: 4px solid rgba(21, 13, 30, 0.9);
  box-shadow:
    inset -8px -8px 0 rgba(0, 0, 0, 0.18),
    inset 8px 7px 0 rgba(255, 255, 255, 0.12);
}

.portrait__hair::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 7px;
  width: 34px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transform: rotate(-14deg);
}

.portrait__body,
.portrait__cape {
  border: 4px solid rgba(21, 13, 30, 0.9);
  box-shadow: inset -8px -8px 0 rgba(0, 0, 0, 0.16), inset 7px 7px 0 rgba(255, 255, 255, 0.14);
}

.portrait__body::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 40px;
  height: 9px;
  border-radius: 999px;
  background: #24151d;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14);
}

.portrait__crown {
  filter: drop-shadow(0 4px 0 rgba(21, 13, 30, 0.4));
}

.quest-modal__frame {
  border-radius: 18px;
  border: 5px solid #16101f;
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.55), transparent 24%),
    linear-gradient(180deg, #fff1c5, #f0b34f);
  box-shadow:
    0 12px 0 rgba(16, 10, 22, 0.62),
    0 40px 86px rgba(0, 0, 0, 0.58),
    inset 0 4px 0 rgba(255, 255, 255, 0.32);
}

.quest-modal__close {
  border: 4px solid #16101f;
  background: linear-gradient(180deg, #fff16e, #f0423c);
}

.dialogue-speaker,
.quest-summary__speaker {
  color: #a51f31;
  font-weight: 900;
}

.phrase {
  border: 3px solid rgba(21, 13, 30, 0.82);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.32),
    0 5px 0 rgba(21, 13, 30, 0.3);
}

.phrase--romani {
  background: linear-gradient(180deg, #ff6559, #a51f31);
}

.phrase--bulgarian {
  background: linear-gradient(180deg, #49df79, #157643);
}

.answer-option:hover,
.answer-option:focus-visible,
.zoo-card:hover,
.zoo-card:focus-visible {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 8px 0 rgba(21, 13, 30, 0.42),
    0 18px 28px rgba(19, 103, 238, 0.22);
}

.answer-option.is-selected {
  background: linear-gradient(180deg, #fff16e, #ffb83f);
  border-color: #16101f;
}

.answer-option.is-correct,
.wordbank-tile.is-placed {
  background: linear-gradient(180deg, #7df58e, #25a75b);
}

.zoo-card {
  border: 4px solid #16101f;
  background:
    radial-gradient(circle at 22% 12%, rgba(255, 255, 255, 0.42), transparent 22%),
    linear-gradient(180deg, #fff16e, #ff9c2f);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.38),
    0 7px 0 rgba(21, 13, 30, 0.44),
    0 16px 22px rgba(0, 0, 0, 0.22);
}

.zoo-card.is-flipped {
  background:
    radial-gradient(circle at 22% 12%, rgba(255, 255, 255, 0.42), transparent 22%),
    linear-gradient(180deg, #4af083, #147b45);
}

.zoo-card__emoji {
  font-size: 3.3rem;
  filter: drop-shadow(0 4px 0 rgba(21, 13, 30, 0.42));
}

.toast {
  border: 4px solid #16101f;
  box-shadow: var(--bs-shadow-strong);
}

@media (max-width: 860px) {
  h1 {
    font-size: clamp(2.45rem, 11vw, 4.2rem);
    -webkit-text-stroke-width: 1.2px;
    text-shadow:
      0 3px 0 #f0423c,
      0 6px 0 #761d2e,
      0 14px 22px rgba(0, 0, 0, 0.38);
  }

  .hero__copy {
    min-height: 360px;
  }

  .battlefield {
    padding: 10px;
  }

  .controls-strip {
    border-radius: 10px;
  }
}

/* ============================================================
   MOBILE / IPAD PLAYABILITY PASS
   Touch-first controls, safe areas, and lighter compact layouts.
   ============================================================ */

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

.battlefield {
  overflow: hidden;
}

.game-canvas {
  aspect-ratio: 980 / 620;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.quest-modal__content,
.phrase-box,
.phrase-pair,
.phrase-with-audio {
  min-width: 0;
}

.quest-modal__content {
  grid-template-columns: minmax(0, 1fr);
  overflow-x: hidden;
}

.quest-modal__content > * {
  min-width: 0;
  max-width: 100%;
}

.phrase-with-audio .phrase,
.phrase {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.phrase-with-audio .phrase {
  display: block;
}

body.touch-active .battlefield,
body.touch-active .game-canvas {
  touch-action: none;
}

main.layout {
  content-visibility: auto;
  contain-intrinsic-size: 900px;
}

.touch-joystick,
.touch-action {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.touch-joystick {
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px));
  left: max(18px, calc(env(safe-area-inset-left) + 14px));
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.42), rgba(255, 214, 97, 0.24) 32%, rgba(15, 10, 24, 0.66) 72%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.touch-joystick[data-active="true"] .touch-joystick__stick {
  transition: none;
}

.touch-joystick__stick::after {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 -2px 0 rgba(22, 13, 24, 0.22);
}

.touch-action {
  right: max(24px, calc(env(safe-area-inset-right) + 18px));
  bottom: max(36px, calc(env(safe-area-inset-bottom) + 22px));
  display: grid;
  place-items: center;
}

body.touch-active .battlefield-overlay {
  position: absolute;
  inset: clamp(10px, 2vw, 22px) clamp(10px, 2vw, 22px) auto;
  margin-top: 0;
  flex-direction: row;
  align-items: flex-start;
  pointer-events: none;
}

body.touch-active .hud-bars {
  width: min(240px, 42%);
  gap: 7px;
}

body.touch-active .hud-bar {
  padding: 7px 9px;
  border-radius: 12px;
}

body.touch-active .hud-bar span {
  margin-bottom: 4px;
  font-size: 0.68rem;
}

body.touch-active .meter {
  height: 8px;
}

body.touch-active .world-tip-shell {
  max-width: min(360px, 46%);
  padding: 8px 10px;
}

body.touch-active .world-tip,
body.touch-active .objective-line {
  font-size: 0.86rem;
  line-height: 1.25;
}

@media (min-width: 700px) and (hover: none) and (pointer: coarse) {
  .touch-joystick {
    width: 150px;
    height: 150px;
  }

  .touch-joystick__stick {
    width: 68px;
    height: 68px;
    margin: -34px 0 0 -34px;
  }

  .touch-action {
    width: 96px;
    height: 96px;
    font-size: 2.15rem;
  }
}

@media (max-width: 720px) {
  .hero,
  .layout,
  .scene-band,
  .world-band {
    width: min(100% - 12px, 1480px);
  }

  .page-frame {
    border-width: 6px;
  }

  .hero {
    gap: 12px;
    padding: 12px 0 16px;
  }

  .hero__copy,
  .status-card,
  .world-band,
  .scene-band,
  .city-card,
  .quest-summary,
  .panels-grid {
    border-width: 3px;
    border-radius: 18px;
    box-shadow:
      0 7px 0 rgba(14, 9, 22, 0.42),
      0 16px 30px rgba(0, 0, 0, 0.28),
      inset 0 2px 0 rgba(255, 255, 255, 0.22);
  }

  .hero__copy {
    min-height: 0;
    padding: 18px;
  }

  .hero__lede {
    font-size: 1rem;
    line-height: 1.38;
    margin: 12px 0 16px;
  }

  .hero__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .button {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
  }

  .section-heading {
    gap: 10px;
  }

  .section-heading {
    flex-direction: column;
  }

  .section-heading,
  .scene-band__meta {
    align-items: stretch;
  }

  .scene-band__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .scene-band__meta .zone-pill,
  .scene-band__meta .pill {
    grid-column: 1 / -1;
  }

  .audio-btn--scene {
    width: 100%;
    min-height: 48px;
  }

  .battlefield {
    padding: 7px;
    border-radius: 16px;
    border-width: 4px;
    box-shadow:
      inset 0 3px 0 rgba(255, 255, 255, 0.28),
      inset 0 -7px 0 rgba(89, 32, 18, 0.28),
      0 7px 0 rgba(16, 10, 22, 0.46),
      0 18px 34px rgba(0, 0, 0, 0.34);
  }

  .game-canvas {
    border-radius: 10px;
  }

  body.touch-active .world-tip-shell {
    display: none;
  }

  body.touch-active .hud-bars {
    width: min(178px, 48%);
  }

  .touch-joystick {
    width: 118px;
    height: 118px;
    border-width: 3px;
  }

  .touch-joystick__stick {
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
  }

  .touch-action {
    width: 76px;
    height: 76px;
    border-width: 3px;
    font-size: 1.75rem;
  }

  .controls-strip {
    display: grid;
    gap: 6px;
    padding: 10px;
    font-size: 0.9rem;
  }

  .quest-modal {
    align-items: stretch;
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .quest-modal__frame {
    max-height: calc(100svh - 16px);
    border-width: 4px;
  }

  .quest-modal__content {
    gap: 12px;
  }

  .answer-options {
    gap: 10px;
  }

  .answer-option,
  .wordbank-tile,
  .zoo-card {
    min-height: 48px;
  }

  .zoo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: clamp(2.1rem, 12vw, 3.1rem);
    max-width: 9.5ch;
  }

  .status-grid {
    gap: 8px;
  }

  .scene-band__meta {
    grid-template-columns: 1fr;
  }

  .touch-joystick {
    width: 108px;
    height: 108px;
  }

  .touch-joystick__stick {
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
  }

  .touch-action {
    width: 70px;
    height: 70px;
    font-size: 1.55rem;
  }

  body.touch-active .hud-bars {
    width: 156px;
  }

  .hud-bar {
    border-width: 2px;
  }

  .quest-modal__footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quest-modal__meta {
    align-items: flex-start;
  }

  .quest-modal__meta .quest-dots {
    flex: 1 1 180px;
  }

  .quest-dots--lg .quest-dots__dot {
    width: 10px;
    height: 10px;
  }

  .phrase {
    font-size: 1.08rem;
    padding: 8px 10px;
  }

  .phrase--locked {
    font-size: 0.92rem !important;
  }

  .phrase-with-audio {
    gap: 6px;
  }

  .phrase-with-audio .audio-btn {
    width: 44px;
  }
}
