:root { color-scheme: dark; font-family: "Chakra Petch", "Segoe UI", sans-serif; background: #050608; color: #e9edf0; --amber: #ffb000; --amber-hot: #ffd45a; --cyan: #52e7ef; --bg: #050608; --panel: #1a1f24; --panel2: #0c0f12; --text: #e9edf0; --muted: #8c959c; --border: #22282e; --accent: #ffb000; --accent-hot: #ffd45a; --accent2: #52e7ef; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -15%, #283039 0, #11151a 32%, transparent 62%), repeating-linear-gradient(90deg, #080a0d 0 2px, #060709 2px 4px); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .16; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E"); }
.console { width: min(96vw, 1080px); margin: 0 auto; padding: 28px 0 40px; position: relative; }
.masthead { display: flex; justify-content: space-between; align-items: end; padding: 0 14px 14px; }
.brand { display: grid; grid-template-columns: auto auto; column-gap: 14px; align-items: end; }
.brand-kicker { grid-column: 1 / -1; color: var(--cyan); font-size: 11px; letter-spacing: .38em; font-weight: 700; }
.brand h1 { margin: -5px 0 -8px; font: 700 clamp(42px, 7vw, 74px)/1 "Chakra Petch", sans-serif; letter-spacing: -.09em; color: #f2f4f5; text-shadow: 3px 3px 0 #090a0c; }
.brand h1 span { color: var(--amber); }
.brand p { margin: 0 0 5px; text-transform: uppercase; color: #8c959c; letter-spacing: .2em; font-size: 11px; }
.system-badges { display: flex; gap: 7px; flex-wrap: wrap; justify-content: end; }
.system-badges span { border: 1px solid #46505a; color: #aeb7bc; padding: 4px 7px 3px; font: 11px/1 "Share Tech Mono", monospace; letter-spacing: .08em; background: #101318; }
.monitor { padding: 10px; border-radius: 19px 19px 8px 8px; background: linear-gradient(#3a4148, #171b20); box-shadow: 0 25px 55px #000c, inset 0 1px #6f7780, 0 0 0 1px #050607; }
.monitor-bezel { padding: clamp(12px, 2.4vw, 28px) clamp(14px, 3.5vw, 40px) 11px; border-radius: 12px 12px 4px 4px; background: linear-gradient(145deg, #242a30, #0c0f12 78%); box-shadow: inset 0 0 0 2px #07090b, inset 0 1px #5b6268; }
.screen-shell { position: relative; width: 100%; max-width: 768px; margin-inline: auto; overflow: hidden; background: #000; border-radius: 9px; box-shadow: 0 0 0 3px #050607, 0 0 0 5px #31373c, inset 0 0 40px #000; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; background: #000; outline: 0; }
canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--cyan); }
#crt-screen { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; image-rendering: auto; }
#crt-screen[hidden] { display: none; }
.screen-glass { position: absolute; inset: 0; pointer-events: none; z-index: 3; background: linear-gradient(110deg, #fff0 0 61%, #bceeff08 66%, #fff0 72%); mix-blend-mode: screen; }
/* WebGL is used normally. This lightweight fallback is only active when a
   browser/device cannot create a WebGL context. */
.screen-shell.crt-fallback #screen { filter: brightness(1.22) contrast(1.05); border-radius: 3%; }
.screen-shell.crt-fallback::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 3%; background: repeating-linear-gradient(0deg, #0000 0 1px, #0005 1px 2px), repeating-linear-gradient(90deg, #f3323212 0 1px, #32f33212 1px 2px, #3232f312 2px 3px); }
#lightgun-overlay { position: absolute; display: none; width: 32px; height: 32px; pointer-events: none; transform: translate(-1px, -1px); z-index: 4; }
#screen.lightgun-active { cursor: none; touch-action: none; }

/* ==========================================================================
   Audio hint — shown (blinking, subtle) in the upper-right corner of the
   display when a machine was booted directly via URL parameters, until the
   first user gesture activates Web Audio.
   ========================================================================== */
.audio-hint {
  display: none;
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 5;
  pointer-events: none;
  padding: 5px 10px;
  border: 1px solid rgba(255, 180, 0, 0.30);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffd45a;
  font: 600 11px/1.4 "Share Tech Mono", monospace;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: audio-hint-blink 1.8s ease-in-out infinite;
}
.audio-hint.show { display: block; }
@keyframes audio-hint-blink {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  .audio-hint { animation: none; opacity: 0.9; }
}

/* ==========================================================================
   Disk status — on-screen feedback for the URL-booted disk (mounted OK /
   failed with reason / ignored), top-left corner of the display.
   ========================================================================== */
.disk-status {
  display: none;
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 5;
  pointer-events: none;
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #b8e6b0;
  border: 1px solid rgba(120, 220, 120, 0.30);
  font: 600 11px/1.4 "Share Tech Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.disk-status.show { display: block; }
.disk-status.error { color: #ff9d8a; border-color: rgba(255, 110, 90, 0.35); }
.disk-status.warn { color: #ffd45a; border-color: rgba(255, 180, 0, 0.30); }
.disk-status.fade { animation: disk-status-fade 4s ease forwards; }
@keyframes disk-status-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}
.monitor-markings { display: flex; justify-content: space-between; margin-top: 10px; color: #6f777d; font: 9px "Share Tech Mono", monospace; letter-spacing: .22em; }
.power-light::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: #38e55a; box-shadow: 0 0 8px #38e55a; }
.control-deck { display: grid; grid-template-columns: minmax(320px, 1.65fr) minmax(245px, 1fr) minmax(190px, .8fr); gap: 1px; margin-top: 10px; padding: 1px; background: #3b4249; border: 1px solid #080a0c; box-shadow: 0 14px 35px #0009; }
.control-group { min-width: 0; padding: 14px 16px 16px; background: linear-gradient(155deg, #20252a, #111419); }
.control-group h2 { margin: 0 0 10px; color: var(--amber); font-size: 10px; letter-spacing: .32em; text-transform: uppercase; }
.select-control { display: grid; gap: 4px; color: #8f989f; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.compact-control { grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 7px; }
.compact-control select { padding-block: 6px; font-size: 12px; }
select:disabled { color: #798188; opacity: .75; }
select { width: 100%; min-width: 0; border: 1px solid #3d464e; border-radius: 2px; padding: 9px 32px 9px 10px; color: #ecf2f3; background: #080b0e; font: 600 14px "Chakra Petch", sans-serif; outline: none; }
select:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px #52e7ef55; }
.media-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.deck-button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 47px; width: 100%; border: 1px solid #4c555d; border-radius: 2px; padding: 7px 10px; color: #e5e9eb; background: linear-gradient(#343b42, #1d2227); box-shadow: inset 0 1px #606970, 0 2px 0 #080a0c; cursor: pointer; font-family: inherit; text-align: left; }
.deck-button:hover { color: var(--amber-hot); border-color: #77818a; background: linear-gradient(#414951, #252b31); }
.deck-button:active { transform: translateY(1px); box-shadow: inset 0 1px 3px #000; }
.deck-button span { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.deck-button small { color: #7d878f; font: 9px "Share Tech Mono", monospace; letter-spacing: .13em; }
.deck-button.danger { border-left: 3px solid #d94836; }
.system-group { display: grid; grid-template-columns: 1fr; gap: 7px; }
.system-group h2 { margin-bottom: 3px; }
.input-group { display: grid; align-content: start; gap: 9px; }
.input-group h2 { margin-bottom: 1px; }
.toggle { display: grid; grid-template-columns: 36px 1fr; gap: 9px; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .switch { position: relative; width: 34px; height: 17px; border: 1px solid #4a535a; background: #090b0e; box-shadow: inset 0 1px 3px #000; }
.toggle .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; background: #687178; transition: .12s; }
.toggle input:checked + .switch::after { left: 19px; background: var(--amber); box-shadow: 0 0 7px #ffb000a0; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--cyan); outline-offset: 2px; }
.toggle strong, .toggle small { display: block; }
.toggle strong { color: #dfe4e6; font-size: 12px; }
.toggle small { color: #737e86; font: 9px "Share Tech Mono", monospace; }
.status-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 15px; border: 1px solid #30373d; border-top: 0; background: #0a0d10; box-shadow: 0 9px 25px #0008; }
.status-led { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.disk-indicators { display: flex; align-items: center; gap: 14px; }
.disk-indicator { display: flex; align-items: center; gap: 6px; color: #6f777d; font: 9px "Share Tech Mono", monospace; letter-spacing: .18em; }
.status-led.disk-led { width: 13px; height: 6px; border-radius: 1px; background: #4a1215; box-shadow: inset 0 1px 1px #0006; transition: background .08s linear, box-shadow .08s linear; }
.status-led.disk-led.motor { background: #9a3a2b; box-shadow: 0 0 4px #9a3a2b, inset 0 0 2px #ff8a6b66; }
.status-led.disk-led.on { background: #ff2626; box-shadow: 0 0 9px #ff2626, 0 0 3px #ff8080, inset 0 0 2px #fff6; }
.tape-counter { display: flex; align-items: center; gap: 5px; color: #6f777d; font: 9px "Share Tech Mono", monospace; letter-spacing: .12em; }
.counter-label { color: #8b9295; }
.counter-window { display: flex; overflow: hidden; padding: 2px 3px; gap: 1px; background: #15110f; border: 1px solid #5a4131; border-radius: 2px; box-shadow: inset 0 1px 2px #000, 0 0 3px #0008; }
.counter-window i { width: 8px; height: 13px; color: #e5b77b; font: 12px/13px "Share Tech Mono", monospace; font-style: normal; text-align: center; text-shadow: 0 0 3px #d47d3a; }
.counter-window i.rolling { animation: counter-roll .14s ease-out; }
@keyframes counter-roll { 0% { transform: translateY(-8px); opacity: .2; } 100% { transform: translateY(0); opacity: 1; } }
output { min-width: 0; overflow: hidden; color: #a9f4f1; font: 11px "Share Tech Mono", monospace; letter-spacing: .06em; text-overflow: ellipsis; white-space: nowrap; }
.keyboard-note { color: #596269; font: 9px "Share Tech Mono", monospace; text-transform: uppercase; }
@media (max-width: 790px) { .console { width: min(97vw, 720px); padding-top: 16px; } .control-deck { grid-template-columns: 1fr 1fr; } .media-group { grid-column: 1 / -1; } .keyboard-note { display: none; } }
@media (max-width: 500px) { .masthead { align-items: start; } .brand p, .system-badges { display: none; } .monitor { padding: 6px; } .monitor-bezel { padding: 10px 11px 8px; } .control-deck { grid-template-columns: 1fr; } .media-group { grid-column: auto; } }
@media (prefers-reduced-motion: reduce) { .toggle .switch::after { transition: none; } }

.vu-meter-module { display: flex; align-items: center; gap: 4px; }
.vu-label { color: #6f777d; font-weight: bold; }
.vu-spacer { width: 6px; }
.vu-bar { display: flex; gap: 2px; height: 6px; }
.vu-bar i { display: block; width: 5px; height: 100%; background: #2a2d31; border-radius: 1px; transition: background 0.05s, box-shadow 0.05s; }
.vu-bar i.on:nth-child(-n+5) { background: #38e55a; box-shadow: 0 0 4px #38e55a; }
.vu-bar i.on:nth-child(n+6):nth-child(-n+7) { background: var(--amber); box-shadow: 0 0 4px var(--amber); }
.vu-bar i.on:nth-child(8) { background: #d94836; box-shadow: 0 0 4px #d94836; }


/* Debugger Styles */
.debugger-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  font-family: "Share Tech Mono", monospace;
  font-size: 13px;
  color: #c5d4db;
}

.debugger-content {
  background: #1e2029;
  border: 1px solid #4a545e;
  border-radius: 6px;
  width: 98vw;
  max-width: 1400px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.debugger-header {
  background: linear-gradient(180deg, #373d47 0%, #22262d 100%);
  padding: 8px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #111;
  border-radius: 6px 6px 0 0;
}

.debugger-header h2 { margin: 0; font-size: 16px; color: #fff; text-shadow: 1px 1px 0 #000; }
.debugger-close { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }

.debugger-body-grid {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 5px;
  gap: 5px;
  background: #2a2e38;
}

.dbg-col { display: flex; flex-direction: column; gap: 5px; }
.dbg-left { flex: 2; }
.dbg-mid { flex: 0.8; }
.dbg-right { flex: 1; }

.debugger-panel {
  background: #11141a;
  border: 1px solid #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.debugger-panel h3 {
  margin: 0;
  font-size: 12px;
  background: #3c424e;
  color: #fff;
  padding: 3px 8px;
  border-bottom: 1px solid #000;
}

.disasm-panel { flex: 1.5; }
.mem-panel { flex: 1; }
.stack-panel { flex: 1; }

.code-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre;
  background: #fff;
  color: #000;
  padding: 2px;
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  font-size: 13px;
}

/* Slim, visible scrollbars for the code views */
.code-view::-webkit-scrollbar { width: 12px; height: 12px; }
.code-view::-webkit-scrollbar-track { background: #d9dde0; }
.code-view::-webkit-scrollbar-thumb { background: #5b6a72; border: 2px solid #d9dde0; }
.code-view::-webkit-scrollbar-thumb:hover { background: #3e4a52; }
.code-view { scrollbar-width: thin; scrollbar-color: #5b6a72 #d9dde0; }

.code-view-disasm { background: #fff; }
.code-view-mem { background: #fff; }
.code-view-stack { background: #fff; }

.code-view .addr { color: #888; }
.code-view .hex { color: #000; }
.code-view .ascii { color: #666; }

.disasm-line { cursor: pointer; display: flex; }
.disasm-line:hover { background: #eee; }
.disasm-line .bp-icon { width: 20px; display: inline-block; text-align: center; color: #ff0000; font-weight: bold; }
.disasm-line .addr { color: #888; margin-right: 8px; }
.disasm-line .mnem { color: #0000d0; font-weight: bold; white-space: pre; }
.disasm-line .bytes { color: #008000; white-space: pre; }
.disasm-line .ascii { color: #808000; white-space: pre; margin-left: 10px; }
.disasm-line.current-pc { background: #ffff00; }
.disasm-line.breakpoint { background: #ffe0e0; }
.disasm-line.current-pc.breakpoint { background: #ffc000; }

.regs-flags { text-align: center; margin-bottom: 8px; font-family: "Courier New", monospace; color: #aaa; }
.regs-flags span { color: #fff; font-size: 15px; }

.regs-table { width: 100%; border-collapse: collapse; font-family: "Courier New", monospace; }
.regs-table td { padding: 2px 5px; border: 1px solid #2a2e38; }
.regs-table td:nth-child(odd) { color: #888; text-align: right; width: 30%; }
.regs-table td:nth-child(even) { color: #fff; text-align: left; }

.mem-header { background: #3c424e; display: flex; padding: 2px; gap: 4px; }
.mem-header input { background: #fff; border: 1px inset #888; width: 60px; font-family: inherit; }

.debugger-toolbar {
  background: #181b22;
  padding: 6px;
  border-top: 1px solid #111;
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-ctrl {
  background: linear-gradient(180deg, #4a545e, #2a2e38);
  border: 1px solid #111;
  border-radius: 3px;
  color: #fff;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: bold;
}
.btn-ctrl:hover { filter: brightness(1.2); }
.btn-ctrl:active { filter: brightness(0.8); }


.editable-hex { outline: none; border-bottom: 1px dotted transparent; }
.editable-hex:focus { background: #3c424e; color: #fff; border-bottom: 1px dotted #fff; }
.stack-line { display: flex; justify-content: space-between; }

.debugger-tabs {
  display: flex;
  gap: 5px;
  margin-left: 20px;
}
.tab-btn {
  background: #2a2e38;
  border: 1px solid #111;
  color: #88929b;
  padding: 6px 16px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  border-bottom: none;
}
.tab-btn.active {
  background: #11141a;
  color: var(--cyan);
  box-shadow: inset 0 2px 0 var(--cyan);
}
#tab-basic { background: #11141a; }


/* ==========================================================================
   Fullscreen — a dedicated .screen-stage wraps ONLY the canvases (the
   picture) and is the fullscreen element. Inside it the 768x544 canvas is
   contain-fitted via aspect-ratio + height:100% + max-width:100% (pure CSS,
   no JS measurement, no object-fit reliance), so the COMPLETE image is
   always visible with correct aspect: side borders on 16:9 PC screens,
   top/bottom borders on portrait displays. Nothing can ever be cut.
   The .is-fullscreen class is kept in sync by app.js.
   ========================================================================== */
.deck-button.active { border-left: 3px solid var(--cyan); }

/* Stage: tightly wraps the picture canvases. Both canvases are stacked in
   the same grid cell (grid-area 1/1) and centered, so #screen and the CRT
   overlay always share the exact same box. */
.screen-stage {
  position: relative;
  width: 100%;
  background: #000;
  display: grid;
  place-items: center;
}
.screen-stage > canvas { grid-area: 1 / 1; }

/* Native fullscreen: only the stage (the picture) is shown — no bezel, no
   console, no overlays. The stage is a centered grid (same effect as your
   flex container) that stacks the two canvases on top of each other.
   layoutFullscreen() in app.js sets the EXACT pixel size like a <video>
   element (aspect 768/544 kept, as large as possible, nothing cut). The CSS
   below is only a no-JS fallback: width/height/object-fit are deliberately
   WITHOUT !important, so the inline pixel sizes from app.js always win. */
.screen-stage.is-fullscreen,
.screen-stage:fullscreen,
.screen-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  background: #000;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.screen-stage.is-fullscreen canvas,
.screen-stage:fullscreen canvas,
.screen-stage:-webkit-full-screen canvas,
body.sim-fullscreen .screen-stage canvas {
  /* Pull #crt-screen (absolute in normal mode) into the grid flow so both
     canvases stack in the same centered cell. */
  position: static !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  image-rendering: pixelated;
  background: #000;
}
/* In simulated mode the whole console area is hidden and the stage fills
   the viewport; the picture gets the same contain treatment. */
body.sim-fullscreen .screen-stage {
  width: 100%;
  height: 100%;
}

body.sim-fullscreen { overflow: hidden; }
body.sim-fullscreen .console {
  width: 100vw; height: 100vh; max-width: none; margin: 0; padding: 0; background: #000;
}
body.sim-fullscreen .masthead,
body.sim-fullscreen .control-deck,
body.sim-fullscreen .status-panel,
body.sim-fullscreen #boot-note { display: none; }
body.sim-fullscreen .monitor {
  width: 100vw; height: 100vh; border-radius: 0; padding: 0; box-shadow: none; background: #000;
}
body.sim-fullscreen .monitor-bezel {
  width: 100%; height: 100%; padding: 0;
  border-radius: 0; background: none; box-shadow: none;
}
body.sim-fullscreen .screen-shell {
  width: 100%; height: 100%; max-width: none;
  border-radius: 0; box-shadow: none; overflow: hidden;
}
body.sim-fullscreen .monitor-markings,
body.sim-fullscreen .screen-glass { display: none; }

/* ==========================================================================
   Minimal GUI mode (gui=false) — show ONLY the .monitor section.
   Kiosk / dedicated game screen: masthead, control deck, status panel and
   boot note are hidden; the monitor is centered on a clean black background.
   ========================================================================== */
body.gui-off { overflow: auto; } /* scrollbar, wenn Inhalt (Monitor + Tastatur) höher als der Viewport */
body.gui-off .masthead,
body.gui-off .control-deck,
body.gui-off .status-panel,
body.gui-off #boot-note { display: none !important; }
body.gui-off .console {
  width: 100vw;
  min-height: 100vh;
  max-width: none;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column; /* Monitor oben, Tastatur DARUNTER */
  align-items: center;
  /* justify-content: center würde bei Überlauf oben+unten abschneiden;
     stattdessen am Anfang ausrichten und mit auto-Margins vertikal zentrieren,
     wenn Platz ist — scrollt sauber, wenn nicht. */
  justify-content: flex-start;
  gap: 14px;
}
body.gui-off .monitor { margin: 0 auto; }
body.gui-off .monitor:first-child { margin-top: auto; }
body.gui-off .vkb-wrap:last-child { margin-bottom: auto; }
/* Tastatur im Minimal-Modus unter dem Monitor zentrieren */
body.gui-off .vkb-wrap {
  width: min(96vw, 768px);
  margin: 0 auto;
  flex: 0 0 auto;
}

/* ==========================================================================
   Minimal GUI mode controls (gui=false):
   - .mini-controls: floating top-right button group (keyboard + fullscreen),
     ONLY visible in minimal mode (kiosk / game screen) where the control
     deck is hidden.
   - .fs-mini: subtle icon buttons (keyboard, fullscreen).
   - .power-light: acts as a Reset button (POWER), clickable + keyboard
     accessible, with a red LED on hover.
   ========================================================================== */
.mini-controls {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 60;
  gap: 8px;
  align-items: center;
}
body.gui-off.audio-ready .mini-controls { display: flex; }
.fs-mini {
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background .15s, color .15s, border-color .15s;
}
.fs-mini:hover,
.fs-mini:focus-visible {
  background: rgba(0, 0, 0, 0.7);
  color: var(--amber-hot);
  border-color: rgba(255, 180, 0, 0.6);
  outline: none;
}
.fs-mini.active {
  color: var(--amber);
  border-color: rgba(255, 180, 0, 0.55);
}

/* POWER -> Reset button */
.power-light {
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.power-light:hover,
.power-light:focus-visible {
  color: #ffb0a0;
  outline: none;
}
.power-light:hover::before,
.power-light:focus-visible::before {
  background: #ff5555;
  box-shadow: 0 0 8px #ff5555;
}

/* ==========================================================================
   Virtual Keyboard (vkb) — unter dem Monitor. CPC- und ZX-Layout im
   JAMSI-Dark-Style. Modifier (SHIFT/CONTROL/SYMB SHIFT/CAPS LOCK) rasten
   sichtbar ein (Klasse .locked, Amber-Hintergrund).
   ========================================================================== */
.vkb-wrap {
  width: min(96vw, 768px);
  margin: 12px auto 0;
}
.vkb-wrap[hidden] { display: none; }
.vkb-wrap .cpc,
.vkb-wrap .zx {
  background: linear-gradient(145deg, #242a30, #0c0f12 78%);
  padding: 14px 10px 16px;
  border-radius: 12px;
  box-shadow: 0 25px 55px rgba(0,0,0,.6), inset 0 1px 2px rgba(255,255,255,.10), 0 0 0 1px #050607;
  width: 100%;
}
.vkb-wrap .kb {
  display: grid;
  grid-template-columns: repeat(36, 1fr); /* CPC: 30 + 6 Fn */
  gap: 4px;
  grid-auto-rows: 42px;
  background: #0a0d10;
  padding: 8px;
  border-radius: 8px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7), 0 0 0 1px #050607;
}
.vkb-wrap .zx .kb { grid-template-columns: repeat(52, 1fr); }
.vkb-wrap .vkb-gap { pointer-events: none; }

.vkb-wrap .key {
  position: relative;
  border: 1px solid #4c555d;
  border-radius: 5px;
  cursor: pointer;
  background: linear-gradient(#343b42, #1d2227);
  box-shadow: inset 0 1px #606970, 0 2px 0 #080a0c;
  color: #e5e9eb;
  font-family: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .04s, box-shadow .04s, background .04s, color .04s, border-color .04s;
  overflow: hidden;
}
.vkb-wrap .key:hover { color: var(--amber-hot); border-color: #77818a; background: linear-gradient(#414951, #252b31); }
.vkb-wrap .key:active,
.vkb-wrap .key.active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 3px #000;
  background: linear-gradient(#252b31, #1d2227);
  color: var(--amber-hot);
}
.vkb-wrap .key .cap { font-style: italic; font-weight: 700; font-size: 15px; line-height: 1.05; }
.vkb-wrap .key.has-sub .cap { margin-top: 7px; }
.vkb-wrap .key .sub {
  position: absolute; top: 2px; left: 5px; right: 5px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 9px; font-style: italic; font-weight: 600; opacity: .9;
  pointer-events: none; color: #8c959c;
}
.vkb-wrap .key:hover .sub, .vkb-wrap .key.active .sub { color: var(--amber); }
.vkb-wrap .key .sub .kw { font-size: 8px; letter-spacing: .3px; }
.vkb-wrap .mod {
  background: linear-gradient(#23282d, #14171b);
  border-color: #39414a;
  box-shadow: inset 0 1px #4a545e, 0 2px 0 #080a0c;
  color: #aeb7bc;
  font-size: 9px;
  letter-spacing: .06em;
}
.vkb-wrap .mod:hover { color: var(--amber-hot); border-color: #77818a; background: linear-gradient(#2b3138, #191d22); }
.vkb-wrap .mod:active, .vkb-wrap .mod.active { transform: translateY(2px); box-shadow: inset 0 1px 3px #000; color: var(--amber); }
.vkb-wrap .mod .cap { font-size: 9px; font-weight: 600; letter-spacing: .3px; line-height: 1.2; text-align: center; margin-top: 0; }
.vkb-wrap .arrow .cap { font-style: normal; font-size: 16px; font-weight: 400; }
.vkb-wrap .zero .cap { position: relative; }
.vkb-wrap .zero .cap::after {
  content: ''; position: absolute; left: -3px; right: -3px; top: 48%;
  height: 1.5px; background: currentColor; transform: rotate(-28deg);
}
.vkb-wrap .enter .cap { display: flex; align-items: center; }
.vkb-wrap .ent {
  display: inline-block; width: 14px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  margin-left: 6px; position: relative; top: -3px;
}
.vkb-wrap .ent::after {
  content: ''; position: absolute; left: -4px; bottom: -4px;
  width: 0; height: 0; border: 4px solid transparent; border-right-color: currentColor;
}
/* Eingerasteter Modifier (SHIFT/CONTROL/SYMB SHIFT/CAPS LOCK) */
.vkb-wrap .key.locked {
  background: linear-gradient(#ffb000, #e09a00);
  border-color: #ffd45a;
  color: #1a1400;
  box-shadow: inset 0 1px #ffe9a8, 0 2px 0 #080a0c;
}
.vkb-wrap .key.locked .sub { color: #5a4300; }
.vkb-wrap.vkb-locked { opacity: .55; pointer-events: none; }

/* ==========================================================================
   Drag & Drop overlay — shown while a file is dragged over the page.
   pointer-events:none so the drop lands on the document listener.
   ========================================================================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-box {
  border: 2px dashed rgba(255, 180, 0, 0.7);
  border-radius: 12px;
  padding: 30px 48px;
  background: rgba(10, 13, 16, 0.88);
  text-align: center;
  color: #e9edf0;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
.drop-title {
  display: block;
  font: 700 22px "Chakra Petch", "Segoe UI", sans-serif;
  letter-spacing: .2em;
  color: var(--amber);
}
.drop-box small {
  display: block;
  margin-top: 8px;
  font: 12px "Share Tech Mono", monospace;
  letter-spacing: .15em;
  color: #8c959c;
}

/* ==========================================================================
   Embedded mode (embedded=true) — absolutely no GUI. The display fills the
   browser window (iframe-friendly) and the canvas is sized by app.js like in
   fullscreen: aspect-ratio preserved, scaled as large as possible, centered.
   ========================================================================== */
body.embedded { overflow: hidden; background: #000; }
body.embedded .masthead,
body.embedded .control-deck,
body.embedded .status-panel,
body.embedded #boot-note,
body.embedded .vkb-wrap { display: none !important; }
/* Floating mini controls (joystick / keyboard / fullscreen) stay available
   in embedded mode — fullscreen needs its toggle here. */
body.embedded.audio-ready .mini-controls { display: flex; }
body.embedded .console {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
}
body.embedded .monitor {
  width: 100%;
  height: 100%;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  background: #000;
}
body.embedded .monitor-bezel {
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
body.embedded .screen-shell {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
body.embedded .screen-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
body.embedded .screen-glass,
body.embedded .monitor-markings { display: none; }

/* ==========================================================================
   Status panel right side — keyboard note + Documentation link.
   ========================================================================== */
.status-right { display: flex; align-items: center; gap: 12px; }
.doc-link {
  color: var(--cyan);
  font: 700 11px "Share Tech Mono", monospace;
  letter-spacing: .12em;
  text-decoration: none;
  text-transform: uppercase;
  border: 1px solid rgba(82, 231, 239, 0.4);
  padding: 4px 8px;
  border-radius: 3px;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.doc-link:hover,
.doc-link:focus-visible {
  color: var(--amber-hot);
  border-color: rgba(255, 180, 0, 0.6);
  background: rgba(255, 180, 0, 0.08);
  outline: none;
}
@media (max-width: 520px) {
  .status-right { gap: 8px; }
  .doc-link { font-size: 10px; padding: 3px 6px; }
}

/* ==========================================================================
   Documentation live iframe demo (docs.html)
   ========================================================================== */
.iframe-demo {
  margin: 12px 0 6px;
  border-radius: 8px;
  overflow: hidden;
  display: inline-block;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.iframe-demo iframe { display: block; }

/* Theme selector in the status bar */
.theme-select { display: inline-flex; align-items: center; }
.theme-select select {
  font: 600 11px "Share Tech Mono", monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  max-width: 150px;
}
.theme-select select:hover { border-color: var(--accent); }

/* ==========================================================================
   Mini-Controls (embedded / kiosk): fast unsichtbar im Ruhezustand,
   werden beim Hover / Fokus "solide". So verbergen die Icons in kleinen
   iframes (z. B. 384x272) nicht das Bild. Auf Touch-Geräten (kein Hover)
   bleiben sie halb sichtbar, damit sie bedienbar bleiben.
   ========================================================================== */
body.embedded .mini-controls,
body.gui-off .mini-controls {
  opacity: 0.04;
  transition: opacity .18s ease;
}
body.embedded .mini-controls:hover,
body.embedded .mini-controls:focus-within,
body.gui-off .mini-controls:hover,
body.gui-off .mini-controls:focus-within {
  opacity: 1;
}
@media (hover: none) {
  body.embedded .mini-controls,
  body.gui-off .mini-controls { opacity: 0.55; }
}

/* ==========================================================================
   Keyboard icon: only in kiosk mode (gui=false). In embedded mode there is
   no way to show the virtual keyboard (the vkb is hidden), so the ⌨ icon is
   hidden there too — joystick + fullscreen remain.
   ========================================================================== */
body.embedded #keyboard-mini { display: none !important; }

/* FPS display in the monitor markings — right-aligned, spaced from POWER */
.fps-display {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6f777d;
  font: 9px "Share Tech Mono", monospace;
  letter-spacing: .12em;
  margin-left: auto;
  margin-right: 14px;
}
.fps-label { opacity: .7; }
.fps-value {
  min-width: 3.2em;
  text-align: right;
  color: #9be8a0;
  font-weight: 700;
  text-shadow: 0 0 4px rgba(120,230,120,.5);
}
.fps-value.turbo { color: #ffd45a; text-shadow: 0 0 4px rgba(255,180,0,.5); }

/* ==========================================================================
   CRT + fullscreen fix:
   - When CRT is active the plain 2D canvas must never show through (it is
     only used as the WebGL texture source). Hide it visually.
   - The CRT canvas is centered in the stage exactly like #screen, also in
     fullscreen / embedded / simulated fullscreen (explicit static + inset
     reset so it cannot sit top-left).
   ========================================================================== */
.screen-shell.crt-enabled #screen { visibility: hidden; }
.screen-stage.is-fullscreen #crt-screen,
.screen-stage:fullscreen #crt-screen,
.screen-stage:-webkit-full-screen #crt-screen,
body.sim-fullscreen .screen-stage #crt-screen,
body.embedded .screen-stage #crt-screen {
  position: static !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  inset: auto !important;
  grid-area: 1 / 1;
}
/* ==========================================================================
   Monitor markings — three balanced zones:
   left: "COLOUR PERSONAL COMPUTER" · center: VU meter + disk LEDs ·
   right: FPS + POWER. Everything vertically centered, even gaps.
   ========================================================================== */
.monitor-markings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  color: #6f777d;
  font: 9px "Share Tech Mono", monospace;
  letter-spacing: .22em;
}
.monitor-markings .marking-left { flex: 0 0 auto; }
.monitor-markings .marking-center {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}
.monitor-markings .marking-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
.monitor-markings .vu-meter-module { display: flex; align-items: center; gap: 4px; }
.monitor-markings .vu-label { font-weight: bold; }
.monitor-markings .vu-spacer { width: 6px; }
.monitor-markings .vu-bar { display: flex; gap: 2px; height: 6px; }
.monitor-markings .vu-bar i { display: block; width: 5px; height: 100%; background: #2a2d31; border-radius: 1px; transition: background 0.05s, box-shadow 0.05s; }
.monitor-markings .vu-bar i.on:nth-child(-n+5) { background: #38e55a; box-shadow: 0 0 4px #38e55a; }
.monitor-markings .vu-bar i.on:nth-child(n+6):nth-child(-n+7) { background: var(--amber); box-shadow: 0 0 4px var(--amber); }
.monitor-markings .vu-bar i.on:nth-child(8) { background: #d94836; box-shadow: 0 0 4px #d94836; }
.monitor-markings .disk-indicators { display: flex; align-items: center; gap: 14px; }
.monitor-markings .disk-indicator { display: flex; align-items: center; gap: 6px; font: inherit; letter-spacing: .18em; }
.monitor-markings .status-led.disk-led { width: 13px; height: 6px; border-radius: 1px; background: #4a1215; box-shadow: inset 0 1px 1px rgba(0,0,0,.4); transition: background .08s linear, box-shadow .08s linear; }
.monitor-markings .status-led.disk-led.motor { background: #9a3a2b; box-shadow: 0 0 4px #9a3a2b; }
.monitor-markings .status-led.disk-led.on { background: #ff2626; box-shadow: 0 0 9px #ff2626, 0 0 3px #ff2626, inset 0 0 2px #fff6; }
.monitor-markings .tape-counter { display: flex; align-items: center; gap: 5px; font: inherit; letter-spacing: .12em; }
.monitor-markings .counter-window { display: flex; overflow: hidden; padding: 2px 3px; gap: 1px; background: #15110f; border: 1px solid #5a4131; border-radius: 2px; box-shadow: inset 0 1px 2px #000, 0 0 3px rgba(0,0,0,.5); }
.monitor-markings .counter-window i { width: 8px; height: 13px; color: #e5b77b; font: 12px/13px "Share Tech Mono", monospace; font-style: normal; text-align: center; text-shadow: 0 0 3px #d47d3a; }
.monitor-markings .counter-window i.rolling { animation: counter-roll .14s ease-out; }
.monitor-markings .fps-display { display: flex; align-items: center; gap: 6px; margin: 0; font: inherit; letter-spacing: .12em; }
.monitor-markings .fps-label { opacity: .7; }
.monitor-markings .fps-value { min-width: 3.2em; text-align: right; color: #9be8a0; font-weight: 700; text-shadow: 0 0 4px rgba(120,230,120,.5); }
.monitor-markings .fps-value.turbo { color: #ffd45a; text-shadow: 0 0 4px rgba(255,180,0,.5); }
/* Rewind control in the monitor markings — between the drive LEDs and the
   FPS display. Click = one step back, hold = continuous visible scrubbing.
   .active lights up while rewind history exists / is being scrubbed. */
.monitor-markings .rewind-monitor {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  letter-spacing: .18em;
  color: inherit;
  background: linear-gradient(#262b30, #191d21);
  border: 1px solid #3a4046;
  border-radius: 2px;
  box-shadow: inset 0 1px #3f464d, 0 1px 0 #000;
  transition: color .1s, border-color .1s, box-shadow .1s;
}
.monitor-markings .rewind-monitor .rewind-arrow { font-size: 11px; line-height: 1; }
.monitor-markings .rewind-monitor:hover,
.monitor-markings .rewind-monitor:focus-visible {
  color: var(--amber-hot);
  border-color: #77818a;
}
.monitor-markings .rewind-monitor:active { transform: translateY(1px); }
.monitor-markings .rewind-monitor.active {
  color: var(--cyan);
  border-color: var(--cyan);
  text-shadow: 0 0 4px currentColor;
}

.monitor-markings .power-light { cursor: pointer; user-select: none; }
.monitor-markings .power-light::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: #38e55a; box-shadow: 0 0 8px #38e55a; }
.monitor-markings .power-light:hover::before, .monitor-markings .power-light:focus-visible::before { background: #ff5555; box-shadow: 0 0 8px #ff5555; }

/* Compressed checkbox inside the Save SNA button */
.deck-button .sna-compress {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font: 9px "Share Tech Mono", monospace;
  letter-spacing: .08em;
  color: inherit;
  cursor: pointer;
}
.deck-button .sna-compress input { accent-color: var(--accent); cursor: pointer; }
