:root {
  color-scheme: dark;
  --ink: #15141f;
  --ink-soft: #242235;
  --sky: #343a55;
  --sky-light: #505976;
  --dirt: #5b3b28;
  --dirt-dark: #35241d;
  --timber: #7b5032;
  --timber-light: #ad7548;
  --paper: #e8d8a5;
  --paper-dark: #c4aa70;
  --text: #f5ecd0;
  --dim: #c5b993;
  --gold: #f6c744;
  --silver: #c8d0d9;
  --oil: #aab1c5;
  --green: #64c466;
  --red: #dc4f45;
  --border: 3px;
  --shadow: 5px 5px 0 #0b0a10;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 50%, transparent 50%) 0 0 / 100% 4px,
    var(--ink);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); background: var(--gold); color: var(--ink); font-weight: 900; }
.skip-link:focus { transform: none; }

.site-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 10px clamp(12px,3vw,28px);
  border-bottom: 4px solid #09080c;
  background: #211a18;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: max-content; color: var(--paper); text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 3px solid #08070a; background: var(--gold); box-shadow: 3px 3px 0 var(--timber); color: #1a1510; font-size: 22px; }
.brand b, .brand small { display: block; }
.brand b { font-size: 18px; line-height: 1; letter-spacing: .08em; }
.brand small { margin-top: 5px; color: var(--timber-light); font-size: 9px; letter-spacing: .14em; }
.header-links { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 7px; }
.header-links a { min-height: 40px; display: inline-flex; align-items: center; border: 3px solid #4b4560; padding: 7px 11px; background: var(--ink-soft); box-shadow: 3px 3px 0 #09080c; color: var(--text); font-size: 10px; font-weight: 900; text-decoration: none; text-transform: uppercase; }
.header-links a:hover { filter: brightness(1.12); }
.network-chip { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; border: 2px solid #4d4135; padding: 6px 10px; background: #151318; color: var(--paper); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.network-chip i { width: 8px; height: 8px; background: var(--green); animation: blink 1.1s steps(1) infinite; }

main { max-width: 1440px; margin: 0 auto; padding: clamp(16px,2.5vw,30px); }
.mine-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 22px; align-items: end; margin-bottom: 18px; }
.eyebrow, .label { display: block; margin: 0 0 4px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; color: var(--paper); font-size: clamp(26px,4vw,45px); line-height: 1; letter-spacing: .06em; text-transform: uppercase; text-shadow: none; }
.intro { max-width: 820px; margin: 11px 0 0; color: var(--dim); font-size: 12px; }
.headline-stats { display: grid; grid-template-columns: repeat(3,minmax(118px,1fr)); gap: 8px; margin: 0; }
.headline-stats div { min-height: 72px; border: 3px solid #09080c; padding: 10px; background: #29242f; box-shadow: 3px 3px 0 #09080c; }
.headline-stats dt { color: var(--dim); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.headline-stats dd { margin: 5px 0 0; color: var(--gold); font-size: 18px; font-weight: 900; }

.grotto-shell { border: 4px solid #09080c; background: #211d27; box-shadow: var(--shadow); }
.mine-marquee { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 72px; padding: 11px 13px; border-bottom: 3px solid #09080c; background: #30261f; }
.mine-marquee > div:first-child { display: flex; align-items: center; gap: 11px; }
.mine-marquee .label { margin: 0; }
.mine-marquee h2 { margin: 2px 0 0; color: var(--paper); font-size: 16px; letter-spacing: .08em; text-transform: uppercase; }
.lamp { display: grid; width: 38px; height: 38px; place-items: center; border: 3px solid #09080c; background: var(--gold); box-shadow: 3px 3px 0 var(--timber); }
.lamp::after { content: "✦"; color: #1b1710; font-size: 18px; }
.snapshot { display: inline-flex; align-items: center; gap: 7px; border: 2px solid #4d4135; padding: 7px 9px; background: #151318; color: var(--dim); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.snapshot i { width: 8px; height: 8px; background: var(--gold); animation: blink .8s steps(1) infinite; }
.snapshot[data-state="ready"] { border-color: #315f36; color: #9fd7a8; }
.snapshot[data-state="ready"] i { background: var(--green); animation: none; }
.snapshot[data-state="error"] { border-color: #6f201e; color: #ffb6ae; }
.snapshot[data-state="error"] i { background: var(--red); }

.mine-toolbar { display: grid; grid-template-columns: minmax(0,1fr) minmax(270px,360px) auto; gap: 10px; align-items: end; padding: 10px 12px; border-bottom: 3px solid #09080c; background: #19171d; }
.crew-filters { display: flex; flex-wrap: wrap; gap: 6px; }
button {
  min-height: 42px;
  border: 3px solid #241b17;
  border-radius: 0;
  padding: 8px 12px;
  background: var(--gold);
  box-shadow: 3px 3px 0 #09080c;
  color: #1b1710;
  font-weight: 900;
  transition: filter 100ms linear, transform 100ms linear, box-shadow 100ms linear;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translate(3px,3px); box-shadow: none; }
button:disabled { cursor: wait; filter: grayscale(.45); opacity: .48; }
.crew-filter { border-color: #4b4560; background: var(--ink-soft); color: var(--dim); font-size: 9px; text-transform: uppercase; }
.crew-filter.active { border-color: var(--gold); background: var(--paper); color: #211812; }
.crew-filter.gold:not(.active) { color: var(--gold); }
.crew-filter.silver:not(.active) { color: var(--silver); }
.crew-filter.oil:not(.active) { color: var(--oil); }
.miner-finder { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 5px; }
.miner-finder label { grid-column: 1/-1; color: var(--dim); font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.miner-finder input { min-width: 0; min-height: 42px; border: 2px solid #4b4560; border-radius: 0; padding: 7px 9px; background: #151318; color: var(--text); }
.miner-finder input:focus { outline: 3px solid var(--gold); outline-offset: 2px; }
.miner-finder > span { grid-column: 1/-1; min-height: 13px; color: var(--dim); font-size: 8px; }
.refresh-button { background: var(--ink-soft); color: var(--text); border-color: #4b4560; }

.mine-window { position: relative; width: 100%; height: min(70vh,780px); min-height: 520px; overflow: auto; overscroll-behavior: contain; background: #09080c; cursor: grab; scrollbar-color: var(--timber-light) #100e14; scrollbar-width: thin; }
.mine-window:active { cursor: grabbing; }
.mine-window:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
#grottoCanvas { display: block; width: 2400px; height: 1280px; image-rendering: pixelated; image-rendering: crisp-edges; }
.shaft-loading, .mine-error { position: sticky; z-index: 4; left: 50%; top: 50%; width: min(440px,calc(100vw - 50px)); border: 3px solid #09080c; padding: 18px; transform: translate(-50%,-50%); background: rgba(33,29,39,.97); box-shadow: 6px 6px 0 #060508; text-align: center; }
.shaft-loading strong, .shaft-loading span, .mine-error strong, .mine-error span { display: block; }
.shaft-loading strong, .mine-error strong { color: var(--paper); font-size: 14px; text-transform: uppercase; }
.shaft-loading span, .mine-error span { margin: 6px 0 12px; color: var(--dim); font-size: 9px; }
.shaft-loading progress { width: 100%; height: 14px; accent-color: var(--gold); }
.loader { display: flex; justify-content: center; gap: 5px; height: 22px; margin-bottom: 8px; }
.loader i { width: 8px; height: 17px; background: var(--gold); animation: dig-loader .7s steps(2) infinite alternate; }
.loader i:nth-child(2) { animation-delay: .18s; }
.loader i:nth-child(3) { animation-delay: .36s; }
.scene-instructions { margin: 0; padding: 7px 11px; border-top: 3px solid #09080c; background: #30261f; color: var(--dim); font-size: 9px; }

.mine-ledger { display: grid; grid-template-columns: repeat(5,1fr); border-top: 3px solid #09080c; }
.mine-ledger > div { display: flex; align-items: center; gap: 9px; min-height: 67px; padding: 10px; border-right: 2px solid #09080c; background: #211d27; color: var(--dim); font-size: 8px; text-transform: uppercase; }
.mine-ledger > div:last-child { border-right: 0; }
.mine-ledger b { display: block; margin-top: 2px; color: var(--gold); font-size: 17px; }
.ledger-icon { color: var(--gold); font-size: 19px; }

.miner-inspector { position: fixed; z-index: 100; right: 18px; bottom: 18px; width: min(370px,calc(100vw - 26px)); max-height: calc(100vh - 96px); overflow: auto; border: 4px solid #09080c; padding: 16px; background: #211d27; box-shadow: 7px 7px 0 #050407, 0 18px 65px rgba(0,0,0,.55); }
.inspector-close { position: absolute; z-index: 2; top: 8px; right: 8px; width: 36px; min-height: 36px; padding: 0; background: var(--red); color: #fff; font-size: 20px; }
.inspector-art { width: 126px; height: 126px; margin-bottom: 13px; border: 3px solid #09080c; background: #151318; box-shadow: 3px 3px 0 var(--timber); }
.inspector-art svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.miner-inspector h2 { margin: 0 0 9px; color: var(--paper); font-size: 24px; letter-spacing: .04em; text-transform: uppercase; }
.shift-ticket { display: flex; align-items: center; justify-content: space-between; gap: 9px; border: 2px dashed #6e5738; padding: 8px; background: #151318; }
.shift-ticket span { color: var(--gold); font-weight: 900; }
.shift-ticket b { color: var(--paper); font-size: 10px; }
.miner-inspector dl { margin: 12px 0; }
.miner-inspector dl div { display: grid; grid-template-columns: 1fr minmax(0,1.25fr); gap: 9px; padding: 8px 0; border-bottom: 1px solid #4d4135; }
.miner-inspector dt { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.miner-inspector dd { margin: 0; overflow-wrap: anywhere; color: var(--paper); font-size: 10px; font-weight: 900; text-align: right; }
.inspector-links { display: grid; }
.inspector-links a { border: 3px solid #241b17; padding: 10px; background: var(--gold); box-shadow: 3px 3px 0 #09080c; color: #1b1710; font-size: 9px; font-weight: 900; text-align: center; text-decoration: none; text-transform: uppercase; }

footer { display: flex; align-items: end; justify-content: space-between; gap: 20px; border-top: 3px solid #09080c; padding: 24px clamp(14px,3vw,30px); background: #211a18; color: var(--dim); }
footer b { color: var(--paper); }
footer p { margin: 4px 0 0; font-size: 9px; }
footer > div:last-child { display: grid; gap: 3px; font-size: 8px; text-align: right; text-transform: uppercase; }
.noscript { padding: 16px; background: var(--red); color: #fff; text-align: center; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes dig-loader { to { height: 7px; transform: translateY(10px); } }

@media (max-width: 980px) {
  .mine-heading { grid-template-columns: 1fr; }
  .headline-stats { max-width: 620px; }
  .mine-toolbar { grid-template-columns: 1fr auto; }
  .crew-filters { grid-column: 1/-1; }
  .mine-ledger { grid-template-columns: repeat(3,1fr); }
  .mine-ledger > div { border-bottom: 2px solid #09080c; }
}

@media (max-width: 650px) {
  .site-header { align-items: flex-start; flex-wrap: wrap; }
  .brand { width: 100%; }
  .header-links { justify-content: flex-start; }
  .network-chip { display: none; }
  .mine-heading { margin-top: 8px; }
  .headline-stats { grid-template-columns: 1fr; }
  .headline-stats div { min-height: 62px; }
  .mine-marquee { align-items: flex-start; flex-direction: column; }
  .snapshot { width: 100%; }
  .mine-toolbar { grid-template-columns: 1fr; }
  .crew-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .crew-filter { min-width: 0; padding-inline: 6px; }
  .miner-finder { grid-template-columns: minmax(0,1fr) auto; }
  .refresh-button { width: 100%; }
  .mine-window { height: 62vh; min-height: 430px; }
  .mine-ledger { grid-template-columns: 1fr 1fr; }
  .miner-inspector { right: 13px; bottom: 13px; }
  footer { align-items: flex-start; flex-direction: column; }
  footer > div:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
