:root {
  color-scheme: dark;
  --bg: #17231d; --card: #1d2a22; --line: #364739; --text: #f3eedf; --muted: #aab5a1;
  --life: #c3e480; --amber: #edc98c; --pink: #ef83b6;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: radial-gradient(ellipse at 28% -10%, #35432a, transparent 62%), var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; user-select: none; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, canvas:focus-visible, .menu-btn:focus-visible { outline: 2px solid #eef8bc; outline-offset: 2px; }
kbd, .stat strong, button { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
#app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }

.topbar { display: flex; align-items: center; gap: 18px; padding: 8px 16px; border-bottom: 1px solid #b0b99a26; background: #17231d9c; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; font-size: 26px; line-height: 1; letter-spacing: -1.5px; color: #f3eedf; }
.brand-period { color: var(--life); }
.brand-icon, .shop-emblem { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: #33462d; border: 1px solid #546647; flex: none; }
.brand-icon.big { width: 56px; height: 56px; margin: 0 auto 10px; }
.brand-icon.big .pixel-icon { width: 36px; height: 36px; }
.pixel-icon { display: block; width: 24px; height: 24px; image-rendering: pixelated; }
.nav { display: flex; gap: 8px; margin-left: auto; }
.utility { display: grid; place-items: center; width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 7px; background: #233126; font: 700 15px var(--mono); }
.utility:hover, .utility[aria-pressed="true"] { color: var(--life); background: #354830; }
.utility[aria-pressed="false"] { color: #7d8676; text-decoration: line-through; }

.hud { flex: 1; display: grid; grid-template-columns: 1.1fr .9fr 1.4fr; max-width: 760px; margin-left: 12px; background: #202f25; border: 1px solid var(--line); border-radius: 10px; min-height: 58px; align-items: center; }
.stat { display: flex; align-items: center; gap: 10px; padding: 4px 14px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.label, .eyebrow { margin: 0; font: 700 10px/1.35 var(--mono); letter-spacing: .12em; color: #b1bb9f; }
.stat .label { display: block; font-size: 9px; white-space: nowrap; }
.stat strong { display: block; font: 700 20px/1.05 var(--mono); margin-top: 2px; white-space: nowrap; }
.stat:first-child strong { color: var(--life); }
.sub { display: block; font: 600 10px var(--mono); color: var(--muted); white-space: nowrap; }
.hud-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; background: #31412e; border-radius: 7px; }
.progress-stat { display: block; }
.progress-top { display: flex; justify-content: space-between; align-items: center; }
.progress-top strong { margin: 0; font-size: 13px; color: var(--life); }
.bar { position: relative; height: 7px; margin: 6px 0 3px; background: #122118; border-radius: 3px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #8dc163, #c3e480); border-radius: 3px; transition: width .3s; }
.bar b { position: absolute; top: 0; bottom: 0; left: 70%; width: 2px; background: #edc98c; }
.bar.wide { width: 280px; margin: 14px auto 8px; }

.layout { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; padding: 12px 16px 14px; }
.world-panel, .workshop { border: 1px solid var(--line); border-radius: 13px; background: var(--card); box-shadow: 0 14px 36px #0b150e45; }
.world-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.map { position: relative; flex: 1; min-height: 0; background: #2b261b; overflow: hidden; isolation: isolate; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; image-rendering: pixelated; touch-action: none; outline-offset: -3px; }
.map-label, .map-guide, .toast, .chip { position: absolute; pointer-events: none; font-family: var(--mono); }
.map-label { top: 12px; left: 12px; padding: 6px 9px; border: 1px solid #fff0be56; border-radius: 5px; background: #554332d9; color: #fff1cf; font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.map-label > span:first-child, .save-status i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; background: var(--life); border-radius: 50%; vertical-align: 1px; }
.map-separator { margin: 0 3px; opacity: .55; }
#minimap { position: absolute; right: 10px; bottom: 10px; width: 180px; height: 124px; border: 1px solid #fff0be66; border-radius: 6px; background: #3a3022; image-rendering: pixelated; cursor: pointer; box-shadow: 0 4px 18px #0006; }
.map-guide { bottom: 14px; left: 50%; transform: translateX(-50%); padding: 7px 11px; color: #fff1d2; background: #342f23e8; border: 1px solid #ffe9bb47; border-radius: 6px; font-size: 11px; text-align: center; max-width: calc(100% - 420px); min-width: 260px; transition: opacity .4s; }
.map-guide:empty { opacity: 0; }
.toast { right: 10px; top: 11px; max-width: min(300px, 56%); font-size: 11px; background: #263e2c; color: #eaf4c7; padding: 8px 11px; border: 1px solid #b8db77; border-radius: 6px; opacity: 0; transform: translateY(-6px); transition: .18s; }
.toast.show { opacity: 1; transform: none; }
.chip { top: 44px; left: 12px; padding: 4px 8px; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: #22331e; background: var(--life); border-radius: 4px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 4px; }
.zoom button { width: 30px; height: 30px; border: 1px solid #ffebbf6e; border-radius: 6px; background: #26372ce0; color: #f7edcf; font: 700 16px var(--mono); }
.zoom button:hover { background: #3a5232; }
.zoom button[aria-pressed="true"] { color: var(--life); border-color: var(--life); }
.toast.show + .stage-banner {}
.stage-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; padding: 14px 22px; background: #203b28f2; color: #ebf8c7; border: 1px solid #c5e487; border-radius: 8px; font: 700 14px var(--mono); box-shadow: 0 5px 28px #28382199; opacity: 0; pointer-events: none; }
.stage-banner small { display: block; font-size: 11px; color: var(--amber); margin-top: 4px; }
.stage-banner.announce { animation: stage-reveal 3.6s both; }
@keyframes stage-reveal { 0%, 100% { opacity: 0; transform: translate(-50%, -40%); } 12%, 84% { opacity: 1; transform: translate(-50%, -50%); } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; background: #202f25; }
.action { display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0; min-height: 50px; border-radius: 7px; border: 1px solid #536847; padding: 6px 10px; touch-action: none; position: relative; overflow: hidden; }
.action.restore { background: #c5e487; color: #22331e; border-color: #dcf5a8; }
.action.restore.cooling { background: #9fbd66; }
.action.plant { background: #334831; color: #e8f2cd; }
.action.plant.poor { opacity: .6; }
.action:hover { filter: brightness(1.08); }
.action:active { transform: translateY(1px); }
.action strong, .action small { display: block; line-height: 1.15; }
.action strong { font-size: 13px; }
.action small { font-size: 10px; opacity: .85; margin-top: 3px; }
.cooldown { margin-left: auto; font: 700 10px var(--mono); opacity: .8; }
kbd { border: 1px solid #b6c3a04a; background: #e8efd612; border-radius: 4px; padding: 2px 5px; font: 700 9px var(--mono); }
.action kbd { margin-left: 6px; }
.action.plant kbd { margin-left: auto; }
.restore kbd { border-color: #31402748; background: #31402714; }

.workshop-column { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 10px; min-height: 0; }
.workshop { padding: 13px; display: flex; flex-direction: column; min-height: 0; }
.shop-head { display: flex; align-items: center; gap: 11px; padding: 2px 3px 11px; }
.shop-head h2 { margin: 2px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -.055em; line-height: 1.02; }
.shop-head .eyebrow { font-size: 8px; color: var(--amber); }
.shop-emblem { width: 42px; height: 42px; background: #3b3828; border-color: #5f5537; }
.buy-mode { margin-left: auto; border: 1px solid var(--line); background: #152119; border-radius: 6px; padding: 4px 8px; font: 700 11px var(--mono); color: var(--amber); }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; border: 1px solid #344637; background: #152119; border-radius: 7px; margin-bottom: 10px; }
.tabs button { background: transparent; border: 1px solid transparent; border-radius: 5px; color: var(--muted); padding: 6px 2px; font-size: 12px; font-weight: 700; position: relative; }
.tabs button[aria-pressed="true"] { background: #394d33; border-color: #53684b; color: #e7f0ce; }
.tabs button.has-afford::after { content: ''; position: absolute; top: 4px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--life); }
.shop-list { display: grid; gap: 7px; align-content: start; overflow-y: auto; min-height: 0; padding-right: 3px; scrollbar-width: thin; scrollbar-color: #3b4d3b transparent; }
.shop-sub { font: 700 9px var(--mono); letter-spacing: .12em; color: var(--amber); margin: 6px 2px 0; }
.item { width: 100%; display: grid; grid-template-columns: 35px minmax(0, 1fr) auto; align-items: center; column-gap: 8px; padding: 8px 7px; background: #253428; border: 1px solid #3b4d3b; border-radius: 7px; text-align: left; min-height: 58px; transition: background .15s, border-color .15s, transform .1s; }
.item:hover { background: #30472e; border-color: #a4c270; }
.item.selected { background: #2f432c; border-color: #7b965b; }
.item.poor { opacity: .62; }
.item.maxed { opacity: .75; }
.item.locked { opacity: .45; }
.item.flash { animation: flash .45s; }
@keyframes flash { 0% { background: #c3e480; transform: scale(1.02); } 100% { background: #253428; } }
.item.pad-focus { outline: 2px solid var(--amber); }
.item-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; background: #17281e; border: 1px solid #81936138; }
.item strong, .item small { display: block; }
.item strong { font-size: 12.5px; line-height: 1.22; }
.item small { font-size: 10px; color: var(--muted); line-height: 1.3; margin-top: 3px; }
.item .lvl { color: var(--amber); }
.item-price { padding: 4px 6px; border-radius: 4px; color: var(--life); background: #17251ba3; font: 700 10px var(--mono); white-space: nowrap; }
.item.poor .item-price { color: #c6be9f; }
.item.selected .item-price { color: #22331e; background: var(--life); }
.prestige-entry { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; text-align: left; padding: 11px 14px; border: 1px solid #6d5a7a; border-radius: 11px; background: linear-gradient(135deg, #2c2836, #24302a); }
.prestige-entry:hover { border-color: var(--pink); }
.prestige-entry-title { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.prestige-entry-title .pixel-icon { width: 18px; height: 18px; }
.prestige-entry strong { font: 700 17px var(--mono); color: var(--pink); }
.prestige-entry-ratio { grid-column: 1 / -1; font: 600 10px var(--mono); color: var(--muted); }
.save-status { font: 600 10px var(--mono); color: var(--muted); padding: 0 4px; }
.save-status i { background: #96b86b; }

.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #142018c4; backdrop-filter: blur(2px); padding: 16px; }
#loading { background: radial-gradient(ellipse at 50% 30%, #2c3a25, #121c16); }
.panel { color: var(--text); background: #26352a; border: 1px solid #72905f; border-radius: 13px; width: min(440px, 100%); padding: 24px; box-shadow: 0 15px 60px #0b120cc9; max-height: calc(100vh - 32px); overflow-y: auto; }
.panel.center { text-align: center; background: transparent; border: 0; box-shadow: none; }
.panel h2 { margin: 3px 0 12px; font-size: 26px; letter-spacing: -.04em; }
.panel h3 { margin: 12px 0 4px; font-size: 14px; color: var(--life); }
.panel p { color: #c8d0bf; font-size: 13px; }
.wide-panel { width: min(820px, 100%); }
.muted { color: var(--muted) !important; }
.small { font-size: 11px !important; }
.menu-list { display: grid; gap: 6px; }
.menu-btn { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 1px solid #4c6346; background: #1e2b22; border-radius: 7px; font-weight: 700; text-align: left; }
.menu-btn:hover, .menu-btn:focus-visible, .menu-btn.pad-focus { border-color: var(--life); background: #2f432c; outline: none; }
.menu-btn.primary { background: var(--life); color: #22331e; border-color: #dcf5a8; justify-content: center; }
.menu-btn.danger { border-color: #bc7767; background: #4a2f29; color: #ffe3d6; }
.menu-btn b { color: var(--life); }
.menu-btn.slider input { flex: 1; max-width: 200px; accent-color: var(--life); }
.confirm { margin-top: 10px; padding: 12px; border: 1px solid #bc7767; border-radius: 8px; background: #2e211e; }
.row { display: flex; gap: 8px; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row .menu-btn { justify-content: center; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.keys { padding-left: 16px; margin: 4px 0; font-size: 12.5px; color: #c8d0bf; }
.keys li { margin: 4px 0; }
.dialog-done { margin-top: 14px; border: 0; border-radius: 6px; background: var(--life); color: #233323; font-weight: 800; padding: 9px 14px; }
.prestige-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wallet { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid #6d5a7a; border-radius: 9px; background: #2c2836; }
.wallet strong { display: block; font: 700 22px var(--mono); color: var(--pink); }
.perk-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.perk-list .item-price { color: var(--pink); }


.changelog-panel { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.changelog-panel h2 { flex: none; padding-right: 36px; }
.dialog-x { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 7px; background: #1e2b22; font: 700 20px/1 var(--mono); color: var(--text); }
.dialog-x:hover, .dialog-x:focus-visible { color: var(--life); background: #354830; border-color: var(--life); outline: none; }
.log-list { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 4px; overflow-y: auto; flex: 1; min-height: 0; }
.log-list > li { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.log-list > li:first-child { padding-top: 4px; }
.log-list > li:last-child { border-bottom: 0; padding-bottom: 4px; }
.log-list h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 6px; font: 700 16px var(--mono); color: var(--life); }
.log-date { font: 600 10px var(--mono); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.log-list ul { margin: 0; padding-left: 18px; color: #c8d0bf; font-size: 13px; }
.log-list li li { margin: 5px 0; }
.changelog-panel .dialog-done { flex: none; margin-top: 12px; }
.touch-pad { display: none; }
.next-tool { display: none; }
@media (pointer: coarse) {
  .touch-pad { position: absolute; left: 8px; bottom: 8px; display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 4px; }
  .touch-pad button { border: 1px solid #ffebbf8a; border-radius: 7px; background: #26372ce8; color: #f7edcf; font: 700 20px var(--mono); touch-action: none; }
  .touch-pad button.on { background: #c5e487; color: #22331e; }
  .touch-pad button:first-child { grid-column: 2; }
  .next-tool { display: block; position: absolute; left: 8px; bottom: 104px; min-width: 64px; height: 44px; border: 1px solid #ffebbf8a; border-radius: 7px; background: #26372ce8; color: #f7edcf; font: 700 13px var(--mono); touch-action: manipulation; }
  .touch-pad button:nth-child(2) { grid-column: 1; }
  .map-guide { display: none; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 290px; }
  .hud .sub { display: none; }
  .map-guide { max-width: calc(100% - 230px); min-width: 0; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  #app { height: auto; display: block; }
  .topbar { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .hud { order: 3; flex-basis: 100%; margin: 0; }
  .stat { padding: 4px 8px; gap: 6px; }
  .stat strong { font-size: 16px; }
  .layout { grid-template-columns: 1fr; padding: 8px; }
  .map { height: 62vh; flex: none; }
  #minimap { width: 120px; height: 83px; }
  .shop-list { max-height: none; overflow: visible; }
  .help-cols, .perk-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: .01s !important; } }
