:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #5b6475;
  --border: #d9dde5;
  --accent: #3b6fd8;
  --accent-hover: #2f5cb8;
  --accent-soft: #e8effc;
  --error: #c0392b;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --text: #e6e9ef;
    --muted: #9aa3b4;
    --border: #2f3542;
    --accent: #6b97ff;
    --accent-hover: #86aaff;
    --accent-soft: #232c40;
    --error: #ff7a6b;
  }
}

* { box-sizing: border-box; }

/* js-dos ships daisyUI/Tailwind styles; keep our basics stable. */
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 600; }
.site-header h1 { font-size: 1.75rem; }
.wx-card h2 { font-size: 1.15rem; }
.option-head { font-size: .95rem; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

.wrap { width: min(960px, 100% - 2rem); margin-inline: auto; }

.site-header { padding: 2rem 0 1rem; }
.site-header .wrap { position: relative; }
.header-links { position: absolute; top: .35rem; right: 0; display: flex; align-items: center; gap: .5rem; }
.github-link {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.github-link:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) { .github-link span { display: none; } .github-link { padding: .45rem; } }
.logo { margin: 0; font-size: 1.75rem; display: flex; align-items: center; gap: .6rem; }
.logo-mark { width: 2.75rem; height: 2.75rem; flex: none; }
.tagline { margin: .25rem 0 0; color: var(--muted); }
.tagline-note { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }

main { flex: 1; padding-bottom: 2rem; }

.wx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1rem;
}
.wx-card h2 { margin: 0 0 1rem; font-size: 1.15rem; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.dz-or { margin: .5rem 0 1rem; color: var(--muted); }

.buttons { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.wx-btn {
  font: inherit;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.wx-btn:hover { border-color: var(--accent); }
.wx-btn:disabled { opacity: .5; cursor: default; }
.wx-btn.wx-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.wx-btn.wx-primary:hover { background: var(--accent-hover); }
.wx-btn.wx-large { padding: .7rem 2rem; font-size: 1.05rem; font-weight: 600; }
.wx-btn.wx-small { padding: .3rem .75rem; font-size: .9rem; }
.wx-btn.wx-ghost { background: transparent; }

.linklike {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer;
}

.hint { color: var(--muted); font-size: .9rem; margin: .75rem 0 0; }
.muted { color: var(--muted); margin: 0 0 1rem; }
.error { color: var(--error); margin: 1rem 0 0; }

.choose-head { display: flex; align-items: center; gap: 1rem; }
.choose-head h2 { margin: 0; }

.program-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 320px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px;
}
.program-list li { border-bottom: 1px solid var(--border); }
.program-list li:last-child { border-bottom: 0; }
.program-list label {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem; cursor: pointer;
}
.program-list label:hover { background: var(--accent-soft); }
.program-list input:checked + .prog-name { font-weight: 600; }
.prog-name { flex: 1; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: .95rem; }
.prog-size { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.options { margin-top: 1.25rem; }
.options summary { cursor: pointer; color: var(--muted); }
.option-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.option-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.option-grid label.check { flex-direction: row; align-items: center; color: var(--text); }
select {
  font: inherit; padding: .4rem .5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}

.start-row { margin-top: 1.5rem; display: flex; justify-content: flex-end; gap: .75rem; }

.run { margin-top: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
/* Title and emulator on the first line, the buttons on their own line below */
.toolbar .spacer { flex-basis: 100%; height: 0; }
.toolbar { margin-bottom: .75rem; }


.screen {
  background: #000;
  border-radius: var(--radius);
  display: flex; justify-content: center; align-items: center;
  /* Fixed area for every emulator; the picture is scaled to fill it (see js/fit.js). */
  height: max(300px, min(75vh, 720px));
  overflow: hidden;
  /* Touch on the picture goes to the emulator (mouse), it must not scroll or zoom the page. */
  touch-action: none; overscroll-behavior: contain;
}
#canvas { display: block; flex: none; image-rendering: pixelated; outline: none; }

.console { margin-top: 1rem; }
.console pre {
  max-height: 240px; overflow: auto; margin: 0;
  padding: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  font-size: .8rem; white-space: pre-wrap; word-break: break-all;
}
.console .err { color: var(--error); }

.site-footer { border-top: 1px solid var(--border); padding: 1rem 0; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: .35rem 0; }

.option-head { font-size: .95rem; margin: 1.25rem 0 0; }

.kind {
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  padding: .1rem .5rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.kind.dos { background: #fdf0d5; color: #8a5a00; }
@media (prefers-color-scheme: dark) {
  .kind.dos { background: #3a2f17; color: #f0c060; }
}

.dos-container { position: relative; width: 100%; height: 100%; }

.kind.emulatorjs { background: #e3f4e8; color: #1d6b38; }
@media (prefers-color-scheme: dark) {
  .kind.emulatorjs { background: #173a24; color: #7fd69c; }
}

.system-panel {
  margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 8px;
  display: grid; gap: .5rem;
}
.system-panel label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); max-width: 320px; }
.system-panel .hint { margin: 0; }
.bios-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.hint.warn { color: var(--error); }

.ejs-container { position: relative; width: 100%; height: 100%; }
.ejs-container > div { width: 100%; height: 100%; }

/* Toolbar buttons with icon; Sound and Play/Pause show their state: green = on/running, red = off/paused */
.wx-icon { display: inline-flex; align-items: center; gap: .4rem; }
.wx-icon svg { flex: none; }
.wx-toggle { --state: #2f9e57; }
.wx-toggle.state-off { --state: #d64545; }
.wx-toggle.state-warn { --state: #d97a1e; } /* orange: e.g. console closed */
@media (prefers-color-scheme: dark) {
  .wx-toggle { --state: #4cc47a; }
  .wx-toggle.state-off { --state: #ff7066; }
  .wx-toggle.state-warn { --state: #f2a253; }
}
.wx-toggle, .wx-toggle:hover:not(:disabled) {
  color: var(--state);
  border-color: color-mix(in srgb, var(--state) 55%, transparent);
  background: color-mix(in srgb, var(--state) 13%, var(--surface));
}
.wx-toggle:hover:not(:disabled) { background: color-mix(in srgb, var(--state) 22%, var(--surface)); }

/* Running emulator */
.emu-badge {
  font-size: .8rem; padding: .15rem .6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.emu-badge:empty { display: none; }

/* Loading screen inside the emulator area */
.screen { position: relative; }
.loader {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .75rem;
  background: #11141a; color: #e6e9ef; padding: 2rem; text-align: left;
}
.loader[hidden] { display: none; }
.loader h3 { margin: 0; font-size: 1.15rem; }
.loader-steps { margin: 0; padding-left: 1.5rem; min-width: min(420px, 90%); }
.loader-steps li { color: #7d8697; margin: .25rem 0; }
.loader-steps li.active { color: #fff; font-weight: 600; }
.loader-steps li.done { color: #7fd69c; }
.loader-steps li.done::after { content: " ✓"; }
.loader progress { width: min(420px, 90%); height: .6rem; accent-color: var(--accent); }
.loader-detail { margin: 0; color: #9aa3b4; font-size: .9rem; min-height: 1.4em; }

/* Fullscreen: the emulator area covers the whole screen */
.screen:fullscreen { width: 100vw; height: 100vh; border-radius: 0; background: #000; }
/* The emulators fill the area; js/fit.js scales canvases to the new size. */

/* Layout: main column, then platforms and emulators side by side on the right */
.layout {
  flex: 1; width: min(1480px, 100% - 2rem);
  display: grid; grid-template-columns: minmax(0, 1fr) 220px 220px; gap: 1.25rem; align-items: start;
}
.layout > main { grid-column: 1; grid-row: 1; }
.layout > .platforms { grid-column: 2; grid-row: 1; }
.layout > .emulators { grid-column: 3; grid-row: 1; }
.site-header .wrap, .site-footer .wrap { width: min(1480px, 100% - 2rem); }
.layout:has(> .platforms[hidden]) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr) 200px 200px; gap: 1rem; }
}
@media (max-width: 960px) {
  /* main column on top, platforms and emulators side by side below it */
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .layout > main { grid-column: 1 / -1; grid-row: 1; padding-bottom: 0; }
  .layout > .platforms { grid-column: 1; grid-row: 2; }
  .layout > .emulators { grid-column: 2; grid-row: 2; }
}
@media (max-width: 600px) {
  /* one column: main, then platforms, then emulators */
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout > main, .layout > .platforms, .layout > .emulators { grid-column: auto; grid-row: auto; }
  .layout > .platforms { order: 2; }
  .layout > .emulators { order: 3; margin-top: 0; }
}

/* Side panels (platforms, emulators) */
.side-panel {
  margin-top: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem .9rem;
}
.side-panel h2 { margin: 0 0 .5rem; font-size: 1rem; }
.side-intro { margin: 0 0 .75rem; font-size: .8rem; color: var(--muted); }

/* Emulators */
.emu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.emu-card {
  padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.emu-card.highlight { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.emu-name { font-weight: 700; font-size: .95rem; }
.emu-version { font-size: .72rem; color: var(--muted); margin-left: .25rem; }
.emu-card p { margin: .25rem 0 0; font-size: .8rem; line-height: 1.35; }
.emu-card .emu-meta { color: var(--muted); font-size: .72rem; }
.platform-group li { cursor: default; border-radius: 6px; }
.platform-group li:hover { background: var(--accent-soft); }
.platform-group { break-inside: avoid; margin-bottom: .6rem; }
.platform-group h3 {
  margin: .5rem 0 .25rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.platform-group ul { list-style: none; margin: 0; padding: 0; }
.platform-group li { display: flex; align-items: center; gap: .5rem; padding: .12rem 0; font-size: .84rem; line-height: 1.2; }
.platform-icon {
  flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); background: var(--accent-soft);
}
.platform-icon svg { width: 16px; height: 16px; }
.platform-icon.logo { background: #fff; border: 1px solid var(--border); }
.platform-icon.logo img { width: 20px; height: 20px; object-fit: contain; }
.platform-name { flex: 1; min-width: 0; }
.bios-tag {
  flex: none; font-size: .62rem; font-weight: 700; letter-spacing: .03em; padding: .05rem .3rem;
  border-radius: 4px; color: var(--muted); border: 1px solid var(--border);
}
.platforms-foot { margin: .4rem 0 0; font-size: .75rem; color: var(--muted); }
.platforms-foot a { display: block; margin-top: .2rem; }

/* Demos: carousel with one tile per platform */
.demos-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.demos-head h2 { margin: 0 0 .2rem; }
.demos-head .muted { margin: 0; font-size: .9rem; }
.carousel-nav { display: flex; gap: .4rem; flex: none; }
.carousel-btn { width: 2.25rem; height: 2.25rem; padding: 0; display: inline-grid; place-items: center; }
.carousel-btn:disabled { opacity: .35; cursor: default; }

.carousel-frame { position: relative; margin: 0 -.25rem; }
.carousel-frame::before, .carousel-frame::after {
  content: ""; position: absolute; top: 0; bottom: .75rem; width: 2.5rem; z-index: 1;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.carousel-frame::before { left: 0; background: linear-gradient(to right, var(--surface), transparent); }
.carousel-frame::after { right: 0; background: linear-gradient(to left, var(--surface), transparent); }
.carousel-frame.more-left::before, .carousel-frame.more-right::after { opacity: 1; }

.demo-carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: 180px; gap: 1rem;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding: 0 .25rem;
  padding: .25rem .25rem .5rem;
  scrollbar-width: none; /* replaced by the always visible bar below (browsers hide overlay scrollbars) */
  cursor: grab;
}
.demo-carousel::-webkit-scrollbar { display: none; }

/* Scroll bar below the carousel: drag the thumb or click the track */
.carousel-bar {
  position: relative; height: 12px; margin: .35rem .25rem 0; border-radius: 999px;
  background: var(--accent-soft); cursor: pointer; touch-action: none;
}
.carousel-thumb {
  position: absolute; top: 0; bottom: 0; left: 0; min-width: 40px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 75%, transparent); cursor: grab;
}
.carousel-bar:hover .carousel-thumb, .carousel-bar.dragging .carousel-thumb { background: var(--accent); }
.carousel-bar.dragging .carousel-thumb { cursor: grabbing; }
/* Dragging with the mouse (see app.js): no snapping or text selection while dragging */
.demo-carousel.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.demo-carousel.dragging .demo-item { cursor: grabbing; }
@media (max-width: 560px) { .demo-carousel { grid-auto-columns: 44%; } }

/* Category tile: logo, name and number of demos; a click opens the demo list below */
.demo-tile {
  --tile: #7d8697;
  scroll-snap-align: start;
  font: inherit; color: var(--text); cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  border-top: 4px solid var(--tile);
  background: var(--bg); padding: 1.1rem .7rem .9rem;
  transition: border-color .15s, background .15s, transform .15s;
}
.demo-tile:hover { border-color: var(--tile); transform: translateY(-2px); }
.demo-tile[aria-expanded="true"] {
  border-color: var(--tile);
  background: color-mix(in srgb, var(--tile) 14%, var(--bg));
  box-shadow: 0 0 0 1px var(--tile);
}
.demo-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-icon {
  flex: none; width: 4.5rem; height: 4.5rem; border-radius: 16px; margin-bottom: .25rem;
  display: grid; place-items: center;
  color: var(--tile); background: color-mix(in srgb, var(--tile) 16%, transparent);
}
.tile-icon svg { width: 44px; height: 44px; }
.tile-icon.logo { background: #fff; border: 1px solid color-mix(in srgb, var(--tile) 35%, transparent); }
.tile-icon.logo img { width: 56px; height: 56px; object-fit: contain; }
.tile-name { font-weight: 600; font-size: .98rem; line-height: 1.25; }
.tile-count { font-size: .8rem; color: var(--muted); }
.demo-carousel.dragging .demo-tile { cursor: grabbing; transform: none; }

/* Demos of the opened category: panel below the carousel, arrow points at the tile */
.demo-list {
  --tile: var(--accent);
  position: relative; margin-top: .9rem; scroll-margin: 1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  border-top: 3px solid var(--tile); padding: .8rem .9rem .9rem;
}
.demo-list::before {
  content: ""; position: absolute; top: -9px; left: calc(var(--arrow, 40px) - 7px);
  width: 14px; height: 14px; background: var(--tile); transform: rotate(45deg);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.demo-list h3 { margin: 0 0 .6rem; font-size: 1rem; }
.demo-list ul {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem;
}

.demo-item {
  font: inherit; color: var(--text); background: var(--surface); cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  width: 100%; height: 100%; text-align: left; padding: .55rem .7rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.demo-item:hover { background: var(--accent-soft); border-color: var(--tile); }
.demo-item[aria-current] { background: color-mix(in srgb, var(--tile) 16%, transparent); box-shadow: inset 3px 0 0 var(--tile); }
.demo-name { font-size: .9rem; line-height: 1.3; }
.demo-file { font-family: ui-monospace, Consolas, monospace; font-size: .75rem; color: var(--muted); }

/* Demo info: panel below the carousel, arrow points at the tile */
.demo-detail {
  --tile: var(--accent);
  position: relative; margin-top: .9rem; scroll-margin: 1rem; /* space when scrolled into view */
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 3px solid var(--tile);
  padding: .9rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem 1.25rem; align-items: start;
}
.demo-detail::before {
  content: ""; position: absolute; top: -7px; left: calc(var(--arrow, 40px) - 6px);
  width: 12px; height: 12px; background: var(--bg);
  border-top: 1px solid var(--border); border-left: 1px solid var(--border);
  transform: rotate(45deg);
}
.demo-info { display: flex; flex-direction: column; gap: .3rem; }
.demo-detail h3 { margin: 0; padding-right: 1.5rem; font-size: 1.05rem; }
.demo-detail p { margin: 0; font-size: .88rem; }
.demo-detail .demo-meta { color: var(--muted); }
.demo-close {
  position: absolute; top: .35rem; right: .45rem;
  font: inherit; font-size: 1.2rem; line-height: 1; color: var(--muted);
  background: none; border: 0; cursor: pointer; padding: .2rem .35rem; border-radius: 6px;
}
.demo-close:hover { background: var(--accent-soft); color: var(--text); }
@media (max-width: 640px) { .demo-detail { grid-template-columns: minmax(0, 1fr); } }

/* Green start button (demo info) */
.wx-btn.wx-go { background: #1f9d55; border-color: #1f9d55; color: #fff; font-weight: 600; }
.wx-btn.wx-go:hover { background: #178046; border-color: #178046; }

/* Complete PC (v86): text mode div and graphics canvas, v86 switches between them */
.v86-container {
  width: 100%; height: 100%; overflow: hidden;
  display: flex; justify-content: center; align-items: center; cursor: pointer;
}
.v86-text { flex: none; white-space: pre; font: 14px/14px ui-monospace, Consolas, monospace; color: #fff; }
.v86-canvas { flex: none; image-rendering: pixelated; }

/* Own operating system button inside the "Open a program" card */
.own-os { margin: 1.5rem auto 0; padding-top: 1.25rem; border-top: 1px solid var(--border); max-width: 560px; }
.own-os-title { margin: 0 0 .75rem; font-weight: 600; }
.own-os .hint { margin-top: .6rem; }

/* Message box */
.msg-dialog {
  width: min(480px, 100vw - 2rem); padding: 1.25rem 1.5rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgb(0 0 0 / .35);
}
.msg-dialog::backdrop { background: rgb(0 0 0 / .45); }
.msg-dialog h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
.msg-dialog.error h3 { color: var(--error); }
.msg-dialog p { margin: 0; }
.msg-files {
  margin: .75rem 0 0; padding: .5rem .75rem .5rem 1.75rem; max-height: 220px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace; font-size: .85rem;
}
.msg-files .more { list-style: none; margin-left: -1rem; color: var(--muted); font-family: inherit; }
.msg-dialog.wide { width: min(760px, 100vw - 2rem); }
.run-options { margin-top: .75rem; }

/* Virtual keyboard between toolbar and picture */
.keys-panel { display: flex; flex-wrap: wrap; gap: .3rem; margin: -.25rem 0 .75rem; align-items: center; }
.keys-panel .key {
  font: inherit; font-size: .8rem; min-width: 2.4rem; padding: .3rem .5rem; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 3px; border-radius: 6px;
}
.keys-panel .key:hover { border-color: var(--accent); }
.keys-panel .key:active { transform: translateY(1px); }
.keys-panel .key[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.keys-panel .key.wide { min-width: 4rem; }
.keys-panel .sep { width: .6rem; }
.keys-panel .hint { margin: 0 0 0 .4rem; font-size: .78rem; }
#btn-keys[aria-expanded="true"], #btn-pad[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.report-form { display: grid; gap: .6rem; margin-top: .75rem; max-height: min(62vh, 640px); overflow: auto; padding-right: .25rem; }
.report-field { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
.report-field input, .report-field select, .report-field textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: .4rem .55rem;
}
.report-field textarea { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; resize: vertical; }
.report-field input:focus, .report-field select:focus, .report-field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.report-shot { max-width: 100%; max-height: 220px; justify-self: start; border: 1px solid var(--border); border-radius: 6px; image-rendering: pixelated; }
.report-attach { display: flex; gap: .5rem; align-items: flex-start; margin-top: .75rem; font-size: .9rem; }
.report-attach input { margin-top: .25rem; }
.report-note { margin-top: .5rem !important; font-size: .82rem; color: var(--muted); }
.msg-actions { margin-top: 1.25rem; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }

/* Demo info: start/options buttons and per-demo options */
.demo-actions { display: flex; gap: .5rem; align-self: center; margin-right: 1.5rem; }
.demo-options {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem 1rem; align-items: end;
  margin-top: .5rem; padding-top: .7rem; border-top: 1px solid var(--border);
}
.demo-options .hint, .demo-options label.check { grid-column: 1 / -1; }
.demo-options label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.demo-options label.check { flex-direction: row; align-items: center; color: var(--text); }
.demo-options select, .demo-options input[type="text"] {
  font: inherit; font-size: .9rem; padding: .35rem .5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.demo-options .hint { margin: 0; font-size: .8rem; }

/* Touch gamepad over the emulator picture (js/gamepad.js) */
.gamepad {
  --gp-size: clamp(110px, 24vmin, 170px);
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: flex-end; gap: .5rem;
  padding: clamp(.5rem, 2vmin, 1.25rem);
  pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.gamepad[hidden], .screen:has(> .loader:not([hidden])) .gamepad { display: none; }
.gamepad > * { pointer-events: auto; touch-action: none; }
.gp-dpad { position: relative; width: var(--gp-size); height: var(--gp-size); opacity: .6; }
.gp-arm { position: absolute; background: #555; border: 2px solid #999; }
.gp-up, .gp-down { left: 33%; width: 34%; height: 40%; }
.gp-left, .gp-right { top: 33%; height: 34%; width: 40%; }
.gp-up { top: 0; border-radius: 8px 8px 0 0; border-bottom: 0; }
.gp-down { bottom: 0; border-radius: 0 0 8px 8px; border-top: 0; }
.gp-left { left: 0; border-radius: 8px 0 0 8px; border-right: 0; }
.gp-right { right: 0; border-radius: 0 8px 8px 0; border-left: 0; }
.gp-dpad::after { content: ""; position: absolute; left: 33%; top: 33%; width: 34%; height: 34%; background: #555; }
.gp-arm.down { background: #8a8a8a; }
.gp-actions {
  position: relative; width: var(--gp-size); height: var(--gp-size); opacity: .6;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}
.gp-btn, .gp-small, .gp-settings {
  font: inherit; color: #ddd; background: #262626; border: 2px solid #bbb; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.gp-btn { border-radius: 50%; }
.gp-btn b { font-size: calc(var(--gp-size) * .13); }
.gp-btn small, .gp-small small { font-size: calc(var(--gp-size) * .075); color: #aaa; max-width: 95%; overflow: hidden; white-space: nowrap; }
.gp-y { grid-area: 1 / 2; } .gp-x { grid-area: 2 / 1; } .gp-b { grid-area: 2 / 3; } .gp-a { grid-area: 3 / 2; }
.gp-btn.down, .gp-small.down { background: #5a5a5a; }
.gp-middle { display: flex; gap: .5rem; align-items: center; opacity: .6; }
.gp-small { border-radius: 8px; padding: .25rem .6rem; min-width: 3.6rem; }
.gp-small b { font-size: .8rem; font-weight: 600; }
.gp-settings { border-radius: 50%; width: 2rem; height: 2rem; font-size: 1rem; }
.gp-settings:hover, .gp-btn:hover, .gp-small:hover { border-color: #fff; }

/* Gamepad mapping dialog */
.pad-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem .75rem; }
.pad-map label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }

/* Multiplayer (js/lobby.js): button in the header, room panel over the side panels */
.badge { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: .1rem .45rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.np-badge { background: color-mix(in srgb, #2da44e 15%, var(--surface)); color: #2da44e; }

.mp-button {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  padding: .4rem .95rem; border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: #fff; font: inherit; font-size: .9rem; font-weight: 700;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: background-color .15s, box-shadow .15s, transform .15s;
}
.mp-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.mp-button.active { background: var(--surface); color: var(--accent); box-shadow: none; }
.mp-button.in-room { background: #2da44e; border-color: #2da44e; box-shadow: 0 2px 8px rgb(45 164 78 / .35); }
.mp-button.in-room.active { background: var(--surface); color: #2da44e; box-shadow: none; }
.mp-button-room { padding: .05rem .5rem; border-radius: 999px; font-size: .8rem;
  background: rgb(255 255 255 / .22); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-button.active .mp-button-room { background: color-mix(in srgb, currentColor 14%, transparent); }
@media (max-width: 560px) { .mp-button > span { display: none; } .mp-button { padding: .45rem .6rem; } }

/* The panel takes the place of the platforms and emulators */
.layout > .multiplayer { grid-column: 2 / 4; grid-row: 1; }
.layout.mp-open > .platforms, .layout.mp-open > .emulators { display: none; }
@media (max-width: 960px) { .layout > .multiplayer { grid-column: 1 / -1; grid-row: 2; } }
@media (max-width: 600px) { .layout > .multiplayer { grid-column: auto; grid-row: auto; order: -1; } }
.layout:has(> .platforms[hidden]) > .multiplayer { grid-column: 1; grid-row: 2; } /* while a program runs */

.multiplayer { padding: 1.1rem 1.2rem 1.2rem; border-top: 3px solid var(--accent); }
.mp-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.mp-head h2 { display: inline-flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.15rem; }
.mp-close { border: 0; background: none; color: var(--muted); cursor: pointer; padding: .25rem; border-radius: 6px; display: inline-flex; }
.mp-close:hover { color: var(--text); background: var(--accent-soft); }

.mp-setup { display: flex; flex-direction: column; gap: .7rem; }
.mp-setup .side-intro { margin-bottom: .1rem; font-size: .85rem; }
.multiplayer label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; }
.mp-optional { font-weight: 400; color: var(--muted); font-size: .78rem; }
.multiplayer input { font: inherit; font-size: .95rem; padding: .45rem .6rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.multiplayer input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.mp-setup > .wx-btn { align-self: stretch; justify-content: center; padding-block: .55rem; font-weight: 700; }
.mp-server { font-size: .8rem; color: var(--muted); }
.mp-server summary { cursor: pointer; }
.mp-server label { margin-top: .4rem; font-weight: 400; }

.mp-room-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .7rem .85rem; border-radius: 8px; background: var(--accent-soft); margin-top: .4rem; }
.mp-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mp-room-name { font-size: 1.3rem; line-height: 1.2; word-break: break-word; }
.mp-lock { color: var(--accent); display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; white-space: nowrap; cursor: help; }
.mp-note { margin: -.2rem 0 0; font-size: .75rem; color: var(--muted); }
.mp-wait { margin: .6rem 0 0; padding: .45rem .6rem; border-radius: 8px; font-size: .85rem;
  background: color-mix(in srgb, #2da44e 12%, var(--surface)); }
.np-restart { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  margin: .5rem 0; padding: .5rem .75rem; border: 1px solid color-mix(in srgb, #2da44e 45%, var(--border));
  border-radius: 8px; background: color-mix(in srgb, #2da44e 10%, var(--surface)); font-size: .9rem; }
.mp-room-input { display: flex; gap: .4rem; margin-top: -.35rem; }
.mp-room-input input { flex: 1; min-width: 0; }
.mp-random { flex: none; display: inline-flex; align-items: center; gap: .3rem; }
.mp-weak { margin: -.2rem 0 0; font-size: .75rem; color: #b26a00; }
@media (prefers-color-scheme: dark) { .mp-weak { color: #e3a33b; } }
.mp-help-link { display: inline; padding: 0; border: 0; background: none; color: var(--accent);
  font: inherit; text-decoration: underline; cursor: pointer; }
.mp-help-btn { display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; padding: 0;
  border: 1px solid currentColor; border-radius: 50%; background: none; color: inherit;
  font-size: .7rem; font-weight: 700; line-height: 1; cursor: pointer; }
.mp-help-btn:hover, .mp-help-link:hover { color: var(--text); }
.mp-help { width: min(620px, 100vw - 2rem); }
.mp-help p { margin: 0 0 .65rem; font-size: .92rem; line-height: 1.45; }
.mp-help .mp-help-small { font-size: .8rem; color: var(--muted); }
.mp-flow { display: flex; align-items: stretch; gap: .4rem; margin: .4rem 0 1rem; }
.mp-flow-box { flex: 1; display: flex; flex-direction: column; gap: .15rem; padding: .55rem .6rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: .8rem; text-align: center; }
.mp-flow-box span { color: var(--muted); }
.mp-flow-relay { border-style: dashed; }
.mp-flow-arrow { align-self: center; color: var(--muted); }
@media (max-width: 560px) { .mp-flow { flex-direction: column; } .mp-flow-arrow { transform: rotate(90deg); } }
.mp-safety { margin: .5rem 0 0; font-size: .8rem; color: var(--muted); }
.mp-safety strong { font-family: ui-monospace, monospace; font-size: .95rem; color: var(--text); letter-spacing: .04em; }
.mp-safety span { display: block; font-size: .72rem; margin-top: .15rem; }
.mp-sub { margin: .9rem 0 .4rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.mp-members { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.mp-member { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.mp-member.online { border-color: color-mix(in srgb, #2da44e 45%, var(--border)); }
.mp-avatar { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: hsl(var(--hue, 220) 55% 50%); }
.mp-member-text { min-width: 0; }
.mp-member-name { display: flex; align-items: center; gap: .35rem; font-weight: 600; }
.mp-member-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-tag { font-size: .68rem; font-weight: 600; padding: 0 .4rem; border-radius: 999px; }
.mp-tag-host { background: color-mix(in srgb, #d4a017 20%, var(--surface)); color: #a07400; }
.mp-tag-you { background: var(--accent-soft); color: var(--accent); }
.mp-member-state { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-member.online .mp-member-state { color: #2da44e; }
.mp-dot { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: #2da44e;
  box-shadow: 0 0 0 3px rgb(45 164 78 / .2); }
.mp-room .hint { margin: .8rem 0 0; font-size: .8rem; }
.mp-actions { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.multiplayer .error { margin: .7rem 0 0; }
