:root {
  color-scheme: dark;
  --black: #050607;
  --panel: #111416;
  --steel-0: #202427;
  --steel-1: #3f4549;
  --steel-2: #777d80;
  --steel-3: #b9bec0;
  --blue: #005c9e;
  --cyan: #00a7c7;
  --green: #24c856;
  --magenta: #d826c9;
  --red: #ef4e58;
  --yellow: #f2db45;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--black);
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -16%, rgba(0, 167, 199, 0.13), transparent 38rem),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.017) 0 1px, transparent 1px 6px),
    #050607;
  color: #d9dcdd;
  font-family: "Courier New", ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { border: 0; color: inherit; font: inherit; cursor: pointer; }

.app-shell { width: min(100%, 1080px); margin: 0 auto; padding: 18px 20px 28px; }

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto 12px;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: .28em;
  filter: drop-shadow(0 3px 0 #000);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(32px, 6vw, 58px);
  font-weight: 900;
  letter-spacing: .03em;
  line-height: .86;
}

.wordmark > span { color: var(--red); }
.wordmark > strong { color: var(--green); font-size: .72em; }
.wordmark small {
  margin-left: .45em;
  color: var(--steel-3);
  font-family: "Courier New", monospace;
  font-size: .18em;
  letter-spacing: .14em;
}

.toolbar { display: flex; gap: 8px; }
.toolbar-link { display: inline-flex; align-items: center; }
.toolbar button, .toolbar-link, .dialog-close {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--steel-2);
  border-radius: 3px;
  background: linear-gradient(#3e4447, #171a1c);
  box-shadow: inset 0 1px #aeb2b4, 0 2px 0 #000;
  color: var(--yellow);
  font: inherit;
  text-decoration: none;
}
.toolbar button:active, .toolbar-link:active, .dialog-close:active { transform: translateY(1px); box-shadow: inset 0 1px #111; }

.console {
  position: relative;
  padding: 10px 12px 12px;
  border: 1px solid #696f72;
  border-radius: 7px;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.075) 48%, transparent 52%),
    repeating-linear-gradient(0deg, #282d30 0 2px, #191d1f 2px 4px);
  box-shadow: inset 0 0 0 2px #0b0d0e, inset 0 0 0 4px #444a4d, 0 18px 55px #000;
}

.console-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1px 6px 8px;
  color: #c9cdcf;
  font-size: 10px;
  letter-spacing: .12em;
}
.console-label i { height: 2px; flex: 1; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green), var(--cyan), var(--magenta)); }

.screen-bezel {
  padding: clamp(8px, 1.6vw, 15px);
  border: 2px solid #090b0c;
  border-radius: 5px;
  background: linear-gradient(145deg, #747a7d, #24282a 18%, #0e1112 82%, #5f6568);
  box-shadow: inset 2px 2px #b9bec0, inset -2px -2px #000;
}

.screen-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  width: 100%;
  border: 2px solid #000;
  border-radius: 2px;
  background: #000;
  box-shadow: 0 0 25px rgba(0, 167, 199, .13);
  touch-action: none;
}

canvas { display: block; width: 100%; height: 100%; outline: none; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.scanlines, .screen-glare { position: absolute; inset: 0; pointer-events: none; }
.scanlines { opacity: .11; background: repeating-linear-gradient(0deg, transparent 0 3px, #000 3px 4px); }
.screen-glare { background: linear-gradient(115deg, rgba(255,255,255,.055), transparent 23%, transparent 72%, rgba(255,255,255,.022)); }

.mobile-controls { display: none; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 8px 3px; }
.dpad { display: grid; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 42px); }
.dpad button, .action-pad button {
  border: 1px solid #777d80;
  background: linear-gradient(#41484b, #171a1c);
  box-shadow: inset 0 1px #b9bec0, 0 3px #000;
  color: var(--yellow);
  touch-action: none;
}
.dpad button:active, .dpad button.active, .action-pad button:active, .action-pad button.active { transform: translateY(2px); background: linear-gradient(#151819, #343a3d); box-shadow: inset 0 1px #000, 0 1px #000; }
.dpad [data-control="up"] { grid-column: 2; grid-row: 1; border-radius: 5px 5px 0 0; color: var(--magenta); }
.dpad [data-control="left"] { grid-column: 1; grid-row: 2; border-radius: 5px 0 0 5px; }
.dpad [data-control="down"] { grid-column: 2; grid-row: 3; border-radius: 0 0 5px 5px; color: var(--magenta); }
.dpad [data-control="right"] { grid-column: 3; grid-row: 2; border-radius: 0 5px 5px 0; }
.action-pad { display: flex; gap: 10px; align-items: flex-end; }
.action-pad button { width: 76px; height: 76px; border-radius: 50%; font-weight: 700; letter-spacing: .06em; }
.jump-button { border-color: #008db0 !important; color: #b7f2ff !important; }
.fire-button { border-color: #c33038 !important; background: radial-gradient(circle at 35% 28%, #ef4e58, #8b1118 58%, #38070a) !important; color: #fff3a0 !important; }

footer { display: flex; justify-content: space-between; gap: 18px; padding: 10px 6px 0; color: var(--yellow); font-size: 11px; }
footer .credit { color: #909699; text-align: right; }

dialog {
  width: min(92vw, 560px);
  border: 2px solid #777d80;
  border-radius: 4px;
  background: #101315;
  box-shadow: inset 0 0 0 2px #292e31, 0 18px 80px #000;
  color: #d9dcdd;
}
dialog::backdrop { background: rgba(0,0,0,.8); }
dialog form { position: relative; padding: 8px 10px 12px; }
.dialog-close { position: absolute; top: 0; right: 0; width: 36px; padding: 0; font-size: 23px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; letter-spacing: .16em; }
dialog h2 { margin: 0 44px 14px 0; color: var(--yellow); }
.help-grid { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 8px 14px; margin: 18px 0; align-items: center; }
kbd { padding: 5px 7px; border: 1px solid #666d70; border-bottom-width: 3px; border-radius: 3px; background: #252a2d; color: #fff; text-align: center; }
.help-note { color: #aeb4b7; font-size: 13px; line-height: 1.5; }

@media (hover: none), (pointer: coarse) { .mobile-controls { display: flex; } }
@media (max-width: 620px) {
  .app-shell { padding: 9px 8px 18px; }
  .topbar { align-items: center; margin-bottom: 8px; }
  .wordmark { font-size: 30px; }
  .wordmark small { display: none; }
  .toolbar button, .toolbar-link { min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .console { padding: 8px; }
  .console-label { font-size: 8px; }
  footer { font-size: 9px; }
  footer .credit { display: none; }
  .dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 38px); }
  .action-pad { gap: 7px; }
  .action-pad button { width: 64px; height: 64px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) { .scanlines { opacity: .07; } }
