:root {
  --cream: #fff9ec;
  --cream-soft: rgba(255, 249, 236, 0.92);
  --ink: #2c2235;
  --ink-soft: #5f536b;
  --sage: #5c946e;
  --sage-dark: #427554;
  --coral: #df6b52;
  --gold: #f2b705;
  --mint: #8ef5c8;
  --shadow: 0 4px 0 rgba(44, 34, 53, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: #9bd6eb;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  cursor: grab;
}

#game-canvas:active {
  cursor: grabbing;
}

/* Subtle illustrated storybook paper texture */
.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image: radial-gradient(rgba(44, 34, 53, 0.55) 0.75px, transparent 0.75px);
  background-size: 6px 6px;
  z-index: 2;
}

.hidden {
  display: none !important;
}

.ui-svg, .inline-ico {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.mobile-only { display: none; }
.desktop-only { display: flex; }

/* --- DYNAMIC MESSENGER-STYLE TOUCH JOYSTICK --- */
.dynamic-joystick {
  position: fixed;
  left: 0;
  top: 0;
  width: 112px;
  height: 112px;
  margin-left: -56px;
  margin-top: -56px;
  pointer-events: none;
  z-index: 18;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.dynamic-joystick.active {
  opacity: 1;
}

.dyn-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 249, 236, 0.24);
  border: 2.5px solid rgba(44, 34, 53, 0.45);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.dyn-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin-left: -21px;
  margin-top: -21px;
  border-radius: 50%;
  background: rgba(255, 249, 236, 0.92);
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 rgba(44, 34, 53, 0.2);
}

.dynamic-joystick.sneaking .dyn-ring {
  border-color: rgba(66, 117, 84, 0.7);
  background: rgba(142, 245, 200, 0.22);
}

.dynamic-joystick.sneaking .dyn-knob {
  background: #d7fbe8;
}

/* Hide in-game HUD cleanly during Loading, Title Showcase & Zoom-in Flight */
.game-hud {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

body.phase-playing .game-hud {
  opacity: 1;
  transform: translateY(0);
}

/* --- TOP HUD (Safe-Area Aware!) --- */
.hud-top {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  right: calc(14px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
  min-width: 0;
}

.hud-right {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  flex-shrink: 0;
}

.pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cream-soft);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  font-weight: 800;
  font-size: 13.5px;
  max-width: 100%;
}

.zone-pill {
  font-family: 'Fredoka', sans-serif;
  font-size: 15.5px;
  letter-spacing: 0.15px;
  white-space: nowrap;
}

.pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sage);
  border: 2px solid var(--ink);
  flex-shrink: 0;
}

.compass-pill {
  font-size: 12.5px;
  padding: 6px 12px;
  background: rgba(255, 246, 214, 0.94);
  color: var(--ink);
}

.mission-pill {
  border-radius: 16px;
  padding: 8px 13px;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.14s ease;
  text-align: left;
}

.mission-pill:hover {
  transform: translateY(-2px);
}

.mission-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.mission-icon svg {
  width: 100%;
  height: 100%;
}

.mission-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 126px;
}

.mission-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.mission-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 13.5px;
}

.progress-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #e5dcc9;
  border: 1.5px solid var(--ink);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5c946e, #7bc47f);
  transition: width 0.35s ease;
}

.mission-sub {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 700;
}

.icon-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, background 0.14s ease;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  transform: translateY(-2px);
}

.cam-btn.active {
  background: #d7fbe8;
  border-color: #2c5e43;
}

/* --- BOTTOM LEFT CONTROLS & SNEAK --- */
.hud-bottom-left {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  pointer-events: none;
  z-index: 10;
}

.sneak-pill {
  font-size: 12.5px;
  padding: 6px 12px;
  opacity: 0.68;
  transition: all 0.18s ease;
}

.sneak-pill.active {
  opacity: 1;
  background: #d7fbe8;
  border-color: #2c5e43;
  transform: scale(1.03);
}

.controls-legend {
  flex-wrap: wrap;
  gap: 6px 11px;
  background: rgba(255, 249, 236, 0.84);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  backdrop-filter: blur(4px);
}

kbd {
  display: inline-block;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 1.5px 0 var(--ink);
  margin-right: 3px;
}

/* --- CATCH TOAST --- */
.catch-toast {
  position: fixed;
  top: calc(78px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -12px);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 9px 16px 9px 10px;
  box-shadow: 0 7px 0 rgba(44, 34, 53, 0.16);
  z-index: 22;
  max-width: calc(100vw - 28px);
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.catch-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  padding: 4px;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e1f5e6;
  border: 1.5px solid var(--ink);
  margin-bottom: 2px;
}

