:root {
  --paper: #e8ddc4;
  --paper-hi: #f3e9d1;
  --paper-deep: #ddcdac;
  --ink: #2a2019;
  --ink-soft: #5b4936;
  --line: #8a7452;
  --gold: #c08a2e;
  --red: #a4432f;
  --blue: #4b6472;
  --green: #6f8a4c;
  --stage-w: 1280px;
  --stage-h: 720px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #191410;
}

body {
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#viewport {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, #33281b 0%, #221a12 46%, #14100b 100%);
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--stage-w);
  height: var(--stage-h);
  transform: translate(-50%, -50%) scale(var(--scene-scale, 1));
  transform-origin: center center;
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .65),
    0 0 0 1px rgba(243, 233, 209, .12);
  overflow: hidden;
  background: var(--paper);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.tabular { font-variant-numeric: tabular-nums; }

button {
  font-family: inherit;
  color: inherit;
  pointer-events: auto;
}

button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ topbar */

#topbar[hidden],
#bottombar[hidden] { display: none; }

#topbar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  pointer-events: auto;
  background:
    linear-gradient(rgba(242, 233, 211, .97), rgba(223, 209, 179, .96));
  border-bottom: 2px solid rgba(42, 32, 25, .88);
  box-shadow: 0 6px 18px rgba(40, 28, 16, .22);
}

.stat { display: flex; align-items: center; gap: 7px; }

.grain-stat { color: var(--ink); }
.grain-icon { width: 18px; height: 18px; color: var(--gold); }
#grain {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .01em;
  min-width: 44px;
  text-align: right;
}
.unit {
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 8px;
}

.dreams { gap: 9px; }
.dream-label {
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.pips { display: flex; gap: 4px; }
.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: rgba(255, 250, 235, .4);
  transition: background .18s, transform .18s;
}
.pip.on {
  background: var(--gold);
  box-shadow: inset 0 0 0 1.5px rgba(243, 233, 209, .55);
}
.pip.newly-lost { transform: scale(1.35); background: var(--red); }

.wave-status {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 270px;
}
.chapter-label {
  font-size: 8.5px;
  letter-spacing: .15em;
  color: var(--ink-soft);
  line-height: 1.2;
}
.wave-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.wave-sub {
  font-size: 9.5px;
  color: var(--ink-soft);
  letter-spacing: .05em;
}
.wave-track {
  width: 168px;
  height: 4px;
  margin-top: 3px;
  background: rgba(42, 32, 25, .2);
  border-radius: 2px;
  overflow: hidden;
}
#wave-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #9c6f22, var(--gold));
  transition: width .3s ease;
}

.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px;
  height: 34px;
  border: 1.6px solid var(--ink);
  border-radius: 4px;
  background: rgba(255, 250, 235, .38);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--ink); color: var(--paper-hi); }
.icon-btn.active { background: var(--ink); color: var(--paper-hi); }
.icon-btn.muted { opacity: .55; text-decoration: line-through; }

/* ----------------------------------------------------------------- bossbar */

#bossbar {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 430px;
  padding: 5px 11px;
  background: rgba(243, 233, 209, .93);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 3px 10px rgba(40, 28, 16, .25);
}
#bossbar[hidden] { display: none; }
.boss-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7d2f22;
  white-space: nowrap;
}
.boss-track {
  flex: 1;
  height: 8px;
  background: rgba(42, 32, 25, .22);
  border: 1px solid var(--ink);
}
#boss-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #7d2f22, #b4563c);
  transition: width .12s linear;
}
.boss-warn {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--red);
  min-width: 86px;
  text-align: right;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------- toast */

#toast {
  position: absolute;
  top: 106px;
  left: 50%;
  transform: translate(-50%, -6px);
  max-width: 540px;
  padding: 7px 18px;
  background: rgba(42, 32, 25, .93);
  color: var(--paper-hi);
  border: 1.5px solid rgba(243, 233, 209, .45);
  border-radius: 3px;
  font-size: 12.5px;
  letter-spacing: .03em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn {
  background: rgba(125, 47, 34, .96);
  border-color: #e0b27a;
}
#toast.boss {
  background: rgba(56, 33, 22, .96);
  border-color: var(--gold);
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: 11px;
}

