:root {
  color-scheme: light;
  --teal: #008080;
  --frame: #121416;
  --face: #c0c0c0;
  --navy: #000080;
  --hi: #ffffff;
  --mid: #dfdfdf;
  --shade: #808080;
  --ink: #000;
  font-family: Tahoma, "Microsoft Sans Serif", sans-serif;
  font-size: 11px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
body {
  background: var(--frame);
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

#screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--frame);
  padding: 12px;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
}

#desktop { flex: 1; position: relative; min-height: 0; background: var(--teal); }

#icons {
  position: absolute;
  z-index: 1;
  inset: 8px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px 8px;
}

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 80px;
  border: 0;
  background: transparent;
  padding: 2px;
  color: #fff;
}
.icon .glyph { width: 32px; height: 32px; }
.icon .glyph svg, .icon .glyph img { width: 32px; height: 32px; display: block; }
.icon .name {
  text-align: center;
  text-shadow: 1px 1px 0 #000;
  padding: 1px 3px;
  line-height: 1.2;
  max-width: 76px;
  word-break: break-word;
}
.icon.sel .name { background: var(--navy); text-shadow: none; }
.icon:focus-visible .name { outline: 1px dotted #fff; }

#taskbar {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
  padding-right: 2px;
  background: var(--face);
  border-top: 2px solid var(--hi);
  box-shadow: inset 0 1px 0 var(--mid);
  z-index: 5;
  flex: none;
}

#start {
  height: 22px;
  padding: 0 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: inset 1px 1px 0 var(--mid), inset -1px -1px 0 var(--shade);
}
#start.down, #start.open {
  border-color: var(--ink) var(--hi) var(--hi) var(--ink);
  box-shadow: inset 1px 1px 0 var(--shade);
  padding: 1px 7px 0 5px;
}
#start svg { width: 16px; height: 16px; }

#tasks { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.task {
  max-width: 180px;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: inset 1px 1px 0 var(--mid);
}
.task.on {
  border-color: var(--ink) var(--hi) var(--hi) var(--ink);
  box-shadow: inset 1px 1px 0 var(--shade);
  background: #d4d0c8;
  font-weight: bold;
}
.task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task svg, .task img { width: 16px; height: 16px; flex: none; display: block; }
#startmenu img { width: 16px; height: 16px; display: block; }

#clock {
  height: 22px;
  min-width: 64px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
}

#volume {
  width: 24px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--face);
  border: 1px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
}
#volume svg { width: 16px; height: 16px; display: block; }
#volume.open {
  border-color: var(--ink) var(--hi) var(--hi) var(--ink);
  box-shadow: inset 1px 1px 0 var(--shade);
}

#volpop {
  position: absolute;
  z-index: 50;
  width: 74px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: 2px 2px 0 #000;
  padding: 8px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#volpop input[type="range"] {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 22px;
  height: 96px;
  accent-color: var(--navy);
  margin: 0;
}
#volpop label { display: flex; align-items: center; gap: 4px; }

#startmenu {
  position: absolute;
  bottom: calc(32px + 12px);
  bottom: calc(32px + max(12px, env(safe-area-inset-bottom, 0px)));
  left: calc(2px + 12px);
  left: calc(2px + max(12px, env(safe-area-inset-left, 0px)));
  width: 180px;
  max-height: calc(100% - 64px);
  overflow: auto;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: 2px 2px 0 #000;
  z-index: 40;
  padding: 2px;
}
#startmenu button {
  display: flex;
  width: 100%;
  text-align: left;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 6px 8px;
}
#startmenu button:hover, #startmenu button:focus { background: var(--navy); color: #fff; }
#startmenu .rule {
  height: 2px;
  margin: 2px 4px;
  border-top: 1px solid var(--shade);
  border-bottom: 1px solid var(--hi);
}
#startmenu svg { width: 16px; height: 16px; }

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--mid) #000 #000 var(--mid);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--shade);
  padding: 2px;
}
.window.maxed { inset: 0; width: auto !important; height: auto !important; }
.window.sizing iframe { pointer-events: none; }
.rz { position: absolute; z-index: 5; }
.rz-n, .rz-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rz-n { top: -2px; }
.rz-s { bottom: -2px; }
.rz-e, .rz-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rz-e { right: -2px; }
.rz-w { left: -2px; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 10px; height: 10px; z-index: 6; }
.rz-ne { top: -2px; right: -2px; cursor: nesw-resize; }
.rz-nw { top: -2px; left: -2px; cursor: nwse-resize; }
.rz-se { right: -2px; bottom: -2px; cursor: nwse-resize; }
.rz-sw { left: -2px; bottom: -2px; cursor: nesw-resize; }