.toast-tag.new { background: #ffe380; }
.toast-tag.warn { background: #ffd6d6; }

.toast-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  line-height: 1.15;
}

.toast-sub {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 700;
}

/* --- AUTOMATIC NON-BLOCKING VILLAGER SPEECH BUBBLE --- */
.dialogue-box {
  position: fixed;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 28px));
  background: rgba(255, 249, 236, 0.95);
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  padding: 13px 17px;
  box-shadow: 0 7px 0 rgba(44, 34, 53, 0.16);
  backdrop-filter: blur(6px);
  z-index: 16;
  pointer-events: none;
  animation: bubbleIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.dialogue-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.dialogue-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sage);
  border: 2px solid var(--ink);
  flex-shrink: 0;
}

.dialogue-speaker {
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  color: var(--ink);
}

.dialogue-role {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
  background: #f1e6cf;
  padding: 1px 8px;
  border-radius: 999px;
}

.dialogue-box p {
  font-size: 13.5px;
  line-height: 1.48;
  font-weight: 700;
  color: var(--ink);
}

/* --- BUTTONS --- */
.btn-primary {
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--sage);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 11px 24px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary:hover {
  background: var(--sage-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}

/* --- MESSENGER-STYLE MINIMAL LOADING SCREEN --- */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 42%, #fffdf5 0%, #f7edd8 58%, #e4f2eb 100%);
  transition: opacity 0.65s ease, visibility 0.65s ease;
  padding: 24px;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(350px, 100%);
}

.loading-emblem {
  position: relative;
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.loading-orbit {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2.5px dashed rgba(44, 34, 53, 0.28);
  animation: spinOrbit 11s linear infinite;
}

.loading-planet-icon {
  width: 78px;
  height: 78px;
  animation: gentleFloat 2.6s ease-in-out infinite;
}

.loading-planet-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 5px 0 rgba(44, 34, 53, 0.12));
}

.loading-butterfly {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 28px;
  height: 28px;
  animation: flutterIcon 1.8s ease-in-out infinite;
}

.loading-butterfly svg {
  width: 100%;
  height: 100%;
}

@keyframes spinOrbit { to { transform: rotate(360deg); } }
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}
@keyframes flutterIcon {
  0%, 100% { transform: translate(0, 0) rotate(-8deg) scale(1); }
  50% { transform: translate(4px, -7px) rotate(10deg) scale(1.1); }
}

.loading-kicker {
  font-family: 'Fredoka', sans-serif;
  font-size: 11.5px;
  letter-spacing: 2.6px;
  color: var(--sage-dark);
  background: #dff4df;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 13px;
  margin-bottom: 8px;
}

.loading-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 34px;
  letter-spacing: 0.4px;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 22px;
}

.loading-bar-wrap { width: 100%; }

.loading-bar-track {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: #efe4ce;
  border: 2px solid var(--ink);
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(44, 34, 53, 0.12);
}

.loading-bar-fill {
  height: 100%;
  width: 6%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5c946e, #7bc97f, #ffd166);
  transition: width 0.25s ease-out;
}

.loading-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}

/* --- MESSENGER-STYLE FLOATING TITLE OVERLAY --- */
.title-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(clamp(20px, 4.5vh, 44px) + env(safe-area-inset-top)) 18px calc(clamp(22px, 4.5vh, 40px) + env(safe-area-inset-bottom));
  z-index: 30;
  pointer-events: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.title-overlay.zooming-out {
  opacity: 0;
  transform: scale(1.04);
}

.title-header {
  text-align: center;
  max-width: 540px;
}

.title-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'Fredoka', sans-serif;
  font-size: 12.5px;
  letter-spacing: 2.2px;
  color: var(--ink);
  background: rgba(255, 249, 236, 0.92);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 5px 15px;
  box-shadow: 0 3px 0 rgba(44, 34, 53, 0.16);
  margin-bottom: 10px;
}

.title-logo {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(36px, 7.5vw, 62px);
  font-weight: 700;
  line-height: 1.04;
  color: #fffdf5;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 12px 24px rgba(44, 34, 53, 0.2);
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.title-tagline {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 249, 236, 0.84);
  border: 2px solid rgba(44, 34, 53, 0.22);
  border-radius: 999px;
  padding: 6px 15px;
  backdrop-filter: blur(5px);
  display: inline-block;
}

