:root {
  --bg: #120d0b;
  --panel: #1d1612;
  --line: #3a2a20;
  --text: #e9dccf;
  --muted: #a8968a;
  --accent: #e8521c;
  --accent-2: #f2a03d;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header, main { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 20px; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0.02em; }
h1 span { color: var(--accent); }
h2 { font-size: 18px; margin: 0 0 8px; }
h2 small { color: var(--muted); font-weight: 400; }
.tagline { margin: 4px 0 16px; color: var(--muted); }
a { color: var(--accent-2); }
code, kbd, pre, textarea { font-family: var(--mono); font-size: 13px; }
kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  background: var(--panel);
}

.screen-wrap { position: relative; }
#screen {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;          /* DOOM's 320×200 shown at 4:3, as on a CRT */
  image-rendering: pixelated;
  background: #000;
  border: 1px solid var(--line);
  outline: none;
  touch-action: none;
}
/* touch controls (src/touch.js): shown from the first touch, over the view */
.touch-pad { display: none; position: absolute; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; }
.screen-wrap.touch .touch-pad { display: block; }
.touch-pad button {
  pointer-events: auto; touch-action: none; position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 50%;
  background: rgba(0, 0, 0, 0.35); color: rgba(255, 255, 255, 0.8);
  font: 600 12px var(--mono); text-transform: uppercase;
}
.touch-pad button.down { background: rgba(255, 160, 60, 0.45); }
.touch-buttons .touch-fire { right: 4%; bottom: 8%; width: 76px; height: 76px; }
.touch-buttons .touch-jump { right: calc(4% + 84px); bottom: 5%; width: 58px; height: 58px; }
.touch-buttons .touch-weapon { right: 4%; bottom: calc(8% + 84px); width: 52px; height: 52px; font-size: 10px; }
.touch-buttons .touch-menu, .touch-buttons .touch-full { left: 8px; top: 8px; width: 48px; height: 32px; border-radius: 6px; font-size: 10px; }
.touch-buttons .touch-full { left: 64px; }
.screen-wrap:fullscreen { display: flex; align-items: center; justify-content: center; background: #000; }
.screen-wrap:fullscreen #screen { width: min(100vw, 100vh * 4 / 3); height: auto; border: 0; }
.touch-stick { position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.2); }
.touch-stick[hidden] { display: none; }
.touch-knob { position: absolute; left: 32px; top: 32px; width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
.touch-menupad { display: none; }
.touch-pad.menu-up .touch-buttons { display: none; }
.touch-pad.menu-up .touch-menupad { display: block; }
.touch-menupad button { width: 52px; height: 44px; border-radius: 8px; bottom: 4%; font-size: 16px; }
.touch-menupad [data-key="ArrowLeft"] { left: 4%; }
.touch-menupad [data-key="ArrowRight"] { left: calc(4% + 116px); }
.touch-menupad [data-key="ArrowUp"] { left: calc(4% + 58px); bottom: calc(4% + 50px); }
.touch-menupad [data-key="ArrowDown"] { left: calc(4% + 58px); }
.touch-menupad [data-key="Enter"] { right: calc(4% + 58px); width: 64px; }
.touch-menupad [data-key="Escape"] { right: 4%; bottom: calc(4% + 50px); }
.status {
  position: absolute;
  inset: auto 12px 12px 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.8);
  border-left: 3px solid var(--accent-2);
  font-family: var(--mono);
  font-size: 13px;
}
.status.error { border-left-color: #ff4040; color: #ffb0b0; }
.status[hidden] { display: none; }

.stats { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 6px 0; min-height: 1.5em; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 6px 0; }
.controls label { display: inline-flex; gap: 6px; align-items: center; }
.controls input[type=file] { max-width: 210px; color: var(--muted); }
select, button, textarea, input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.pill { font-family: var(--mono); font-size: 12px; color: var(--accent-2); }
.keys { color: var(--muted); font-size: 13px; }

section { margin: 24px 0; }
.console textarea { width: 100%; resize: vertical; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.run { margin: 6px 0; }
.out {
  background: #000;
  border: 1px solid var(--line);
  padding: 8px;
  max-height: 320px;
  overflow: auto;
  white-space: pre;
  margin: 0;
}
.about ul { padding-left: 20px; }
.about li { margin: 6px 0; }
