:root {
  color-scheme: dark;
  font-family: Consolas, "Courier New", monospace;
  color: #bbc2d8;
  background: #071726;
  /* art-layout.css supplies the selected mural geometry; layout.js scales it. */
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  display: grid; place-items: center;
  background: #071726;
  background-repeat: no-repeat;
}
.cabinet {
  position: relative;
  background: url("art/cabinet-frame.png") no-repeat center / 100% 100%;
}
.bezel { position: absolute; }
#screen {
  position: relative; z-index: 0; width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  background: #030616; border-radius: 0; border: 0;
  touch-action: none; cursor: crosshair; outline: none;
}
/* The playfield keeps keyboard focus without drawing a second rim over the cabinet. */
#screen:focus-visible { outline: none; }
#ngplus-frame {
  position: absolute; inset: -3px; z-index: 1; border: 1px solid #ffdb49;
  color: #ffdb49; pointer-events: none;
}
#ngplus-frame[hidden] { display: none; }
#ngplus-frame span {
  position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  padding: 0 5px; background: #030616; font-size: 9px; font-weight: 700;
  line-height: 10px; letter-spacing: 0; white-space: nowrap;
}
#game, #game .ejs_parent, #game .ejs_game { width: 100% !important; height: 100% !important; position: absolute !important; inset: 0 !important; background: #030616 !important; }
/* The complete native picture meets the calibrated physical glass. */
#game canvas { width: 100% !important; height: 100% !important; display: block !important; image-rendering: pixelated !important; image-rendering: crisp-edges !important; }
.ejs_menu_bar, .ejs_controls, .ejs_virtualGamepad, .ejs_context_menu, .ejs_start_button, .ejs_loading_text, .ejs_button { display: none !important; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 24px; background: #150e24; color: #b7d6cf; font-size: 11px; letter-spacing: 1px; pointer-events: none; }
#loading[hidden] { display: none; }
.loading-orbit { width: 56px; height: 56px; border: 1px solid #30506b; border-radius: 50%; position: relative; animation: orbit 2s linear infinite; }
.loading-orbit:before { content: ""; width: 12px; height: 12px; background: #ffbb6b; border-radius: 50%; position: absolute; left: 21px; top: 21px; box-shadow: 0 0 28px #ffa65355; }
.loading-orbit:after { content: ""; position: absolute; width: 5px; height: 5px; background: #77e0e6; border-radius: 50%; top: -3px; left: 24px; }
.bezel-label {
  position: absolute; top: calc(100% + 10 * var(--unit)); left: 1%; right: 1%;
  display: flex; align-items: center; gap: 7px;
  color: #97b2bd; text-shadow: 1px 1px #030616;
  font-size: clamp(4px, calc(7 * var(--unit)), 7px); letter-spacing: calc(2 * var(--unit));
}
.led { width: 4px; height: 4px; background: #76d4d0; border-radius: 50%; box-shadow: 0 0 7px #76d4d080; }
.serial { margin-left: auto; }
footer { position: absolute; left: 11%; right: 11%; bottom: 4%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
footer p { font-size: clamp(7px, calc(10 * var(--unit)), 10px); line-height: 1.5; color: #b6c7d2; text-shadow: 1px 1px #030616; margin: 0; max-width: 48%; }
.controls { display: flex; align-items: center; gap: 6px; }
.speed-control { display:flex; align-items:center; }
.speed-label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
#speed { height:clamp(24px,calc(32 * var(--unit)),32px); min-width:52px; padding:2px 3px; color:#c5dfd3; background:#160f27; border:1px solid #74776e; border-radius:5px; font:11px Consolas,monospace; }
#speed:focus-visible { outline:2px solid #ffbf6a; outline-offset:3px; }
.directions { color: #9de4cb; font-size: 15px; letter-spacing: 1px; line-height: 1; display: flex; flex-direction: column; text-align: center; margin-right: 10px; white-space: nowrap; }
.directions span { font-size: 6px; letter-spacing: 1.5px; margin-top: 4px; color: #9daebb; }
button, a {
  width: clamp(24px, calc(32 * var(--unit)), 32px); height: clamp(24px, calc(32 * var(--unit)), 32px);
  border: 1px solid #74776e; border-radius: 5px; padding: 6px;
  background: #160f27db; color: #c5dfd3; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
button:hover, a:hover { border-color: #93e9c9; color: #e0fff0; background: #30223c; }
button:focus-visible, a:focus-visible { outline: 2px solid #ffbf6a; outline-offset: 3px; }
svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
#sound[aria-pressed=true] { color: #8195a4; }
#sound[aria-pressed=true] svg { opacity: .45; }
#crt[aria-pressed=true]{color:#ffd6a0;border-color:#c7a578;box-shadow:inset 0 0 7px #ffb9641a}
#pause .play-triangle { display: none; }
#pause[aria-pressed=true] .pause-bars { display: none; }
#pause[aria-pressed=true] .play-triangle { display: block; }
#pause[aria-pressed=true] { color: #ffbf6a; border-color: #c18b4d; }
button:disabled { opacity: .35; cursor: wait; }
/* Story pause overlay; gameplay uses the native cartridge placard. */
#paused { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: #030616d9; color: #dcebf4; cursor: default; letter-spacing: 6px; font-size: 22px; }
#paused[hidden] { display: none; }
#paused small { font-size: 9px; color: #7793a9; letter-spacing: 2px; }
#resume { width: auto; height: 38px; padding: 0 24px; font: inherit; font-size: 11px; letter-spacing: 2px; border-color: #6a9bae; color: #a8eced; background: #102535; }
.cabinet:fullscreen { display: grid; place-items: center; background: #030616; width: 100%; height: 100%; padding: 0; }
.cabinet:fullscreen .bezel-label { display: none; }
.cabinet:fullscreen .bezel { position: relative; left: auto; top: auto; width: min(calc(100vw - 8px), calc((100dvh - 20px) * 4 / 3)); }
.cabinet:fullscreen #screen { border: 0; border-radius: 0; }
.cabinet:fullscreen footer { left: auto; right: 12px; bottom: 12px; margin: 0; z-index: 9; }
.cabinet:fullscreen footer p, .cabinet:fullscreen .directions, .cabinet:fullscreen #sound, .cabinet:fullscreen footer a { display: none; }
.cabinet:fullscreen footer button { background: #071223dd; width: 32px; height: 32px; }
@keyframes orbit { to { transform: rotate(360deg); } }
@media (max-width: 550px), (max-height: 420px) {
  .bezel-label { display: none; }
  .directions { display: none; }
  .controls { gap: 4px; }
  footer { gap: 5px; bottom: calc(4% - 12px); }
  footer p { max-width: 52%; }
  button, a { padding: 5px; }
}
@media (prefers-reduced-motion: reduce) { .loading-orbit { animation: none; } }

#shop-controls { position:absolute; left:8%; top:calc(220 * var(--unit)); width:84%; transform:translateY(-50%); z-index:4; display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); align-items:center; gap:8px; padding:6px 8px; background:#071223eb; border:1px solid #8eb8bd60; border-radius:5px; }
#shop-controls[hidden] { display:none; }
.shop-controls-label { color:#dbc592; font-size:clamp(8px,calc(11 * var(--unit)),11px); letter-spacing:.3px; white-space:nowrap; }
.shop-controls-actions { display:flex; justify-content:center; gap:4px; }
#shop-controls button { width:auto; min-width:28px; height:clamp(24px,calc(40 * var(--unit)),40px); padding:4px clamp(3px,calc(8 * var(--unit)),8px); font:inherit; font-size:clamp(7.5px,calc(11 * var(--unit)),11px); white-space:nowrap; }
#shop-controls #shop-dismiss { justify-self:end; width:28px; height:28px; min-width:28px; padding:5px; border-radius:50%; background:transparent; }
#shop-controls #shop-dismiss:hover { background:#30223c; }
#shop-controls [data-shop-key="0"] { touch-action:none; user-select:none; }
.cabinet:fullscreen #shop-controls { left:50%; top:8px; width:min(900px,calc(100% - 24px)); transform:translateX(-50%); }
.cabinet:fullscreen:has(#shop-controls:not([hidden])) .bezel { width:min(calc(100vw - 8px),calc((100dvh - 80px) * 4 / 3)); margin-top:44px; }
@media (max-width:600px), (max-height:600px) {
  #shop-controls { grid-template-columns:minmax(0,1fr) 28px; gap:4px; }
  .shop-controls-label { grid-column:1; grid-row:1; }
  .shop-controls-actions { grid-column:1 / -1; grid-row:2; gap:3px; }
  #shop-controls #shop-dismiss { grid-column:2; grid-row:1; }
  .cabinet:fullscreen:has(#shop-controls:not([hidden])) .bezel { width:min(calc(100vw - 8px),calc((100dvh - 108px) * 4 / 3)); margin-top:64px; }
}
