@font-face {
  font-family: Handjet;
  src: url("fonts/handjet.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #1a1e32; --navy1: #0e1e5c; --navy2: #1a3484;
  --blue-d: #001858; --blue: #003399; --gold: #ffcc00; --gold-d: #c89000;
  --gld-hi: #fff6b8; --gld-mid: #fad048; --gld-lo: #ce9210;
  --btn-hi: #f4f8ff; --btn-mid: #cedefa; --btn-lo: #9cb8ec;
  --white: #f8f8f8; --text: #383840;
}
* { box-sizing: border-box; }
html { background: var(--navy1); }
body {
  margin: 0; color: var(--white);
  font: 22px/1.3 Handjet, "Courier New", monospace; letter-spacing: .02em;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' shape-rendering='crispEdges'%3E%3Cpath fill='%23001858' d='M10 12h6v2h-6zM12 10h2v6h-2zM34 36h6v2h-6zM36 34h2v6h-2z'/%3E%3C/svg%3E"),
    linear-gradient(var(--navy1) 0, var(--blue-d) 45%, var(--navy2) 100%);
  min-height: 100vh;
}
main { max-width: 1000px; margin: auto; padding: 32px 16px 24px; text-align: center; }
header { margin-bottom: 24px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
a { color: var(--gold); text-underline-offset: 3px; }
button, .file-button { font: inherit; cursor: pointer; }
button:focus-visible, .file-button:focus-within, a:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 4px;
}
.back, .toolbar button, .multiplayer button, .file-button, .console .boot button {
  position: relative; display: inline-block; padding: 8px 20px 6px;
  color: var(--ink); text-decoration: none; font-weight: 700;
  background: linear-gradient(var(--gld-hi) 0, var(--gld-mid) 45%, var(--gold) 55%, var(--gld-lo) 100%);
  border: 3px solid var(--gold-d); border-radius: 8px;
  box-shadow: 0 2px 0 #fff inset, 4px 4px 0 var(--ink);
}
.back:active, .toolbar button:active, .console .boot button:active {
  transform: translate(2px, 2px); box-shadow: 0 2px 0 #fff inset, 2px 2px 0 var(--ink);
}

/* DS Lite proportions, based on a 474 × 491 open console.
   Screens: 224 × 168, at (125,36) and (125,288). A single 256 × 480
   emulator surface includes a 96px gap; clipping preserves native stylus coordinates. */
.console {
  width: 100%; max-width: 640px; aspect-ratio: 474 / 491;
  position: relative; margin: auto; isolation: isolate; container-type: inline-size;
  filter: drop-shadow(5px 7px 0 #080d26aa);
}
.lid, .base {
  position: absolute; left: 0; width: 100%;
  border: 1px solid #090a0a; border-radius: 2.6cqw;
  background:
    linear-gradient(90deg, #ffffff06, transparent 15%, #ffffff03 50%, transparent 85%, #0003),
    linear-gradient(110deg, #303131, #202222 45%, #292b2b 75%, #1c1e1e);
  box-shadow: inset 0 0 0 1px #818484, inset 0 0 0 3px #151717,
    inset 0 0 0 4px #3c3e3e, inset 0 7px 10px #0008;
}
.lid { top: 0; height: 47.25%; }
.base {
  top: 52.75%; height: 47.25%; border-radius: 1.8cqw 1.8cqw 2.6cqw 2.6cqw;
  background: linear-gradient(90deg, #1c1e1e, #2e3030 19%, #151717 24%, #282a2a 76%, #1b1d1d 82%, #252727);
}
.bumper { position: absolute; width: 3%; height: 6%; border-radius: .5cqw; background: #202222; box-shadow: inset 0 1px 3px #0004; }
.bumper.tl { left: 12.5%; top: 8%; } .bumper.tr { right: 12.5%; top: 8%; }
.bumper.bl { left: 12.5%; bottom: 4%; } .bumper.br { right: 12.5%; bottom: 4%; }
.speaker {
  position: absolute; top: 46%; width: 12.3%; height: 15.5%;
  background: radial-gradient(circle, #030505 0 15%, #555858 19%, transparent 24%) 0 0 / 33.333% 50%;
}
.speaker.left { left: 6.4%; } .speaker.right { right: 6.4%; }
.bezel {
  position: absolute; background: #181a1a; border: 1px solid #090b0b; border-radius: .7cqw;
  box-shadow: 0 1px 1px #6e7373, inset 0 0 0 2px #303232, inset 0 0 0 4px #171919;
}
.bezel.top { left: 24.05%; top: 4.89%; width: 51.9%; height: 39.1%; }
.bezel.bottom { left: 23.63%; top: 55.4%; width: 52.75%; height: 39.5%; box-shadow: 0 1px 1px #757979, 0 0 5px #000, inset 0 0 0 3px #303232, inset 0 0 0 6px #0f1111; }
#display {
  position: absolute; left: 26.371308%; top: 7.331976%; width: 47.257384%; height: 85.539715%;
  background: #000;
  clip-path: polygon(0 0, 100% 0, 100% 40%, 0 40%, 0 60%, 100% 60%, 100% 100%, 0 100%);
}
#game { display: block; width: 100%; height: 100%; border: 0; }
.console:not(.running) #game { visibility: hidden; }
.hinge {
  position: absolute; left: .3%; top: 46.85%; height: 6.7%; width: 99.4%;
  background: linear-gradient(#131515, #555858 17%, #343636 36%, #202222 70%, #0d0f0f 91%, #3c3e3e);
  border: 1px solid #080a0a; border-radius: 3cqw;
  box-shadow: inset 0 1px 1px #b0b3b3, 0 2px 3px #0009;
}
.hinge i { position: absolute; top: 0; height: 100%; width: 12%; border-right: 1px solid #090b0b; box-shadow: 1px 0 #5b5e5e; }
.hinge i:first-child { left: 0; } .hinge i:last-child { right: 0; border-right: 0; border-left: 1px solid #090b0b; box-shadow: -1px 0 #5b5e5e; }
.mic { position: absolute; top: 33%; left: 49.4%; font: 1.3cqw Arial, sans-serif; color: #101212; text-shadow: 0 1px #5c5e5e; padding-left: 2cqw; }
.mic::before { content: ""; position: absolute; left: 0; top: 0; width: .65cqw; height: 2.3cqw; border-radius: .2cqw; background: #090b0b; box-shadow: 1px 0 #666; }
.led { position: absolute; right: 4.7%; top: 48.1%; height: 4.1%; width: .7%; border-radius: 2px; background: #b2ba8c; box-shadow: -1.5cqw 0 #626969; }
.running .led { background: #c4e65c; box-shadow: 0 0 5px #b5e85a66, -1.5cqw 0 #a0b4a7; }
.console button {
  position: absolute; touch-action: none; user-select: none; -webkit-user-select: none;
  color: #c0c3c3; border: 1px solid #060808;
  background: linear-gradient(135deg, #404343, #1d2020 60%, #111313);
  box-shadow: inset 1px 1px 2px #737676, inset -1px -1px 2px #030505, 0 1px 3px #000;
  font-family: Arial, sans-serif; font-weight: 400; text-shadow: 0 1px #000;
  padding: 0;
}
.console button:active, .console button.pressed { background: #171a1a; box-shadow: inset 1px 2px 3px #000; transform: translateY(1px); }
/* Shoulder controls sit on the outer hinge caps, as the shoulders are behind the base. */
.console .shoulder { top: 47.2%; width: 10%; height: 5.6%; border: 0; box-shadow: none; background: transparent; color: #9b9e9e; border-radius: 3cqw; font-size: 2cqw; }
.shoulder.l { left: 1%; } .shoulder.r { right: 7%; }
.dpad { position: absolute; left: 4.64%; top: 64.15%; width: 13.92%; aspect-ratio: 1; filter: drop-shadow(0 1px 1px #000); }
.dpad button, .dpad span { position: absolute; width: 34%; height: 34%; border-radius: .3cqw; }
.dpad::before, .dpad::after {
  content: ""; position: absolute;
  clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%);
}
.dpad::before { inset: -2%; background: #030505; }
.dpad::after { inset: 0; background: linear-gradient(135deg, #737676, #333737 10%, #242727 65%, #080b0b); }
.console .dpad button { z-index: 2; border: 0; box-shadow: none; background: transparent; }
.console .dpad button.pressed, .console .dpad button:active { background: #0004; box-shadow: inset 0 1px 3px #0008; }
.dpad span { left: 33%; top: 33%; }
.dpad .up { left: 33%; top: 0; border-bottom: 0; border-radius: .4cqw .4cqw 0 0; }
.dpad .down { left: 33%; top: 66%; border-top: 0; border-radius: 0 0 .4cqw .4cqw; }
.dpad .left { left: 0; top: 33%; border-right: 0; border-radius: .4cqw 0 0 .4cqw; }
.dpad .right { left: 66%; top: 33%; border-left: 0; border-radius: 0 .4cqw .4cqw 0; }
.dpad i { position: absolute; background: #d3d6d6; border-radius: 1px; width: 10%; height: 50%; left: 45%; top: 25%; box-shadow: 1px 0 #000; }
.dpad .left i, .dpad .right i { width: 50%; height: 10%; left: 25%; top: 45%; }
.abxy { position: absolute; right: 3.35%; top: 60.9%; width: 16.88%; aspect-ratio: 1; }
.abxy button { width: 32%; height: 32%; border-radius: 50%; font-size: 2.9cqw; }
.abxy .x { left: 34%; top: 0; } .abxy .b { left: 34%; bottom: 0; }
.abxy .y { left: 0; top: 34%; } .abxy .a { right: 0; top: 34%; }
.system { position: absolute; left: 79.3%; top: 84.7%; width: 16%; height: 9%; display: grid; gap: 10%; }
.console .system button { position: relative; background: none; border: 0; box-shadow: none; text-align: left; font-size: 1.65cqw; display: flex; align-items: center; gap: 7%; }
.system i { width: 18%; aspect-ratio: 1; flex: none; border-radius: 50%; background: linear-gradient(135deg, #3d4040, #111414); border: 1px solid #060808; box-shadow: inset 1px 1px 1px #6c7070, 0 1px 1px #000; }
.system button.pressed i { background: #111; box-shadow: inset 0 1px 2px #000; }
.boot {
  position: absolute; left: 26.371308%; top: 7.331976%; width: 47.257384%; height: 34.215886%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: linear-gradient(var(--navy1), var(--blue-d)); font-size: 3cqw;
}
.boot[hidden] { display: none; }
.console .boot button { margin-top: 5%; font-family: Handjet, monospace; font-size: 3.8cqw; padding: 2% 7%; text-shadow: none; }
.loading { max-width: 520px; margin: 26px auto 0; text-align: left; }
.loading label { color: var(--gold); }
progress { display: block; width: 100%; height: 22px; margin-top: 8px; border: 2px solid var(--gold-d); border-radius: 3px; background: var(--blue-d); accent-color: var(--gold); }
progress::-webkit-progress-bar { background: var(--blue-d); }
progress::-webkit-progress-value { background: linear-gradient(var(--gld-hi), var(--gold), var(--gld-lo)); }
progress::-moz-progress-bar { background: linear-gradient(var(--gld-hi), var(--gold), var(--gld-lo)); }
.loading p, #status { color: var(--btn-lo); font-size: 19px; }
#status { margin: 24px 0 16px; }
#status:empty { display: none; }
.toolbar { margin-top: 24px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.toolbar button, .file-button { font-size: 23px; padding: 8px 18px 6px; }
.toolbar button:disabled, .file-button:has(input:disabled) { opacity: .5; cursor: default; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
footer { color: var(--btn-lo); font-size: 18px; margin: 30px 0 8px; }
.console:fullscreen { background: #151b2c; width: min(100vw, 96.5377vh); max-width: none; margin: auto; }
@media (max-width: 520px) {
  main { padding: 24px 12px; }
  header { justify-content: center; gap: 12px; }
  .toolbar { gap: 10px; }
  .toolbar button, .file-button { font-size: 21px; padding: 7px 14px 5px; }
  .console .boot button { border-width: 2px; border-radius: 4px; box-shadow: 0 1px 0 #fff inset, 2px 2px 0 var(--ink); }
}

.controls {
  max-width: 520px; margin: 30px auto 0; padding: 12px 18px;
  text-align: left; color: var(--text); background: var(--white);
  border: 3px solid var(--blue); border-radius: 4px;
  box-shadow: 0 0 0 2px var(--white), 0 0 0 5px var(--blue-d), 5px 5px 0 5px var(--ink);
}
.controls summary { cursor: pointer; color: var(--blue); font-weight: 700; }
.controls summary:focus-visible { outline: 3px solid var(--gold-d); outline-offset: 4px; }
.controls table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 21px; }
.controls th, .controls td { padding: 6px 4px; border-bottom: 1px solid var(--btn-mid); text-align: left; }
.controls tbody th { font-weight: 500; white-space: nowrap; }
.controls kbd { font: inherit; padding: 0 5px; border: 1px solid var(--btn-lo); border-radius: 3px; background: var(--btn-hi); color: var(--blue-d); }


.controls p { margin: 14px 4px 4px; font-size: 20px; }


.controls .controller-note { display: flex; align-items: center; gap: 8px; }
.controller-note img { flex: none; image-rendering: pixelated; }

.multiplayer form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin: 1rem 0; }
.multiplayer label { display: grid; gap: .3rem; flex: 1 1 12rem; }
.multiplayer input { min-width: 0; padding: .6rem; color: var(--blue-d); background: var(--btn-hi); border: 1px solid var(--blue); border-radius: .3rem; font: inherit; }
.multiplayer button { padding: .6rem 1rem; cursor: pointer; }
.multiplayer button:disabled { cursor: default; opacity: .5; }

.multiplayer a { color: var(--blue); }

