:root {
  --ink: #3a2a1c;
  --muted: #6b5748;
  --cream: #f6efe4;
  --paper: #fffaf3;
  --orange: #f08a3a;
  --orange-deep: #e07228;
  --meadow: #7cb56a;
  --sky: #cfe8f6;
  --panel: rgba(255, 250, 243, 0.9);
  --line: rgba(90, 68, 48, 0.16);
  --seal: #e07228;
  --soft-shadow: 0 12px 28px rgba(58, 72, 48, 0.14);
}

* { box-sizing: border-box; }

body.safari-world {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #eaf6fb 0%, var(--sky) 45%, #b8d9a8 100%);
  color: var(--ink);
  font-family: Nunito, "Trebuchet MS", sans-serif;
}

body.safari-world.is-booting .world-hud,
body.safari-world.is-booting .world-card,
body.safari-world.is-booting .world-hint,
body.safari-world.is-booting .world-pad,
body.safari-world.is-booting .world-modal {
  opacity: 0;
  pointer-events: none;
}

#world {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#world canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* —— Boot: splash + soft load —— */

.world-boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.world-boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.world-splash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  overflow: hidden;
  background: #9ec8e4;
  transition: opacity 0.4s ease, transform 0.45s ease;
}

.world-splash[hidden] {
  display: none;
}

.world-splash.is-leaving {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.world-splash-art {
  position: absolute;
  inset: 0;
}

.world-splash-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  display: block;
  transform: scale(1.02);
  animation: splash-drift 12s ease-in-out infinite alternate;
}

.world-splash-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(180, 214, 236, 0.08) 0%, transparent 34%),
    linear-gradient(0deg, rgba(42, 32, 22, 0.42) 0%, transparent 42%);
  pointer-events: none;
}

.world-splash-copy {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 1.2rem 2.4rem;
  max-width: 28rem;
  animation: splash-rise 0.7s ease both;
}

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

.world-splash-enter {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--paper);
  background: linear-gradient(180deg, #f5a04e 0%, var(--orange-deep) 100%);
  padding: 0.72rem 1.45rem 0.78rem;
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 8px 0 #c45f1c,
    0 14px 24px rgba(70, 40, 12, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.world-splash-enter:hover {
  transform: translateY(-1px);
}

.world-splash-enter:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 3px 0 #c45f1c,
    0 8px 16px rgba(70, 40, 12, 0.22);
}

.world-splash-enter:focus-visible {
  outline: 3px solid #fff6e8;
  outline-offset: 3px;
}

.world-loading {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 1.4rem 1.6rem 1.55rem;
  border-radius: 1.6rem;
  background: var(--panel);
  border: 2px solid rgba(240, 138, 58, 0.28);
  box-shadow: var(--soft-shadow);
  min-width: min(16rem, calc(100vw - 2rem));
  animation: splash-rise 0.45s ease both;
}

.world-loading[hidden] {
  display: none;
}

.world-loading-mascot {
  width: 7rem;
  height: 7rem;
  border-radius: 1.35rem;
  object-fit: cover;
  box-shadow: 0 10px 20px rgba(48, 56, 36, 0.16);
  animation: mascot-bob 1.15s ease-in-out infinite;
}

.world-loading-title {
  margin: 0.35rem 0 0;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 650;
  font-size: 1.2rem;
  color: var(--ink);
}

.world-loading-note {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.world-loading-dots {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.world-loading-dots span {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--orange);
  animation: load-dot 1s ease-in-out infinite;
}

.world-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.world-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes splash-drift {
  from { transform: scale(1.02) translateY(0); }
  to { transform: scale(1.06) translateY(-1.2%); }
}

@keyframes splash-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-8px) scale(1.03, 0.97); }
}

@keyframes load-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* —— In-world chrome —— */

.world-hud,
.world-card,
.world-hint {
  position: fixed;
  z-index: 2;
  transition: opacity 0.4s ease;
}

.world-hud {
  top: 0.85rem;
  left: 0.9rem;
  pointer-events: none;
  max-width: min(20.5rem, calc(100vw - 1.8rem));
}

.world-hud a,
.world-modes,
.world-pad {
  pointer-events: auto;
}

