: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.22);
  --shadow: 0 10px 28px rgba(15, 25, 10, 0.32), 0 2px 6px rgba(15, 25, 10, 0.2);
  --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: .2em; text-transform: uppercase; }
.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: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------------- top bar */
#topbar {
  top: 10px; left: 10px; right: 10px; height: 58px;
  display: flex; align-items: center; gap: 6px; padding: 0 10px;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; padding-right: 10px; 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: 3px; gap: 2px; }
.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 { width: 38px; height: 38px; transform: rotate(-90deg); }
.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: 6px; align-items: center; }
.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); }
.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: 80px; left: 10px; width: 76px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; z-index: 9;
}
#toolbar button {
  border: 0; background: transparent; border-radius: 10px; padding: 8px 2px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--ink-2);
}
#toolbar button svg { width: 28px; height: 28px; }
#toolbar button:hover { background: var(--paper-2); }
#toolbar button.on { background: var(--moss); color: #fff; }
#toolbar .sep { height: 1px; background: var(--line); margin: 3px 6px; }

#toolpanel {
  top: 80px; left: 94px; width: 318px; max-height: calc(100vh - 100px);
  display: flex; flex-direction: column; z-index: 9; overflow: hidden;
}
.tp-head { padding: 12px 14px 6px; position: relative; }
.tp-collapse { position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper-2); 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: 12px; }
#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: 19px; color: var(--moss-2); }
.tp-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; padding: 6px 12px 4px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--paper-2); border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 12px; overflow-y: auto; }
.tool-card {
  border: 1.5px solid transparent; background: var(--paper-2); border-radius: 10px; padding: 6px 4px 5px;
  display: flex; flex-direction: column; align-items: center; cursor: pointer; text-align: center; min-height: 96px;
}
.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: 11px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.tool-card .cost { font-size: 11px; font-weight: 800; color: var(--moss-2); margin-top: 2px; }
.tool-card.poor .cost { color: var(--bad); }
.tool-desc { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: 12.5px; line-height: 1.4; background: var(--paper-2); }
.tool-desc b { font-size: 13.5px; display: block; margin-bottom: 2px; }
.tool-desc .sci { font-style: italic; color: var(--muted); font-size: 12px; }
.brush { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 700; font-size: 12px; }
.bsz { display: flex; gap: 4px; }
.brush button { width: 30px; height: 26px; 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: 10px; margin-top: 6px; 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: 80px; right: 10px; width: 300px; max-height: calc(100vh - 290px); overflow-y: auto; z-index: 8; padding: 12px 14px 14px; }
#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.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: 4px 8px; font-size: 12.5px; margin-top: 8px; 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: 12px 0 5px; }
.plant-row { display: flex; gap: 8px; align-items: center; padding: 5px 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.45; color: var(--ink-2); margin: 6px 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: 10px; bottom: 188px; padding: 8px 12px; 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: 10px; bottom: 10px; padding: 6px; 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: 78px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; 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: 400px; display: flex; flex-direction: column-reverse; gap: 6px; z-index: 11; pointer-events: none; }
.toast {
  pointer-events: auto; background: rgba(36, 46, 34, 0.93); color: #f4eddb; border-radius: 11px; padding: 9px 12px 9px 12px;
  font-size: 13px; line-height: 1.35; box-shadow: var(--shadow); display: flex; gap: 10px; 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: 12px; padding: 16px 20px 10px; 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: 14px 20px 20px; 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; }
.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: 8px; padding: 12px 20px; 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: 8px; }
.menu-list button { text-align: left; padding: 10px 14px; 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) {
  .brand .title { font-size: 16px; }
  #stat-score > div:last-child, #stat-species .small { display: none; }
  #infopanel { width: 260px; }
}
@media (max-width: 900px) {
  .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; }
}
@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; }
.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; }
@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; }
  #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 { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #toolpanel .tool-grid { gap: 4px; padding: 6px 10px; overflow: visible; flex: none; }
  #toolpanel .tool-desc { flex: none; }
  .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-desc { font-size: 11.5px; padding: 8px 10px; }
  #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; }

  .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: 78px; 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: 8px 12px; 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: 2px 12px 10px; border-top: 1px solid var(--line); }
.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; }
body.campaign #banner { top: 124px; }

.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.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; }
.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: 424px; transform: none; min-width: 0; width: min(400px, calc(100vw - 424px - 320px)); } }
@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; }
}

/* ---------------------------------------------------------------- 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; }
#topbar.tight-2 #stat-weather, #topbar.tight-2 #stat-season, #topbar.tight-2 #stat-date { display: none !important; }
#topbar.tight-3 .stat .small, #topbar.tight-3 #stat-score > div:last-child, #topbar.tight-3 #visitor-stars { display: none !important; }
#topbar.tight-4 #stat-visitors, #topbar.tight-4 .top-actions select { display: none !important; }
#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; }
}
