:root {
  --ground: #0D0E0B;
  --panel: #13140F;
  --panel-2: #11120E;
  --line: #262821;
  --line-2: #2E3029;
  --line-3: #3A3C33;
  --ink: #E9E8E1;
  --ink-2: #B9B8AF;
  --ink-3: #8A897F;
  --accent: #8EF0A8;
  --warn: #F5B85C;
  --crit: #FF8A7A;
  --stone: #E9E6DC;
  --stone-2: #F3F1EA;
  --stone-ink: #1B1C17;
  --stone-ink-2: #4A483F;
  --stone-ink-3: #5E5B50;
  --stone-line: #C9C5B7;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: #C4FAD2; }
img, canvas { display: block; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); }
.eyebrow { margin: 0 0 12px; font-family: var(--mono); font-size: 13px; letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
h1, h2, h3 { font-weight: 400; }
.display { font-family: var(--serif); line-height: 1; margin: 0; }
.h2 { font-family: var(--serif); font-size: clamp(40px, 5vw, 64px); line-height: 1; margin: 0; font-weight: 400; }

/* ---------- nav ---------- */
.nav { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(13,14,11,.92); backdrop-filter: blur(8px); z-index: 20; }
.nav .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo span { font-family: var(--mono); font-weight: 500; letter-spacing: .18em; font-size: 15px; }
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; font-size: 15px; }
.nav-links a { color: var(--ink-2); text-decoration: none; }
.nav-links a:hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border-radius: 999px;
  border: 1px solid var(--line-3); background: transparent; color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--ground); font-weight: 600; }
.btn-primary:hover { background: #B5F6C6; border-color: #B5F6C6; color: var(--ground); }
.btn-outline-accent { border-color: var(--accent); }
.btn-sm { min-height: 44px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; border-radius: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-dashed { border-style: dashed; border-color: #4A4C42; border-radius: 12px; }

/* ---------- hero ---------- */
.hero { display: flex; flex-wrap: wrap; gap: 64px; align-items: center; padding-top: 88px; padding-bottom: 88px; }
.hero-copy { flex: 999 1 520px; min-width: 0; }
.hero h1 { font-family: var(--serif); font-size: clamp(52px, 7vw, 96px); line-height: .98; letter-spacing: -.01em; margin: 0; }
.hero h1 em { color: var(--accent); }
.hero p.lead { margin: 28px 0 0; max-width: 560px; font-size: 19px; color: var(--ink-2); }
.cta-row { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- monitor card ---------- */
.monitor { flex: 1 1 380px; min-width: 0; max-width: 480px; border: 1px solid var(--line-2); border-radius: 20px; background: var(--panel); padding: 28px; }
.monitor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }
.monitor .name { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.pulse { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; }
.pulse i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; animation: beat 1.1s ease-in-out infinite; }
.pulse.dead i { animation: none; }
@keyframes beat { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
.ekg { margin: 22px 0 10px; width: 100%; height: 80px; }
.clock { font-family: var(--mono); font-size: 46px; font-weight: 500; letter-spacing: .02em; margin: 4px 0 18px; }
.bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--accent); transition: width .6s ease; }
.bar.thin { height: 8px; }
.bar-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; color: var(--ink-3); }

/* ---------- strip ---------- */
.strip { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.strip .wrap { padding-top: 26px; padding-bottom: 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; font-family: var(--mono); font-size: 14px; color: var(--ink-2); }
.strip b { color: var(--accent); font-weight: 500; margin-right: 10px; }

/* ---------- sections ---------- */
section.block { padding-top: 104px; padding-bottom: 40px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 40px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

.card { border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); padding: 22px; display: flex; flex-direction: column; gap: 14px; color: var(--ink); text-decoration: none; transition: border-color .15s; }
a.card:hover { border-color: var(--ink-3); color: var(--ink); }
.card h3 { margin: 0; font-family: var(--serif); font-size: 28px; line-height: 1.1; overflow-wrap: anywhere; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card p { margin: 0; font-size: 15px; color: var(--ink-2); }
.card .meta { display: flex; justify-content: space-between; margin-top: 8px; font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.thumb { width: 100%; aspect-ratio: 1; border-radius: 10px; image-rendering: pixelated; background: var(--ground); }

.pill { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; text-transform: uppercase; white-space: nowrap; }
.h-thriving, .h-steady { color: var(--accent); }
.h-low { color: var(--warn); }
.h-critical { color: var(--crit); }
.h-fossil { color: var(--ink-3); }

.empty { border: 1px dashed var(--line-3); border-radius: 16px; padding: 40px 24px; text-align: center; color: var(--ink-2); }

/* how it works */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); border-top: 1px solid var(--line-2); }
.steps > div { padding: 32px 28px 32px 0; border-bottom: 1px solid var(--line-2); }
.steps .n { font-family: var(--mono); font-size: 14px; color: var(--accent); }
.steps h3 { margin: 14px 0 10px; font-family: var(--serif); font-size: 34px; }
.steps p { margin: 0; color: var(--ink-2); font-size: 16px; }

/* museum (stone) */
.museum { background: var(--stone); color: var(--stone-ink); margin-top: 72px; }
.museum .wrap { padding-top: 104px; padding-bottom: 104px; }
.museum .eyebrow { color: var(--stone-ink-3); }
.museum .muted { color: var(--stone-ink-2); }
.museum .dim { color: var(--stone-ink-3); }
.museum .card { background: var(--stone-2); border-color: var(--stone-line); color: var(--stone-ink); }
.museum a.card:hover { border-color: var(--stone-ink-3); color: var(--stone-ink); }
.museum .card p { color: var(--stone-ink-2); }
.museum .thumb { filter: grayscale(1) sepia(.35) contrast(.9) brightness(1.05); background: #D8D4C7; }
.museum .empty { border-color: var(--stone-line); color: var(--stone-ink-2); }
dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
dl.facts dt { color: var(--stone-ink-3); }
dl.facts dd { margin: 0; font-family: var(--mono); }

/* CTA + footer */
.cta { border-top: 1px solid var(--line); text-align: center; }
.cta .wrap { padding-top: 104px; padding-bottom: 104px; }
.cta h2 { font-family: var(--serif); font-size: clamp(44px, 6vw, 80px); line-height: 1; margin: 0 auto; max-width: 820px; }
footer { border-top: 1px solid var(--line); }
footer .wrap { padding-top: 28px; padding-bottom: 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--ink-3); }

/* ---------- forms / dialog ---------- */
dialog { border: 1px solid var(--line-2); border-radius: 20px; background: var(--panel); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.65); }
.dialog-body { padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.dialog-body h2 { font-family: var(--serif); font-size: 40px; margin: 0; line-height: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 13px; color: var(--ink-3); }
input, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--ground);
  border: 1px solid var(--line-3); border-radius: 10px; padding: 11px 14px; min-height: 46px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.form-error { color: var(--crit); font-size: 14px; min-height: 20px; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ground); padding: 12px 20px; border-radius: 999px; font-weight: 500; font-size: 15px; transition: all .25s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--crit); }

