:root {
  --bg: #050510;
  --panel: #10102a;
  --line: #3a3aa0;
  --green: #4cff7c;
  --gold: #ffd24a;
  --text: #e8e8ff;
  --muted: #8f8fc0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  background: radial-gradient(ellipse at 50% 0%, #1a1a52 0%, var(--bg) 60%) fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
#app { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 8px 16px; min-height: 100%; }
#topbar { width: 100%; max-width: 820px; display: flex; justify-content: space-between; align-items: center; }
h1 { margin: 0; font-size: clamp(16px, 4vw, 24px); letter-spacing: 2px; text-transform: uppercase; color: var(--green); text-shadow: 0 0 10px #0a5; }
button {
  font: inherit; color: var(--text); background: #1c1c52; border: 2px solid var(--line); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; touch-action: manipulation;
}
button:hover, button:focus-visible { border-color: var(--green); outline: none; }
button:active { transform: translateY(1px); }
button.ghost { background: transparent; }
button.on { background: var(--line); }
#stage { position: relative; line-height: 0; }
#screen {
  image-rendering: pixelated; image-rendering: crisp-edges; background: #000;
  border: 3px solid var(--line); border-radius: 4px; box-shadow: 0 0 30px #20208a88;
  touch-action: none; user-select: none; cursor: pointer;
}
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--green); line-height: 1.4; }
#hud { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 820px; width: 100%; }
#hud div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; text-align: center; min-width: 64px; }
#hud span { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
#hud b { font-size: 15px; color: var(--gold); }
#hud b.lives { color: #ff6b8b; letter-spacing: 2px; }
#controls { display: flex; gap: 10px; }
#controls button { min-width: 84px; font-weight: bold; }
#hint { margin: 0; max-width: 640px; text-align: center; font-size: 12px; color: var(--muted); }

.panel {
  position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 380px); max-height: 88vh; overflow: auto;
  background: var(--panel); border: 2px solid var(--green); border-radius: 10px; padding: 16px;
  box-shadow: 0 0 0 100vmax #000a, 0 0 40px #0a5a;
  display: flex; flex-direction: column; gap: 8px;
}
.panel.wide { width: min(94vw, 560px); }
.panel.modal { z-index: 20; }
.panel h2 { margin: 0 0 4px; font-size: 18px; color: var(--green); text-transform: uppercase; letter-spacing: 1px; }
.panel p { margin: 0; line-height: 1.45; }
.prose { white-space: pre-wrap; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; padding: 6px; }
ol { list-style: none; padding: 0; margin: 0; }
ol li { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px dashed #2c2c70; }
ol li b { color: var(--gold); }
input { font: inherit; padding: 10px; border-radius: 6px; border: 2px solid var(--line); background: #000; color: var(--text); }
@media (max-width: 480px) {
  #hud div { min-width: 56px; padding: 3px 6px; }
  #hint { display: none; }
}
