:root {
  color-scheme: dark;
  --bg: #151719;
  --surface: #1d2023;
  --surface-raised: #272b2f;
  --line: #424950;
  --line-bright: #68727b;
  --text: #f3f1ea;
  --muted: #aab0b4;
  --accent: #f06a35;
  --accent-strong: #ff8354;
  --cyan: #56c9c2;
  --yellow: #f2c14e;
  --danger: #ef5261;
  --focus: #f7d56b;
  font-family: "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 20px 20px;
}

button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: #141617;
  background: var(--focus);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.arcade-shell {
  width: min(100% - 32px, 900px);
  margin: 0 auto;
  padding: 20px 0 18px;
}

.topbar, footer, .control-deck {
  border: 1px solid var(--line);
  background: rgba(29, 32, 35, .96);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 18px;
  border-bottom: 0;
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--accent);
  color: var(--accent-strong);
  font: 700 15px/1 "Courier New", monospace;
}
.kicker { margin: 0 0 2px; color: var(--muted); font-size: 9px; letter-spacing: .22em; }
h1 { margin: 0; font: 700 clamp(17px, 3vw, 26px)/1 "Courier New", monospace; letter-spacing: .06em; }
h1 span { color: var(--accent-strong); font-size: .58em; white-space: nowrap; }

.status-strip { display: flex; gap: clamp(12px, 3vw, 28px); }
.status-strip span { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.status-strip strong { display: block; margin-top: 3px; color: var(--text); font-size: 15px; letter-spacing: .08em; }

.machine {
  display: grid;
  grid-template-columns: 26px minmax(0, 480px) 26px;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: #202327;
}

.screen-frame {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--line-bright);
  background: #0e1113;
  aspect-ratio: 2 / 3;
}

canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }

.side-rail {
  display: flex;
  align-items: center;
  justify-content: space-around;
  color: #7f878d;
  font: 600 8px/1 "Courier New", monospace;
  letter-spacing: .18em;
  writing-mode: vertical-rl;
}
.side-rail i { width: 1px; height: 34%; background: var(--line); }
.side-rail-left { transform: rotate(180deg); }

.control-deck {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  padding: 14px 18px;
  border-top: 0;
}
.control-help { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.control-help p { margin: 0; color: var(--muted); font-size: 9px; }
kbd { min-width: 22px; padding: 3px 5px; border: 1px solid var(--line-bright); color: var(--text); background: var(--surface-raised); font: 600 9px/1 "Courier New", monospace; }
.system-controls { display: flex; gap: 8px; }
.utility-button, .touch-button {
  min-height: 44px;
  border: 1px solid var(--line-bright);
  color: var(--text);
  background: var(--surface-raised);
  cursor: pointer;
}
.utility-button { padding: 0 14px; font-size: 9px; letter-spacing: .08em; }
.utility-button:hover, .touch-button:hover { border-color: var(--accent-strong); }
.utility-button:active, .touch-button:active, .touch-button.is-active { color: #151719; background: var(--accent-strong); }
.utility-button:focus-visible, .touch-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.utility-button:disabled, .touch-button:disabled { cursor: not-allowed; opacity: .45; }

.touch-controls { display: none; grid-column: 1 / -1; grid-template-columns: 1fr 1fr 1.3fr; gap: 10px; }
.touch-button { min-height: 54px; font-size: 13px; font-weight: 600; }
.touch-button.action { border-color: var(--accent); color: var(--accent-strong); }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 9px 14px; border-top: 0; color: #777f84; font-size: 8px; letter-spacing: .1em; }
footer p { margin: 0; }
footer span[aria-label] { color: var(--accent-strong); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (pointer: coarse), (max-width: 700px) {
  .arcade-shell { width: min(100% - 16px, 560px); padding-top: 8px; }
  .topbar { align-items: flex-start; padding: 10px 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .kicker, .control-help { display: none; }
  h1 { font-size: 15px; }
  .status-strip { gap: 10px; }
  .status-strip span { font-size: 7px; }
  .status-strip strong { font-size: 12px; }
  .machine { grid-template-columns: 10px minmax(0, 480px) 10px; padding: 7px; }
  .side-rail span { display: none; }
  .control-deck { grid-template-columns: 1fr; padding: 10px; }
  .touch-controls { display: grid; }
  .system-controls { justify-content: center; }
  footer { justify-content: center; text-align: center; }
  footer p:first-child { display: none; }
}

@media (max-height: 780px) and (orientation: landscape) {
  .arcade-shell { width: min(100% - 12px, 1020px); padding: 6px 0; }
  .topbar { padding: 7px 12px; }
  .machine { grid-template-columns: 10px minmax(0, min(480px, calc(100vh - 142px) * 2 / 3)) 10px; padding: 5px; }
  .control-deck { padding: 7px 10px; }
  .touch-controls { grid-column: 1; }
  .system-controls { grid-column: 2; grid-row: 1; }
  footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
