:root {
  color-scheme: dark;
  font-family: "Courier New", monospace;
  color: #d3dbe4;
  background: #000;
  --muted: #9aa8b8;
  --line: #334051;
  --accent: #e6bd77;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: #111926;
  border: 1px solid var(--line);
  padding: 10px 12px;
  -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
main {
  --controls-space: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 1132px;
  min-height: 100svh;
  margin: auto;
  padding: 16px;
}
main:fullscreen {
  --controls-space: 0px;
  max-width: none;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: auto;
  background: #000;
  padding: 0;
  gap: 0;
}
main:fullscreen .toolbar,
main:fullscreen .controls,
main:fullscreen .touch-controls { display: none; }
.screen {
  position: relative;
  width: min(100%, max(160px, (100dvh - var(--controls-space)) * 1.6));
  aspect-ratio: 8 / 5;
  flex-shrink: 0;
  background: #000;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  outline: 0;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  background: #0009;
}
.overlay h1 { font-size: clamp(20px, 4vw, 36px); margin: 0 0 20px; }
#launch { color: #171611; background: var(--accent); border-color: var(--accent); }
.run-overlay { background: transparent; padding: 0; pointer-events: none; }
.run-overlay h1,
.run-overlay #continue-count {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.run-overlay #launch {
  position: absolute;
  top: 31%;
  left: 12%;
  width: 76%;
  height: 42%;
  color: transparent;
  border-color: transparent;
  background: transparent;
  pointer-events: auto;
  touch-action: manipulation;
}
main[data-status="ready"] .run-overlay #launch { inset: 0; width: 100%; height: 100%; }
#load-error { max-width: 420px; font-size: 13px; line-height: 1.6; color: #ff947d; }
#cheat-status {
  position: absolute;
  top: 4%;
  right: 2%;
  z-index: 1;
  max-width: 96%;
  margin: 0;
  padding: 4px 6px;
  color: var(--accent);
  background: #000d;
  font-size: clamp(8px, 1.2vw, 12px);
  pointer-events: none;
}
.toolbar { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.toolbar button { font-size: 11px; }
main[data-status="score-entry"] :is(.toolbar, .controls, .touch-controls) { display: none; }
main[data-status="score-entry"]:not(:fullscreen) { --controls-space: 32px; }
.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}
.controls > span { max-width: 100%; }
kbd { color: #d3dbe4; font: inherit; }
.touch-controls { display: none; }
:is(.shop-panel, .menu-panel, .score-panel) {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
:is(.shop-panel, .menu-panel, .score-panel) button {
  position: absolute;
  pointer-events: auto;
  border: 0;
  padding: 0;
  background: transparent;
  touch-action: manipulation;
}
:is(.shop-panel, .menu-panel, .score-panel) button:hover:not(:disabled) { background: transparent; }
:is(.shop-panel, .menu-panel, .score-panel) button:focus-visible { outline-offset: -2px; }
.score-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.score-panel button { position: static; }
.menu-choice { left: 0; width: 100%; height: 11%; }
.menu-choice:nth-child(1) { top: 30%; }
.menu-choice:nth-child(2) { top: 42%; }
.menu-choice:nth-child(3) { top: 54%; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 600px) {
  main { --controls-space: 190px; padding: 8px; }
  .toolbar { gap: 6px; }
  .toolbar button { font-size: 10px; padding: 10px; }
  .controls { gap: 6px 14px; font-size: 10px; }
}
@media (pointer: coarse) {
  main { --controls-space: 240px; }
  .touch-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 10px; font-size: 11px; color: var(--muted); }
  .touch-controls button { min-height: 44px; font-size: 11px; touch-action: none; }
  .toolbar button { min-height: 44px; }
  main:fullscreen { --controls-space: 56px; }
  main:fullscreen[data-status="score-entry"] { --controls-space: 0px; }
  main:fullscreen:not([data-status="score-entry"]) .touch-controls { display: flex; }
  main:fullscreen .touch-controls span,
  main:fullscreen:not([data-status="playing"]) :is(#touch-dive, #touch-fire) { display: none; }
}
