:root {
  color-scheme: dark;
  --ink: #080b08;
  --panel: #121711;
  --line: #344034;
  --bone: #f2eddf;
  --dim: #90988b;
  --gold: #e3aa35;
  --green: #69d46d;
  --red: #ef5b55;
  --diamond: #8ed7e6;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--bone); background: var(--ink); font-family: "Courier New", ui-monospace, monospace; background-image: radial-gradient(circle at 50% 10%, rgba(142,215,230,.08), transparent 38%), repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.012) 3px 4px); }
button, a { font: inherit; }
button { cursor: pointer; }
.cabinet { width: min(1180px, 100%); min-height: 100vh; margin: auto; padding: clamp(12px, 2vw, 24px); display: grid; align-content: center; gap: 12px; }
.cabinet__head, .cabinet__foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.back { color: var(--dim); text-decoration: none; text-transform: uppercase; font-size: 12px; letter-spacing: .12em; }
.back:hover { color: var(--gold); }
.brand { display: grid; justify-items: center; line-height: 1; }
.brand span { color: var(--diamond); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.brand strong { margin-top: 5px; font-size: clamp(19px, 3vw, 28px); text-transform: uppercase; letter-spacing: -.04em; }
.head-actions { display: flex; gap: 7px; }
.head-actions button { border: 1px solid var(--line); border-radius: 3px; padding: 7px 9px; color: var(--dim); background: var(--panel); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.head-actions button:hover, .head-actions button:focus-visible { color: var(--bone); border-color: var(--gold); }

.screen { position: relative; overflow: hidden; isolation: isolate; aspect-ratio: 16 / 9; border: 2px solid #3b493a; border-radius: 8px; background: #071008; box-shadow: 0 0 0 6px #151c14, 0 20px 70px rgba(0,0,0,.58), inset 0 0 70px rgba(0,0,0,.6); }
.screen::after { content: ""; position: absolute; inset: 0; z-index: 7; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.025) 3px 4px); mix-blend-mode: screen; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }

.hud { position: absolute; inset: 10px 14px auto; z-index: 3; display: grid; grid-template-columns: repeat(3, auto) minmax(170px, 1fr); align-items: start; gap: 22px; pointer-events: none; text-shadow: 2px 2px #000; }
.hud > div:not(.stability) { display: grid; gap: 2px; }
.hud span { color: var(--dim); font-size: clamp(8px, 1.2vw, 11px); text-transform: uppercase; letter-spacing: .13em; }
.hud strong { color: var(--bone); font-size: clamp(13px, 2vw, 20px); letter-spacing: .08em; }
.stability { display: grid; gap: 4px; justify-items: end; }
.stability > div { width: min(33vw, 300px); height: 14px; padding: 2px; border: 1px solid #5b6858; background: #151011; }
.stability i { display: block; width: 100%; height: 100%; background: var(--green); transform-origin: left; transition: transform 90ms linear, background 140ms ease; }

.overlay { position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; background: rgba(3,7,4,.8); backdrop-filter: blur(2px); }
.overlay[hidden] { display: none; }
.eyebrow { margin: 0; color: var(--diamond); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.overlay h1 { margin: 0; font-size: clamp(38px, 8vw, 80px); line-height: .9; text-transform: uppercase; letter-spacing: -.08em; text-shadow: 5px 5px #193b34; }
.overlay > p:not(.eyebrow):not(.keys) { max-width: 58ch; margin: 0; color: #bdc5b8; font-size: clamp(11px, 1.7vw, 15px); line-height: 1.55; }
.start { min-width: 180px; padding: 12px 18px; border: 2px solid #f1cb6d; border-radius: 3px; color: #171006; background: var(--gold); box-shadow: 4px 4px 0 #6f4a0b; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.start:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #6f4a0b; }
.keys { margin: 0; color: var(--dim); font-size: 10px; text-transform: uppercase; }
kbd { margin: 0 2px; padding: 2px 5px; border: 1px solid #52604f; border-bottom-width: 2px; border-radius: 2px; color: var(--bone); background: #121812; }

.hold { position: absolute; right: 18px; bottom: 18px; z-index: 5; width: 86px; height: 86px; border: 3px solid rgba(242,237,223,.72); border-radius: 50%; color: #171006; background: rgba(227,170,53,.88); box-shadow: 0 0 0 5px rgba(227,170,53,.1); font-weight: 900; text-transform: uppercase; touch-action: none; }
.hold:active, .hold.is-held { transform: scale(.94); color: #071008; background: var(--diamond); box-shadow: 0 0 22px rgba(142,215,230,.45); }
.cabinet__foot { color: var(--dim); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.cabinet__foot p { margin: 0; }
.status { white-space: nowrap; }
.status i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (pointer: coarse), (max-width: 760px) {
  .cabinet { align-content: start; padding: 10px; }
  .cabinet__head { flex-wrap: wrap; }
  .brand { order: -1; width: 100%; }
  .screen { aspect-ratio: 27 / 43; }
  .keys { display: none; }
  .hold { width: 80px; height: 80px; right: 16px; bottom: 16px; }
  .cabinet__foot { display: block; line-height: 1.5; }
  .status { margin-top: 4px !important; }
  .hud { grid-template-columns: repeat(3, auto); gap: 12px; }
  .stability { grid-column: 1 / -1; justify-items: stretch; }
  .stability > div { width: 100%; height: 11px; }
}

@media (prefers-reduced-motion: reduce) { .screen::after { display: none; } }