.world-hud-panel {
  padding: 0.8rem 0.95rem 0.9rem;
  border-radius: 1.35rem;
  background: var(--panel);
  border: 2px solid rgba(240, 138, 58, 0.22);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.world-brand {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  align-items: baseline;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.world-brand-commit {
  font-size: 1.28rem;
  color: var(--ink);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 0 #c4a88a;
}

.world-brand-safari {
  font-size: 1.28rem;
  color: var(--orange-deep);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 0 #c45f1c;
}

.world-tagline {
  margin: 0.22rem 0 0.28rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.world-status,
.world-nav {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.world-nav { margin-top: 0.18rem; }

.world-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.72rem;
}

.world-modes button,
.world-pad button {
  appearance: none;
  border: 2px solid #e4d4be;
  background: linear-gradient(180deg, #fffdf8 0%, #f4eadc 100%);
  color: var(--ink);
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.38rem 0.82rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 3px 0 #d7c4a8;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}

.world-modes button:active,
.world-pad button:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 1px 0 #d7c4a8;
}

.world-modes button[aria-checked="true"] {
  background: linear-gradient(180deg, #f5a04e 0%, var(--orange-deep) 100%);
  border-color: #d9782a;
  color: var(--paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 3px 0 #c45f1c;
}

.world-modes button:focus-visible,
.world-pad button:focus-visible,
.world-card-open:focus-visible,
.world-modal-close:focus-visible,
.world-modal-done:focus-visible,
.world-modal a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.world-marks-badge {
  margin: 0.7rem 0 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.62rem 0.24rem;
  border-radius: 0.7rem;
  background: #efe4d2;
  border: 1.5px dashed rgba(105, 84, 58, 0.35);
  color: #5a4636;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.world-marks-badge--splash {
  position: absolute;
  left: 0.9rem;
  bottom: 0.85rem;
  z-index: 2;
  margin: 0;
  background: rgba(246, 239, 228, 0.92);
}

.world-marks-sprout {
  width: 0.72rem;
  height: 0.72rem;
  display: inline-block;
  background:
    radial-gradient(circle at 30% 70%, var(--meadow) 0 42%, transparent 43%),
    radial-gradient(circle at 70% 70%, #6aa85a 0 38%, transparent 39%),
    linear-gradient(180deg, transparent 45%, #6a8f4e 45% 100%);
  border-radius: 50% 50% 40% 40%;
}

.world-pad {
  position: fixed;
  z-index: 2;
  left: 0.9rem;
  bottom: 0.85rem;
  display: none;
  gap: 0.35rem;
  transition: opacity 0.4s ease;
}

body[data-camera="wander"] .world-pad {
  display: flex;
}

@media (hover: hover) and (pointer: fine) {
  .world-pad { display: none !important; }
}

.world-hud a,
.world-modal a {
  color: var(--orange-deep);
  font-weight: 700;
  text-decoration: none;
}

.world-hud a:hover,
.world-modal a:hover {
  text-decoration: underline;
}

.world-card {
  top: 0.85rem;
  right: 0.9rem;
  width: min(17rem, calc(100vw - 1.8rem));
  background: var(--panel);
  border: 2px solid rgba(240, 138, 58, 0.24);
  border-radius: 1.35rem;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
  padding: 0.9rem 1rem 1rem;
}

.world-card[hidden] { display: none; }

.world-card[data-pinned="true"] {
  border-color: rgba(224, 114, 40, 0.55);
  box-shadow: 0 14px 34px rgba(180, 90, 30, 0.18);
}

.world-card-flag {
  margin: 0 0 0.35rem;
  display: inline-block;
  padding: 0.14rem 0.58rem;
  border-radius: 999px;
  background: rgba(240, 138, 58, 0.14);
  color: var(--orange-deep);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.world-card-flag[hidden] { display: none; }

.world-card-mark {
  display: flex;
  justify-content: center;
}

.world-card-mark svg {
  width: 96px;
  height: 96px;
}

.world-card-title {
  margin: 0.4rem 0 0.2rem;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.28rem;
  font-weight: 650;
  line-height: 1.15;
  color: var(--ink);
}

.world-card-meta {
  margin: 0 0 0.55rem;
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--muted);
}

.world-card-open {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  border: 0;
  cursor: pointer;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--paper);
  background: linear-gradient(180deg, #f5a04e 0%, var(--orange-deep) 100%);
  padding: 0.42rem 0.9rem 0.48rem;
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 3px 0 #c45f1c;
}

.world-card-open:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 1px 0 #c45f1c;
}

.world-card-open[hidden] { display: none; }

/* —— Specimen detail modal (stay in park) —— */

.world-modal {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 1rem;
}

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

.world-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 34, 26, 0.38);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.world-modal-sheet {
  position: relative;
  z-index: 1;
  width: min(24rem, calc(100vw - 1.6rem));
  max-height: min(34rem, calc(100vh - 2rem));
  overflow: auto;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 1.55rem;
  background: var(--panel);
  border: 2px solid rgba(240, 138, 58, 0.28);
  box-shadow: 0 18px 42px rgba(48, 40, 28, 0.28);
  animation: splash-rise 0.28s ease both;
}

.world-modal-close {
  appearance: none;
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  width: 2.1rem;
  height: 2.1rem;
  border: 2px solid #e4d4be;
  border-radius: 999px;
  background: linear-gradient(180deg, #fffdf8 0%, #f4eadc 100%);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 #d7c4a8;
}

.world-modal-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange-deep);
}

.world-modal-mark {
  display: flex;
  justify-content: center;
  margin: 0.2rem 0 0.35rem;
}

.world-modal-mark svg {
  width: 112px;
  height: 112px;
}

.world-modal-title {
  margin: 0;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  padding-right: 2rem;
}

.world-modal-meta {
  margin: 0.35rem 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.world-modal-facts {
  margin: 0;
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 0.35rem 0.65rem;
  font-size: 0.86rem;
}

.world-modal-facts dt {
  margin: 0;
  font-weight: 800;
  color: var(--muted);
}

.world-modal-facts dd {
  margin: 0;
  font-weight: 650;
  color: var(--ink);
  word-break: break-word;
}

.world-modal-facts code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 600;
}

.world-modal-sightings {
  margin-top: 0.9rem;
}

.world-modal-sightings h3 {
  margin: 0 0 0.4rem;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.world-modal-sightings ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.world-modal-sightings li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.7rem;
  background: rgba(240, 138, 58, 0.08);
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink);
}

.world-modal-sightings li span:last-child {
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

.world-modal-done {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 1rem;
  border: 0;
  cursor: pointer;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--paper);
  background: linear-gradient(180deg, #f5a04e 0%, var(--orange-deep) 100%);
  padding: 0.62rem 1rem 0.68rem;
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 4px 0 #c45f1c;
}

.world-modal-done:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 1px 0 #c45f1c;
}

body.safari-world.is-detail .world-hud,
body.safari-world.is-detail .world-card,
body.safari-world.is-detail .world-hint,
body.safari-world.is-detail .world-pad {
  opacity: 0.35;
  pointer-events: none;
}

.world-hint {
  left: 0.9rem;
  bottom: 0.85rem;
  margin: 0;
  padding: 0.42rem 0.82rem;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid rgba(240, 138, 58, 0.18);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(48, 56, 36, 0.1);
}

.world-hint[hidden] { display: none; }

@media (max-width: 720px) {
  .world-card {
    top: auto;
    right: 0.6rem;
    left: 0.6rem;
    bottom: 0.6rem;
    width: auto;
  }

  .world-modal {
    padding: 0.6rem;
    align-items: end;
  }

  .world-modal-sheet {
    width: 100%;
    max-height: min(78vh, calc(100vh - 1.2rem));
    border-radius: 1.35rem 1.35rem 1.1rem 1.1rem;
  }

  .world-modal-facts {
    grid-template-columns: 6.2rem 1fr;
  }

  .world-hud {
    max-width: min(18.5rem, calc(100vw - 1.4rem));
  }

  .world-brand-commit,
  .world-brand-safari {
    font-size: 1.12rem;
  }

  .world-hint { display: none; }

  body[data-camera="wander"] .world-pad {
    top: 10.2rem;
    bottom: auto;
  }

  .world-splash-copy {
    padding-bottom: 3.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .world-splash-art img,
  .world-loading-mascot,
  .world-loading-dots span,
  .world-splash-copy,
  .world-loading,
  .world-modal-sheet {
    animation: none !important;
  }

  .world-boot,
  .world-splash {
    transition: none;
  }
}
