:root {
  --forest: #102822;
  --deep: #0a1d1a;
  --jade: #1d4136;
  --sage: #b4cbb9;
  --amber: #f2cb79;
  --linen: #fff4d9;
  --rim: #36564a;
  --shadow: 0 18px 60px #06131042;
  background: var(--forest);
}

body {
  background: radial-gradient(ellipse at 36% -4%, #395d49 0, transparent 49%),
    linear-gradient(152deg, #17382f, var(--deep) 68%);
  color: var(--linen);
  min-height: 100vh;
}

.top, main, body > footer { max-width: 1440px; margin-inline: auto; }
.top {
  position: relative;
  background: transparent;
  border-bottom: 1px solid #95b69b36;
  gap: 16px;
  padding-block: 12px;
}
.top .brand { color: var(--linen); white-space: nowrap; }
.top a, .top button { color: var(--linen); }
.top button, .camera-controls button, .bottom-nav button, .bottom-nav a {
  background: #13372ded;
  border: 1px solid #60827285;
  border-radius: 10px;
  color: var(--linen);
}
.top button:hover, .camera-controls button:hover, .bottom-nav button:hover, .bottom-nav a:hover { background: #32584a; }
.top button:focus-visible, .camera-controls button:focus-visible, .bottom-nav :focus-visible { outline-color: #ffe18b; }

main { padding: 17px 32px 10px; }
.intro { margin-bottom: 13px; }
.intro h1 {
  color: var(--linen);
  font: 700 clamp(2.5rem, 5.5vw, 4.35rem)/.99 Georgia, serif;
  margin: 8px 0 6px;
  letter-spacing: -.048em;
  text-shadow: 0 5px 26px #0c231d80;
}
.intro .eyebrow, .hud .eyebrow { color: var(--amber); letter-spacing: .15em; }
.intro p, .player-picker { color: #e2eddd; }
.player-picker select { border-color: #567565; background: #183a2f; color: var(--linen); }
.hud {
  color: var(--linen);
  background: linear-gradient(125deg, #284f3c, #132f28 70%);
  border-color: var(--rim);
  border-radius: 18px;
  padding: 13px 19px;
  margin-bottom: 12px;
}
.hud h2 { font: 700 clamp(1.3rem, 3.5vw, 2.1rem)/1.14 Georgia, serif; }
.hud-values > span { text-align: center; }
.hud-values b { color: #ffe3a4; }
.hud-values small { color: #d0e4d0; }
.welcome { color: var(--ink); }

.bottom-nav {
  position: static;
  width: 100%;
  justify-content: flex-start;
  background: #112e27bd;
  border: 1px solid var(--rim);
  border-radius: 15px;
  padding: 7px;
  margin: 0 0 14px;
  gap: 7px;
  box-shadow: none;
}
.bottom-nav button, .bottom-nav a { min-height: 44px; font-size: .88rem; padding: 8px 13px; }
.bottom-nav button.active { background: var(--amber); border-color: var(--amber); color: #263524; }
.bottom-nav a { margin-left: auto; display: inline-flex; align-items: center; }
.island-layout { grid-template-columns: minmax(0, 1fr) minmax(275px, 335px); gap: 17px; }
.world, .side { border-color: var(--rim); border-radius: 18px; box-shadow: var(--shadow); }
.world { background: #18372e; color: var(--linen); }
.side, .farm-strip, .object-actions, .setup, .parent-info { color: #254537; }
.side, .setup { background: #fbf5e4; }
.side-heading .eyebrow { color: #507051; }
.side-heading h2 { font: 700 clamp(1.45rem, 2.2vw, 1.9rem)/1.13 Georgia, serif; color: #233c2c; }

.island-viewport {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(415px, 59vh, 630px);
  background: #387d79;
}
.island-viewport:focus-within { outline: 3px solid #ffe18b; outline-offset: -4px; }
.island-viewport canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.island-viewport canvas[data-scene] { z-index: 1; pointer-events: none; background: transparent; }
#world { z-index: 2; }
[data-engine="3d"] #world { opacity: 0; }
[data-engine="flat"] canvas[data-scene] { display: none; }
.world-toolbar {
  position: absolute;
  z-index: 4;
  inset: 13px 13px auto;
  gap: 10px;
  padding: 0;
  background: none;
  align-items: flex-start;
  pointer-events: none;
}
.world-toolbar .sanctuary-stage-status { display: flex; align-items: flex-start; flex-direction: column; gap: 5px; }
.sanctuary-stage-status span, .sanctuary-stage-status small, .sanctuary-map-tag {
  display: inline-block;
  background: #0d2d28e6;
  border: 1px solid #b8cdb275;
  border-radius: 20px;
  color: #fff3cf;
  padding: 5px 10px;
  font-size: .77rem;
  font-weight: 700;
}
#sanctuary-phase[data-phase="night"] { background: #222950ed; }
#sanctuary-phase[data-phase="dusk"] { background: #573b44ed; }
.sanctuary-stage-status small { padding: 3px 8px; font-size: .66rem; color: #dbefdd; }
.camera-controls button { pointer-events: auto; width: 44px; min-height: 44px; padding: 0; line-height: 1; }
.sanctuary-map-tag { z-index: 3; position: absolute; left: 15px; bottom: 14px; letter-spacing: .12em; pointer-events: none; }
.island-markers, .island-sparkles { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.island-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  border: 1px solid #fff1b793;
  background: #15352cec;
  color: #fff3c9;
  padding: 4px 8px;
  border-radius: 15px;
  font-weight: 700;
  font-size: .72rem;
  white-space: nowrap;
  box-shadow: 0 3px 8px #0a211e78;
}
.island-marker.glowing { background: #ffe7a2; color: #2f3822; border-color: #fff3c0; }
.island-marker[hidden] { display: none; }
.island-sparkles > span {
  position: absolute;
  color: #ffec9a;
  text-shadow: 0 1px 12px #eeba4a;
  animation: sanctuary-sparkle 850ms ease-out both;
}
@keyframes sanctuary-sparkle {
  0% { opacity: 0; transform: scale(.35) translateY(0); }
  23% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.5) translate(var(--drift), -62px); }
}

.map-help { background: #18372e; color: #dce8d5; gap: 10px; }
.map-help #guide { font-weight: 700; }
.sanctuary-progress { display: flex; align-items: center; gap: 6px 17px; flex-wrap: wrap; padding: 4px 13px; }
.sanctuary-progress a { display: inline-flex; align-items: center; min-height: 44px; color: #ffe4a5; font-size: .85rem; }
#save-status { color: #c9ddcd; }
.farm-strip, .object-actions { background: #f9f2dd; }
.plot-button.ready { background: #ffe8a0; }
#world-host .farm-strip { border-top: 1px solid #9fbcaa49; }
.side .job-card { background: #fffaf0; }
#object-actions { border-color: #c1d0b7; }

.setup { max-width: none; padding: 0; overflow: hidden; border-color: var(--rim); }
.setup:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(325px, .9fr); }
.setup .island-viewport { height: 100%; min-height: 470px; }
.setup .camera-controls, .setup .island-markers { display: none; }
.setup #world { pointer-events: none; }
.setup-content { padding: clamp(16px, 2.5vw, 28px); min-width: 0; }
.setup-illustration { gap: 12px; }
.setup-illustration > img { width: 76px; height: 86px; }
.setup-illustration h2 { font: 700 clamp(1.45rem, 3vw, 2rem)/1.12 Georgia, serif; }
.setup .monkey-choices { max-height: 164px; overflow: auto; padding: 4px; }
.setup .monkey-choice { min-width: 68px; }
.setup .setup-bottom { align-items: stretch; gap: 8px; }
.setup .setup-bottom > button { min-height: 52px; font-size: 1rem; }

.sanctuary-list { display: grid; gap: 10px; }
.sanctuary-card {
  border: 1px solid #d7dec5;
  border-radius: 13px;
  background: #fffcf1;
  padding: 11px 12px;
}
.sanctuary-card-title { display: flex; align-items: center; gap: 9px; }
.sanctuary-card h3 { margin: 0; color: #203f32; font-size: 1.03rem; }
.sanctuary-card small { color: #54745b; font-weight: 700; font-size: .75rem; }
.sanctuary-card p { margin: 7px 0 8px; font-size: .88rem; line-height: 1.4; }
.sanctuary-icon {
  display: grid;
  place-items: center;
  flex: 0 0 39px;
  height: 39px;
  border-radius: 12px;
  background: #e9eed3;
  font-size: 1.2rem;
}
.sanctuary-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.sanctuary-card button { min-height: 44px; padding: 6px 9px; font-size: .82rem; }
.sanctuary-night { background: #f3f0f9; border-color: #d7d0e7; margin-top: 10px; }
.sanctuary-night .sanctuary-icon { background: #e7ddf5; }
.sanctuary-stickers { margin-bottom: 18px; padding: 12px; border: 1px solid #d2dbc5; border-radius: 14px; background: #fff9e8; }
.sanctuary-stickers h3 { margin: 0; }
.sanctuary-stickers .section-heading > span { font-size: .84rem; font-weight: 700; }
.sanctuary-stickers ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.sanctuary-stickers li { min-width: 0; padding: 6px; background: #f8f0dc; border: 1px dashed #c8b994; border-radius: 10px; text-align: center; }
.sanctuary-stickers li.collected { background: #e2edcf; border-style: solid; border-color: #acbd91; }
.sanctuary-stickers li span { display: block; font-size: 1.45rem; }
.sanctuary-stickers li strong, .sanctuary-stickers li small { display: block; font-size: .75rem; overflow-wrap: anywhere; }
.sanctuary-stickers li small { margin-top: 2px; }
#dialog { color: #254537; }
.sanctuary-dialog-art, .sanctuary-question-art {
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  background: radial-gradient(ellipse at top, #e8f2d4, #f8ebca);
  color: #315344;
}
.sanctuary-dialog-art { font-size: 3.5rem; }
.sanctuary-question-art { font-size: clamp(1.2rem, 4.8vw, 2.25rem); white-space: pre-line; margin: 10px 0; }
.sanctuary-reward { font-weight: 700; }
.catalog [data-build] .eco-detail { color: #375947; line-height: 1.32; font-size: .79rem; }
body > footer, body > footer a { color: #cbdac9; }

@media (max-width: 900px) {
  main { padding-inline: 14px; }
  .island-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 285px); }
  .island-viewport { height: clamp(410px, 66vw, 560px); }
}
@media (max-width: 780px) {
  .island-layout, .setup:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  .island-viewport { height: clamp(315px, 105vw, 520px); }
  .setup .island-viewport { height: clamp(250px, 78vw, 410px); min-height: 0; }
  .intro { flex-wrap: wrap; gap: 12px; }
  .top-actions { justify-content: flex-start; }
  .top-actions a { padding: 8px 4px; }
  .hud-values { gap: 8px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-nav button, .bottom-nav a { width: 100%; justify-content: center; white-space: normal; }
  .world-toolbar { inset: 8px 8px auto; }
  .map-help { align-items: flex-start; flex-wrap: wrap; }
  .sanctuary-map-tag { font-size: .59rem; left: 8px; bottom: 7px; }
  .camera-controls button { width: 44px; min-height: 44px; }
}
@media (max-width: 370px) {
  .camera-controls { gap: 3px !important; }
  .sanctuary-stage-status span { font-size: .68rem; }
}
@media print {
  .setup-scene, .island-viewport, .bottom-nav { display: none !important; }
}

.island-viewport[data-phase="night"]::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 24%;
  pointer-events: none;
  background:
    radial-gradient(circle at 9% 43%, #e7e9d6 0 1px, transparent 2px),
    radial-gradient(circle at 16% 18%, #ffedac 0 1px, transparent 2px),
    radial-gradient(circle at 27% 58%, #c1dcf3 0 1px, transparent 2px),
    radial-gradient(circle at 36% 29%, #d4edf6 0 1px, transparent 2px),
    radial-gradient(circle at 43% 12%, #ffffff 0 1px, transparent 2px),
    radial-gradient(circle at 52% 49%, #feefc2 0 1px, transparent 3px),
    radial-gradient(circle at 60% 28%, #e0edff 0 1px, transparent 2px),
    radial-gradient(circle at 69% 50%, #e6edbc 0 1px, transparent 2px),
    radial-gradient(circle at 76% 21%, #e5eff2 0 1px, transparent 2px),
    radial-gradient(circle at 89% 39%, #f6f4cc 0 1px, transparent 3px),
    radial-gradient(circle at 94% 18%, #d9deff 0 1px, transparent 2px),
    linear-gradient(#161a3e73, transparent);
}
