:root {
  --bg: #0d1117;
  --surround: #2b2b2b;   /* dark grey around the picture in full screen */
  --panel: #161b22;
  --ink: #e6edf3;
  --muted: #8b949e;
  --line: #30363d;
  --accent: #2ea043;
}

* { box-sizing: border-box; }

/* The page gradient is sized to the body's box.  Without these it tiles below
   the content -- the light centre of the gradient repeats and shows as a
   paler band under the screen -- so pin it: no repeat, a solid colour behind
   it, and a body at least as tall as the viewport. */
html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 20% 10%, #1f2937 0%, var(--bg) 45%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.toolbar h1 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button, .fileLabel {
  background: #21262d;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover, .fileLabel:hover { border-color: var(--accent); }

.toggleLabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #21262d;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.toggleLabel:hover {
  border-color: var(--accent);
}

.toggleLabel input {
  margin: 0;
}

.fileLabel input { display: none; }

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.screenWrap {
  margin-top: 12px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

#screen {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

.status {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.status.hidden {
  display: none;
}

.status div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.debugWrap {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}

.debugWrap.hidden {
  display: none;
}

.debugHeader {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.debugControls {
  display: flex;
  gap: 8px;
}

.debugControls button {
  padding: 4px 8px;
  font-size: 0.8rem;
}

.debugLog {
  margin: 0;
  padding: 8px;
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 90px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}


/* --- Full screen ---
   NB each rule is written out per prefix rather than as a selector list:
   a list containing a selector the browser does not know is discarded
   whole, which would drop the letterbox in Firefox (no :-webkit-full-screen)
   and in Safari before 16.4 (no :fullscreen).
   -----------------------------------------------------------
   The original MAVIS display was ~4:3, so the picture is letterboxed to that
   ratio and centred, with the dark grey surround filling whatever is left.
   The canvas is 640x500 (1.28:1); presenting it at 4:3 matches the real
   display, whose pixels were not square. */
.screenWrap:fullscreen {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surround);
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screenWrap:-webkit-full-screen {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surround);
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screenWrap:fullscreen #screen {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
  max-width: none;
  image-rendering: pixelated;
  background: #000;
}

.screenWrap:-webkit-full-screen #screen {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
  max-width: none;
  image-rendering: pixelated;
  background: #000;
}