/* ---------- world page ---------- */
.world-head { padding-top: 40px; padding-bottom: 28px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 24px; }
.world-head h1 { font-family: var(--serif); font-size: clamp(48px, 6vw, 80px); line-height: 1; margin: 6px 0 0; overflow-wrap: anywhere; }
.world-layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; padding-bottom: 80px; }
.stage { flex: 999 1 560px; min-width: 0; }
.side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.panel { border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); padding: 22px; }
.panel h2 { font-family: var(--serif); font-size: 28px; margin: 0 0 14px; }

.canvas-frame { position: relative; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); padding: 14px; }
#board { width: 100%; aspect-ratio: 1; image-rendering: pixelated; cursor: crosshair; border-radius: 6px; background: var(--ground); touch-action: manipulation; }
.fossil .palette, .fossil .cooldown { display: none; }
[hidden] { display: none !important; }
.manual-pay { font-size: 14px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 12px; }
.manual-pay summary { cursor: pointer; min-height: 32px; color: var(--ink); }
.manual-pay p { margin: 8px 0 0; }
.manual-pay code { font-family: var(--mono); font-size: 12px; background: var(--ground); border: 1px solid var(--line-3); border-radius: 6px; padding: 2px 6px; word-break: break-all; user-select: all; }
.empty-hint { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; max-width: 320px; text-align: center; color: var(--ink-3); font-size: 15px; pointer-events: none; }
.empty-hint[hidden] { display: none; }
.fossil #board { cursor: default; filter: grayscale(1) sepia(.4) contrast(.85) brightness(.9); }
.board-status { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.palette { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.swatch { aspect-ratio: 1; min-height: 36px; border-radius: 8px; border: 2px solid var(--line-3); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ground) inset; }
.cooldown { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 12px; }
.cooldown > div { height: 100%; width: 0; background: var(--accent); }

.fossil-banner { display: none; border: 1px solid var(--stone-line); background: var(--stone); color: var(--stone-ink); border-radius: 16px; padding: 22px; margin-bottom: 20px; }
.fossil .fossil-banner { display: block; }
.fossil-banner h2 { font-family: var(--serif); font-size: 34px; margin: 0 0 6px; }
.fossil-banner p { margin: 0; color: var(--stone-ink-2); }

.fuel-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { flex: 1 1 auto; min-width: 0; }
.inline-form .btn { flex: 0 0 auto; border-radius: 12px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.list li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1E2019; color: var(--accent); border: 1px solid #2F4A36; }
.log li { color: var(--ink-2); }
.log time { color: var(--ink-3); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.notice { font-size: 14px; color: var(--warn); margin: 10px 0 0; }

@media (max-width: 560px) {
  .nav-links { gap: 14px; }
  .monitor { padding: 22px; }
  .clock { font-size: 38px; }
  .palette { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .swatch { min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse i { animation: none; }
  html { scroll-behavior: auto; }
}