.titlebar {
  height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px 2px 3px;
  background: var(--shade);
  color: var(--mid);
  font-weight: bold;
  flex: none;
}
.window.focus .titlebar { background: var(--navy); color: #fff; }
.titlebar .ticon { width: 16px; height: 16px; flex: none; }
.titlebar .ticon svg, .titlebar .ticon img { width: 16px; height: 16px; display: block; }
.titlebar .ttext { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbs { display: flex; gap: 2px; }
.tb {
  width: 16px;
  height: 14px;
  padding: 0;
  line-height: 12px;
  font-size: 10px;
  font-weight: bold;
  background: var(--face);
  color: #000;
  border: 1px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: inset 1px 1px 0 var(--mid);
}
.tb:active { border-color: var(--ink) var(--hi) var(--hi) var(--ink); }

.menubar { display: flex; gap: 0; padding: 1px 0; position: relative; flex: none; }
.menubar > button {
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 7px;
}
.menubar > button:hover, .menubar > button.open {
  background: var(--navy);
  color: #fff;
}
.menu-pop {
  position: absolute;
  top: 100%;
  min-width: 168px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) #000 #000 var(--hi);
  box-shadow: inset -1px -1px 0 var(--shade), inset 1px 1px 0 var(--mid);
  padding: 2px;
  z-index: 6;
}
.menu-pop button {
  display: block;
  width: 100%;
  position: relative;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 3px 8px 3px 22px;
}
.menu-pop button:hover, .menu-pop button:focus { background: var(--navy); color: #fff; }
.menu-pop button.checked::before { content: "✓"; position: absolute; left: 6px; }
.menu-pop .sep {
  height: 2px;
  margin: 3px 2px;
  border-top: 1px solid var(--shade);
  border-bottom: 1px solid var(--hi);
}

.client { flex: 1; min-height: 0; position: relative; }
.sunken {
  background: #fff;
  border: 2px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
  box-shadow: inset 1px 1px 0 #000, inset -1px -1px 0 var(--mid);
  overflow: auto;
}

.dane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--face);
  min-height: 0;
}
.dane-bar {
  display: flex;
  gap: 4px;
  padding: 3px;
  flex: none;
}
.dane-bar .nav { min-width: 22px; padding: 0 4px; }
.dane-bar button:disabled { color: var(--shade); }
.n64host { position: absolute; inset: 0; background: #000; }
.n64host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }

.dane-bar input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: #000;
  background: #fff;
  border: 2px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
  padding: 2px 4px;
}
.dane iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.addr {
  margin: 2px 2px 0;
  padding: 2px 4px;
  background: #fff;
  border: 2px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
  flex: none;
}