/* A character line, kept out of the topbar and above the build pads. */
#bark {
  position: absolute;
  top: 70px;
  left: 18px;
  width: min(370px, 44%);
  padding: 9px 14px 10px 17px;
  background:
    linear-gradient(180deg, rgba(247, 238, 218, .97), rgba(230, 216, 186, .95));
  border: 1.5px solid rgba(42, 32, 25, .82);
  border-left: 5px solid var(--gold, #c08a2e);
  border-radius: 2px;
  box-shadow:
    0 7px 18px rgba(40, 28, 16, .28),
    inset 0 0 18px rgba(120, 90, 50, .1);
  pointer-events: none;
  z-index: 20;
  animation: bark-in .22s ease both;
}
#bark[hidden] { display: none; }
.bark-speaker {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.bark-text {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-style: italic;
  line-height: 1.45;
}
@keyframes bark-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- bottombar */

#bottombar {
  position: absolute;
  inset: auto 0 0 0;
  height: 100px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  pointer-events: auto;
  background:
    linear-gradient(rgba(223, 209, 179, .98), rgba(235, 223, 196, .98));
  border-top: 2px solid rgba(42, 32, 25, .88);
  box-shadow: 0 -6px 18px rgba(40, 28, 16, .22);
}

#buildcards {
  display: grid;
  grid-template-columns: repeat(4, 146px);
  grid-auto-rows: 34px;
  gap: 6px 7px;
  flex: 0 0 auto;
  align-content: center;
}