.title-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  background: var(--sage);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 13px 30px;
  box-shadow: 0 6px 0 var(--ink), 0 12px 22px rgba(44, 34, 53, 0.2);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.btn-play:hover {
  background: var(--sage-dark);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 0 var(--ink), 0 16px 26px rgba(44, 34, 53, 0.24);
}

.btn-play:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.btn-play-arrow {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.btn-play-arrow svg {
  width: 13px;
  height: 13px;
}

.title-mini-hints {
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 14px;
  background: rgba(255, 249, 236, 0.88);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 15px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  box-shadow: 0 3px 0 rgba(44, 34, 53, 0.14);
}

/* --- UNIFIED CONFIG DRAWER (Desktop Right Drawer / Mobile Bottom Sheet — Keeps 3D Shaheen Visible!) --- */
.config-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) 16px;
  background: rgba(44, 34, 53, 0.14);
  pointer-events: none;
}

.config-panel {
  pointer-events: auto;
  width: min(350px, 100%);
  max-height: min(86dvh, 640px);
  background: rgba(255, 249, 236, 0.96);
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 12px 0 rgba(44, 34, 53, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: pan-y;
  animation: cfgSlideIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cfgSlideIn {
  from { opacity: 0; transform: translateX(18px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.config-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: #f3e8d2;
  border-bottom: 2px solid var(--ink);
}

.config-topbar h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  line-height: 1.15;
}

.config-topbar p {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.config-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 14px 4px;
}

.config-tab {
  font-family: 'Fredoka', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: #f2e8d4;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.config-tab.active {
  background: var(--sage);
  color: #fff;
  box-shadow: 0 3px 0 var(--ink);
}

.config-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 15px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.cfg-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cfg-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.swatch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 13px;
  border: 2px solid rgba(44, 34, 53, 0.25);
  background: #fffdf7;
  cursor: pointer;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch-btn.active {
  border-color: var(--ink);
  background: #eef8ef;
  box-shadow: 0 3px 0 var(--ink);
  transform: translateY(-1px);
}

.swatch-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: block;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cfg-chip {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: #fffdf7;
  border: 2px solid rgba(44, 34, 53, 0.3);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cfg-chip.active {
  background: #ffe38a;
  border-color: var(--ink);
  box-shadow: 0 2.5px 0 var(--ink);
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.toggle-row {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffdf7;
  border: 2px solid rgba(44, 34, 53, 0.22);
  border-radius: 13px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-ui {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #dfd5c2;
  border: 2px solid var(--ink);
  position: relative;
  transition: background 0.16s ease;
  flex-shrink: 0;
}

.switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  transition: transform 0.16s ease;
}

.toggle-row input:checked + .switch-ui {
  background: var(--sage);
}

.toggle-row input:checked + .switch-ui::after {
  transform: translateX(18px);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fffdf7;
  border: 2px solid rgba(44, 34, 53, 0.22);
  border-radius: 14px;
  padding: 10px 12px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
}

.slider-head strong {
  color: var(--sage-dark);
  font-size: 12.5px;
}

.cfg-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #e5dcc9;
  border: 1.5px solid var(--ink);
  outline: none;
  cursor: pointer;
}

.cfg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sage);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 rgba(44, 34, 53, 0.25);
  cursor: pointer;
}

.cfg-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sage);
  border: 2px solid var(--ink);
  cursor: pointer;
}

/* --- FIELD GUIDE (BUKU SERANGGA) MODAL --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 34, 53, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  z-index: 40;
}

.guide-book {
  width: min(740px, 100%);
  max-height: min(86dvh, 720px);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 12px 0 rgba(44, 34, 53, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guide-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #f3e8d2;
  border-bottom: 2px solid var(--ink);
}

.guide-topbar h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
}

.guide-topbar p {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--sage-dark);
}

.guide-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-reset {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 13px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff3e6;
  color: var(--ink);
  cursor: pointer;
}

.btn-reset:hover { background: #ffe0cc; }

.guide-grid {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 11px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.guide-card {
  display: flex;
  gap: 11px;
  background: #fffdf7;
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 3px 0 rgba(44, 34, 53, 0.1);
}

.guide-card.locked { background: #f6f1e4; }

.guide-card.pinned {
  border-color: var(--coral);
  box-shadow: 0 3px 0 rgba(223, 107, 82, 0.35);
}

.guide-icon {
  width: 58px;
  height: 58px;
  border-radius: 13px;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  padding: 5px;
  flex-shrink: 0;
}

.guide-icon svg { width: 100%; height: 100%; }

.silhouette {
  width: 100%;
  height: 100%;
  filter: brightness(0) opacity(0.32);
}

.guide-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.guide-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 14.5px;
  line-height: 1.2;
}

.rarity-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  white-space: nowrap;
}

.rarity-common { background: #e2f5e5; }
.rarity-uncommon { background: #d6f3ff; }
.rarity-rare { background: #ffe4ef; }
.rarity-legendary { background: #ffea94; }

.guide-latin {
  font-size: 11.5px;
  font-style: italic;
  color: var(--ink-soft);
}

.guide-habitat {
  font-size: 12px;
  font-weight: 800;
  color: var(--sage-dark);
}

.guide-fact {
  font-size: 11.5px;
  line-height: 1.38;
  color: var(--ink-soft);
  margin-top: 2px;
}

.guide-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.guide-caught {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
}

.btn-track {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #fff5d9;
  color: var(--ink);
  cursor: pointer;
}

.btn-track.active {
  background: var(--coral);
  color: #fff;
}

/* --- VICTORY MODAL --- */
.victory-card {
  width: min(420px, 100%);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 12px 0 rgba(44, 34, 53, 0.22);
}

