:root {
  color-scheme: dark;
  --ink: #15141f;
  --ink-soft: #242235;
  --cave: #100c0a;
  --dirt: #5b3b28;
  --dirt-dark: #35241d;
  --timber: #7b5032;
  --timber-light: #ad7548;
  --paper: #e8d8a5;
  --paper-dark: #c4aa70;
  --text: #f5ecd0;
  --dim: #c5b993;
  --gold: #f6c744;
  --green: #64c466;
  --red: #dc4f45;
  --blue: #5aa9d6;
  --shadow: 5px 5px 0 #09080c;
  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;
}
body[data-busy="true"] { cursor: progress; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button, .header-links a {
  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;
  letter-spacing: .02em;
  transition: filter 100ms linear, transform 100ms linear, box-shadow 100ms linear;
}
button:hover:not(:disabled), .header-links a:hover { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translate(3px,3px); box-shadow: none; }
button:disabled { cursor: not-allowed; filter: grayscale(.5); opacity: .48; }
button.ghost { border-color: #4b4560; background: var(--ink-soft); color: var(--text); }
:focus-visible { outline: 3px solid #fff8ca; outline-offset: 3px; }
.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; }

.topbar { position: relative; z-index: 30; display: flex; align-items: center; gap: 14px; 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 { display: inline-flex; align-items: center; border-color: #4b4560; background: var(--ink-soft); color: var(--text); font-size: 9px; text-decoration: none; text-transform: uppercase; }
.wallet-button { min-width: 138px; }
.network-strip { display: flex; justify-content: space-between; gap: 12px; padding: 8px clamp(12px,3vw,28px); border-bottom: 3px solid #09080c; background: #2d211b; color: var(--dim); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.network-strip span { display: inline-flex; align-items: center; gap: 7px; }
.network-strip i { width: 8px; height: 8px; background: var(--green); }
body[data-wallet-state="wrong-chain"] .network-strip i { background: var(--red); animation: blink .8s steps(1) infinite; }

main { width: min(1440px,100%); margin: 0 auto; padding: clamp(16px,2.5vw,30px); }
.eyebrow { 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; }
.shaft-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: end; margin-bottom: 18px; }
h1 { max-width: 850px; margin: 0; color: var(--paper); font-size: clamp(30px,5vw,58px); line-height: .96; letter-spacing: .02em; text-transform: uppercase; }
.intro { max-width: 820px; margin: 13px 0 0; color: var(--dim); font-size: 12px; }
.headline-stats { display: grid; grid-template-columns: repeat(2,minmax(145px,1fr)); gap: 8px; margin: 0; }
.headline-stats div { min-height: 74px; 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: clamp(14px,2vw,19px); font-weight: 900; }

.shaft-machine, .nft-pot, .shaft-ledger, .truth-board { border: 4px solid #09080c; background: #211d27; box-shadow: var(--shadow); }
.shaft-machine { margin-bottom: 20px; }
.machine-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; padding: 12px 15px; border-bottom: 3px solid #09080c; background: #30261f; }
.machine-top h2, .section-heading h2, .truth-board h2 { margin: 0; color: var(--paper); font-size: clamp(17px,2.5vw,24px); letter-spacing: .07em; text-transform: uppercase; }
.machine-status { 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; }
.machine-status i { width: 8px; height: 8px; background: var(--gold); animation: blink .8s steps(1) infinite; }
.machine-status[data-state="ready"] { border-color: #315f36; color: #9fd7a8; }
.machine-status[data-state="ready"] i { background: var(--green); animation: none; }
.machine-status[data-state="danger"] { border-color: #6f201e; color: #ffb6ae; }
.machine-status[data-state="danger"] i { background: var(--red); }

.shaft-layout { display: grid; grid-template-columns: minmax(0,1fr) 370px; min-height: 650px; }
.shaft-window { position: relative; min-width: 0; overflow: hidden; border-right: 4px solid #09080c; background: var(--cave); }
#shaftCanvas { display: block; width: 100%; height: 650px; image-rendering: pixelated; image-rendering: crisp-edges; }
.depth-gauge, .block-gauge { position: absolute; z-index: 4; top: 12px; border: 2px solid #09080c; padding: 8px; background: rgba(21,19,24,.88); box-shadow: 3px 3px 0 #050407; }
.depth-gauge { left: 12px; width: 125px; }
.block-gauge { right: 12px; text-align: right; }
.depth-gauge span, .block-gauge span { display: block; color: var(--dim); font-size: 7px; letter-spacing: .1em; }
.depth-gauge b, .block-gauge b { display: block; margin-top: 3px; color: var(--gold); font-size: 11px; }
.depth-gauge > div { height: 7px; margin-top: 6px; border: 1px solid #5b4e3d; background: #0d0b0e; }
.depth-gauge i { display: block; width: 0; height: 100%; background: var(--gold); transition: width .4s linear; }
.scene-copy { position: absolute; z-index: 4; right: 16px; bottom: 16px; left: 16px; border: 3px solid #09080c; padding: 12px 14px; background: rgba(33,29,39,.94); box-shadow: 5px 5px 0 #050407; }
.scene-copy p { margin-bottom: 2px; color: var(--gold); font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.scene-copy h3 { margin: 0; color: var(--paper); font-size: clamp(16px,2.3vw,23px); text-transform: uppercase; }
.scene-copy span { display: block; margin-top: 4px; color: var(--dim); font-size: 9px; }
body[data-scene-state="win"] .scene-copy { border-color: var(--gold); }
body[data-scene-state="loss"] .scene-copy { border-color: #4b4560; }

.control-house { padding: 17px; background: #24212b; }
.control-house > h2 { margin: 0 0 14px; color: var(--paper); font-size: 22px; text-transform: uppercase; }
.wallet-ledger { border: 3px solid #09080c; background: #151318; }
.wallet-ledger div { display: grid; grid-template-columns: 1fr minmax(0,1.3fr); gap: 10px; padding: 9px; border-bottom: 1px solid #4d4135; }
.wallet-ledger div:last-child { border-bottom: 0; }
.wallet-ledger span { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.wallet-ledger b { overflow-wrap: anywhere; color: var(--paper); font-size: 9px; text-align: right; }
.attempt-ticket, .entry-ticket { position: relative; margin-top: 13px; border: 3px dashed #6e5738; padding: 13px; background: var(--paper); color: #302419; }
.attempt-ticket p { margin: 0; font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.attempt-ticket h3 { margin: 2px 0 10px; font-size: 20px; }
.attempt-ticket dl { margin: 0; }
.attempt-ticket dl div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(48,36,25,.25); }
.attempt-ticket dt { font-size: 8px; text-transform: uppercase; }
.attempt-ticket dd { margin: 0; font-size: 9px; font-weight: 900; }
.attempt-ticket[data-phase="venturing"] #blocksRemaining { color: #9c2f29; font-size: 14px; letter-spacing: .08em; animation: timer-pulse 1s steps(2) infinite; }
.ticket-tear { position: absolute; inset: -3px auto -3px -3px; width: 7px; background: repeating-linear-gradient(180deg,#09080c 0 5px,transparent 5px 10px); }
.entry-ticket { text-align: center; }
.entry-ticket .ticket-label { display: block; font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.entry-ticket b { display: block; margin: 5px 0; font-size: 21px; }
.entry-ticket small { display: block; font-size: 8px; }
.primary-action { width: 100%; min-height: 55px; margin-top: 13px; font-size: 13px; text-transform: uppercase; }
.control-house > .ghost { width: 100%; margin-top: 8px; }
.action-note { margin: 11px 0 0; color: var(--dim); font-size: 8px; text-align: center; }

.nft-pot { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(320px,.8fr); margin-bottom: 20px; overflow: hidden; }
.nft-pot > img { display: block; width: 100%; height: 100%; min-height: 310px; object-fit: cover; image-rendering: pixelated; border-right: 4px solid #09080c; }
.nft-pot > div { padding: clamp(18px,3vw,32px); background: #29242f; }
.nft-pot h2 { margin: 0; color: var(--paper); font-size: clamp(25px,4vw,42px); line-height: 1; text-transform: uppercase; }
.nft-pot p:not(.eyebrow) { margin: 15px 0; color: var(--dim); font-size: 11px; }
.nft-pot p b { color: var(--gold); }
.nft-pot dl { display: grid; grid-template-columns: repeat(3,1fr); margin: 0 0 16px; border: 3px solid #09080c; }
.nft-pot dl div { padding: 10px; border-right: 2px solid #09080c; background: #17151c; }
.nft-pot dl div:last-child { border-right: 0; }
.nft-pot dt { color: var(--dim); font-size: 7px; text-transform: uppercase; }
.nft-pot dd { margin: 4px 0 0; color: var(--paper); font-size: 11px; font-weight: 900; }
.nft-pot a { color: var(--gold); font-size: 9px; font-weight: 900; text-transform: uppercase; }

.shaft-ledger { margin-bottom: 20px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 13px 15px; border-bottom: 3px solid #09080c; background: #30261f; }
.section-heading > span { color: var(--dim); font-size: 8px; text-transform: uppercase; }
.ledger-grid { display: grid; grid-template-columns: repeat(4,1fr); }
.ledger-grid article { display: flex; align-items: center; gap: 10px; min-height: 86px; padding: 13px; border-right: 2px solid #09080c; background: #29242f; }
.ledger-grid article:last-child { border-right: 0; }
.ledger-grid article > span { color: var(--gold); font-size: 25px; }
.ledger-grid small, .ledger-grid b { display: block; }
.ledger-grid small { color: var(--dim); font-size: 7px; text-transform: uppercase; }
.ledger-grid b { margin-top: 3px; color: var(--paper); font-size: 17px; }
.history-panel { border-top: 3px solid #09080c; padding: 13px; background: #19171d; }
.history-heading { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.history-heading h3 { margin: 0; color: var(--paper); font-size: 13px; text-transform: uppercase; }
.history-heading span { color: var(--dim); font-size: 8px; }
.history-list { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 10px; }
.history-ticket { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; border: 2px solid #4d4135; padding: 9px; background: #24212b; }
.history-ticket > span { color: var(--gold); font-size: 18px; }
.history-ticket b, .history-ticket small { display: block; }
.history-ticket b { color: var(--paper); font-size: 9px; }
.history-ticket small { margin-top: 2px; color: var(--dim); font-size: 7px; }
.history-ticket button, .history-ticket a { min-height: 34px; padding: 5px 7px; font-size: 8px; text-decoration: none; }
.history-ticket a { color: var(--gold); font-weight: 900; }
.history-empty { grid-column: 1/-1; padding: 16px; color: var(--dim); font-size: 9px; text-align: center; }

.truth-board { padding: 17px; }
.truth-board > div { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 13px; }
.truth-board article { border: 2px solid #4d4135; padding: 11px; background: #29242f; }
.truth-board article b { color: var(--paper); font-size: 9px; text-transform: uppercase; }
.truth-board article p { margin: 5px 0 0; color: var(--dim); font-size: 8px; }
.randomness-note { margin: 12px 0 0; border-left: 4px solid var(--red); padding: 9px 11px; background: #2c1d1d; color: #f2c6b7; font-size: 8px; }

.result-overlay { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(7,6,10,.86); }
.result-card { width: min(480px,100%); border: 4px solid #09080c; padding: 24px; background: #211d27; box-shadow: 9px 9px 0 #050407; text-align: center; }
.result-card[data-result="win"] { border-color: var(--gold); background: #352e20; }
.result-mark { display: grid; width: 90px; height: 90px; place-items: center; margin: 0 auto 14px; border: 4px solid #09080c; background: var(--paper); box-shadow: 5px 5px 0 #09080c; color: #211812; font-size: 44px; }
.result-card[data-result="win"] .result-mark { background: var(--gold); animation: jackpot .65s steps(2) infinite alternate; }
.result-card h2 { margin: 0; color: var(--paper); font-size: clamp(24px,5vw,37px); text-transform: uppercase; }
.result-card > p:not(.eyebrow) { margin: 9px 0 15px; color: var(--dim); font-size: 10px; }
.result-card a { display: block; margin-bottom: 13px; color: var(--gold); font-size: 9px; font-weight: 900; }
.result-card button { width: 100%; }

.toast-log { position: fixed; z-index: 300; right: 14px; bottom: 14px; display: grid; width: min(380px,calc(100vw - 28px)); gap: 7px; pointer-events: none; }
.toast { border: 3px solid #09080c; padding: 10px 12px; background: var(--paper); box-shadow: 4px 4px 0 #09080c; color: #211812; font-size: 9px; font-weight: 900; }
.toast.error { background: var(--red); color: white; }
footer { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-top: 30px; 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: 4px; font-size: 8px; text-align: right; text-transform: uppercase; }
footer a { color: var(--gold); }
.noscript { padding: 16px; background: var(--red); color: white; text-align: center; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes jackpot { to { transform: translateY(-5px) rotate(2deg); box-shadow: 8px 10px 0 #09080c,0 0 35px rgba(246,199,68,.45); } }
@keyframes timer-pulse { 50% { color: #d09119; } }

@media (max-width: 1080px) {
  .shaft-heading { grid-template-columns: 1fr; }
  .headline-stats { max-width: 660px; grid-template-columns: repeat(4,1fr); }
  .shaft-layout { grid-template-columns: minmax(0,1fr) 330px; }
  .ledger-grid { grid-template-columns: repeat(2,1fr); }
  .ledger-grid article:nth-child(2) { border-right: 0; }
  .ledger-grid article:nth-child(-n+2) { border-bottom: 2px solid #09080c; }
  .truth-board > div { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; }
  .brand { width: 100%; }
  .header-links { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4,1fr); }
  .header-links a { justify-content: center; padding-inline: 4px; }
  .wallet-button { position: absolute; top: 10px; right: 12px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .headline-stats { grid-template-columns: repeat(2,1fr); }
  .shaft-layout { grid-template-columns: 1fr; }
  .shaft-window { border-right: 0; border-bottom: 4px solid #09080c; }
  #shaftCanvas { height: 560px; }
  .control-house { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .control-house > .eyebrow, .control-house > h2, .wallet-ledger, .attempt-ticket, .entry-ticket, .action-note { grid-column: 1/-1; margin-top: 0; }
  .primary-action, .control-house > .ghost { margin-top: 0; }
  .history-list { grid-template-columns: repeat(2,1fr); }
  .nft-pot { grid-template-columns: 1fr; }
  .nft-pot > img { min-height: 260px; border-right: 0; border-bottom: 4px solid #09080c; }
}

@media (max-width: 520px) {
  .network-strip { align-items: flex-start; flex-direction: column; }
  .headline-stats { grid-template-columns: 1fr; }
  .headline-stats div { min-height: 60px; }
  .nft-pot dl { grid-template-columns: 1fr; }
  .nft-pot dl div { border-right: 0; border-bottom: 2px solid #09080c; }
  .nft-pot dl div:last-child { border-bottom: 0; }
  .shaft-machine, .nft-pot, .shaft-ledger, .truth-board { border-width: 3px; }
  .machine-top, .section-heading { align-items: flex-start; flex-direction: column; }
  .machine-status { width: 100%; }
  #shaftCanvas { height: 510px; }
  .depth-gauge { width: 108px; }
  .block-gauge { max-width: 160px; }
  .scene-copy { right: 9px; bottom: 9px; left: 9px; }
  .control-house { grid-template-columns: 1fr; }
  .control-house > * { grid-column: 1 !important; }
  .ledger-grid { grid-template-columns: 1fr; }
  .ledger-grid article { border-right: 0; border-bottom: 2px solid #09080c; }
  .ledger-grid article:last-child { border-bottom: 0; }
  .history-list { grid-template-columns: 1fr; }
  .truth-board > div { grid-template-columns: 1fr; }
  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; }
}
