:root {
  color-scheme: dark;
  --paper: #e3dac4;
  --amber: #ffc348;
  --dark-steel: #272825;
  --mono: "Lucida Console", Monaco, monospace;
  --steel: linear-gradient(180deg, #dadad0 0%, #c0c1b5 47%, #a3a59a 50%, #c8c9bc 100%);
  --grain: none;
  font-family: var(--mono);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background: radial-gradient(ellipse at 50% 40%, #35302b 0%, #191817 56%, #100f0f 100%);
}
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, canvas:focus-visible { outline: 2px solid #ffda73; outline-offset: 2px; }
.cabinet {
  position: relative;
  width: min(1130px, calc(100% - 44px));
  margin: clamp(18px, 5vh, 58px) auto;
  padding: 15px 20px 21px;
  border: 3px outset #7e7d72;
  background:
    var(--grain),
    repeating-linear-gradient(90deg, #141412 0 2px, #79796f 2px 3px, transparent 3px 113px),
    repeating-linear-gradient(0deg, #141412 0 2px, #74746a 2px 3px, transparent 3px 58px),
    linear-gradient(125deg, #6e6e62, #505049 32%, #383934 90%);
  box-shadow: inset 0 0 40px #000c, 0 0 0 2px #141410, 0 18px 55px #000c;
}
.cabinet::before,
.cabinet::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 11px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(150deg, transparent 44%, #151512 45% 56%, transparent 57%), linear-gradient(#9b9b8b, #3e403b);
  box-shadow: inset 0 0 0 1px #c0bba1, 1px 2px 2px #111;
  pointer-events: none;
}
.cabinet::after { inset: auto 3px 4px auto; }
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px 10px;
  border: 2px solid;
  border-color: #161713 #73746b #919184 #151613;
  background: var(--grain), linear-gradient(#20211e, #34352f);
  box-shadow: inset 0 2px 7px #000b;
  margin: 0 0 12px;
}
h1 {
  margin: 0 0 0 4px;
  padding: .055em .19em .07em .025em;
  font: 950 italic clamp(24px, 5.4vw, 64px)/1.04 "Arial Black", Impact, sans-serif;
  letter-spacing: -.065em;
  color: #ffe096;
  background: linear-gradient(#fff0b4 15%, #f9bc44 49%, #e98712 51%, #fbd071 86%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(1px 1px 0 #792d0e) drop-shadow(1px 2px 0 #48210e) drop-shadow(1px 2px 0 #13130e);
}
h1 span { letter-spacing: -.07em; }
.top-actions { display: flex; gap: 7px; }
.top-actions button, #rotate, #primary {
  border: 2px outset #a2a194;
  border-radius: 1px;
  padding: 6px 9px;
  background: var(--steel);
  box-shadow: 1px 2px 1px #12120f;
  color: #10110e;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
.top-actions button:disabled, #rotate:disabled {
  opacity: 1;
  color: #383a32;
  border-color: #6a6c61;
  background: #a5a69b;
  box-shadow: none;
}
.top-actions button:hover:not(:disabled), #rotate:hover:not(:disabled) { filter: brightness(1.2); }
.top-actions button:active:not(:disabled), #rotate:active:not(:disabled), #primary:active { border-style: inset; }
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 206px;
  gap: 7px;
  padding: 6px;
  border: 3px inset #898a7c;
  background: var(--grain), #1c1d19;
}
.stage { min-width: 0; }
.stage-top, .stage-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid #46483c;
  background: var(--grain), linear-gradient(#171915, #282a22);
  font: bold 11px/1.3 var(--mono);
  color: #d6c9a5;
}
.stage-top { letter-spacing: .095em; }
#mode-label { color: var(--amber); }
.stage-bottom { min-height: 38px; }
#rotate span { padding-left: 2px; }
.screen {
  position: relative;
  overflow: hidden;
  border: 3px solid;
  border-color: #88897e #3d3e35 #3d3e35 #88897e;
  outline: 1px solid #090907;
  outline-offset: -4px;
}
canvas { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; background: #351b14; touch-action: manipulation; cursor: crosshair; }
canvas:focus-visible { outline-offset: -4px; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 7px; background: #150e09a6; }
.overlay[hidden] { display: none; }
.prompt {
  width: min(100%, 374px);
  padding: clamp(10px, 2.5vw, 26px);
  text-align: center;
  border: 4px ridge #8d8d7e;
  background: var(--grain), linear-gradient(#3a3a30, #272822);
  box-shadow: 4px 5px 0 #110d08bc, inset 0 0 10px #171610;
}
.prompt h2 { margin: 0; color: #ffd06a; text-shadow: 2px 2px #271307; text-transform: uppercase; font: 950 clamp(19px, 3.1vw, 32px)/1 Impact, "Arial Narrow", sans-serif; letter-spacing: .035em; }
.prompt p { margin: 11px auto 15px; color: #f1e7ca; font-size: 13px; line-height: 1.45; }
#primary { border-color: #e9b45a; background: linear-gradient(#ffdf78, #cd8d2c); padding: 7px 13px; }
#primary:hover { filter: brightness(1.16); }
#primary span { padding-left: 4px; }
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 2px outset #66665c;
  background: var(--grain), repeating-linear-gradient(0deg, #151511 0 2px, #45463e 2px 28px);
  box-shadow: inset 0 0 14px #1c1c18;
}
.panel { background: var(--grain), #33342e; border: 2px groove #86867a; padding: 7px; }
.label, .help h2 {
  color: #eeead4;
  font: bold 10px/1.4 var(--mono);
  letter-spacing: .14em;
}
.vitals { display: grid; gap: 6px; }
.vitals .label {
  position: relative;
  padding: 3px 7px 3px 19px;
  background: var(--steel);
  color: #10120d;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid #dadbd0;
  border-bottom-color: #62665a;
}
.vitals .label::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  width: 8px;
  aspect-ratio: 1;
  transform: translateY(-50%);
  border-radius: 50%;
  background: linear-gradient(140deg, #a5a797 44%, #2f3129 45% 57%, #6f7164 58%);
  box-shadow: 0 0 0 1px #55574d;
}
.digits, .lives, .reading {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 3px 6px;
  border: 2px inset #595b50;
  background: repeating-linear-gradient(0deg, #171710 0 1px, #090a06 1px 3px);
}
.digits {
  font: 900 28px/.95 var(--mono);
  letter-spacing: .02em;
  color: #ff674c;
  text-shadow: 2px 2px #662219;
}
.digits.muted { font-size: 21px; color: #e4ad64; text-shadow: 1px 2px #49301a; }
.lives { gap: 8px; color: #ff674c; font: bold 17px/1 var(--mono); text-shadow: 1px 2px #662219; }
#life-count { min-width: 2ch; text-align: right; }
.reading { margin: 3px 0 7px; align-items: baseline; justify-content: space-between; gap: 4px; }
#claimed { color: #d5f17c; text-shadow: 1px 1px #3d5b25; font: 900 24px/.95 var(--mono); }
#target { color: #eee4be; font-size: 12px; white-space: nowrap; }
.meter { height: 9px; border: 1px solid #777965; background: #171812; position: relative; }
#fill { background: repeating-linear-gradient(90deg, #d6ee69 0 5px, #94ab4c 5px 6px); height: 100%; width: 0; }
#threshold { position: absolute; width: 2px; top: -2px; bottom: -2px; background: #f6e7a8; }
.help { margin-top: auto; }
.help h2 { margin: 0 0 4px; }
.help > div { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 4px; font-size: 10px; }
.help > p { display: none; margin: 0; font-size: 11px; line-height: 1.45; }
kbd { display: inline-block; padding: 1px 3px; border: 1px outset #727463; color: #ffdd8f; background: #24251d; font: 9px var(--mono); white-space: nowrap; }
@media (max-width: 810px) {
  .game { grid-template-columns: 1fr; }
  .dashboard { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .vitals { grid-row: span 2; }
  .help { margin-top: 0; grid-column: 1 / -1; }
}
@media (max-width: 510px) {
  .cabinet { width: calc(100% - 16px); margin: 10px auto; padding: 8px; }
  .masthead { margin-bottom: 7px; padding: 5px 6px; gap: 6px; }
  h1 { margin-left: 0; }
  .top-actions { gap: 4px; }
  .top-actions button, #rotate { padding: 5px; font-size: 10px; }
  .game { padding: 3px; gap: 4px; }
  .stage-top, .stage-bottom { padding: 3px 4px; font-size: 9px; min-height: 24px; }
  .stage-bottom { min-height: 31px; }
  .dashboard { padding: 4px; gap: 4px; }
  .panel { padding: 5px; }
  .prompt p { font-size: 11px; margin: 6px auto 8px; }
  #primary { padding: 5px 8px; font-size: 11px; }
  .digits { font-size: 22px; }
  .digits.muted { font-size: 18px; }
}
@media (max-width: 380px) {
  .top-actions button { font-size: 9px; }
}
@media (pointer: coarse) {
  .help > div { display: none; }
  .help > p { display: block; }
}

.score-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
#multiplier { color: #fff0a8; background: #332818; padding: 0 3px; text-shadow: none; letter-spacing: 0; }
#magnet-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px 5px;
  border: 2px outset #779087;
  background: linear-gradient(#486561, #293e3a);
  color: #e8f8ec;
  text-align: left;
  font-size: 11px;
}
#magnet-button[aria-pressed="true"] { border-style: inset; background: #315e58; color: #fff4b2; }
#magnet-count { color: #bfe8c2; }
.equipment details { margin-top: 6px; font-size: 10px; line-height: 1.5; }
.equipment summary { cursor: pointer; color: #f0d190; }
.equipment ul { margin: 6px 0 0; padding-left: 14px; }
.equipment li + li { margin-top: 3px; }
@media (pointer: coarse) { #magnet-button kbd { display: none; } }
