:root {
  --bg: #0b0e0a; --card: #141a12; --card2: #0e130d; --text: #dcd6c4; --muted: #8f978a; --line: #2b3427;
  --gold: #d9b45a; --gold2: #f0d68a; --ok: #8ff0c0; --warn: #ffb86b; --bad: #ff7a7a; --accent: #c8e04a;
  --serif: 'Crimson Pro', Georgia, 'Times New Roman', serif; --display: 'Cinzel', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.5 var(--serif); overflow: hidden; }
canvas#game { display: block; position: fixed; inset: 0; width: 100vw; height: 100vh; cursor: crosshair; }
button { font: 600 15px/1 var(--display); letter-spacing: 0.05em; color: var(--text); background: #1d2519; border: 1px solid #3a4a34; border-radius: 6px; padding: 12px 18px; cursor: pointer; transition: background 0.15s; }
button:hover { background: #26301f; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: #3a4d28; border-color: #6a8a3a; color: #f0f0d8; }
button.primary:hover { background: #4a6232; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 12px; margin-top: 6px; }

/* ---------- overlay cards ---------- */
#ui { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(8,12,7,0.55), rgba(4,6,4,0.85)); overflow: auto; padding: 24px; backdrop-filter: blur(3px); z-index: 20; }
#ui[hidden] { display: none; }
.card { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--line); outline: 1px solid rgba(217,180,90,0.12); outline-offset: 4px; border-radius: 4px; padding: 30px 36px; width: min(1080px, 96vw); max-height: 94vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.card h1 { margin: 0; font: 800 46px/1.1 var(--display); letter-spacing: 0.24em; color: var(--gold2); text-shadow: 0 0 24px rgba(217,180,90,0.25); }
.card h2 { margin: 0 0 8px; font: 700 26px/1.2 var(--display); letter-spacing: 0.06em; color: var(--gold2); }
.card h3 { margin: 20px 0 8px; font: 700 13px/1 var(--display); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); }
.card h4 { margin: 14px 0 6px; font: 700 15px var(--display); letter-spacing: 0.04em; color: #e8e0c8; }
.hero { margin-bottom: 16px; }
.sub { margin: 6px 0 0; color: var(--muted); font-style: italic; font-size: 18px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); }
code { background: #0a0d09; padding: 1px 7px; border-radius: 4px; color: var(--accent); font-size: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 6px; align-items: center; }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 32px; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.chronicle p { margin: 0 0 10px; font-size: 17px; }
.chronicle p:first-letter { font-family: var(--display); font-size: 150%; color: var(--gold2); }
.chronicle.collapsed p:nth-child(n+3) { display: none; }
.chronicle .more { font-size: 14px; }

table { border-collapse: collapse; width: 100%; font-size: 15px; }
td, th { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-style: italic; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; box-shadow: 0 0 6px currentColor; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font: 600 11px/1.6 var(--display); text-transform: uppercase; letter-spacing: 0.08em; background: #2a2d35; color: #bbb; }
.badge.stable { background: #21332a; color: var(--ok); }
.badge.thin { background: #3a3222; color: var(--warn); }
.badge.endangered, .badge.absent { background: #3a2222; color: var(--bad); }
.badge.bloom, .badge.burnt { background: #3a2a12; color: #ff9a3a; }
.badge.eaten { background: #21332a; color: var(--ok); }
.badge.seen { background: #223045; color: #8fd0ff; }
.badge.unknown { background: #2a2d35; color: #777; }
ul.plain { list-style: none; padding: 0; margin: 4px 0; }
ul.plain li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
ul.help li b { color: var(--gold2); font-family: var(--display); font-size: 13px; letter-spacing: 0.06em; }
ul.events { margin: 6px 0 0; padding-left: 18px; color: #d9c98a; font-size: 15px; }
.biome { margin-bottom: 12px; }
.stats { color: var(--muted); margin: 0 0 8px; font-style: italic; }
.quote { border-left: 2px solid var(--gold); padding: 6px 14px; margin: 10px 0; font-style: italic; color: #e8e0c8; }
.quote .who { display: block; font: 700 12px var(--display); letter-spacing: 0.14em; color: var(--gold); font-style: normal; margin-bottom: 4px; }
.epilogue { background: rgba(217,180,90,0.06); border: 1px solid rgba(217,180,90,0.25); padding: 14px 18px; border-radius: 4px; margin: 6px 0 12px; }
.epilogue h3 { margin-top: 0; }
.lore h2 { font-size: 22px; }
.lore .text { font-size: 18px; white-space: pre-line; }

.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.offer { display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; gap: 6px 14px; border: 1px solid; border-radius: 4px; padding: 14px; background: rgba(0,0,0,0.25); }
.offer .icon { grid-row: 1 / span 2; font: 800 32px/52px var(--display); text-align: center; text-shadow: 0 0 12px currentColor; }
.offer .body b { display: block; font: 700 17px var(--display); letter-spacing: 0.03em; }
.offer .body .slot { display: block; color: var(--muted); font-size: 14px; font-style: italic; }
.offer .body p { margin: 4px 0 0; font-size: 15px; }
.offer .btns { grid-column: 2; display: flex; gap: 8px; }
.offer.unknown { opacity: 0.55; }
.slots-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.slotcard { border: 1px solid; border-radius: 4px; padding: 10px; background: rgba(0,0,0,0.25); min-height: 120px; }
.slotcard .slot { display: block; color: var(--muted); font: 600 11px var(--display); text-transform: uppercase; letter-spacing: 0.1em; }
.slotcard .icon { font: 800 28px var(--display); }
.slotcard p { margin: 4px 0 0; font-size: 14px; color: #bbb; }
@media (max-width: 860px) { .slots-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-size: 14px; }
#hud[hidden] { display: none; }
.panel, .hp-panel, .biome-panel, .boss-panel, .slots { position: absolute; background: rgba(6,9,6,0.62); border: 1px solid rgba(217,180,90,0.18); border-radius: 4px; padding: 10px 14px; backdrop-filter: blur(2px); }
.hp-panel { top: 16px; left: 16px; width: 300px; }
.bar { position: relative; height: 16px; background: #2a1c1c; border-radius: 2px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, #c94a4a, #e06a5a); transition: width 0.12s; }
.bar.hp.adrenal .fill { background: linear-gradient(90deg, #f0705a, #ffb070); }
.bar .txt { position: absolute; inset: 0; line-height: 16px; padding-left: 8px; font: 600 12px var(--display); letter-spacing: 0.06em; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.threat { height: 7px; margin-top: 8px; background: #2a2438; }
.bar.threat .fill { background: linear-gradient(90deg, #a080c0, #d0b0e0); }
.threat-txt { margin-top: 4px; color: #cfc8b8; font-style: italic; }
.biome-panel { top: 16px; left: 50%; transform: translateX(-50%); width: 460px; text-align: center; }
.bname { font: 700 15px var(--display); letter-spacing: 0.1em; color: var(--gold2); }
.brow { display: flex; align-items: center; gap: 10px; margin-top: 6px; justify-content: center; }
.apex { font: 600 12px var(--display); letter-spacing: 0.05em; }
.apex.alive { color: #ffb0a0; } .apex.dead { color: var(--ok); } .apex.absent { color: #999; }
.bar.biomass { width: 170px; height: 11px; background: #2a2e1c; }
.bar.biomass .fill { background: linear-gradient(90deg, #8fb03a, #c8e04a); }
.btxt { font-size: 13px; color: #e8e0c8; }
.bhint { margin-top: 4px; color: #a8a898; font-style: italic; font-size: 14px; }
.bhint.open { color: var(--ok); }
.boss-panel { top: 16px; left: 50%; transform: translateX(-50%); width: 520px; text-align: center; border-color: rgba(201,74,106,0.5); }
.bossname { font: 700 16px var(--display); letter-spacing: 0.12em; color: #ffb0c0; margin-bottom: 6px; }
.bar.boss { height: 14px; background: #2a1420; }
.bar.boss .fill { background: linear-gradient(90deg, #a02a4a, #c94a6a); }
.boss-panel.phase2 .bar.boss .fill { background: linear-gradient(90deg, #c94a6a, #ff4a6a); }
.slots { left: 16px; bottom: 16px; padding: 10px 14px 8px; }
.dash { font: 600 11px var(--display); letter-spacing: 0.08em; color: #666; margin-bottom: 6px; }
.dash.ready { color: #8fb0c0; }
.slotrow { display: flex; gap: 10px; align-items: flex-end; }
.slot { position: relative; width: 52px; height: 52px; background: #0d110c; border: 2px solid #333; border-radius: 4px; }
.slot .icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 800 24px var(--display); text-shadow: 0 0 10px currentColor; }
.slot .cd { position: absolute; left: 0; right: 0; top: 0; background: rgba(0,0,0,0.65); height: 0; }
.slot .key { position: absolute; top: 100%; left: 0; right: 0; text-align: center; font: 600 10px var(--display); letter-spacing: 0.06em; color: #aaa; margin-top: 3px; }
.slot .sname { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: 10px; color: #777; margin-bottom: 2px; font-style: italic; }
.slot.gut { width: 40px; height: 40px; }
.slot.gut .icon { font-size: 18px; }
.gutlabel { font: 600 10px var(--display); letter-spacing: 0.08em; color: #888; margin: 0 2px 14px 8px; }
.slotrow { padding-top: 14px; padding-bottom: 14px; }
.hints { position: absolute; right: 16px; bottom: 16px; color: rgba(255,255,255,0.55); font-size: 13px; text-align: right; }
#labels { position: absolute; inset: 0; overflow: hidden; }
.flabel { position: absolute; left: 0; top: 0; white-space: nowrap; }
.flabel.prompt { background: rgba(6,9,6,0.7); border: 1px solid rgba(217,180,90,0.3); padding: 3px 10px; border-radius: 3px; font: 600 12px var(--display); letter-spacing: 0.06em; color: #f0e8d0; }
.flabel.prompt.gate { color: var(--ok); }
.flabel.prompt.eating { color: var(--accent); }
.flabel.num { font: 700 15px var(--display); text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,0.6); }
.flabel.chp { width: 44px; height: 5px; background: rgba(0,0,0,0.6); border-radius: 2px; overflow: hidden; }
.flabel.chp i { display: block; height: 100%; background: #e05a5a; }
.flabel.chp.bloom i { background: #ff9a3a; }
#arrows { position: absolute; inset: 0; }
.arrow { position: absolute; left: 0; top: 0; width: 0; height: 0; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 16px solid #fff; filter: drop-shadow(0 0 4px #000); transform-origin: 0 50%; }
#voice { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); max-width: 720px; background: rgba(6,9,6,0.72); border: 1px solid rgba(217,180,90,0.3); border-radius: 4px; padding: 10px 18px; font-size: 18px; font-style: italic; color: #f0e8d0; opacity: 0; }
#voice[hidden] { display: none; }
#voice .speaker { font: 700 12px var(--display); letter-spacing: 0.16em; color: var(--gold); font-style: normal; margin-right: 12px; }
#voice.show { animation: voice 0.4s ease-out forwards; }
@keyframes voice { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

#banner { position: fixed; top: 20%; left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; z-index: 15; font: 800 40px/1.2 var(--display); letter-spacing: 0.2em; color: var(--gold2); text-shadow: 0 2px 14px rgba(0,0,0,0.9), 0 0 30px rgba(217,180,90,0.25); }
#banner small { display: block; font: italic 400 18px/1.4 var(--serif); letter-spacing: 0.04em; color: #d8d0b8; margin-top: 8px; }
#banner.show { animation: banner 3.6s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }
#toast { position: fixed; bottom: 190px; left: 50%; transform: translateX(-50%); background: rgba(6,9,6,0.85); border: 1px solid var(--line); padding: 8px 14px; border-radius: 4px; opacity: 0; pointer-events: none; z-index: 15; font-size: 15px; }
#toast.show { animation: toast 2.4s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
pre { white-space: pre-wrap; color: var(--bad); font-size: 13px; }
