:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f4fff8;
  background: #07110f;
  --bar: #0b1d19;
  --line: #44e4a4;
  --muted: #a9c8bc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-width: 0; min-height: 100%; margin: 0; }
body { min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 50% -15%, #194b3d, #07110f 48%); }
button, a { font: inherit; }
button, .world-home { min-height: 44px; }
button:focus-visible, a:focus-visible, iframe:focus-visible { outline: 3px solid #fff16a; outline-offset: 2px; }
.skip-link { position: fixed; z-index: 20; top: 4px; left: 8px; transform: translateY(-150%); padding: 8px 12px; color: #07110f; background: #fff16a; }
.skip-link:focus { transform: none; }
.world-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bar) 96%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--line) 45%, transparent);
  box-shadow: 0 3px 18px #0008;
}
.world-home { display: inline-flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; white-space: nowrap; }
.world-home > span { display: grid; place-items: center; min-width: 34px; min-height: 34px; padding: 3px; border: 2px solid var(--line); border-radius: 10px; color: var(--line); }
.world-context { min-width: 0; margin: 0; text-align: center; }
.world-context strong, .world-context span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-context span { color: var(--muted); font-size: .78rem; }
.world-context .world-growth-chip { color: #fff16a; font-weight: 850; }
.world-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.world-actions button, .world-actions a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; color: #f4fff8; background: #123128; border: 1px solid #397962; border-radius: 9px; cursor: pointer; text-decoration: none; }
.world-view { min-width: 0; padding: clamp(16px, 4vw, 42px) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.world-intro { max-width: 52rem; margin: 0 auto 22px; }
.world-intro h1 { margin: 4px 0; font-size: clamp(1.7rem, 5vw, 3.2rem); }
.world-intro p { color: var(--muted); }
.world-adult-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.world-adult-links a { min-height: 44px; display: inline-flex; align-items: center; color: #fff16a; font-weight: 750; }
.world-guide { max-width: 80rem; margin: 0 auto 18px; padding: 14px; background: #0b1d18; border: 1px solid #397962; border-radius: 16px; }
.world-guide summary { min-height: 44px; display: flex; align-items: center; color: #fff16a; font-size: 1rem; font-weight: 850; cursor: pointer; }
.world-guide summary::before { content: "▸"; margin-right: 8px; transition: transform 160ms ease; }
.world-guide[open] summary::before { transform: rotate(90deg); }
.world-guide ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.world-guide li { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; gap: 2px 8px; padding: 10px; background: #10251f; border-radius: 11px; }
.world-guide li > span { grid-row: 1 / span 2; font-size: 1.5rem; }
.world-guide strong, .world-guide small { display: block; }
.world-guide small { margin-top: 2px; color: var(--muted); line-height: 1.35; }
.eyebrow { color: #76f9bb !important; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.discovery-invitation { max-width: 80rem; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin: 0 auto 16px; padding: 14px 16px; color: #f4fff8; background: linear-gradient(105deg, #17382d, #312c15); border: 2px solid #fff16a; border-radius: 16px; box-shadow: 0 0 24px #fff16a24; }
.discovery-invitation__icon { font-size: 2.35rem; }
.discovery-invitation h2, .discovery-invitation p { margin: 0; }
.discovery-invitation h2 { font-size: 1.05rem; }
.discovery-invitation p { margin-top: 3px; color: #d5e9df; line-height: 1.35; }
.discovery-invitation button, .discovery-later { padding: 9px 13px; color: #07110f; background: #fff16a; border: 0; border-radius: 10px; font-weight: 850; cursor: pointer; }
.discovery-meadow { max-width: 80rem; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; margin: 0 auto 16px; padding: 16px; background: linear-gradient(120deg, #102d24, #1a3820); border: 2px solid #397962; border-radius: 16px; }
.discovery-meadow h2, .discovery-meadow p { margin: 0; }
.discovery-meadow h2 { margin-top: 2px; font-size: 1.15rem; color: #fff16a; }
.discovery-meadow p:not(.eyebrow) { margin-top: 4px; color: var(--muted); }
.discovery-meadow__preview { display: flex; min-width: 70px; justify-content: center; gap: 2px; font-size: 1.65rem; }
.discovery-meadow > button, .discovery-item button { min-height: 44px; padding: 9px 13px; color: #07110f; background: #76f9bb; border: 0; border-radius: 10px; font-weight: 850; cursor: pointer; }
.discovery-meadow > button:disabled { opacity: .65; cursor: default; }
.habitat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 12px; max-width: 80rem; margin: auto; }
.habitat-card { position: relative; min-width: 0; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 96px; padding: 10px; color: #f4fff8; text-decoration: none; background: #10251f; border: 2px solid #275c4b; border-radius: 14px; overflow: clip; }
.habitat-card:hover { border-color: var(--line); box-shadow: 0 0 18px #44e4a433; }
.habitat-card img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; }
.habitat-card span { min-width: 0; }
.habitat-card strong, .habitat-card small, .habitat-label, .habitat-learning { display: block; }
.habitat-learning { margin-top: 4px; color: #fff16a; font-size: .76rem; font-weight: 850; }
.habitat-label { margin-top: 3px; color: #76f9bb; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.habitat-card small { margin-top: 4px; color: var(--muted); line-height: 1.25; }
.habitat-progress { display: flex !important; align-items: center; gap: 5px; width: fit-content; max-width: 100%; margin-top: 7px; padding: 4px 7px; color: #b7ccbf; background: #07110f99; border: 1px solid #397962; border-radius: 999px; font-size: .75rem; font-weight: 800; line-height: 1.25; }
.habitat-progress__icon { flex: 0 0 auto; font-size: .95rem; }
.habitat-card[data-reward-state="growing"] { background: linear-gradient(110deg, #10251f, #17382d); border-color: #397962; }
.habitat-card[data-reward-state="growing"] .habitat-progress { color: #fff16a; border-color: #76f9bb; box-shadow: 0 0 12px #44e4a426; }
.habitat-card--grew { border-color: #fff16a; box-shadow: 0 0 0 3px #fff16a33, 0 0 28px #44e4a455; }
.habitat-return-growth { display: flex !important; align-items: center; gap: 7px; width: fit-content; max-width: 100%; margin-top: 8px; padding: 6px 9px; color: #07110f; background: #fff16a; border-radius: 10px; font-size: .75rem; line-height: 1.25; }
.habitat-return-growth > span { flex: 0 0 auto; }
.habitat-return-growth strong { display: inline; }
.play-route { height: 100vh; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.game-viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #020706; padding-bottom: env(safe-area-inset-bottom); }
.game-viewport iframe { display: block; width: 100%; height: 100%; border: 0; background: #07090e; }
.route-message { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; }
.world-dialog { width: min(92vw, 440px); max-height: min(80vh, 560px); overflow: auto; padding: 22px; color: #f4fff8; background: #10251f; border: 2px solid var(--line); border-radius: 16px; }
.world-dialog::backdrop { background: #000b; }
.world-dialog h2 { margin-top: 0; }
.dialog-close { float: right; width: 44px; padding: 0; color: #fff; background: #1b4034; border: 1px solid #397962; border-radius: 50%; font-size: 1.5rem; }
.discovery-choices { clear: both; display: grid; gap: 10px; margin: 16px 0; }
.discovery-choice { min-height: 72px; display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px 12px; color: #f4fff8; text-align: left; background: #17382d; border: 2px solid #397962; border-radius: 13px; cursor: pointer; }
.discovery-choice:hover { border-color: #fff16a; }
.discovery-choice:disabled { opacity: .62; cursor: wait; }
.discovery-choice__icon { font-size: 2rem; text-align: center; }
.discovery-choice strong, .discovery-choice small { display: block; }
.discovery-choice small { margin-top: 3px; color: var(--muted); text-transform: capitalize; }
.discovery-choice-status { min-height: 1.5em; color: #fff16a; font-weight: 750; }
.discovery-later { width: 100%; color: #f4fff8; background: #1b4034; border: 1px solid #397962; }
.discovery-welcome { clear: both; text-align: center; }
.discovery-welcome > span { display: block; margin: 8px 0; font-size: 4rem; line-height: 1; }
.discovery-welcome h2 { color: #fff16a; }
.discovery-quick-fact { padding: 10px; text-align: left; background: #07110f; border-left: 4px solid #76f9bb; border-radius: 8px; }
.discovery-collection { clear: both; display: grid; gap: 12px; margin-top: 16px; }
.discovery-item { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; padding: 12px; background: #17382d; border: 1px solid #397962; border-radius: 13px; }
.discovery-item__icon { grid-row: 1 / span 2; align-self: start; font-size: 2rem; text-align: center; }
.discovery-item h3, .discovery-item p { margin: 0; }
.discovery-item p { margin-top: 3px; color: var(--muted); }
.discovery-item__controls { grid-column: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.discovery-item select { min-height: 44px; min-width: 0; padding: 8px; color: #f4fff8; background: #07110f; border: 1px solid #76f9bb; border-radius: 9px; }
.discovery-item button:disabled { opacity: .6; cursor: default; }
.recovery-code { padding: 12px; text-align: center; font-size: 1.35rem; font-weight: 800; letter-spacing: .08em; background: #07110f; border-radius: 10px; user-select: all; }
.learning-recovery { padding: 4px 14px 8px; border-left: 5px solid var(--line); border-radius: 10px; background: #07110f; }
.learning-recovery--working { border-left-color: #fff16a; }
.learning-recovery--waiting { border-left-color: #ffbf69; }
.learning-recovery p { color: var(--muted); line-height: 1.5; }
.world-growth-total { margin: 4px 0; color: #fff16a; font-size: clamp(1.8rem, 7vw, 2.8rem); font-weight: 900; }
[data-offline-status] { position: fixed; z-index: 18; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); margin: 0; padding: 8px 12px; color: #07110f; background: #fff16a; border-radius: 10px; font-weight: 800; box-shadow: 0 5px 18px #0008; }
@media (max-width: 760px), (min-resolution: 1.5dppx) and (max-width: 1100px) {
  .world-bar { grid-template-columns: auto minmax(0, 1fr); }
  .world-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .world-actions button, .world-actions a { min-width: 0; padding: 3px 4px; font-size: .78rem; line-height: 1.1; }
  .discovery-invitation { grid-template-columns: auto minmax(0, 1fr); }
  .discovery-invitation button { grid-column: 1 / -1; width: 100%; }
  .discovery-meadow { grid-template-columns: minmax(0, 1fr) auto; }
  .discovery-meadow > button { grid-column: 1 / -1; width: 100%; }
  .world-guide ol { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .world-view { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .habitat-card { grid-template-columns: 60px minmax(0, 1fr); gap: 10px; }
  .habitat-card img { width: 60px; height: 60px; }
  .habitat-card > b { grid-column: 2; justify-self: start; }
  .habitat-return-growth { white-space: normal; }
  .world-dialog { width: calc(100vw - 20px); padding: 16px; }
}
@media (max-width: 320px) {
  .world-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .habitat-grid { grid-template-columns: minmax(0, 1fr); }
  .discovery-item__controls { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 430px) and (min-width: 761px) {
  .world-bar { grid-template-columns: auto minmax(0, 1fr) auto; padding-top: max(3px, env(safe-area-inset-top)); padding-bottom: 3px; }
  .world-actions { grid-column: auto; flex-wrap: nowrap; }
  .world-actions button, .world-actions a { padding: 3px 7px; }
  .world-context span { display: none; }
  .world-context .world-growth-chip { display: block; }
}
body.play-route[data-focus-mode="true"] {
  position: relative;
  display: block;
}
body.play-route[data-focus-mode="true"] .game-viewport {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin-left: 0;
}
body.play-route[data-focus-mode="true"] .world-bar {
  position: fixed;
  z-index: 16;
  top: max(6px, env(safe-area-inset-top));
  left: max(6px, env(safe-area-inset-left));
  right: auto;
  width: 48px;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 4px;
  padding: 4px;
  border: 2px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bar) 92%, transparent);
  box-shadow: 0 3px 18px #000a;
}
body.play-route[data-focus-mode="true"] .world-home {
  width: 44px;
  min-width: 44px;
  justify-content: center;
}
body.play-route[data-focus-mode="true"] .world-home b,
body.play-route[data-focus-mode="true"] .world-context,
body.play-route[data-focus-mode="true"] .world-actions > :not([data-focus]):not([data-fullscreen][aria-pressed="true"]) {
  display: none;
}
body.play-route[data-focus-mode="true"] .world-actions {
  display: block;
}
body.play-route[data-focus-mode="true"] .world-actions [data-focus],
body.play-route[data-focus-mode="true"] .world-actions [data-fullscreen][aria-pressed="true"] {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  font-size: .72rem;
}
/* Reward motion is decorative and never carries state. Keep unrelated interface
   motion out of this policy; low-motion users receive the same static reward. */
@media (prefers-reduced-motion: no-preference) {
  .habitat-card[data-reward-moment="return"] { animation: habitat-welcome 700ms ease-out both; }
  .habitat-card[data-reward-moment="return"] .habitat-return-growth { animation: reward-badge-arrive 520ms 120ms cubic-bezier(.2,.8,.2,1) both; }
  .habitat-card[data-reward-moment="return"] .habitat-return-growth > span { animation: reward-icon-sprout 620ms 180ms cubic-bezier(.2,.9,.2,1.25) both; }
  .discovery-welcome[data-reward-moment="discovery"] { animation: discovery-welcome-arrive 420ms ease-out both; }
  .discovery-welcome[data-reward-moment="discovery"] > span { animation: reward-icon-sprout 680ms 80ms cubic-bezier(.2,.9,.2,1.25) both; }
}
@keyframes habitat-welcome { from { transform: translateY(5px); filter: brightness(.82); } to { transform: none; filter: none; } }
@keyframes reward-badge-arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes reward-icon-sprout { from { opacity: 0; transform: scale(.72) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes discovery-welcome-arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