.tower-card {
  position: relative;
  width: auto;
  height: 34px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 3px;
  border: 1.6px solid var(--ink);
  border-radius: 5px;
  background: linear-gradient(#f6edd9, #e4d5b5);
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .12s;
}
.tower-card:hover { transform: translateY(-1px); box-shadow: 0 2px 0 rgba(42, 32, 25, .28); }
.tower-card.selected {
  border-color: var(--gold);
  background: linear-gradient(#fdf6e4, #eddcb8);
  box-shadow: inset 0 0 0 2px rgba(192, 138, 46, .55), 0 3px 0 rgba(42, 32, 25, .25);
}
.tower-card.poor { opacity: .55; }

/* Locked men stay on the bar as a teaser: you can inspect them, not buy them. */
.tower-card.locked {
  opacity: .62;
  background: linear-gradient(#e6dcc6, #d5c6a6);
  border-style: dashed;
  cursor: help;
}
.tower-card.locked .portrait {
  filter: grayscale(.85) contrast(.9);
  opacity: .75;
}
.tower-card.locked .t-cost { color: var(--ink-soft); font-style: italic; }
.tower-card.locked:hover { transform: none; box-shadow: none; }
.tower-card .key {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 7px;
  font-weight: 700;
  color: var(--ink-soft);
  opacity: .7;
  pointer-events: none;
}
.portrait {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.2px solid var(--ink);
  background: #e9dec6;
  display: grid;
  place-items: center;
  color: var(--fur, #8a7a66);
  overflow: hidden;
}
.portrait svg { width: 21px; height: 21px; display: block; }
.portrait svg .skin { fill: var(--skin, #d3a982); stroke: var(--ink); stroke-width: 1.1; stroke-linejoin: round; }
.portrait svg .shirt { fill: var(--fur, #8a7a66); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.portrait svg .hat { fill: var(--hat, #4a4436); stroke: var(--ink); stroke-width: 1.1; stroke-linejoin: round; }
.portrait svg .hair { fill: var(--hair, #4a3828); stroke: var(--ink); stroke-width: .8; stroke-linejoin: round; }
.portrait svg .scarf { fill: var(--accent, #a9c17a); stroke: var(--ink); stroke-width: 1.1; stroke-linejoin: round; }
.portrait svg .ink { fill: var(--ink); }
.portrait svg .gear { fill: var(--accent, #c8c39a); stroke: var(--ink); stroke-width: 1.1; }
.portrait svg .line { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linecap: round; }

.card-text { display: flex; flex-direction: column; min-width: 0; }

.t-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-weapon { display: none; }
.t-cost {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.t-cost.low { color: var(--red); }
.badge-air {
  position: absolute;
  top: -1px;
  right: -1px;
  padding: 0 2px;
  border-radius: 2px;
  background: var(--blue);
  color: var(--paper-hi);
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: .1em;
}

#sidepanel {
  flex: 1 1 auto;
  min-width: 0;
  height: 76px;
  padding: 6px 11px;
  border: 1.5px dashed rgba(90, 73, 54, .55);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}
.side-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.side-title .wave-num { color: var(--ink-soft); font-weight: 400; letter-spacing: .04em; }
.side-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip {
  padding: 1px 5px;
  border: 1px solid rgba(42, 32, 25, .28);
  border-radius: 2px;
  background: rgba(42, 32, 25, .07);
  font-size: 9.5px;
  white-space: nowrap;
}
.chip.air { background: var(--blue); border-color: #2f4049; color: var(--paper-hi); }
.side-hint { font-size: 10px; color: var(--ink-soft); line-height: 1.35; }
.side-hint strong { color: var(--ink); }

.insp { display: flex; align-items: center; gap: 10px; height: 100%; }
.insp-main { flex: 1; min-width: 0; }
.insp-name { font-size: 13px; font-weight: 700; display: flex; align-items: baseline; gap: 7px; }
.insp-name .lv {
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.insp-line {
  font-size: 9.5px;
  color: var(--ink-soft);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.insp-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: 300px; }

.mini {
  border: 1.4px solid var(--ink);
  border-radius: 3px;
  background: rgba(255, 250, 235, .45);
  padding: 4px 7px;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mini:hover:not(:disabled) { background: var(--ink); color: var(--paper-hi); }
.mini:disabled { opacity: .4; cursor: not-allowed; }
.mini.up { background: var(--ink); color: var(--paper-hi); }
.mini.up:hover:not(:disabled) { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.mini.danger:hover:not(:disabled) { background: var(--red); border-color: var(--red); }

.send-btn {
  flex: 0 0 auto;
  width: 166px;
  height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: linear-gradient(#3b2d1f, #2a2019);
  color: var(--paper-hi);
  cursor: pointer;
  letter-spacing: .1em;
  transition: background .12s;
}
.send-btn:hover:not(:disabled) { background: linear-gradient(#71502a, #4b321a); }
.send-btn:disabled { opacity: .5; cursor: default; }
.send-title { font-size: 12px; font-weight: 700; }
.send-sub { font-size: 9.5px; letter-spacing: .03em; opacity: .82; }

/* ----------------------------------------------------------------- tooltip */

#tooltip {
  position: absolute;
  width: 238px;
  padding: 8px 10px;
  background: #f8f0dc;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(42, 32, 25, .24);
  font-size: 11px;
  line-height: 1.4;
  z-index: 40;
  pointer-events: none;
}
#tooltip[hidden] { display: none; }
#tooltip h4 { margin: 0; font-size: 13px; }
#tooltip .sub {
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
#tooltip .row { display: flex; justify-content: space-between; gap: 10px; }
#tooltip .row span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; }
#tooltip .blurb { margin-top: 5px; color: var(--ink-soft); font-style: italic; }
#tooltip .tier { margin-top: 4px; font-size: 10px; color: var(--ink-soft); }

/* ----------------------------------------------------------------- overlay */

#overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  pointer-events: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(40, 30, 20, .52), rgba(18, 13, 9, .78));
  backdrop-filter: blur(1.5px);
}
#overlay[hidden] { display: none; }

.screen {
  width: 620px;
  max-height: 648px;
  overflow: auto;
  padding: 26px 38px 24px;
  text-align: center;
  background:
    linear-gradient(rgba(246, 237, 217, .98), rgba(226, 212, 181, .99));
  border: 3px double var(--ink);
  box-shadow:
    0 22px 50px rgba(0, 0, 0, .5),
    inset 0 0 0 1px rgba(255, 250, 235, .7),
    inset 0 0 60px rgba(120, 90, 50, .12);
  animation: screen-in .22s ease both;
}
.screen.narrow { width: 470px; }
.screen[hidden] { display: none; }

/* ------------------------------------------------------------- chapter card */

.chapter-screen {
  width: 540px;
  padding: 28px 38px 26px;
  background:
    linear-gradient(rgba(248, 239, 219, .99), rgba(228, 214, 183, .99));
  box-shadow:
    0 22px 50px rgba(0, 0, 0, .52),
    inset 0 0 0 1px rgba(255, 250, 235, .75),
    inset 0 0 70px rgba(120, 90, 50, .14);
}
.chapter-screen .eyebrow {
  letter-spacing: .24em;
}
.chapter-setting {
  margin: 2px 0 15px;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.chapter-flavor {
  max-width: 420px;
  margin: 0 auto 18px;
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
}
.chapter-brief {
  margin: 0 0 20px;
  padding: 12px 14px;
  display: grid;
  gap: 9px;
  text-align: left;
  border-top: 1px solid rgba(42, 32, 25, .24);
  border-bottom: 1px solid rgba(42, 32, 25, .24);
  background: rgba(255, 250, 235, .3);
}
.chapter-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: baseline;
}
.chapter-key {
  font-size: 8.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.chapter-value {
  font-size: 12px;
  line-height: 1.45;
}
#chapter-stipend {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#chapter-start {
  min-width: 190px;
}

.chapter-actions {
  margin-top: 2px;
  align-items: center;
}

.chapter-actions #chapter-menu {
  padding-inline: 16px;
  background: transparent;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 9.5px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
h1 {
  margin: 0 0 8px;
  font-size: 62px;
  line-height: .92;
  font-weight: 400;
  letter-spacing: .015em;
  text-shadow: 2px 2px 0 rgba(255, 250, 235, .5);
}
h2 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: .01em;
}
.tagline {
  max-width: 450px;
  margin: 0 auto 18px;
  font-size: 14.5px;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
}
.route-line {
  max-width: 536px;
  margin: -6px auto 16px;
  font-size: 8.5px;
  letter-spacing: .04em;
  line-height: 1.65;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}
.difficulty button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 4px;
  border: 1.6px solid var(--ink);
  border-radius: 3px;
  background: rgba(255, 250, 235, .35);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.difficulty button small {
  font-size: 8.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  opacity: .62;
}
.difficulty button:hover { background: rgba(192, 138, 46, .2); }
.difficulty button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-hi);
}

.primary {
  padding: 13px 30px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper-hi);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.primary:hover { background: var(--gold); border-color: var(--gold); color: var(--ink); }

.howto {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 32, 25, .22);
  text-align: left;
  font-size: 11.5px;
}
.howto summary {
  cursor: pointer;
  text-align: center;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: " +"; }
.howto[open] summary::after { content: " –"; }
.howto ul {
  margin: 10px auto 0;
  max-width: 470px;
  padding-left: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.howto li { margin-bottom: 4px; }
kbd {
  display: inline-block;
  min-width: 15px;
  padding: 0 4px;
  border: 1px solid rgba(42, 32, 25, .5);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: rgba(255, 250, 235, .5);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  text-align: center;
}

.best {
  margin: 13px 0 0;
  font-size: 10px;
  letter-spacing: .07em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
#end-best { margin-bottom: 12px; }

.row { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.row button {
  padding: 11px 18px;
  border: 1.6px solid var(--ink);
  border-radius: 3px;
  background: rgba(255, 250, 235, .35);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.row button:hover { background: var(--ink); color: var(--paper-hi); }
.row button.primary { background: var(--ink); color: var(--paper-hi); }
.row button.primary:hover { background: var(--gold); border-color: var(--gold); color: var(--ink); }

.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 10px;
  margin: 16px 0 4px;
}
.end-stats .cell {
  padding-top: 6px;
  border-top: 1px solid rgba(42, 32, 25, .28);
}
.end-stats .label {
  display: block;
  font-size: 8.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.end-stats .value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.end-stats .value.bad { color: var(--red); }
.end-stats .value.good { color: var(--green); }

/* ------------------------------------------------------------ crash gates */

.file-gate,
.fatal-gate {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 40%, rgba(32, 24, 16, .78), rgba(16, 12, 8, .92));
  pointer-events: auto;
}

.fatal-gate[hidden] { display: none; }

.file-card,
.fatal-card {
  width: 560px;
  max-width: 100%;
  padding: 24px 30px;
  text-align: center;
  background: linear-gradient(rgba(246, 237, 217, .99), rgba(226, 212, 181, .99));
  border: 3px double var(--ink);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .55);
}

.file-card h2,
.fatal-card h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 400;
}

.file-card p,
.fatal-card p {
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.file-card .eyebrow,
.fatal-card .eyebrow {
  margin: 0 0 2px;
}

.file-card code,
.fatal-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink);
}

.code-block {
  display: block;
  margin: 4px auto 10px;
  padding: 8px 12px;
  max-width: 380px;
  border: 1px solid rgba(42, 32, 25, .35);
  background: rgba(255, 250, 235, .55);
  text-align: left;
  line-height: 1.7;
  user-select: all;
}

.file-label {
  margin: 12px 0 0 !important;
  font-size: 10px !important;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.file-note {
  margin-top: 14px !important;
  font-size: 11px !important;
}

.fatal-card pre {
  margin: 12px 0;
  padding: 10px 12px;
  max-height: 120px;
  overflow: auto;
  border: 1px solid rgba(42, 32, 25, .35);
  background: rgba(255, 250, 235, .55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-align: left;
  white-space: pre-wrap;
  color: #7d2f22;
}

.fatal-card button {
  margin-top: 8px;
  padding: 11px 24px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper-hi);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
}

.fatal-card button:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

/* ------------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* Small viewport guard: stage scales, keep scroll out of the way. */
.screen::-webkit-scrollbar { width: 8px; }
.screen::-webkit-scrollbar-thumb { background: rgba(42, 32, 25, .35); border-radius: 4px; }
