:root {
  --paper: #f4eddb;
  --paper-2: #e9dfc5;
  --paper-3: #dccfae;
  --ink: #2b3a2a;
  --ink-2: #4a5646;
  --muted: #7a7a62;
  --moss: #4f7d3b;
  --moss-2: #3b6230;
  --rust: #b5602f;
  --sky: #3d7fa6;
  --line: rgba(90, 70, 35, 0.15);
  --shadow: 0 8px 24px rgba(15, 25, 10, 0.2), 0 1px 3px rgba(15, 25, 10, 0.12);
  --ui-edge: 18px;
  --ui-top: 100px;
  --inspect-width: 296px;
  --good: #4f8d3b;
  --warn: #c07a2a;
  --bad: #b8483a;
  --display: 'Fraunces', Georgia, serif;
  --ui: 'Nunito', system-ui, sans-serif;
}

/* Loading screen: painted straight from the HTML while three.js and the world load. */
.loading-screen {
  position: fixed; inset: 0; z-index: 100; overflow: hidden; display: grid; place-items: center;
  background: #16291f; color: #f3ecd6; font-family: var(--ui);
  transition: opacity .7s ease, visibility .7s ease;
}
.loading-screen.done { opacity: 0; visibility: hidden; pointer-events: none; }
.ls-sky { position: absolute; inset: 0; background:
  radial-gradient(ellipse 60% 45% at 50% 36%, rgba(242, 196, 90, .22), transparent 70%),
  linear-gradient(#1b3326 0%, #24422f 55%, #1d3a2a 100%); }
.ls-ridges { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46vh; min-height: 240px; }
.ls-ridges .lr-far { fill: #2e5039; animation: ls-drift 26s ease-in-out infinite alternate; }
.ls-ridges .lr-mid { fill: #22412f; animation: ls-drift 20s ease-in-out infinite alternate-reverse; }
.ls-ridges .lr-near { fill: #142a1d; }
.ls-ridges .lr-mist { animation: ls-mist 9s ease-in-out infinite alternate; }
.ls-center { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px; margin-top: -6vh; width: min(92vw, 520px); }
.ls-logo { position: relative; width: clamp(150px, 24vh, 230px); aspect-ratio: 1; }
.ls-halo { position: absolute; inset: -18%; border-radius: 50%; background: radial-gradient(circle, rgba(242, 200, 110, .34), rgba(242, 200, 110, 0) 65%); animation: ls-breathe 4s ease-in-out infinite; }
.ls-emblem { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 14px 22px rgba(4, 16, 10, .45)); }
.ls-emblem .sg-sapling { transform-origin: 100px 126px; animation: ls-grow 1.6s cubic-bezier(.2, .9, .25, 1.15) .15s both; }
.ls-emblem .sg-rays { transform-origin: 100px 96px; animation: ls-spin 60s linear infinite; }
.ls-emblem .sg-rings ellipse { stroke-dasharray: 120; stroke-dashoffset: 120; animation: ls-draw 1.4s ease-out forwards; }
.ls-emblem .sg-rings ellipse:nth-child(2) { animation-delay: .2s; }
.ls-emblem .sg-rings ellipse:nth-child(3) { animation-delay: .4s; }
.ls-title { font: 700 clamp(40px, 6.4vw, 66px)/1 var(--display); letter-spacing: -.01em; margin: 22px 0 8px; color: #f6efd8; text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.ls-tagline { color: #bcd2a8; font-size: clamp(11px, 1.4vw, 13px); font-weight: 800; letter-spacing: .16em; text-transform: uppercase; text-align: center; max-width: 92vw; line-height: 1.5; }
.ls-progress { width: min(100%, 320px); margin-top: clamp(22px, 4.5vh, 40px); }
.ls-track { position: relative; height: 6px; border-radius: 6px; background: rgba(233, 224, 190, .16); overflow: hidden; }
.ls-bar { width: 8%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8fbf6a, #d7e7a2); box-shadow: 0 0 14px rgba(200, 225, 150, .7); transition: width .5s ease; }
.ls-track::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .25), transparent); transform: translateX(-100%); animation: ls-shimmer 1.6s ease-in-out infinite; }
.ls-status { margin-top: 10px; color: #e3dcc2; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; }
.ls-tip { max-width: 400px; min-height: 2.8em; margin: clamp(14px, 3vh, 26px) 0 0; color: #a9bfa0; font-size: 13px; line-height: 1.5; font-style: italic; }
.ls-tip::before { content: 'Field note  '; font-style: normal; font-weight: 800; letter-spacing: .12em; font-size: 10.5px; color: #d2bf86; text-transform: uppercase; margin-right: 6px; }
.ls-retry { margin-top: 16px; border: 0; border-radius: 9px; background: #d7e7a2; color: #1b3326; padding: 10px 20px; font: 800 13px var(--ui); cursor: pointer; }
.ls-retry.hidden { display: none; }
@keyframes ls-grow { 0% { transform: scale(.15, .05); opacity: 0; } 40% { opacity: 1; } 100% { transform: none; } }
@keyframes ls-spin { to { transform: rotate(360deg); } }
@keyframes ls-draw { to { stroke-dashoffset: 0; } }
@keyframes ls-breathe { 50% { transform: scale(1.06); opacity: .75; } }
@keyframes ls-shimmer { to { transform: translateX(100%); } }
@keyframes ls-drift { to { transform: translateX(-28px); } }
@keyframes ls-mist { to { opacity: .35; transform: translateX(40px); } }
@media (max-height: 560px) { .ls-tip { display: none; } .ls-center { margin-top: -10vh; } }
@media (prefers-reduced-motion: reduce) {
  .ls-emblem *, .ls-halo, .ls-ridges *, .ls-track::after { animation: none !important; }
  .ls-emblem .sg-rings ellipse { stroke-dashoffset: 0; }
  .loading-screen, .ls-bar { transition-duration: .01ms; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--ui); color: var(--ink);
  background: radial-gradient(ellipse at 50% 35%, #56715a 0%, #34493a 55%, #1f2c24 100%); }
canvas#view { position: fixed; inset: 0; display: block; cursor: crosshair; }
canvas#fx { position: fixed; inset: 0; pointer-events: none; }
#topbar, #toolbar, #toolpanel, #infopanel, #legend, #minimap-wrap, #banner, #toasts, #cursor-tip { user-select: none; -webkit-user-select: none; }
body.painting #toolpanel, body.painting #infopanel { opacity: 0.25; pointer-events: none; transition: opacity 0.2s; }
body.panels-hidden #toolpanel, body.panels-hidden #infopanel, body.panels-hidden #legend, body.panels-hidden #minimap-wrap { display: none !important; }
button, select { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

.panel {
  position: fixed;
  background: rgba(244, 237, 219, 0.9); /* a little of the land shows through */
  -webkit-backdrop-filter: blur(10px) saturate(1.1); backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------------- top bar */
#topbar {
  top: var(--ui-edge); left: var(--ui-edge); right: var(--ui-edge); height: 64px;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; padding-right: 14px; border-right: 1px solid var(--line); margin-right: 4px; }
.logo { width: 30px; height: 30px; }
.title { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1; color: var(--moss-2); letter-spacing: 0.2px; }
.subtitle { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.title, #stat-season, #stat-date, .stat .label, .stat .small { white-space: nowrap; }
#topbar { overflow: hidden; }
.stat.money, .speed, #stat-score { flex-shrink: 0; }
.top-actions { flex-shrink: 0; }
.stat { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: transparent; border: 0; text-align: left; }
button.stat { cursor: pointer; }
button.stat:hover { background: var(--paper-2); }
.stat.money { font-weight: 800; font-size: 18px; color: var(--moss-2); min-width: 104px; font-variant-numeric: tabular-nums; }
.stat.money.low { color: var(--bad); }
.stat .small, .small { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat .label { font-weight: 800; font-size: 14px; }
#stat-season { font-weight: 800; font-size: 14px; }
.weather { width: 28px; height: 28px; display: inline-grid; place-items: center; }
.weather svg { width: 26px; height: 26px; }
.speed { display: flex; background: var(--paper-2); border-radius: 10px; padding: 4px; gap: 3px; margin-inline: 6px; }
#stat-score { border-left: 1px solid var(--line); border-radius: 0 10px 10px 0; padding-left: 16px; }
.speed button { width: 32px; height: 30px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.speed button svg { width: 15px; height: 15px; fill: var(--ink-2); }
.speed button:hover { background: var(--paper-3); }
.speed button.on { background: var(--moss); }
.speed button.on svg { fill: #fff; }
.ring { position: relative; width: 38px; height: 38px; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); } /* (fills the ring, which is smaller on phones) */
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: var(--paper-3); }
.ring .fill { stroke: var(--moss); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset 0.6s, stroke 0.6s; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.ico { width: 22px; height: 22px; color: var(--ink-2); }
.spacer { flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; border-left: 1px solid var(--line); padding-left: 14px; }
.top-actions select { max-width: 190px; text-overflow: ellipsis; }
.top-actions select, button.ghost {
  height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper-2);
  padding: 0 12px; font-weight: 700; font-size: 13px; cursor: pointer;
}
button.ghost:hover, .top-actions select:hover { background: var(--paper-3); }
button.ghost.on { background: var(--moss); color: #fff; border-color: var(--moss-2); }
.top-actions .icon-btn, #btn-menu { background: transparent; border-color: transparent; }
button:focus-visible, select:focus-visible, .tool-card:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--rust); color: #fff; font-size: 11px; margin-left: 5px; }

/* ---------------- toolbar */
#toolbar {
  top: var(--ui-top); left: var(--ui-edge); width: 68px; padding: 6px;
  display: flex; flex-direction: column; gap: 5px; z-index: 9;
  max-height: calc(100dvh - var(--ui-top) - var(--ui-edge)); overflow-y: auto;
}
#toolbar button {
  border: 0; background: transparent; border-radius: 10px; padding: 9px 1px; cursor: pointer; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; color: var(--ink-2);
}
#toolbar button svg { width: 24px; height: 24px; }
#toolbar button:hover { background: var(--paper-2); }
#toolbar button.on { background: var(--moss); color: #fff; }
#toolbar .sep { height: 1px; flex-shrink: 0; background: var(--line); margin: 4px 8px; }

#toolpanel {
  top: var(--ui-top); left: 100px; width: 296px; max-height: calc(100dvh - var(--ui-top) - var(--ui-edge));
  display: flex; flex-direction: column; z-index: 9; overflow: hidden;
}
.tp-head { padding: 18px 18px 10px; position: relative; flex: none; }
.tp-collapse { position: absolute; right: 14px; top: 14px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 18px; font-weight: 800; line-height: 1; color: var(--ink-2); }
.tp-collapse:hover { background: var(--paper-3); }
#toolpanel.collapsed .tp-head { padding-bottom: 18px; }
#toolpanel.collapsed .tabs, #toolpanel.collapsed .tool-grid, #toolpanel.collapsed .tool-desc { display: none; }
.tp-head h2 { padding-right: 34px; }
.tp-head h2 { margin: 0; font-family: var(--display); font-size: 21px; color: var(--moss-2); }
.tp-head p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.tabs { display: flex; gap: 6px; padding: 2px 18px 12px; flex-wrap: wrap; flex: none; }
.tabs button { border: 1px solid transparent; background: transparent; color: var(--ink-2); border-radius: 20px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.tabs button:hover { background: var(--paper-2); }
.tabs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 2px 18px 16px; overflow-y: auto; min-height: 0; }
.tool-card {
  border: 1.5px solid transparent; background: rgba(233, 223, 197, .45); border-radius: 10px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; cursor: pointer; text-align: center; min-height: 110px;
}
.tool-card:hover { border-color: var(--paper-3); background: #efe5cc; }
.tool-card.on { border-color: var(--moss); background: #e6ecd2; }
.tool-card img { width: 52px; height: 52px; object-fit: contain; image-rendering: auto; }
.tool-card .nm { font-size: 12px; font-weight: 700; line-height: 1.35; margin-top: 6px; }
.tool-card .cost { font-size: 11px; font-weight: 800; color: var(--moss-2); margin-top: 4px; }
.tool-card.poor .cost { color: var(--bad); }
.tool-desc { border-top: 1px solid var(--line); padding: 16px 18px 18px; font-size: 12.5px; line-height: 1.55; background: rgba(233, 223, 197, .35); flex: none; max-height: 45vh; overflow-y: auto; }
.tool-desc b { font-size: 13.5px; display: block; margin-bottom: 6px; }
.tool-desc .sci { font-style: italic; color: var(--muted); font-size: 12px; }
.tool-notes summary { cursor: pointer; color: var(--ink-2); font-size: 12px; padding-block: 4px; }
.tool-notes summary:hover { color: var(--moss-2); }
.tool-notes summary:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; border-radius: 4px; }
.tool-notes-body { padding-top: 8px; }
.tool-notes-body > div + div:not(.prefs) { margin-top: 8px; }
.brush { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 700; font-size: 12px; }
.bsz { display: flex; gap: 4px; }
.brush button { width: 32px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; display: grid; place-items: center; }
.brush button.on { background: var(--ink); color: var(--paper); }
.brush button span { display: block; background: currentColor; border-radius: 50%; }
.prefs { display: flex; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--ink-2); flex-wrap: wrap; }
.prefs span { background: var(--paper); border-radius: 6px; padding: 1px 6px; }

/* ---------------- info panel */
#infopanel { top: var(--ui-top); right: var(--ui-edge); width: 296px; max-height: calc(100dvh - 306px); overflow-y: auto; z-index: 8; padding: 18px; }
#infopanel h3 { margin: 0 0 2px; font-family: var(--display); font-size: 18px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
#infopanel .close { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
#infopanel .minimize { position: absolute; top: 8px; right: 32px; border: 0; background: transparent; font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; color: var(--muted); }
#infopanel h3 { padding-right: 46px; }
#infopanel .animal-hero { padding-right: 40px; }
#infopanel .animal-hero h3 { overflow-wrap: break-word; hyphens: auto; padding-right: 0; }
@media (max-height: 520px) { #infopanel .animal-hero h3 { font-size: 15px; } }
#infopanel.min > *:not(h3):not(.close):not(.minimize):not(.animal-hero) { display: none; }
#infopanel.min .animal-hero img { display: none; }
#infopanel.min { max-height: none; }
.chip { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 7px 12px; font-size: 12.5px; margin-top: 12px; align-items: center; }
.kv .k { color: var(--muted); font-weight: 700; }
.bar { height: 7px; background: var(--paper-3); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--moss); }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 800; color: var(--muted); margin: 18px 0 8px; }
.plant-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.plant-row img { width: 34px; height: 34px; object-fit: contain; }
.plant-row .nm { font-weight: 700; font-size: 12.5px; }
.plant-row .st { font-size: 11.5px; }
.st.good { color: var(--good); } .st.warn { color: var(--warn); } .st.bad { color: var(--bad); }
.info-desc { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); margin: 10px 0; }
.btn { border: 1px solid var(--moss-2); background: var(--moss); color: #fff; font-weight: 700; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; }
.btn.secondary { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; border-color: #8a2e22; }
.btn:hover { filter: brightness(1.06); }
.animal-hero { display: flex; gap: 10px; align-items: center; }
.animal-hero img { width: 64px; height: 56px; object-fit: contain; background: var(--paper-2); border-radius: 10px; }

/* ---------------- legend */
#legend { right: var(--ui-edge); bottom: 202px; padding: 12px 16px; font-size: 12px; z-index: 7; max-width: 300px; }
#legend .row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
#legend .grad { height: 10px; border-radius: 5px; width: 180px; margin: 4px 0; }
#legend .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); width: 180px; }

/* ---------------- minimap */
#minimap-wrap { right: var(--ui-edge); bottom: var(--ui-edge); padding: 8px; z-index: 7; }
#mini-toggle { position: absolute; top: -26px; right: 4px; height: 22px; padding: 0 10px; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: 0; background: var(--paper); font-size: 11px; font-weight: 800; cursor: pointer; color: var(--ink-2); }
#minimap-wrap.collapsed { padding: 0; border: 0; box-shadow: none; background: transparent; }
#minimap-wrap.collapsed canvas { display: none; }
#minimap-wrap.collapsed #mini-toggle { position: static; border-radius: 8px; border: 1px solid var(--line); box-shadow: var(--shadow); }
#banner { top: var(--ui-top); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 12px 16px; z-index: 11; font-size: 13.5px; max-width: calc(100vw - 40px); }
#banner.fire { border-color: #d0602a; background: #fbe8d8; }
#banner.flood { border-color: #4d8fc0; background: #e2eef6; }
#banner .bi { width: 22px; height: 22px; flex: none; }
#banner .btn { padding: 4px 10px; white-space: nowrap; }
.stars { color: #d8a020; letter-spacing: 1px; }
#visitor-stars { color: #b8901a; letter-spacing: 1px; white-space: nowrap; }
#minimap { display: block; width: 200px; height: 150px; border-radius: 8px; cursor: pointer; }

/* ---------------- toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; width: 360px; display: flex; flex-direction: column-reverse; gap: 6px; z-index: 11; pointer-events: none; }
.toast {
  pointer-events: auto; background: rgba(36, 46, 34, 0.8); color: #f4eddb; border-radius: 11px; padding: 7px 11px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: 12.5px; line-height: 1.33; box-shadow: 0 4px 14px rgba(15, 25, 10, 0.25); display: flex; gap: 9px; align-items: flex-start;
  border-left: 4px solid #9ab07a; animation: toastIn 0.3s ease-out; cursor: default;
}
.toast.clickable { cursor: pointer; }
.toast .ti { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.toast.good { border-left-color: #8cc46a; } .toast.warn { border-left-color: #e0a040; }
.toast.discover { border-left-color: #f2c94c; background: rgba(46, 52, 28, 0.95); }
.toast.goal { border-left-color: #f2c94c; background: rgba(70, 58, 22, 0.95); }
.toast.season { border-left-color: #7fb0d0; }
.toast.fire { border-left-color: #ff7a3a; background: rgba(70, 36, 22, 0.95); }
.toast.flood { border-left-color: #6aa8d8; background: rgba(26, 44, 60, 0.95); }
.toast.fade { opacity: 0; transform: translateX(-10px); transition: all 0.5s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#cursor-tip {
  position: fixed; pointer-events: none; z-index: 12; background: rgba(36, 46, 34, 0.92); color: #f4eddb;
  font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 7px; white-space: nowrap;
}
#cursor-tip .bad { color: #ff9b8a; }

/* ---------------- modals */
.modal-back { position: fixed; inset: 0; background: rgba(15, 22, 12, 0.5); z-index: 20; display: grid; place-items: center; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); width: min(980px, calc(100vw - 40px)); max-height: calc(100vh - 60px); display: flex; flex-direction: column; overflow: hidden; }
.modal.narrow { width: min(620px, calc(100vw - 40px)); }
.modal-head { display: flex; align-items: center; gap: 16px; padding: 22px 28px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 24px; color: var(--moss-2); flex: 1; }
.modal-head .x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 22px 28px 28px; overflow-y: auto; }
.guide { display: grid; grid-template-columns: 1fr 320px; gap: 16px; min-height: 0; }
.guide-list { overflow-y: auto; max-height: calc(100vh - 220px); padding-right: 4px; }
.guide-group { font-size: 12px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.gcard { position: relative; background: var(--paper-2); border-radius: 11px; padding: 8px 6px; text-align: center; cursor: pointer; border: 1.5px solid transparent; }
.gcard .locate { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 4px; border-radius: 50%; border: 1px solid var(--moss-2); background: var(--moss); color: #fff; cursor: pointer; display: grid; place-items: center; }
.gcard .locate svg { width: 14px; height: 14px; }
.gcard .locate:hover { filter: brightness(1.1); }
.gcard:hover { border-color: var(--paper-3); }
.gcard.on { border-color: var(--moss); }
.gcard img { width: 76px; height: 60px; object-fit: contain; }
.gcard.unknown img { filter: brightness(0) opacity(0.35); }
.gcard .nm { font-size: 12px; font-weight: 700; line-height: 1.15; }
.gcard .pop { font-size: 11px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.gcard .pop.here { color: var(--good); }
.guide-detail { background: var(--paper-2); border-radius: 14px; padding: 14px; align-self: start; position: sticky; top: 0; }
.guide-detail h3 { margin: 4px 0 0; font-family: var(--display); font-size: 20px; }
.guide-detail .hero { width: 100%; height: 120px; object-fit: contain; background: var(--paper); border-radius: 10px; }
.guide-detail .hero-wrap { background: var(--paper); border-radius: 10px; } /* (so an unknown animal's silhouette darkens only the animal, not its backdrop) */
.need { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; margin: 4px 0; }
.goal { display: flex; gap: 12px; align-items: flex-start; padding: 11px 4px; border-bottom: 1px dashed var(--line); }
.goal .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--paper-3); flex: none; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 13px; }
.goal.done .check { background: var(--moss); border-color: var(--moss); }
.goal .gn { font-weight: 800; font-size: 14.5px; }
.goal .gd { font-size: 12.5px; color: var(--ink-2); margin: 2px 0; }
.goal .gp { font-size: 12px; color: var(--muted); font-weight: 700; }
.goal .gr { margin-left: auto; font-weight: 800; color: var(--moss-2); white-space: nowrap; font-size: 13px; }
.goal.done .gn { color: var(--muted); text-decoration: line-through; }
.report { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.report h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.srow { display: grid; grid-template-columns: 170px 1fr 44px; gap: 8px; align-items: center; font-size: 12.5px; margin: 5px 0; }
.srow .bar i.neg { background: var(--bad); }
.srow .v { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.intro { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.intro h3 { font-family: var(--display); color: var(--moss-2); margin: 14px 0 4px; font-size: 17px; }
.intro ul { margin: 4px 0; padding-left: 20px; }
.intro li { margin: 3px 0; }
.intro kbd { background: var(--paper-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-family: var(--ui); font-size: 12px; font-weight: 700; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line); background: var(--paper-2); }
.journal-row { font-size: 13px; padding: 7px 2px; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.journal-row .d { color: var(--muted); font-weight: 700; font-size: 12px; white-space: nowrap; width: 128px; flex: none; }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-list button { text-align: left; padding: 12px 16px; font-size: 14px; }

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--paper-3); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1380px) {
  .subtitle { display: none; }
  #btn-journal { display: none; }
}
@media (max-width: 1180px) {
  .stat .small:not(#visitor-stars) { display: none; }
  #stat-date { display: block !important; }
  #btn-trees { display: none; }
  .top-actions select { max-width: 150px; }
}
@media (max-width: 980px) {
  :root { --inspect-width: 260px; }
  .brand .title { font-size: 16px; }
  #stat-score > div:last-child, #stat-species .small { display: none; }
  #infopanel { width: 260px; }
}
@media (max-width: 900px) {
  :root { --inspect-width: 240px; }
  .brand > div, #stat-weather { display: none; }
  #stat-date { display: none !important; }
  .brand { padding-right: 6px; }
  .stat.money { min-width: 0; font-size: 16px; }
  .top-actions select { max-width: 120px; padding: 0 6px; }
  #btn-trees, #btn-journal { display: none; }
  #toolpanel { width: 280px; }
  #infopanel { width: 240px; }
  #topbar { gap: 6px; padding-inline: 10px; }
  .top-actions { gap: 6px; padding-left: 8px; }
  .speed { margin-inline: 0; }
  #stat-score { padding-left: 10px; }
  #stat-visitors { display: none; }
  #stat-season { display: none; }
  #stat-date-short { display: block; }
}
@media (max-width: 860px) {
  #visitor-stars, #stat-visitors .ico { display: none; }
  .top-actions select { max-width: 110px; }
}
@media (max-width: 720px) {
  .speed button { width: 26px; }
  #stat-species, #stat-season { display: none; }
  #toasts { width: 300px; }
}

/* settings */
.icon-btn { display: inline-grid; place-items: center; }
.icon-btn svg { display: block; }
.settings .section-title { margin-top: 14px; }
.settings .section-title:first-child { margin-top: 0; }
.audio-credits { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.audio-credits summary { cursor: pointer; color: var(--ink-2); font-size: 12px; font-weight: 700; }
.audio-credits summary:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; border-radius: 3px; }
.audio-credits[open] summary { margin-bottom: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.set-row > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-row small { color: var(--ink-2, #6a6a58); font-size: 12px; }
.set-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--moss); flex: none; }
.set-row select { flex: none; padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper-2); font: inherit; }
.set-slide { display: flex; align-items: center; gap: 8px; flex: none; }
.set-slide input { width: 120px; accent-color: var(--moss); }
.set-slide output { width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* feedback */
.fb-rate { display: flex; gap: 8px; }
.fb-rate button { font-size: 24px; width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--paper-2); cursor: pointer; filter: grayscale(0.6); }
.fb-rate button:hover { filter: none; }
.fb-rate button.on { filter: none; border-color: var(--moss); background: var(--paper-3); }
.feedback textarea, .fb-contact input { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13.5px; background: #fffdf6; color: var(--ink); resize: vertical; }
.fb-contact { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.fb-status { color: var(--bad); margin-top: 8px; min-height: 1em; }
.feedback a { color: var(--moss-2); font-weight: 700; }
@media (max-width: 1180px) { #btn-feedback { padding-left: 8px; padding-right: 8px; } }

/* ---------------------------------------------------------------- phones and tablets */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; overscroll-behavior: none; }
#view { touch-action: none; } /* the game handles every gesture on the map itself */

/* rotate buttons for touch screens (desktop has Q / E) */
#view-ctrls { display: none; right: calc(10px + env(safe-area-inset-right)); bottom: 196px; z-index: 7; padding: 4px; gap: 4px; }
#view-ctrls button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--paper-2); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
#view-ctrls button svg { width: 22px; height: 22px; }
#view-ctrls button:active { background: var(--moss); color: #fff; }
/* touch screens: a thumbstick in the bottom-left corner that moves the map, so one finger on
   the map is always free to paint */
#joystick { display: none; position: fixed; left: calc(74px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 6;
  width: 108px; height: 108px; border-radius: 50%; touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle, rgba(250,244,226,.10) 0 54%, rgba(250,244,226,.30) 55% 100%);
  border: 2px solid rgba(250,244,226,.55); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
#joystick .js-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: var(--paper-2); box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .12s ease-out; pointer-events: none; }
#joystick.on .js-knob { transition: none; background: var(--moss); }
@media (pointer: coarse) { #joystick { display: block; } }
body.panels-hidden #joystick, body.photo-mode #joystick { display: none !important; }
/* (touch: the rotate buttons step left of an open inspect panel instead of hiding under it) */
@media (pointer: coarse) { #infopanel:not(.hidden):not(.min) ~ #view-ctrls { right: calc(320px + env(safe-area-inset-right)); } }
@media (pointer: coarse) and (max-height: 520px) { #infopanel:not(.hidden):not(.min) ~ #view-ctrls { right: calc(264px + env(safe-area-inset-right)); } }
@media (pointer: coarse) {
  #view-ctrls { display: flex; }
  body.mini-collapsed #view-ctrls { bottom: 52px; }
  .tool-card, #toolbar button, .tabs button, .btn, button.ghost { touch-action: manipulation; }
}

/* "turn your phone sideways": portrait phones only */
#rotate-hint { display: none; position: fixed; inset: 0; z-index: 200; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 32px; text-align: center; color: #f3ecd6; font-family: var(--ui);
  background: radial-gradient(ellipse 80% 50% at 50% 38%, rgba(242, 196, 90, .18), transparent 70%), linear-gradient(#1b3326, #16291f); }
#rotate-hint h2 { font: 700 30px/1.1 var(--display); margin: 8px 0 0; color: #f6efd8; }
#rotate-hint p { margin: 0; max-width: 300px; color: #bcd2a8; font-size: 15px; line-height: 1.5; }
.rh-phone { width: 120px; height: 120px; }
.rh-device { transform-origin: 60px 60px; animation: rh-turn 2.6s ease-in-out infinite; }
.rh-arrow { animation: rh-fade 2.6s ease-in-out infinite; }
@keyframes rh-turn { 0%, 25% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
@keyframes rh-fade { 0%, 20% { opacity: 1; } 45%, 90% { opacity: 0; } 100% { opacity: 1; } }
@media (orientation: portrait) and (max-width: 700px) { #rotate-hint { display: flex; } }

/* short landscape screens (phones on their side): tighter bars, panels that fit */
@media (max-height: 520px) {
  #topbar { top: 6px; height: 46px; left: calc(6px + env(safe-area-inset-left)); right: calc(6px + env(safe-area-inset-right)); padding: 0 6px; gap: 4px; border-radius: 12px; }
  .logo { width: 26px; height: 26px; }
  .brand { padding-right: 4px; margin-right: 0; }
  .brand > div, #stat-weather, #stat-season, #stat-date, #btn-journal, #btn-trees, #btn-feedback { display: none !important; }
  .stat.money { font-size: 15px; }
  .speed button { width: 28px; height: 28px; }
  .speed { margin-inline: 0; padding: 3px; gap: 2px; }
  .top-actions { gap: 4px; padding-left: 6px; }
  #stat-score { padding-left: 10px; }
  #stat-score .ring { width: 30px; height: 30px; }
  .stat .small, #visitor-stars, #stat-score > div:last-child { display: none; }
  .top-actions select { max-width: 96px; height: 32px; font-size: 12px; }
  button.ghost { padding: 5px 8px; font-size: 12.5px; }

  #toolbar { top: 58px; left: calc(6px + env(safe-area-inset-left)); width: 54px; padding: 4px; gap: 2px; max-height: calc(100dvh - 64px); overflow-y: auto; }
  #toolbar button { padding: 4px 1px 3px; font-size: 9px; gap: 1px; border-radius: 8px; }
  #toolbar button svg { width: 21px; height: 21px; }
  #toolbar .sep { margin: 1px 4px; }
  #toolpanel { top: 58px; left: calc(66px + env(safe-area-inset-left)); width: 270px; max-height: calc(100dvh - 64px); }
  .tp-head { padding: 8px 12px 4px; }
  .tp-head h2 { font-size: 16px; }
  .tp-head p { display: none; }
  #toolpanel.collapsed .tp-head p { display: block; margin: 2px 0 4px; font-size: 12px; } /* folded: which tool is in hand */
  #toolpanel { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #toolpanel .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 6px 10px; overflow: visible; flex: none; }
  #toolpanel .tool-desc { flex: none; max-height: none; overflow: visible; }
  .tp-collapse { top: 6px; right: 8px; }
  .tabs { padding: 6px 10px; gap: 4px; }
  .tabs button { padding: 4px 8px; }
  .tool-desc .prefs span { font-size: 10.5px; padding: 1px 6px; }
  .tool-card { min-height: 74px; padding: 4px 3px; }
  .tool-card img { width: 38px; height: 38px; }
  .tool-card .nm { font-size: 10.5px; }
  .tool-card .nm, .tool-card .cost { margin-top: 2px; }
  .tool-desc { font-size: 11.5px; padding: 8px 10px; }
  .tool-desc b { margin-bottom: 2px; }
  .brush { gap: 6px; margin-top: 8px; }
  .brush button { width: 30px; height: 26px; }
  .prefs { margin-top: 6px; }
  #infopanel { top: 58px; right: calc(6px + env(safe-area-inset-right)); width: 250px; max-height: calc(100dvh - 150px); padding: 10px 12px; }
  #banner { top: 58px; font-size: 12px; padding: 5px 8px; }
  #toasts { width: min(340px, 44vw); bottom: 6px; }
  .toast { font-size: 12px; padding: 7px 10px; }
  #toasts .toast:nth-child(n+3) { display: none; }
  #legend { bottom: 52px; right: calc(60px + env(safe-area-inset-right)); max-width: 220px; }
  #minimap-wrap { right: calc(6px + env(safe-area-inset-right)); bottom: 6px; }
  #minimap-wrap:not(.collapsed) canvas { width: 180px; height: 135px; }
  #view-ctrls { right: calc(6px + env(safe-area-inset-right)); bottom: 160px; flex-direction: column; }
  body.mini-collapsed #view-ctrls { bottom: 44px; }
  #view-ctrls button { width: 36px; height: 36px; }
  #joystick { left: calc(68px + env(safe-area-inset-left)); bottom: calc(10px + env(safe-area-inset-bottom)); width: 96px; height: 96px; }
  #joystick .js-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }

  .modal { width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)); max-height: calc(100dvh - 12px); border-radius: 14px; }
  .modal-head { padding: 8px 14px; }
  .modal-head h2 { font-size: 18px; }
  .modal-body { padding: 10px 14px 12px; }
  .modal-foot { padding: 8px 14px; }
  .intro { font-size: 13px; }
  .guide { grid-template-columns: 1fr 250px; gap: 10px; }
  .guide-list { max-height: calc(100dvh - 120px); }
  .guide-detail { max-height: calc(100dvh - 120px); overflow-y: auto; padding: 10px; }
  .guide-detail .hero { max-height: 90px; }
  .gcard img { width: 60px; height: 46px; }
}

/* ---------------------------------------------------------------- campaign */
#quest { top: var(--ui-top); left: 50%; transform: translateX(-50%); z-index: 10; padding: 0; width: min(440px, calc(100vw - 460px)); min-width: 300px; overflow: hidden; }
#quest .q-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 12px 16px; cursor: pointer; font: inherit; color: var(--ink); text-align: left; }
#quest .q-head b { font-family: var(--display); font-size: 15px; color: var(--moss-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#quest .q-ch { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
#quest .q-n { font-size: 12px; font-weight: 800; background: var(--moss); color: #fff; border-radius: 10px; padding: 1px 8px; }
#quest .q-caret { color: var(--muted); font-size: 12px; }
#quest .q-body { padding: 6px 16px 14px; border-top: 1px solid var(--line); max-height: min(480px, calc(100dvh - var(--ui-top) - 100px)); overflow-y: auto; }
.q-goal { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 12.5px; line-height: 1.35; }
.q-goal small { display: block; color: var(--muted); font-weight: 700; margin-top: 1px; }
.q-goal.ok > span:last-child { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.q-box { flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 5px; border: 1.5px solid var(--moss); display: grid; place-items: center; font-size: 11px; font-weight: 900; color: #fff; }
.q-goal.ok .q-box { background: var(--moss); }
.q-more { margin-top: 4px; border: 0; background: transparent; color: var(--moss-2); font: 800 12px var(--ui); cursor: pointer; padding: 2px 0; }
.q-tip, .q-help-text { font-size: 12px; line-height: 1.45; margin: 8px 0; }
.q-tip { padding: 8px 10px; background: var(--paper-2); border-left: 3px solid var(--moss); border-radius: 4px; }
.q-help { display: block; border: 0; background: transparent; color: var(--moss-2); font: 800 12px var(--ui); cursor: pointer; padding: 6px 0; text-align: left; }
body.campaign #banner { top: 154px; }

.tool-card { position: relative; }
.tool-card.locked { opacity: .5; filter: grayscale(.85); cursor: help; }
.tool-card.locked .cost { color: var(--muted); }
.tool-card .lock { position: absolute; top: 5px; right: 6px; width: 15px; height: 15px; color: var(--ink-2); }
.tool-card .lock svg { width: 100%; height: 100%; }
#toolbar button.locked { opacity: 0.45; } /* campaign: nothing unlocked here yet */
#toolbar button.fresh { position: relative; }
#toolbar button.fresh::after { content: ''; position: absolute; top: 5px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #e8a33a; box-shadow: 0 0 0 2px var(--paper); animation: fresh-pulse 1.4s ease-in-out infinite; }
@keyframes fresh-pulse { 50% { transform: scale(1.35); opacity: .7; } }

.modes { display: grid; gap: 10px; }
.mode-card { display: flex; flex-direction: column; gap: 4px; text-align: left; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper-2); padding: 14px 16px; cursor: pointer; font: inherit; color: var(--ink); }
.mode-card b { font-family: var(--display); font-size: 18px; color: var(--moss-2); }
.mode-card span { font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.mode-card:hover { border-color: var(--moss); }
.mode-card.danger { border-color: var(--bad); }
.mode-card.danger span { color: var(--bad); font-weight: 700; }
.mode-card:disabled { opacity: 0.5; cursor: not-allowed; border-color: var(--line); }
.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* the world map with a pin on each place */
.world { position: relative; border-radius: 14px; overflow: hidden; background: linear-gradient(#c4d8d6, #b5ccc9); border: 1.5px solid var(--line); margin: 0 0 10px; }
.world svg { display: block; width: 100%; height: auto; }
.wm-land { fill: #efe5c6; stroke: #b3a179; stroke-width: 0.8; stroke-linejoin: round; }
.wm-sea { fill: #bdd2cf; stroke: #b3a179; stroke-width: 0.6; }
.wm-grid { stroke: rgba(255, 255, 255, 0.35); stroke-width: 0.6; fill: none; }
.wm-eq { stroke: rgba(255, 255, 255, 0.6); stroke-width: 0.8; stroke-dasharray: 3 4; fill: none; }
.wm-pin { position: absolute; transform: translate(-50%, -100%); padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink); display: flex; flex-direction: column; align-items: center; }
.wm-pin i { width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--rust); border: 2px solid #fff8e6; box-shadow: 0 2px 5px rgba(20, 30, 10, 0.35); transition: transform 0.15s, background 0.15s; }
.wm-pin i::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: #fff8e6; }
.wm-pin span { position: absolute; display: flex; flex-direction: column; align-items: center; white-space: nowrap; background: rgba(250, 244, 226, 0.92); border-radius: 7px; padding: 1px 6px 2px; box-shadow: 0 1px 3px rgba(20, 30, 10, 0.18); pointer-events: none; }
/* which side of the pin its name sits on (see worldmap.js) */
.wm-pin.wm-s span { left: 50%; top: calc(100% + 5px); transform: translateX(-50%); }
.wm-pin.wm-n span { left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%); }
.wm-pin.wm-n.on em, .wm-pin.wm-n:hover em { display: none; } /* (a name above its pin stays one line, clear of the map's top edge) */
.wm-pin.wm-e span { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); align-items: flex-start; }
.wm-pin.wm-sw span { right: calc(50% - 8px); top: calc(100% + 5px); align-items: flex-end; }
.wm-pin.wm-se span { left: calc(50% - 8px); top: calc(100% + 5px); align-items: flex-start; }
.wm-pin.wm-w span { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); align-items: flex-end; }
/* the region only on the picked pin, or under the pointer */
.wm-pin em { display: none; }
.wm-pin.on em, .wm-pin:hover em, .wm-pin:focus-visible em { display: block; }
.wm-pin.on, .wm-pin:hover, .wm-pin:focus-visible { z-index: 3; }
.wm-pin b { font-family: var(--display); font-size: 12px; color: var(--moss-2); line-height: 1.15; }
.wm-pin em { font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.wm-pin:hover i, .wm-pin:focus-visible i { transform: rotate(-45deg) scale(1.15); }
.wm-pin.on i { background: var(--moss); transform: rotate(-45deg) scale(1.2); }
.wm-pin.on span { box-shadow: 0 0 0 1.5px var(--moss), 0 1px 4px rgba(20, 30, 10, 0.2); }
.wm-pin.on::before { content: ''; position: absolute; left: 50%; bottom: -3px; width: 26px; height: 10px; margin-left: -13px; border-radius: 50%; border: 2px solid var(--moss); opacity: 0.7; animation: wm-ping 1.8s ease-out infinite; }
@keyframes wm-ping { from { transform: scale(0.5); opacity: 0.8; } to { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wm-pin.on::before { animation: none; } }
.wm-cap { margin: -4px 2px 12px; color: var(--ink-2); }
.map-pick .map-card { cursor: default; flex-direction: row; gap: 12px; align-items: flex-start; }
.map-pick .map-card img { width: 42%; flex: none; margin: 0; }
.map-pick .map-card div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
@media (max-width: 520px) {
  .wm-pin span { padding: 1px 4px 2px; }
  .wm-pin b { font-size: 10px; }
  .wm-pin em, .wm-pin:hover em { display: none; }
  .wm-pin i { width: 15px; height: 15px; }
  .map-pick .map-card { flex-direction: column; }
  .map-pick .map-card img { width: 100%; }
}
.map-card { display: flex; flex-direction: column; gap: 3px; text-align: left; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper-2); padding: 12px 14px; cursor: pointer; font: inherit; color: var(--ink); }
.map-card b { font-family: var(--display); font-size: 17px; color: var(--moss-2); }
.map-card .rg { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3, var(--ink-2)); }
.map-card span.bl { font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
.map-card em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--moss); }
.map-card:hover { border-color: var(--moss); }
.map-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: center 30%; border-radius: 9px; margin-bottom: 6px; display: block; background: var(--paper-3, #ddd6bf); }
.intro-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.intro-map { position: relative; padding: 0; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--paper-2); font: inherit; color: var(--ink); text-align: left; }
.intro-map img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: center 30%; display: block; }
.intro-map span { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px 8px; }
.intro-map b { font-family: var(--display); font-size: 15px; color: var(--moss-2); }
.intro-map em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.intro-map:hover { border-color: var(--moss); }
.map-card.on { border-color: var(--moss); box-shadow: inset 0 0 0 1.5px var(--moss); }
.map-resume { margin-top: 10px; width: 100%; }
@media (max-width: 520px) { .maps { grid-template-columns: 1fr; } }
.ch-story { font-size: 14px; line-height: 1.55; color: var(--ink-2); margin: 0 0 6px; }
.ch-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-tool { display: flex; align-items: center; gap: 6px; background: var(--paper-2); border-radius: 10px; padding: 4px 10px 4px 4px; font-size: 12px; font-weight: 700; }
.ch-tool img { width: 30px; height: 30px; object-fit: contain; }
.ch-tool.more { padding: 4px 10px; color: var(--muted); }
.goal.chapter.later { opacity: .55; }
.goal.chapter.now { border-color: var(--moss); }
.ch-goals { margin-top: 4px; }
/* keep the tracker between the tool panel (left) and the info panel (right) on narrower screens */
@media (max-width: 1240px) { #quest { left: 410px; transform: none; min-width: 0; width: min(400px, calc(100vw - 410px - var(--inspect-width) - 36px)); } }
@media (max-width: 1100px) and (min-height: 521px) {
  #quest .q-ch { display: none; }
  #quest .q-head { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  #quest .q-head b { flex-basis: 100%; white-space: normal; }
  #quest .q-caret { margin-left: auto; }
  #quest .q-body { padding-inline: 12px; }
}
@media (max-height: 520px) {
  #quest { top: 58px; left: calc(346px + env(safe-area-inset-left)); transform: none; min-width: 0; width: min(300px, calc(100vw - 346px - 262px)); }
  #quest .q-head { padding: 5px 10px; }
  #quest .q-ch { display: none; }
  body.campaign #banner { top: 96px; }
}
/* There is no room between the side panels on phones; keep campaign help readable. */
@media (max-width: 800px) {
  #quest { left: auto; right: max(12px, env(safe-area-inset-right)); transform: none; width: min(320px, calc(100vw - 24px)); }
}

/* ---------------------------------------------------------------- top bar fitting */
/* the see-through, journal and feedback buttons live in the ☰ menu except on very wide screens */
@media (max-width: 1599px) { #btn-trees, #btn-journal { display: none !important; } }
@media (max-width: 1499px) { #btn-feedback { display: none !important; } }
.top-actions { flex-shrink: 0; }
#stat-money { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* if it still doesn't fit, fold lower-priority pieces away (set from JS) */
#topbar.tight-1 .brand > div { display: none; }
#stat-visitors[hidden] { display: none !important; } /* maps without visitors */
#topbar.tight-2 .stat .small:not(#stat-date), #topbar.tight-2 #stat-score > div:last-child { display: none !important; }
#topbar.tight-3 #stat-visitors, #topbar.tight-3 #stat-weather, #topbar.tight-3 #stat-season, #topbar.tight-3 #stat-date { display: none !important; }
#topbar.tight-3 #stat-date-short { display: block; }
#topbar.tight-4 .top-actions select { display: none !important; }
/* small phones: the species count (it's in the field guide) and then the mute button (it's in Settings) */
#topbar.tight-5 #stat-species { display: none !important; }
#topbar.tight-6 #btn-sound, #topbar.tight-6 #btn-goals .gl { display: none !important; } /* (Goals shrinks to its 3/17 badge) */
#topbar.tight-6 #btn-goals .badge { margin-left: 0; }
#btn-sound .snd-x { display: none; }
#btn-sound.muted .snd-x { display: inline; }
#btn-sound.muted .snd-waves { display: none; }
#btn-sound.muted { color: var(--muted); }

/* ---------------------------------------------------------------- settings */
.settings-modal { width: min(720px, calc(100vw - 40px)); }
.settings-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 18px; min-height: 340px; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; }
.settings-nav button { text-align: left; border: 0; background: transparent; border-radius: 9px; padding: 9px 12px; font: 700 13.5px var(--ui); color: var(--ink-2); cursor: pointer; }
.settings-nav button:hover { background: var(--paper-2); }
.settings-nav button.on { background: var(--moss); color: #fff; }
.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; font: 700 13px var(--ui); color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--moss); color: #fff; }
.diff-desc { margin: 6px 2px 10px; }
@media (max-width: 640px), (max-height: 520px) {
  .settings-wrap { grid-template-columns: 1fr; gap: 8px; min-height: 0; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; }
  .settings-nav button { padding: 6px 10px; font-size: 12.5px; }
}
@media (max-height: 520px) { .intro-map img, .map-card img { aspect-ratio: 21 / 8; } }
@media (max-height: 520px) { .world { max-width: 470px; margin-inline: auto; } .wm-pin em, .wm-pin:hover em, .wm-pin.on em { display: none; } .wm-pin b { font-size: 10.5px; } .map-pick .map-card img { width: 34%; } }
.set-row.now-playing { cursor: default; }
.set-row.now-playing .btn { flex-shrink: 0; padding: 6px 12px; font-size: 12.5px; }

/* photo mode: only the land, a soft vignette and blurred edges, and a small bar to save the picture */
body.photo-mode > *:not(#view):not(#fx):not(#photo-bar):not(#photo-vignette):not(#thennow) { visibility: hidden !important; }
#photo-vignette, #photo-bar { display: none; }
body.photo-mode #photo-vignette { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: radial-gradient(ellipse at center, rgba(20,24,16,0) 55%, rgba(20,24,16,0.42) 100%);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 52%, black 100%); mask-image: radial-gradient(ellipse at center, transparent 52%, black 100%); }
body.photo-mode #photo-bar { display: flex; position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 41;
  align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-radius: 999px; background: rgba(28,38,26,0.72); color: #f3ecd6;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; }
body.photo-mode #photo-bar .btn { padding: 7px 14px; }
@media (max-width: 520px) { body.photo-mode #photo-bar span { display: none; } }
/* compact notifications: at most a few lines each (the full text is in the field journal), and
   the older one steps back */
.toast > span:last-child { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.toast.season > span:last-child { -webkit-line-clamp: 9; } /* (the opening story and the seasons: read in full) */
.toast + .toast { opacity: 0.82; }
/* then and now: two pictures of the same view, wiped between with a slider */
#thennow { position: fixed; inset: 0; z-index: 50; background: rgba(16, 22, 14, 0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
#thennow .tn-stage { position: relative; width: min(100%, calc((100vh - 110px) * 1.6)); aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; touch-action: none; cursor: ew-resize; box-shadow: 0 12px 40px rgba(0,0,0,0.45); }
#thennow img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
#thennow .tn-then { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--x)) 0 0); }
#thennow .tn-handle { position: absolute; top: 0; bottom: 0; left: var(--x); width: 3px; margin-left: -1.5px; background: #fff8e6; box-shadow: 0 0 10px rgba(0,0,0,0.4); }
#thennow .tn-handle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: #fff8e6; color: #2b3a2a; display: grid; place-items: center; font-weight: 800; box-shadow: 0 2px 10px rgba(0,0,0,0.35); }
#thennow .tn-tag { position: absolute; top: 14px; padding: 5px 12px; border-radius: 999px; background: rgba(28,38,26,0.72); color: #f7f0dc; font-weight: 800; font-size: 13px; }
#thennow .tn-l { left: 14px; } #thennow .tn-r { right: 14px; }
#thennow .tn-bar { display: flex; align-items: center; gap: 10px; color: #f3ecd6; font-size: 13px; }
@media (max-height: 520px) { #thennow { gap: 8px; padding: 8px; } #thennow .tn-stage { width: min(100%, calc((100vh - 70px) * 1.6)); } }
/* keystone moments: letterbox bars, the panels step aside, a title card tells the story */
body.moment-on #joystick, body.moment-on #view-ctrls, body.moment-on #toolpanel, body.moment-on #infopanel, body.moment-on #legend, body.moment-on #minimap-wrap, body.moment-on #toolbar, body.moment-on #quest, body.moment-on #toasts, body.moment-on #cursor-tip, body.moment-on #topbar, body.moment-on #banner { opacity: 0; pointer-events: none; transition: opacity 0.6s; }
#moment { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#moment .lb { position: absolute; left: 0; right: 0; height: 0; background: #0e120c; transition: height 1.1s cubic-bezier(.4,0,.2,1); }
#moment .lb-top { top: 0; } #moment .lb-bot { bottom: 0; }
#moment.bars .lb { height: 9vh; }
#moment .mo-card { position: absolute; left: max(24px, 4vw); bottom: calc(9vh + 20px); max-width: min(520px, 86vw); padding: 16px 20px 16px; border-radius: 14px;
  background: rgba(22, 30, 20, 0.78); color: #f4eddb; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(12px); transition: opacity 0.9s, transform 0.9s; pointer-events: auto; }
#moment.card .mo-card { opacity: 1; transform: none; }
#moment .mo-card small { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #c9d8a8; }
#moment .mo-card h2 { font: 700 28px var(--display); margin: 4px 0 6px; color: #fff8e6; }
#moment .mo-beat { font-size: 12px; font-weight: 800; color: #c9d8a8; margin: 0 0 6px; }
#moment .mo-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: #e8e0c8; }
#moment .mo-btns { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-height: 520px) { #moment.bars .lb { height: 6vh; } #moment .mo-card { bottom: calc(6vh + 8px); left: max(14px, env(safe-area-inset-left)); max-width: min(400px, 46vw); max-height: calc(88vh - 24px); overflow-y: auto; padding: 10px 14px; } #moment .mo-card h2 { font-size: 20px; } #moment .mo-card p { font-size: 12.5px; margin-bottom: 8px; } }
/* loading screen on short (phone landscape) screens: keep the horizon low, under the progress bar */
@media (max-height: 520px) { .ls-ridges { height: 30vh; min-height: 0; } }

/* money panel: where the money comes from and where it goes */
#stat-money { cursor: pointer; }
.ledger { display: grid; grid-template-columns: 1fr auto auto; column-gap: 16px; row-gap: 5px; font-size: 13px; align-items: baseline; }
.ledger > span:not(.k) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .k small { display: block; font-size: 11px; color: var(--ink-3, var(--ink-2)); line-height: 1.3; margin-top: 1px; }
.ledger .mh { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3, var(--ink-2)); margin-top: 12px; }
.ledger .mh:first-child { margin-top: 0; }
.ledger .tot { font-weight: 800; border-top: 1px solid var(--line); padding-top: 4px; }
.ledger .neg { color: var(--bad); }
@media (max-height: 520px) { .ledger { font-size: 12px; column-gap: 10px; } .ledger .k small { display: none; } }

/* the date for phones, and the overlay menu as a button where the dropdown doesn't fit */
#stat-date-short { display: none; font-weight: 800; font-size: 12px; white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#btn-overlay { display: none; }
#btn-overlay.on { background: var(--moss); color: #fff; }
#topbar.tight-4 #btn-overlay { display: inline-grid !important; }
@media (max-height: 520px) {
  #stat-date-short { display: block !important; }
  .top-actions select { display: none !important; }
  #btn-overlay { display: inline-grid !important; }
  /* notifications: one at a time, two lines, out of the way (the field journal has them in full) */
  #toasts { width: min(320px, 40vw); }
  #toasts .toast:nth-child(n+2) { display: none; }
  .toast > span:last-child, .toast.season > span:last-child { -webkit-line-clamp: 2; }
  .toast .ti { width: 16px; height: 16px; }
}
/* the Undo button at the foot of the toolbar */
#toolbar button.undo:disabled { opacity: 0.38; cursor: default; }
.toast.open > span:last-child, .toast.season.open > span:last-child { -webkit-line-clamp: unset; display: block; max-height: 50vh; overflow-y: auto; }
.toast:not(.clickable) { cursor: pointer; }
#btn-undo-float { display: none; }
@media (max-height: 520px) {
  #toolbar button.undo, #toolbar .sep:last-of-type { display: none; }
  #btn-undo-float { display: grid; place-items: center; position: fixed; z-index: 7; left: calc(176px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom));
    width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--paper-2); color: var(--ink-2); box-shadow: 0 3px 10px rgba(20, 30, 15, 0.25); }
  #btn-undo-float svg { width: 22px; height: 22px; }
  #btn-undo-float:disabled { opacity: 0.45; }
  #btn-undo-float:active:not(:disabled) { background: var(--moss); color: #fff; }
  body.moment-on #btn-undo-float, body.photo-mode #btn-undo-float { opacity: 0; pointer-events: none; }
}
/* save status: a small tag tucked under the right end of the top bar, outside its row so it never
   pushes the buttons around. "Saved" fades after a moment; a failed save stays. */
#save-status { position: fixed; top: 86px; right: 24px; z-index: 11; pointer-events: none;
  font: 700 11px/1 var(--ui); color: var(--moss-2); background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.12); transition: opacity .4s; }
#save-status:empty, #save-status.faded { opacity: 0; }
#save-status.error { color: #ae443c; }
@media (max-height: 520px) { #save-status { top: 56px; right: calc(10px + env(safe-area-inset-right)); font-size: 10px; padding: 3px 6px; } }

/* Keep notifications in the open map space, clear of the brush and minimap. */
@media (min-width: 800px) and (min-height: 521px) {
  #toasts {
    --toast-left: 100px;
    --toast-right: 244px;
    left: calc((100vw + var(--toast-left) - var(--toast-right)) / 2);
    bottom: var(--ui-edge);
    width: min(360px, calc(100vw - var(--toast-left) - var(--toast-right)));
  }
  body:not(.panels-hidden):has(#toolpanel:not(.hidden):not(.collapsed)) #toasts { --toast-left: 410px; }
}
@media (min-width: 800px) and (max-width: 1100px) and (min-height: 521px) {
  #toasts .toast:nth-child(n+2) { display: none; }
  .toast:not(.open) > span:last-child { -webkit-line-clamp: 3; }
}