.victory-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
}

.victory-badge svg { width: 100%; height: 100%; }

.victory-card h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 26px;
  margin-bottom: 10px;
}

.victory-card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 20px;
}

/* --- MOBILE ACTION BUTTONS (bottom-right only; touch anywhere else to steer!) --- */
.touch-actions-wrap {
  display: none;
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 19;
}

.touch-btn {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: var(--cream-soft);
  box-shadow: 0 5px 0 rgba(44, 34, 53, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: 'Fredoka', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink);
  touch-action: none;
  transition: transform 0.1s ease, background 0.12s ease;
}

.touch-btn svg {
  width: 22px;
  height: 22px;
}

.touch-btn:active {
  transform: scale(0.93);
}

.touch-btn.catch {
  background: #ffe08a;
  width: 74px;
  height: 74px;
  font-size: 11.5px;
}

.touch-btn.catch svg {
  width: 28px;
  height: 28px;
}

.touch-btn.sneak.active {
  background: #c7f9de;
  border-color: #2c5e43;
}

/* --- MOBILE & TABLET RESPONSIVE LAYOUT --- */
@media (hover: none) and (pointer: coarse), (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .touch-actions-wrap { display: flex; }
  .hud-bottom-left { display: none; }

  .hud-top {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
    gap: 6px;
  }

  .hud-left {
    flex: 1;
    min-width: 0;
  }

  .hud-right {
    gap: 6px;
  }

  .zone-pill {
    font-size: 13px;
    padding: 6px 10px;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
  }

  .zone-pill #zone-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compass-pill {
    font-size: 11px;
    padding: 4px 9px;
    width: fit-content;
    max-width: 100%;
  }

  .compass-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mission-pill {
    padding: 6px 9px;
    gap: 6px;
  }

  .mission-icon {
    width: 22px;
    height: 22px;
  }

  .mission-meta {
    min-width: 44px;
  }

  .mission-label {
    display: none;
  }

  .mission-row {
    justify-content: center;
    font-size: 12px;
  }

  .mission-sub {
    display: none;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn svg {
    width: 17px;
    height: 17px;
  }

  /* Leave room on right side for Catch button on phones! */
  .dialogue-box {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(104px + env(safe-area-inset-right));
    bottom: calc(18px + env(safe-area-inset-bottom));
    transform: none;
    width: auto;
    padding: 11px 13px;
  }

  @keyframes bubbleIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  .dialogue-box p {
    font-size: 12.5px;
    line-height: 1.42;
  }

  .title-tagline {
    font-size: 12px;
    border-radius: 16px;
  }

  .title-mini-hints {
    font-size: 11px;
    text-align: center;
    border-radius: 16px;
  }

  .guide-grid {
    grid-template-columns: 1fr;
    padding: 11px;
  }

  .guide-topbar h2 {
    font-size: 17px;
  }

  /* Compact Bottom Sheet on Phones — leaves upper 56% open so Shaheen's FULL body (hat to boots) is visible! */
  .config-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    background: transparent;
  }

  .config-panel {
    width: 100%;
    max-height: 44dvh;
    border-radius: 22px;
    animation: cfgSheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .config-topbar {
    padding: 10px 14px;
  }

  .config-topbar h2 {
    font-size: 16.5px;
  }

  .config-topbar p {
    display: none;
  }

  .config-tabs {
    padding: 8px 12px 2px;
  }

  @keyframes cfgSheetUp {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