.files {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px 4px;
  padding: 8px;
  height: 100%;
}
.files .icon { color: #000; width: 84px; }
.files .icon .name { text-shadow: none; }
.files .icon.sel .name { color: #fff; }

.statusbar {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  flex: none;
  min-height: 18px;
}
.statusbar span {
  border: 1px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
  padding: 1px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.statusbar .grow { flex: 1; }

.sheet {
  height: 100%;
  overflow: auto;
  background: #fff;
  color: #000;
  padding: 10px 12px 16px;
  user-select: text;
}
.sheet h1 { font-size: 13px; margin: 0 0 6px; }
.sheet p { margin: 0 0 8px; line-height: 1.45; }
.gets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
a.cmd {
  display: inline-block;
  text-decoration: none;
  color: #000;
  text-align: center;
}
.shots { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.shots img {
  width: 180px;
  max-width: 100%;
  height: auto;
  border: 1px solid #808080;
  background: #000;
}

.note {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  margin: 0;
  padding: 6px 8px;
  background: #fff;
  color: #000;
  font: 18px/1.45 "Courier New", Courier, monospace;
  user-select: text;
}

.shade {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: transparent;
}
.dialog { position: relative; width: min(420px, calc(100% - 24px)); max-height: calc(100% - 24px); }
.dialog .client { padding: 14px 12px 10px; overflow: auto; }
.dlg-row { display: flex; gap: 12px; align-items: flex-start; }
.dlg-icon { width: 32px; height: 32px; flex: none; }
.dlg-text { white-space: pre-wrap; line-height: 1.35; padding-top: 2px; }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.dlg-buttons button, .cmd {
  min-width: 78px;
  padding: 4px 12px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) var(--ink) var(--ink) var(--hi);
  box-shadow: inset 1px 1px 0 var(--mid), inset -1px -1px 0 var(--shade);
}
.dlg-buttons button:focus, .cmd:focus { outline: 1px dotted #000; outline-offset: -4px; }
.dlg-buttons button:active, .cmd:active {
  border-color: var(--ink) var(--hi) var(--hi) var(--ink);
  box-shadow: inset 1px 1px 0 var(--shade);
}

.copy-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.copy-row .doc {
  width: 22px;
  height: 26px;
  background: #fff;
  border: 1px solid #000;
  box-shadow: 2px 2px 0 #888;
  animation: fly 0.7s linear infinite;
}
@keyframes fly {
  0% { transform: translateX(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(18px); opacity: 0; }
}
.meter {
  flex: 1;
  height: 18px;
  border: 2px solid;
  border-color: var(--shade) var(--hi) var(--hi) var(--shade);
  box-shadow: inset 1px 1px 0 #000;
  background: var(--face);
  overflow: hidden;
}
.meter > div {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--navy) 0 10px, var(--face) 10px 12px);
  background-size: 24px 100%;
  animation: march 0.45s linear infinite;
}
@keyframes march { to { background-position: 24px 0; } }
.copy-meta { margin-top: 8px; line-height: 1.4; }

.shake { animation: shake 0.18s linear; }
@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.gb {
  --plastic: #c6b15a;
  --ink: #2a2208;
  background:
    linear-gradient(160deg, #fff6, transparent 28%),
    var(--plastic);
  color: var(--ink);
  border-radius: 10px 10px 22px 22px;
  padding: 10px 14px 12px;
  box-shadow: inset 2px 2px 0 #fff8, inset -3px -4px 0 #0004, 0 1px 0 #0004;
  display: flex;
  flex-direction: column;
  min-height: 0;
  touch-action: none;
}
.gb-top, .gb-mid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.power { display: flex; align-items: center; gap: 5px; font-size: 8px; letter-spacing: 0.14em; font-weight: bold; }
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a1010;
  box-shadow: inset 0 0 0 1px #0006;
}
.gb.on .led { background: #ff2a22; box-shadow: 0 0 6px #f44, inset 0 0 0 1px #0004; }
.grill {
  width: 42px;
  height: 12px;
  background: radial-gradient(circle, #0007 0.8px, transparent 1.2px) 0 0 / 4px 4px;
  opacity: 0.7;
}
.well {
  margin-top: 6px;
  background: #2b2b2b;
  border-radius: 8px 8px 16px 16px;
  padding: 12px 16px 16px;
  box-shadow: inset 0 2px 4px #000, 0 1px 0 #fff4;
}
.lcd {
  position: relative;
  background: #10140c;
  padding: 6px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 2px #3a3a3a;
}
.lcd canvas {
  width: 160px;
  height: 144px;
  max-width: 100%;
  max-height: 100%;
  background: #0c1208;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
.lcd::after {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.12) 2px 3px);
}
.gb-name {
  margin: 8px 0 2px;
  text-align: center;
  font-weight: bold;
  letter-spacing: 0.18em;
  font-size: 12px;
}
.pads {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  touch-action: none;
}
.dpad {
  width: 96px;
  height: 96px;
  display: grid;
  grid-template-columns: 32px 32px 32px;
  grid-template-rows: 32px 32px 32px;
}
.dpad button, .dpad i {
  width: 32px;
  height: 32px;
  background: #1c1c1c;
  border: 0;
  padding: 0;
  box-shadow: inset 1px 1px 0 #444, inset -2px -2px 0 #000;
}
.dpad button.down { background: #3a3a3a; }
.dpad .u { grid-area: 1 / 2; }
.dpad .l { grid-area: 2 / 1; }
.dpad .r { grid-area: 2 / 3; }
.dpad .d { grid-area: 3 / 2; }
.dpad i { grid-area: 2 / 2; border-radius: 50%; pointer-events: none; }
.mid { display: flex; justify-content: center; gap: 10px; transform: rotate(-18deg); }
.mid label, .ab label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  font-weight: bold;
  letter-spacing: 0.08em;
}
.mid button {
  width: 40px;
  height: 14px;
  border-radius: 8px;
  border: 0;
  background: #2a2a2a;
  box-shadow: inset 1px 1px 0 #555, 0 2px 0 #0008;
}
.mid button.down { transform: translateY(1px); background: #444; }
.ab { position: relative; width: 108px; height: 96px; }
.ab label { position: absolute; }
.ab .b { left: 0; top: 8px; }
.ab .a { right: 0; bottom: 0; }
.ab button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 35% 30%, #7a3a52, #2a1018 72%);
  box-shadow: inset 2px 2px 0 #fff3, 0 3px 0 #0006;
}
.ab button.down { transform: translateY(2px); filter: brightness(1.25); }

.window.n64 .client {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.n64play {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--face);
}
.n64screen {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  margin: 4px 4px 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.n64screen canvas,
.n64screen iframe {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  touch-action: none;
  border: 0;
}
.n64screen canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.n64pad {
  position: relative;
  flex: none;
  width: min(100%, 520px);
  aspect-ratio: 520 / 280;
  margin: 2px auto 6px;
  touch-action: none;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
}
.n64pad .shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.n64pad > button,
.n64pad .stick,
.n64pad .cross {
  position: absolute;
  z-index: 1;
  border: 0;
  padding: 0;
  color: #fff;
}
.n64pad button { font-weight: bold; line-height: 1; }
.n64pad button:focus { outline: none; }
.n64pad > button.down { transform: translateY(2px); filter: brightness(1.18); }
.n64pad .shoulder {
  display: grid;
  place-items: center;
  border-radius: 8px 8px 5px 5px;
  background: linear-gradient(180deg, #e4eaef 0%, #b4bcc4 38%, #7d868e 100%);
  color: #22262a;
  text-shadow: 0 1px 0 #fff8;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #3a4046;
  font-size: 3.4cqw;
}
.n64pad .shoulder.l { left: 2.7%; top: 0.7%; width: 23.1%; height: 12.9%; }
.n64pad .shoulder.r { left: 74.2%; top: 0.7%; width: 23.1%; height: 12.9%; }
.n64pad .cross {
  left: 5.4%;
  top: 24%;
  width: 26%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}
.n64pad .cross button,
.n64pad .cross i {
  background: linear-gradient(180deg, #4a5058, #2a2e34);
  box-shadow: inset 0 1px 0 #7a828a, 0 2px 0 #14171a;
}
.n64pad .cross .u { grid-area: 1 / 2; border-radius: 5px 5px 1px 1px; }
.n64pad .cross .l { grid-area: 2 / 1; border-radius: 5px 1px 1px 5px; }
.n64pad .cross .r { grid-area: 2 / 3; border-radius: 1px 5px 5px 1px; }
.n64pad .cross .d { grid-area: 3 / 2; border-radius: 1px 1px 5px 5px; }
.n64pad .cross i { grid-area: 2 / 2; border-radius: 2px; }
.n64pad .cross button.down { background: #6a727a; }
.n64pad .stick {
  left: 34.2%;
  top: 22.9%;
  width: 19.2%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #5a626a, #2a3036 72%);
  box-shadow: inset 0 4px 6px #0008, 0 1px 0 #c5ccd2;
}
.n64pad .stick .cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 62%, #5e666e 0 16%, transparent 17%),
    radial-gradient(circle at 38% 32%, #f4f7f9, #c5ccd2 42%, #8b949c 75%);
  box-shadow: 0 4px 0 #1c2126, inset 0 -3px 0 #5c656c;
}
.n64pad .z {
  left: 38.8%;
  top: 83%;
  width: 10.4%;
  height: 12%;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 3.4cqw;
  color: #1c2126;
  background: linear-gradient(180deg, #e7edf2 0%, #a8b1b8 46%, #6d767e 100%);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #2c3338;
}
.n64pad .start {
  left: 37.7%;
  top: 71.4%;
  width: 12.3%;
  height: 9.3%;
  border-radius: 40%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 40% 35%, #4e545c, #2a2e32 72%);
  color: #f0f0f0;
  letter-spacing: 0.06em;
  font-size: 2.1cqw;
  box-shadow: inset 0 1px 0 #6a7076, 0 2px 0 #1a1e22;
}
.n64pad .cbtn,
.n64pad .a,
.n64pad .b {
  display: grid;
  place-items: center;
  border-radius: 50%;
  aspect-ratio: 1;
}
.n64pad .cbtn {
  width: 8.5%;
  font-size: 3.2cqw;
  color: #5a4300;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #f0cc18 50%, #c49800 82%);
  box-shadow: inset 0 1px 0 #fff8, 0 2px 0 #6d5600;
}
.n64pad .c-up { left: 76.9%; top: 20.7%; }
.n64pad .c-left { left: 68.1%; top: 37.1%; }
.n64pad .c-right { left: 85.8%; top: 37.1%; }
.n64pad .c-down { left: 76.9%; top: 53.6%; }
.n64pad .b {
  left: 66.9%;
  top: 73.6%;
  width: 9.2%;
  font-size: 3.6cqw;
  background: radial-gradient(circle at 35% 30%, #8dffa8, #1a9a42 48%, #0c5c26 80%);
  box-shadow: inset 0 2px 0 #ffffff55, 0 3px 0 #063214;
}
.n64pad .a {
  left: 82.7%;
  top: 70.7%;
  width: 11.9%;
  font-size: 5cqw;
  background: radial-gradient(circle at 35% 30%, #8eb6ff, #2152d4 46%, #16388f 78%);
  box-shadow: inset 0 2px 0 #ffffff66, 0 3px 0 #0c1c44;
}

#off {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: #000;
  color: #d18b2c;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}
#off p { margin: 0; font-size: 16px; letter-spacing: 0.02em; }
#off button {
  margin-top: 18px;
  background: transparent;
  color: #d18b2c;
  border: 1px solid #d18b2c;
  padding: 6px 10px;
}

.ctx {
  position: absolute;
  z-index: 45;
  min-width: 120px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hi) #000 #000 var(--hi);
  padding: 2px;
}
.ctx button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 4px 16px;
}
.ctx button:hover, .ctx button:focus { background: var(--navy); color: #fff; }

@media (hover: none) {
  .titlebar { height: 28px; }
  .tb { width: 28px; height: 22px; font-size: 14px; }
  .menubar > button { padding: 6px 10px; }
  #taskbar { height: 40px; }
  #start, .task { height: 32px; }
  #volume, #clock { height: 32px; }
  #volume { width: 36px; }
  #startmenu { bottom: calc(42px + 12px); bottom: calc(42px + max(12px, env(safe-area-inset-bottom, 0px))); }
  #startmenu button { padding: 10px 8px; }
  .dlg-buttons button, a.cmd, button.cmd { min-height: 36px; }
  .dpad {
    width: 120px;
    height: 120px;
    grid-template-columns: 40px 40px 40px;
    grid-template-rows: 40px 40px 40px;
  }
  .dpad button, .dpad i { width: 40px; height: 40px; }
  .ab { width: 118px; height: 108px; }
  .ab button { width: 56px; height: 56px; }
  .mid button { width: 52px; height: 22px; }
  .mid label, .ab label { font-size: 9px; }
}

@media (max-width: 720px), (max-height: 520px) and (hover: none) {
  .window:not(.dialog) {
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    max-width: none;
  }
  .window.device .client {
    display: flex;
    flex-direction: column;
    padding: 4px;
    min-height: 0;
  }
  .gb {
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: hidden;
    border-radius: 8px;
    padding: 8px 10px 10px;
  }
  .well {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
  }
  .lcd {
    width: 100%;
    height: 100%;
    max-height: none;
    min-height: 0;
  }
  .lcd canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    max-height: 100%;
    min-height: 72px;
    aspect-ratio: 160 / 144;
    object-fit: contain;
  }
  .n64screen { min-height: 120px; }
  .n64screen canvas,
  .n64screen iframe {
    width: 100% !important;
    height: auto !important;
    max-height: none;
    min-height: 120px;
  }
  .pads { gap: 4px; margin-top: 2px; }
  .gb-name { margin: 4px 0; }
  .statusbar span:last-child:empty { display: none; }
  #icons {
    inset: 0;
    padding: 8px;
    overflow: auto;
  }
  .rz { display: none; }
  .icon { width: 88px; }
}

@media (max-width: 720px) and (min-height: 521px) {
  .n64play { justify-content: center; }
  .n64screen { flex: 0 0 auto; max-height: 48%; }
  .n64screen canvas,
  .n64screen iframe { max-height: 46dvh; }
}

@media (max-height: 520px) and (hover: none) {
  .n64play { flex-direction: row; align-items: center; }
  .n64screen { align-self: stretch; margin: 2px; }
  .n64screen canvas,
  .n64screen iframe {
    width: auto !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    min-height: 96px;
  }
  .n64pad {
    width: auto;
    height: min(100%, 78dvh);
    max-width: 48%;
    margin: 0 2px 0 0;
  }
  .window.device .gb {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "dpad screen ab"
      "mid screen ab";
    align-items: center;
    column-gap: 6px;
    padding: 6px;
  }
  .window.device .gb-top,
  .window.device .gb-name { display: none; }
  .window.device .pads { display: contents; }
  .window.device .dpad { grid-area: dpad; }
  .window.device .well { grid-area: screen; margin: 0; height: 100%; }
  .window.device .mid { grid-area: mid; transform: none; align-self: center; }
  .window.device .ab { grid-area: ab; align-self: center; }
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  color: #5dff6a;
  padding:
    max(18px, env(safe-area-inset-top, 0px))
    max(18px, env(safe-area-inset-right, 0px))
    max(18px, env(safe-area-inset-bottom, 0px))
    max(18px, env(safe-area-inset-left, 0px));
}
#boot::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.22) 2px 3px);
}
.boot-log {
  position: relative;
  z-index: 1;
  margin: 0;
  white-space: pre;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(14px, 2.2vw, 16px);
  line-height: 1.5;
  color: #5dff6a;
  text-shadow: 0 0 8px rgba(80, 255, 110, 0.35);
}
.caret {
  display: inline-block;
  width: 0.62em;
  height: 1em;
  margin-left: 2px;
  background: #5dff6a;
  vertical-align: text-bottom;
  box-shadow: 0 0 8px rgba(80, 255, 110, 0.7);
  animation: caret 1.06s steps(1) infinite;
}
@keyframes caret {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .copy-row .doc, .meter > div, .shake, .caret { animation: none; }
  #boot { display: none; }
}
