* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #F4EFE2; color: #3A2E25; user-select: none;
}
#webgl { width: 100%; height: 100%; display: block; cursor: crosshair; }

/* Subtle cold-pressed paper tooth & warm sketchbook edge vignette over 3D viewport */
.paper-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background:
    radial-gradient(ellipse at center, rgba(246, 241, 229, 0) 64%, rgba(92, 75, 59, 0.14) 100%),
    repeating-linear-gradient(0deg, rgba(92, 75, 59, 0.018) 0px, rgba(92, 75, 59, 0.018) 1px, transparent 1px, transparent 4px);
}

.story-picker-wrap { margin: 14px 0 12px; text-align: left; }
.story-picker-label {
  display: block; font-size: 0.76rem; font-weight: 700; color: #5C4B3B; margin-bottom: 5px;
}
.story-select {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid #6E5B4B;
  background: #FFFDF7; color: #3A2E25; font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
}
.avatar-picker-wrap { margin: 0 0 12px; text-align: left; }
.avatar-auto-tag {
  background: #E5F0EB; color: #2D5236; border: 1px solid #528265; border-radius: 999px;
  padding: 1px 7px; font-size: 0.66rem; font-weight: 700; margin-left: 6px;
}
.avatar-stage-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.avatar-stage {
  flex: 1; background: radial-gradient(circle at 50% 42%, #FFFDF8 0%, #EFE6D1 100%);
  border: 1.5px solid #8C7A68; border-radius: 10px; padding: 4px 8px 6px;
  display: flex; flex-direction: column; align-items: center;
}
#avatarPreviewCanvas {
  width: 170px; height: 114px; display: block;
}
.avatar-stage-caption {
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.avatar-stage-caption strong { font-family: 'Fraunces', serif; font-size: 0.94rem; color: #2E241C; }
.avatar-stage-caption span { font-size: 0.7rem; color: #6E5B4B; font-weight: 600; }
.avatar-nav-btn {
  width: 30px; height: 96px; flex-shrink: 0; border-radius: 8px;
  background: #FAF6EC; border: 1.5px solid #8C7A68; color: #3A2E25;
  font-size: 0.88rem; font-weight: 800; cursor: pointer;
}
.avatar-nav-btn:hover { background: #EFE7D6; }
.avatar-slider {
  display: flex; gap: 7px; overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; padding: 2px 2px 6px; scrollbar-width: thin;
}
.avatar-pill {
  flex: 0 0 92px; scroll-snap-align: center;
  background: #FFFDF7; border: 1.5px solid #B5A38D; border-radius: 9px;
  padding: 5px 4px; font-family: inherit; color: #3A2E25; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}
.avatar-pill:hover { background: #EFE7D6; transform: translateY(-2px); }
.avatar-pill.active {
  background: #FDF1D6; border: 2px solid #3E6B48;
  box-shadow: 0 3px 10px rgba(58, 46, 37, 0.18); transform: translateY(-2px);
}
.avatar-thumb-img {
  width: 58px; height: 48px; object-fit: contain; display: block;
  border-radius: 6px; background: #F5EEDF;
}
.avatar-pill-name {
  font-size: 0.7rem; font-weight: 800; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 84px;
}
.hero-lvl-badge { cursor: pointer; }
.theme-picker-wrap { margin: 0 0 12px; text-align: left; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.theme-pill {
  background: #FFFDF7; border: 1.5px solid #B5A38D; border-radius: 8px;
  padding: 6px 8px; font-family: inherit; font-size: 0.74rem; font-weight: 700;
  color: #3A2E25; cursor: pointer; text-align: center;
}
.theme-pill:hover { background: #EFE7D6; }
.theme-pill.active { background: #FDF1D6; border-color: #5C4B3B; box-shadow: 0 2px 6px rgba(58,46,37,0.14); }

/* ==================== THEME 2: 🧱 VOXEL 3D (MagicaVoxel / Crossy Road) ==================== */
body[data-theme="voxel"] { background: #CBEAF8; color: #1E293B; }
body[data-theme="voxel"] .paper-overlay { opacity: 0; }
body[data-theme="voxel"] .title-card,
body[data-theme="voxel"] .hero-card,
body[data-theme="voxel"] .nav-banner,
body[data-theme="voxel"] .step-card,
body[data-theme="voxel"] .clip-bar,
body[data-theme="voxel"] .discovery-toast,
body[data-theme="voxel"] .parchment-modal,
body[data-theme="voxel"] .zone-pill,
body[data-theme="voxel"] .dock-slot {
  background: rgba(255, 255, 255, 0.96);
  border: 3px solid #1E293B;
  border-radius: 4px;
  box-shadow: 4px 4px 0 #1E293B;
}
body[data-theme="voxel"] .title-inner { border: 2px dashed #94A3B8; border-radius: 2px; }
body[data-theme="voxel"] .sketch-title { color: #16A34A; text-shadow: 3px 3px 0 #1E293B; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; }
body[data-theme="voxel"] .btn-begin,
body[data-theme="voxel"] .nav-walk-btn,
body[data-theme="voxel"] .clip-btn.primary {
  background: #22C55E; color: #FFFFFF; border: 2px solid #1E293B; border-radius: 4px; box-shadow: 2px 2px 0 #1E293B;
}
body[data-theme="voxel"] .btn-clips {
  background: #0EA5E9; color: #FFFFFF; border: 2px solid #1E293B; border-radius: 4px; box-shadow: 2px 2px 0 #1E293B;
}
body[data-theme="voxel"] .minimap-ring { border: 3px solid #1E293B; border-radius: 8px; box-shadow: 4px 4px 0 #1E293B; }
body[data-theme="voxel"] #minimap { border-radius: 4px; }
body[data-theme="voxel"] .npc-plate {
  background: #FFFFFF; border: 2px solid #1E293B; border-radius: 4px; box-shadow: 2px 2px 0 #1E293B;
}

/* ==================== THEME 3: 🟡 NEWSPRINT (editorial halftone) ==================== */
body[data-theme="newsprint"] { background: #F4F2EA; color: #191919; }
body[data-theme="newsprint"] .paper-overlay {
  background: radial-gradient(rgba(25, 25, 25, 0.06) 1px, transparent 1px);
  background-size: 14px 14px;
}
body[data-theme="newsprint"] .title-card,
body[data-theme="newsprint"] .hero-card,
body[data-theme="newsprint"] .nav-banner,
body[data-theme="newsprint"] .step-card,
body[data-theme="newsprint"] .clip-bar,
body[data-theme="newsprint"] .discovery-toast,
body[data-theme="newsprint"] .parchment-modal,
body[data-theme="newsprint"] .zone-pill,
body[data-theme="newsprint"] .dock-slot {
  background: #FFFFFF;
  border: 2.5px solid #191919;
  border-radius: 0;
  box-shadow: 5px 5px 0 #191919;
}
body[data-theme="newsprint"] .clip-bar,
body[data-theme="newsprint"] .nav-banner {
  border-top: 6px solid #FFF200;
}
body[data-theme="newsprint"] .title-inner { border: 0; border-top: 6px solid #FFF200; border-radius: 0; }
body[data-theme="newsprint"] .sketch-title {
  color: #191919; background: #FFF200; display: inline-block; padding: 2px 14px;
  text-shadow: none; font-weight: 800;
}
body[data-theme="newsprint"] .clip-eyebrow,
body[data-theme="newsprint"] .step-eyebrow,
body[data-theme="newsprint"] .modal-eyebrow {
  background: #FFF200; color: #191919; display: inline-block; padding: 2px 8px; font-weight: 800;
}
body[data-theme="newsprint"] .btn-begin,
body[data-theme="newsprint"] .nav-walk-btn,
body[data-theme="newsprint"] .clip-btn.primary {
  background: #FFF200; color: #191919; border: 2px solid #191919; border-radius: 0; font-weight: 800;
}
body[data-theme="newsprint"] .btn-clips {
  background: #191919; color: #FFF200; border: 2px solid #191919; border-radius: 0; font-weight: 800;
}
body[data-theme="newsprint"] .hatched-bar.red { background: #191919; }
body[data-theme="newsprint"] .hatched-bar.gold { background: #FFF200; }
body[data-theme="newsprint"] .hero-lvl-badge {
  background: #FFF200; border: 2.5px solid #191919; border-radius: 0; color: #191919;
}
body[data-theme="newsprint"] .nav-step-pill.current,
body[data-theme="newsprint"] .clip-dot.active { background: #FFF200; border-color: #191919; color: #191919; }
body[data-theme="newsprint"] .nav-step-pill.done,
body[data-theme="newsprint"] .clip-dot.done { background: #191919; border-color: #191919; color: #FFF200; }
body[data-theme="newsprint"] .npc-plate {
  background: #FFF200; border: 2px solid #191919; border-radius: 0; color: #191919; box-shadow: 3px 3px 0 #191919;
}
body[data-theme="newsprint"] .npc-plate .role { color: #333333; }
body[data-theme="newsprint"] .minimap-ring { border: 2.5px solid #191919; box-shadow: 4px 4px 0 #191919; }

/* Vox-Director Paper-Collage Masking Tape Strips, Torn Edges & Bold Stamps */
body[data-theme="newsprint"] .clip-bar::before,
body[data-theme="newsprint"] .title-card::before,
body[data-theme="newsprint"] .nav-banner::before {
  content: "";
  position: absolute; top: -11px; left: 18px; width: 64px; height: 20px;
  background: rgba(246, 233, 178, 0.84);
  border: 1px solid rgba(25, 25, 25, 0.28);
  transform: rotate(-4deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
body[data-theme="newsprint"] .clip-bar::after,
body[data-theme="newsprint"] .title-card::after {
  content: "";
  position: absolute; top: -10px; right: 20px; width: 58px; height: 19px;
  background: rgba(255, 242, 0, 0.78);
  border: 1px solid rgba(25, 25, 25, 0.3);
  transform: rotate(5deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
body[data-theme="newsprint"] .clip-bar {
  background: linear-gradient(180deg, #FFFDF5 0%, #F7F3E5 100%);
  border-bottom: 4px dashed #191919;
}
body[data-theme="newsprint"] .bar-label { color: #FFFFFF; text-shadow: 0 1px 2px #000000; }
body[data-theme="newsprint"] .xp-wrap .bar-label { color: #191919; text-shadow: none; }

.record-btn.recording {
  background: #DC2626 !important; color: #FFFFFF !important; border-color: #7F1D1D !important;
  animation: recPulse 1s infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* ---------- CHEERING CELEBRATION & CONFETTI ---------- */
.cheer-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 95;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 90px;
  overflow: hidden;
}
.cheer-banner {
  background: #FFF200; color: #191919; border: 3px solid #191919;
  box-shadow: 6px 6px 0 #191919; padding: 12px 26px;
  font-family: 'Fraunces', Georgia, serif; font-size: 1.45rem; font-weight: 800;
  animation: cheerPop 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes cheerPop {
  0% { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.confetti-piece {
  position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 2px;
  pointer-events: none; z-index: 96;
  animation: confettiFall 1.85s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(88vh) rotate(680deg); opacity: 0; }
}

/* ---------- COIN RUSH MINI-GAME HUD ---------- */
.minigame-hud {
  position: fixed; top: 94px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: rgba(246, 241, 229, 0.96); border: 2px solid #5C4B3B; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(58, 46, 37, 0.2); z-index: 26;
}
.mg-pill {
  font-size: 0.84rem; font-weight: 800; color: #2E241C;
  padding: 2px 10px; border-radius: 999px; background: #EFE7D6;
}
.mg-pill.gold { background: #F0C95A; border: 1px solid #5C4B3B; }
.mg-pill.power { background: #E5F0EB; border: 1px solid #3E6B48; color: #2D5236; }
.btn-clips {
  background: repeating-linear-gradient(-45deg, #528265, #528265 5px, #477559 5px, #477559 10px);
  color: #FFFDF7; border: 1.5px solid #3A2E25; border-radius: 8px;
  padding: 10px 18px; font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.btn-clips:hover { filter: brightness(1.06); }

/* ---------- STORY CLIPS CINEMATIC PLAYER BAR ---------- */
.clip-bar {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  width: min(680px, 94vw); background: rgba(246, 241, 229, 0.96);
  border: 1.5px solid #5C4B3B; border-radius: 10px; padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(58, 46, 37, 0.2); z-index: 25;
}
.clip-bar-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px;
}
.clip-eyebrow { font-size: 0.74rem; font-weight: 800; color: #3E6B48; letter-spacing: 0.04em; text-transform: uppercase; }
.clip-progress-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.clip-dot {
  width: 9px; height: 9px; border-radius: 50%; border: 1px solid #6E5B4B;
  background: #EDE4D0; cursor: pointer;
}
.clip-dot.done { background: #528265; }
.clip-dot.active { background: #D9A73E; transform: scale(1.25); }
.clip-text { font-family: 'Fraunces', Georgia, serif; font-size: 1.02rem; line-height: 1.45; color: #2E241C; margin-bottom: 6px; }
.clip-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.clip-pill {
  background: #EFE7D6; border: 1px solid #B5A38D; border-radius: 999px;
  padding: 2px 9px; font-size: 0.72rem; font-weight: 700; color: #5C4B3B;
}
.clip-pill.clue { background: #E5F0EB; border-color: #3E6B48; color: #2D5236; }
.clip-controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.clip-btn {
  background: #FAF6EC; border: 1px solid #8C7A68; border-radius: 6px;
  padding: 6px 11px; font-size: 0.78rem; font-weight: 700; color: #3A2E25; cursor: pointer;
}
.clip-btn:hover { background: #EFE7D6; }
.clip-btn.primary {
  background: #F0C95A; border-color: #5C4B3B;
}
.story-switch-card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid #B5A38D; background: #FFFDF7;
}
.story-switch-card.active { border-color: #3E6B48; background: #E5F0EB; }

/* ---------- TOP-CENTER BOOK NAVIGATION BANNER ---------- */
.nav-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100vw - 470px)); min-width: 260px;
  background: rgba(246, 241, 229, 0.95); border: 1.5px solid #6E5B4B;
  border-radius: 9px; padding: 8px 12px;
  box-shadow: 0 4px 14px rgba(58, 46, 37, 0.14); z-index: 20;
}
.nav-banner-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px;
}
.nav-target-label {
  font-size: 0.8rem; font-weight: 800; color: #2E241C;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-dist-badge {
  background: #FDF1D6; border: 1px solid #B8862B; border-radius: 999px;
  padding: 1px 8px; font-size: 0.72rem; font-weight: 800; color: #7C4A2D; flex-shrink: 0;
}
.nav-guide-btn {
  background: #FAF6EC; border: 1px solid #8C7A68; border-radius: 6px;
  padding: 3px 8px; font-size: 0.72rem; font-weight: 700; color: #3A2E25; cursor: pointer; flex-shrink: 0;
}
.nav-guide-btn:hover { background: #EFE7D6; }
.nav-walk-btn {
  background: #F0C95A; border: 1px solid #5C4B3B; border-radius: 6px;
  padding: 3px 9px; font-size: 0.72rem; font-weight: 800; color: #2E241C; cursor: pointer; flex-shrink: 0;
}
#minimap { cursor: pointer; }
.nav-walk-btn:hover { filter: brightness(1.05); }
.nav-route-row {
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow-x: auto;
}
.nav-step-pill {
  min-width: 22px; height: 22px; border-radius: 999px; border: 1px solid #8C7A68;
  background: #EFE7D6; color: #5C4B3B; font-size: 0.68rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.nav-step-pill.done { background: #528265; border-color: #2D5236; color: #FFFDF7; }
.nav-step-pill.current { background: #F0C95A; border-color: #5C4B3B; color: #2E241C; transform: scale(1.08); }
.nav-step-line { height: 2px; flex: 1; min-width: 8px; background: #C8B9A0; border-radius: 2px; }
.nav-step-line.done { background: #528265; }
@media (max-width: 820px) {
  .nav-banner { top: 96px; width: min(420px, 92vw); }
}

/* ---------- LANDING TITLE OVERLAY (BRUSHWILD STYLE) ---------- */
.title-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(244, 239, 226, 0.28); backdrop-filter: blur(1.5px); z-index: 60; padding: 20px;
}
.title-card {
  background: #F6F1E5; border: 1.5px solid #6E5B4B; border-radius: 10px; padding: 6px;
  max-width: 520px; width: 100%; max-height: 94vh; overflow-y: auto;
  box-shadow: 0 14px 36px rgba(58, 46, 37, 0.16); position: relative;
}
.title-inner {
  border: 1px solid #B5A38D; border-radius: 7px; padding: 16px 20px 16px; text-align: center;
}
.sketch-title {
  font-family: 'Fraunces', Georgia, serif; font-size: 1.95rem; margin: 0 0 4px;
  color: #3E6B48; letter-spacing: -0.02em;
  text-shadow: 1.5px 1.5px 0 #3A2E25;
}
.title-sub { margin: 0 0 6px; font-size: 0.86rem; color: #5C4B3B; font-weight: 600; }
.title-hint { margin: 0 0 10px; font-size: 0.75rem; color: #7C6A58; }
.title-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn-begin {
  background: repeating-linear-gradient(-45deg, #F0C95A, #F0C95A 5px, #E7BC49 5px, #E7BC49 10px);
  color: #2E241C; border: 1.5px solid #5C4B3B; border-radius: 8px;
  padding: 10px 20px; font-weight: 700; font-size: 0.94rem; cursor: pointer;
}
.btn-begin:hover { filter: brightness(1.04); }
.btn-outline {
  background: #F9F5EB; color: #3A2E25; border: 1.5px solid #8C7A68; border-radius: 8px;
  padding: 10px 16px; font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
}
.btn-outline:hover { background: #EFE7D6; }

/* ---------- TOP-LEFT HERO CARD (CLEAN BRUSHWILD PROPORTIONS) ---------- */
.hero-card {
  position: fixed; top: 14px; left: 14px; width: 290px;
  background: rgba(246, 241, 229, 0.96); border: 1.5px solid #6E5B4B;
  border-radius: 9px; padding: 10px 12px; display: flex; align-items: center; gap: 11px;
  box-shadow: 0 4px 14px rgba(58, 46, 37, 0.12); z-index: 22;
}
.hero-lvl-badge {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid #9E4B3C; background: #FAF6EC; color: #3A2E25;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}
.hero-info { flex: 1; min-width: 0; }
.hero-row-top {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; white-space: nowrap;
}
.hero-name { overflow: hidden; text-overflow: ellipsis; }
.hero-gold {
  color: #5C4B3B; font-size: 0.76rem; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.coin-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #F0C95A;
  border: 1.5px solid #8C6414; display: inline-block;
}
.stat-bar-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.stat-bar-row:last-of-type { margin-bottom: 0; }
.hatched-bar-wrap {
  position: relative; flex: 1; height: 12px; border: 1px solid #8C7A68; border-radius: 4px;
  background: #EDE4D0; overflow: hidden;
}
.hatched-bar-wrap.xp-wrap { height: 9px; }
.stat-readout {
  min-width: 48px; text-align: right; font-size: 0.7rem; font-weight: 700;
  color: #3A2E25; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.hatched-bar { height: 100%; transition: width 0.3s ease; }
.hatched-bar.red {
  background: repeating-linear-gradient(-45deg, #C86050, #C86050 4px, #DC7868 4px, #DC7868 8px);
}
.hatched-bar.gold {
  background: repeating-linear-gradient(-45deg, #D9A73E, #D9A73E 4px, #EBC364 4px, #EBC364 8px);
}
.slot-svg { width: 20px; height: 20px; color: #3A2E25; display: block; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2.5px solid #3E6B48; outline-offset: 2px;
}
.zone-map-btn {
  cursor: pointer; font-family: inherit; transition: background 0.14s ease, transform 0.14s ease;
}
.zone-map-btn:hover { background: #FFFDF7; transform: translateY(-1px); }
.book-map-modal { max-width: 820px; width: 94vw; padding: 20px 22px; }
.book-map-sub { margin: -6px 0 10px; font-size: 0.82rem; color: #6E5B4B; font-weight: 600; }
.book-map-canvas-wrap {
  border: 2px solid #6E5B4B; border-radius: 10px; overflow: hidden;
  background: #F4EBD6; box-shadow: inset 0 0 24px rgba(92, 75, 59, 0.14);
}
#bookMapCanvas { width: auto; max-width: 100%; max-height: 56vh; height: auto; display: block; margin: 0 auto; cursor: pointer; }
.nav-route-row { overflow-x: hidden; padding: 2px 0; }

.discovery-toast {
  position: fixed; top: 96px; left: 14px; max-width: 290px;
  background: rgba(246, 241, 229, 0.94); border: 1.5px solid #6E5B4B;
  border-radius: 8px; padding: 8px 12px; font-size: 0.82rem; font-weight: 600;
  color: #3A2E25; box-shadow: 0 4px 10px rgba(58,46,37,0.1); z-index: 20;
}

/* ---------- TOP-RIGHT CIRCULAR COMPASS MINIMAP ---------- */
.minimap-wrap {
  position: fixed; top: 14px; right: 14px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; z-index: 20;
}
.minimap-ring {
  position: relative; width: 142px; height: 142px; border-radius: 50%;
  border: 2px solid #5C4B3B; background: #EFE6D1; padding: 1px;
  box-shadow: 0 4px 14px rgba(58, 46, 37, 0.16); overflow: hidden;
}
#minimap { display: block; border-radius: 50%; width: 100%; height: 100%; }
.compass-n {
  position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  background: #F6F1E5; border: 1px solid #5C4B3B; border-radius: 50%;
  width: 18px; height: 18px; font-size: 0.66rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.zone-pill {
  background: rgba(246, 241, 229, 0.94); border: 1.5px solid #6E5B4B;
  border-radius: 6px; padding: 4px 10px; font-size: 0.78rem; color: #5C4B3B;
}

/* ---------- BOTTOM-CENTER ONBOARDING / INTERACT CARD ---------- */
.step-card {
  position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%);
  background: rgba(246, 241, 229, 0.95); border: 1.5px solid #6E5B4B;
  border-radius: 8px; padding: 10px 14px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 4px 14px rgba(58,46,37,0.14); z-index: 20; max-width: 92vw;
}
.step-eyebrow { font-size: 0.72rem; font-weight: 700; color: #A64B38; margin-bottom: 2px; }
.step-body { font-size: 0.86rem; font-weight: 600; color: #3A2E25; }
.btn-skip {
  background: #FAF6EC; border: 1px solid #8C7A68; border-radius: 6px;
  padding: 6px 12px; font-size: 0.8rem; font-weight: 700; color: #3A2E25; cursor: pointer;
}
.btn-skip:hover { background: #EFE7D6; }

/* ---------- BOTTOM HAND-DRAWN ICON HOTBAR ---------- */
.bottom-dock {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; align-items: center; z-index: 20;
}
.dock-group { display: flex; gap: 6px; }
.dock-slot {
  position: relative; width: 48px; height: 48px; border-radius: 7px;
  background: rgba(246, 241, 229, 0.95); border: 1.5px solid #6E5B4B;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 3px 8px rgba(58,46,37,0.12);
}
.dock-slot:hover { background: #FFFDF7; transform: translateY(-2px); }
.slot-key {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  background: #F6F1E5; border: 1px solid #8C7A68; border-radius: 4px;
  padding: 0 4px; font-size: 0.62rem; font-weight: 700; color: #5C4B3B; white-space: nowrap;
}
.slot-icon { font-size: 1.25rem; }

/* ---------- FLOATING 3D NPC NAMEPLATES ---------- */
.nameplates-layer { position: fixed; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.npc-plate {
  position: absolute; transform: translate(-50%, -100%);
  background: rgba(246, 241, 229, 0.92); border: 1px solid #6E5B4B;
  border-radius: 999px; padding: 3px 10px; font-size: 0.74rem; font-weight: 700;
  color: #3A2E25; white-space: nowrap; box-shadow: 0 2px 6px rgba(58,46,37,0.14);
}
.npc-plate .role { color: #7C6A58; font-weight: 600; }

/* ---------- MODALS ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(44, 36, 28, 0.48); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 70;
}
.parchment-modal {
  background: #F6F1E5; border: 1.5px solid #5C4B3B; border-radius: 12px;
  max-width: 540px; width: 100%; padding: 24px 26px; box-shadow: 0 16px 40px rgba(44,36,28,0.25);
  max-height: 85vh; overflow-y: auto;
}
.modal-eyebrow { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; color: #3E6B48; text-transform: uppercase; }
.parchment-modal h2 { font-family: 'Fraunces', serif; margin: 6px 0 12px; font-size: 1.45rem; }
.dlg-story { font-size: 0.98rem; line-height: 1.6; margin: 0 0 16px; }
.dlg-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.dlg-choice-btn {
  text-align: left; padding: 11px 14px; border-radius: 8px; border: 1.5px solid #6E5B4B;
  background: #FFFDF7; color: #3A2E25; font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.dlg-choice-btn:hover { background: #E5F0EB; }
.dlg-feedback { padding: 10px 12px; border-radius: 8px; background: #FDF1D6; border: 1px solid #B8862B; font-size: 0.88rem; margin-bottom: 14px; }
.dlg-feedback.success { background: #E5F0EB; border-color: #3E6B48; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.satchel-content { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.satchel-card { padding: 10px 12px; border-radius: 8px; border: 1px solid #B5A38D; background: #FFFDF7; font-size: 0.88rem; }
.hidden { display: none !important; }

@media (max-width: 560px) {
  .hero-card { width: 210px; padding: 8px 10px; gap: 8px; }
  .hero-lvl-badge { width: 32px; height: 32px; font-size: 0.95rem; }
  .minimap-ring { width: 92px; height: 92px; }
  .zone-pill { font-size: 0.7rem; padding: 3px 7px; }
  .dock-slot { width: 42px; height: 42px; }
}

/* ---------- HUD layout: no overlaps at any width ----------
   Wide: the route banner sits in the gap between the hero card (left, 14+290px) and the minimap
   (right, 14+142px). Narrow (<=820px): it drops below the hero card, left of a smaller minimap
   column. Phones (<=560px): slimmer pieces, and the toolbar becomes a swipeable row. */
/* Ring hugs the right edge even when the zone label under it is wider than the ring. */
.minimap-wrap { align-items: flex-end; }
.nav-banner {
  left: 318px; right: 170px; margin-inline: auto;
  width: auto; max-width: 460px; min-width: 0; transform: none;
}
@media (max-width: 820px) {
  .minimap-ring { width: 104px; height: 104px; }
  .zone-pill { max-width: 124px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.72rem; }
  .nav-banner { top: 92px; left: 14px; right: 138px; max-width: none; margin: 0; }
}
@media (max-width: 560px) {
  .hero-card { width: auto; max-width: calc(100vw - 14px - 92px - 24px); }
  .minimap-ring { width: 92px; height: 92px; }
  .zone-pill { max-width: 104px; }
  .nav-banner { top: 92px; right: 122px; padding: 6px 9px; }
  .nav-guide-btn { display: none; }
  .bottom-dock {
    left: 8px; right: 8px; transform: none; max-width: none;
    overflow-x: auto; justify-content: flex-start; gap: 10px; padding-bottom: 2px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .bottom-dock::-webkit-scrollbar { display: none; }
  .dock-group { flex-shrink: 0; }
  .dock-slot { width: 40px; height: 40px; flex-shrink: 0; }
}

/* ---------- LOOK CLOSER inspect card + Clue Book ---------- */
.insp-quote {
  margin: 0 0 14px; padding: 12px 16px; border-left: 4px solid #B8862B; background: #FBF5E6;
  border-radius: 0 8px 8px 0; font-family: 'Fraunces', Georgia, serif; font-style: italic; color: #3A2E25;
}
.insp-quote p { margin: 0 0 6px; font-size: 1.02rem; line-height: 1.55; }
.insp-quote cite { display: block; font-style: normal; font-family: inherit; font-size: 0.74rem; color: #7C6A58; letter-spacing: 0.02em; }
.insp-question { font-weight: 800; font-size: 1rem; margin: 0 0 10px; color: #2E241C; }
.dlg-choice-btn:disabled { cursor: default; opacity: 0.75; }
.dlg-choice-btn.correct { background: #E5F0EB; border-color: #3E6B48; opacity: 1; }
.dlg-choice-btn.wrong { background: #F8E3DE; border-color: #A64B38; opacity: 1; }
.clue-row .clue-ico { display: inline-block; width: 1.4em; }
.clue-row .clip-btn { margin-left: 8px; padding: 2px 10px; font-size: 0.75rem; }
.clue-quote { margin-top: 6px; font-family: 'Fraunces', Georgia, serif; font-style: italic; color: #5C4B3B; font-size: 0.85rem; }
.clue-count { font-weight: 800; color: #3E6B48; margin: 0 0 4px; }
@media (max-width: 560px) {
  .parchment-modal { padding: 16px 16px; max-height: 90vh; }
  .insp-quote { padding: 9px 12px; }
  .insp-quote p { font-size: 0.9rem; line-height: 1.45; }
  .insp-question { font-size: 0.94rem; }
  .dlg-choice-btn { padding: 9px 12px; font-size: 0.86rem; }
}

/* ---------- WRITING DESK ---------- */
.writing-modal { max-width: 620px; }
.wr-form { margin: -6px 0 8px; font-weight: 800; color: #A64B38; font-size: 0.85rem; }
.wr-label { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #3E6B48; margin: 4px 0 6px; }
.wr-words { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.wr-word { border: 1.5px solid #B5A38D; background: #FFFDF7; border-radius: 999px; padding: 4px 11px; font-size: 0.8rem; color: #3A2E25; }
.wr-word small { color: #7C6A58; }
.wr-word.used { border-color: #3E6B48; background: #E5F0EB; }
.wr-word.used b::before { content: "✓ "; color: #3E6B48; }
.wr-help { margin: 0 0 10px; font-size: 0.86rem; }
.wr-help summary { cursor: pointer; font-weight: 800; color: #5C4B3B; }
.wr-help ul { margin: 6px 0 8px 18px; padding: 0; }
.wr-starters { display: flex; flex-wrap: wrap; gap: 6px; }
.wr-text {
  width: 100%; box-sizing: border-box; border: 1.5px solid #6E5B4B; border-radius: 10px; padding: 12px 14px;
  font: 1rem/1.6 'Fraunces', Georgia, serif; color: #2E241C;
  /* Ruled lines under each line of text: start at the top padding and scroll with the text. */
  background: #FFFDF7 repeating-linear-gradient(transparent 0 1.52rem, #EFE4D0 1.52rem 1.6rem) 0 12px / 100% 1.6rem local;
  resize: vertical; min-height: 180px;
}
.wr-text:focus { outline: 2px solid #F0C95A; outline-offset: 1px; }
.wr-bar { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; font-size: 0.82rem; font-weight: 800; color: #6E5B4B; }
.wr-bar .btn-outline { padding: 6px 12px; font-size: 0.8rem; }
.wr-checks { list-style: none; padding: 0; margin: 0 0 10px; font-size: 0.86rem; }
.wr-checks li { padding: 2px 0; }
.wr-checks li.todo { color: #8A4A2E; }
@media (max-width: 560px) {
  .wr-word small { display: none; }
  .wr-text { min-height: 150px; font-size: 0.95rem; }
}

/* ---------- CHAPTERS ---------- */
.story-meta { margin: 6px 0 0; font-size: 0.8rem; font-weight: 800; color: #3E6B48; letter-spacing: 0.01em; }
.chapter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 0 6px; font-size: 0.86rem; color: #5C4B3B; }
.chapter-head strong { color: #3E6B48; }
.chapter-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.chapter-row { display: grid; grid-template-columns: 1.6em 1fr 70px; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #B5A38D; border-radius: 8px; background: #FFFDF7; font-size: 0.86rem; }
.chapter-row.active { border-color: #B8862B; background: #FDF6E3; }
.chapter-row.done { border-color: #3E6B48; }
.chapter-row .ch-main { display: flex; flex-direction: column; min-width: 0; }
.chapter-row small { color: #7C6A58; }
.chapter-row .ch-bar { height: 7px; border-radius: 4px; background: #EFE7D6; overflow: hidden; }
.chapter-row .ch-bar i { display: block; height: 100%; background: #528265; }
.chapter-row.todo { opacity: 0.75; }

/* ---------- WHAT WOULD YOU DO? dilemmas ---------- */
.dm-hint { margin: -6px 0 10px; font-size: 0.8rem; font-weight: 700; color: #7C6A58; }
.dm-option { display: flex; gap: 8px; align-items: flex-start; }
.dm-option .dm-val { flex: none; }
.dm-option.picked { border-color: #B8862B; background: #FDF1D6; opacity: 1; }
.dm-after { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.dm-after > div { padding: 10px 12px; border-radius: 8px; border: 1px solid #C8B9A0; background: #FFFDF7; }
.dm-thought { border-color: #B8862B !important; background: #FDF6E3 !important; }
.dm-book { font-family: 'Fraunces', Georgia, serif; }
.dm-label { display: block; font-family: inherit; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: #3E6B48; margin-bottom: 3px; }
.journal-h { margin: 14px 0 4px; font-family: 'Fraunces', serif; }
.choice-row .clip-btn { margin-left: 6px; padding: 2px 10px; font-size: 0.75rem; }

/* ---------- For grown-ups ---------- */
.grownups-link { display: inline-block; margin-top: 6px; font-size: 0.78rem; font-weight: 800; color: #5C4B3B; text-decoration: underline; text-underline-offset: 3px; }
.dock-slot .slot-emoji { font-size: 1.25rem; line-height: 1; }
a.dock-slot { text-decoration: none; }

/* ---------- FAMILY SYNC ---------- */
.family-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; margin-top: 8px; }
.family-btn { background: #FAF6EC; border: 1.5px solid #8C7A68; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 0.78rem; color: #3A2E25; cursor: pointer; }
.playing-as { font-size: 0.78rem; font-weight: 800; color: #3E6B48; }
.family-row .grownups-link { margin-top: 0; }
#famBody { font-size: 0.92rem; }
.fam-points { margin: 6px 0 12px 18px; padding: 0; }
.fam-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.fam-join { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #C8B9A0; }
.fam-join label { font-weight: 800; font-size: 0.85rem; }
.fam-join div, .fam-add-row { display: flex; gap: 8px; margin-top: 6px; }
.fam-join input, .fam-add-row input { flex: 1; min-width: 0; padding: 9px 12px; border: 1.5px solid #6E5B4B; border-radius: 8px; font: 700 1rem 'Nunito', system-ui, sans-serif; background: #FFFDF7; }
.fam-code { font: 800 1.7rem 'Fraunces', Georgia, serif; letter-spacing: 0.08em; text-align: center; padding: 12px; border: 2px dashed #B8862B; border-radius: 10px; background: #FDF6E3; margin: 6px 0 10px; user-select: all; }
.fam-code-inline { letter-spacing: 0.06em; user-select: all; }
.fam-warn { font-size: 0.85rem; color: #7C4A2D; background: #FDF1D6; border: 1px solid #B8862B; border-radius: 8px; padding: 8px 10px; }
.fam-kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.fam-kid { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; border: 1.5px solid #B5A38D; border-radius: 10px; background: #FFFDF7; cursor: pointer; font: inherit; color: #3A2E25; }
.fam-kid.current { border-color: #3E6B48; background: #E5F0EB; }
.fam-kid small { color: #3E6B48; font-weight: 800; font-size: 0.7rem; }
.fam-emoji { font-size: 1.7rem; line-height: 1; }
.fam-add, .fam-more { margin: 8px 0; }
.fam-add summary, .fam-more summary { cursor: pointer; font-weight: 800; color: #5C4B3B; }
.fam-emojis { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.fam-e { font-size: 1.3rem; border: 1.5px solid transparent; border-radius: 8px; background: none; cursor: pointer; padding: 2px 4px; }
.fam-e.on { border-color: #3E6B48; background: #E5F0EB; }
.fam-hint { font-size: 0.78rem; color: #7C6A58; margin: 6px 0 0; }
.fam-msg { min-height: 1.2em; font-size: 0.85rem; font-weight: 700; color: #3E6B48; margin: 6px 0 0; }
.fam-msg.bad { color: #A64B38; }
.btn-outline.danger { color: #A64B38; border-color: #A64B38; }

/* ---------- Safe areas (iPad/iPhone app and home-screen web app) ----------
   The page runs edge to edge (viewport-fit=cover); keep the HUD clear of the status bar and the home
   indicator. In a normal browser tab the insets are 0, so nothing moves. */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
.hero-card { top: calc(14px + var(--sat)); left: calc(14px + var(--sal)); }
.minimap-wrap { top: calc(14px + var(--sat)); right: calc(14px + var(--sar)); }
.nav-banner { top: calc(14px + var(--sat)); }
.discovery-toast { top: calc(96px + var(--sat)); left: calc(14px + var(--sal)); }
.bottom-dock { bottom: calc(14px + var(--sab)); }
.step-card { bottom: calc(78px + var(--sab)); }
.title-overlay { padding-top: calc(20px + var(--sat)); padding-bottom: calc(20px + var(--sab)); }
@media (max-width: 820px) {
  .nav-banner { top: calc(92px + var(--sat)); }
  .discovery-toast { top: calc(166px + var(--sat)); } /* below the route banner */
}
@media (max-width: 560px) {
  .nav-banner { top: calc(92px + var(--sat)); }
  .bottom-dock { left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); }
}

/* Touch screens have no keyboard: hide the shortcut letters on the toolbar. */
@media (pointer: coarse) { .slot-key { display: none; } }
