:root {
  color-scheme: light;
  --accent: #00a8e8;
  --text: #3c4043;
  --muted: #727983;
  --card: #fff;
  --button: #eef0f2;
  --top: #f7f8fa;
  --bottom: #e2e6ea;
  --line: #d5d9de;
  --shadow: #28323c18;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bottom);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #26b9f2;
  --text: #e6e9ec;
  --muted: #9aa3ad;
  --card: #262b31;
  --button: #343a42;
  --top: #1c2025;
  --bottom: #0f1113;
  --line: #3c434b;
  --shadow: #0006;
}
:root[data-theme="milk"] {
  --accent: #a96941;
  --text: #4b3327;
  --muted: #876d5d;
  --card: #fff9ef;
  --button: #efdfcc;
  --top: #fff7e9;
  --bottom: #ead6be;
  --line: #d4baa1;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100svh;
  background:
    repeating-linear-gradient(0deg, transparent 0 5px, #88888808 5px 8px),
    linear-gradient(var(--top), var(--bottom));
}
button,
select,
input {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  border: 1px solid transparent;
  border-bottom: 3px solid var(--line);
  border-radius: 999px;
  padding: 11px 21px;
  background: var(--button);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
button:hover {
  filter: brightness(0.96);
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.primary {
  background: var(--accent);
  border-bottom-color: #0002;
  color: white;
}
a {
  color: var(--accent);
}
.player-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 3vw;
  background: var(--card);
}
#stats {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
#screen-wrap {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#screen {
  width: 100%;
  height: min(58vh, 650px);
  object-fit: contain;
}
.player-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 14px;
}
.player-tools button {
  font-size: 12px;
  padding: 8px 14px;
}
#touch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: auto;
  padding: 5px 30px;
  touch-action: none;
  user-select: none;
}
#touch button {
  touch-action: none;
  min-height: 48px;
  min-width: 48px;
}
.dpad {
  display: grid;
  grid-template: repeat(3, 45px) / repeat(3, 50px);
}
.dpad button {
  border-radius: 12px;
  padding: 0;
}
.up {
  grid-area: 1/2;
}
.left {
  grid-area: 2/1;
}
.right {
  grid-area: 2/3;
}
.down {
  grid-area: 3/2;
}
.middle,
.ab {
  display: flex;
  gap: 12px;
}
.ab button {
  width: 70px;
  height: 70px;
  background: var(--accent);
  color: white;
  font-size: 23px;
}
button.held {
  filter: brightness(0.7);
  transform: translateY(2px);
}
.keyboard-hint {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin: 12px;
}
.player-bar strong {
  max-width: 30vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 25px;
  color: var(--text);
  background: var(--card);
  width: min(520px, 95vw);
  padding: 30px;
  box-shadow: 0 30px 100px #0004;
}
dialog::backdrop {
  background: #17232d70;
  backdrop-filter: blur(7px);
}
dialog h2 {
  font-size: 27px;
  margin-top: 0;
}
dialog p {
  font-size: 13px;
  color: var(--muted);
}
label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin: 20px 0;
  font-weight: 600;
  font-size: 14px;
}
select {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--text);
}
label.check {
  justify-content: flex-start;
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: #252c33;
  color: white;
  padding: 13px 23px;
  border-radius: 16px;
  max-width: 90vw;
  box-shadow: 0 8px 30px #0003;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}
#toast.visible {
  opacity: 1;
}
[hidden] {
  display: none !important;
}
body.dragging {
  outline: 8px solid var(--accent);
  outline-offset: -8px;
}
#player:fullscreen {
  background: var(--bottom);
  overflow: auto;
}
#player:fullscreen #screen {
  height: 65vh;
}
@media (max-width: 550px) {
  .player-bar {
    gap: 8px;
  }
  .player-bar button {
    padding: 8px;
    font-size: 11px;
  }
  #stats {
    font-size: 10px;
  }
  #touch {
    padding: 0 12px;
  }
  .ab button {
    width: 56px;
    height: 56px;
  }
  .middle {
    gap: 4px;
  }
  .middle button {
    padding: 5px 9px;
    font-size: 11px;
  }
  #screen {
    height: 44vh;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* The desktop MenuView proportions use the viewport in place of its Swing component. */
#home {
  --unit: 1svh;
  --dock-size: calc(var(--unit) * 8.16);
  min-height: 100svh;
  display: grid;
  grid-template-rows: 10svh 73svh 17svh;
  background:
    radial-gradient(circle at 18% 20%, #ffffffa0, transparent 50%),
    radial-gradient(circle at 90% 95%, #00a8e81a, transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 4px, #00000009 4px 6px),
    linear-gradient(var(--top), var(--bottom));
}
:root[data-theme="dark"] #home {
  background:
    radial-gradient(circle at 18% 20%, #ffffff10, transparent 50%),
    radial-gradient(circle at 90% 95%, #26b9f21e, transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 4px, #ffffff06 4px 6px),
    linear-gradient(var(--top), var(--bottom));
}
.desktop-top,
.desktop-status,
.desktop-pill {
  display: flex;
  align-items: center;
}
.desktop-top {
  justify-content: space-between;
  padding: 1svh 3vw 0;
  gap: 12px;
}
.desktop-status {
  gap: 1vw;
  min-width: 0;
}
.desktop-pill {
  background: var(--card);
  height: 5.6svh;
  min-height: 34px;
  padding: 0 2.5svh;
  gap: 1.2svh;
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: 0 2px 3px #151c2552;
  white-space: nowrap;
  color: var(--muted);
  font-size: clamp(12px, 2svh, 20px);
}
.desktop-pill strong,
#clock {
  color: var(--text);
  font-size: clamp(15px, 2.85svh, 29px);
  font-weight: 800;
  letter-spacing: 0.025em;
}
.desktop-pill strong span {
  color: var(--accent);
}
#crumb {
  border-left: 2px solid var(--line);
  padding-left: 1.5svh;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
#menu-back {
  min-width: 0;
}
#pad-status {
  gap: 0.8svh;
}
#pad-status.active {
  background: var(--accent);
  color: #fff;
}
#pad-status canvas {
  width: 3.7svh;
  height: 3.7svh;
}
.desktop-grid {
  position: relative;
  padding: 3.5svh 6vw 5svh;
}
#games {
  display: grid;
  height: 64.5svh;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  place-items: center;
}
#games .tile {
  width: min(88%, 22.575svh);
  height: 84%;
  position: relative;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.3svh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  box-shadow: 0 3px 5px #14212b73;
  transition:
    transform 130ms ease,
    box-shadow 130ms ease;
}
#games .tile:hover,
#games .tile.selected {
  transform: scale(1.045);
  z-index: 1;
}
#games .tile.selected {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
  box-shadow:
    0 0 10px 7px var(--accent),
    0 3px 5px #14212b73;
}
.tile-art {
  background:
    linear-gradient(#ffffff55, transparent 55%),
    linear-gradient(
      var(--console-color),
      color-mix(in srgb, var(--console-color), #000 12%)
    );
  color: white;
  flex: 0 0 70%;
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: 4% 7% 0;
  overflow: hidden;
  width: 100%;
}
.tile-art small {
  color: #fffc;
  font-size: clamp(7px, 1.4svh, 14px);
  letter-spacing: 0.035em;
}
.tile-art b {
  position: absolute;
  inset: 17% 0 0;
  display: grid;
  place-items: center;
  font-size: min(5.6svh, 4.5vw);
  line-height: 1;
  letter-spacing: 0.03em;
}
.game-art {
  flex-basis: 72%;
  background:
    linear-gradient(145deg, #ffffff55, transparent), var(--console-color);
}
.game-art::after,
.game-art::before {
  content: "";
  position: absolute;
  width: 68%;
  aspect-ratio: 1;
  border: 0.6svh solid #ffffff25;
  border-radius: 50%;
  top: -25%;
  right: -20%;
}
.game-art::before {
  right: auto;
  top: 52%;
  left: -30%;
}
.tile-title {
  width: 100%;
  padding: 0 5%;
  align-content: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(8px, 1.7svh, 19px);
  font-weight: 700;
}
.tile-title small {
  display: block;
  margin-top: 0.2svh;
  color: var(--muted);
  font-size: clamp(7px, 1.27svh, 14px);
  font-weight: 400;
}
.tile-title .has-games {
  color: var(--accent);
}
#pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4svh;
  height: 5svh;
}
#pages button {
  padding: 0;
  border: 0;
  width: 1.2svh;
  height: 1.2svh;
  background: var(--line);
}
#pages button[aria-current] {
  background: var(--accent);
  transform: scale(1.3);
}
#empty-system {
  position: absolute;
  width: 62%;
  inset: 20% 19% 18%;
  background: var(--card);
  border-radius: 3svh;
  box-shadow: 0 3px 5px var(--shadow);
  text-align: center;
  padding: 4svh 4vw;
}
#empty-system h2 {
  font-size: clamp(16px, 3svh, 34px);
}
#empty-system p {
  color: var(--muted);
}
.desktop-footer {
  display: grid;
  justify-items: center;
  position: relative;
}
#dock {
  height: 90%;
  display: flex;
  align-items: start;
  gap: calc(var(--dock-size) * 0.9);
  padding: 2svh calc(var(--dock-size) * 0.9) 0;
  background: color-mix(in srgb, var(--card), transparent 52%);
  border-radius: 4.25svh;
}
#dock button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: clamp(10px, 2.04svh, 23px);
  width: var(--dock-size);
  display: grid;
  justify-items: center;
  gap: 1.15svh;
  white-space: nowrap;
}
.dock-circle {
  width: var(--dock-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 2px 4px #17212c50;
}
.dock-circle canvas {
  width: 70%;
  height: 70%;
}
#dock button.selected {
  color: var(--accent);
}
#dock button.selected .dock-circle {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
#menu-hint,
#open-rom {
  position: absolute;
  bottom: 1.5svh;
  font-size: clamp(10px, 1.7svh, 17px);
}
#menu-hint {
  left: 3vw;
  color: var(--muted);
}
#open-rom {
  right: 3vw;
  margin: 0;
  padding: 0.7svh 1vw;
}
#settings {
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  padding: 4svh 4vw;
  border: 0;
  border-radius: 0;
  background: linear-gradient(var(--top), var(--bottom));
}
.settings-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4svh;
}
.settings-heading h2 {
  font-size: clamp(22px, 4.6svh, 48px);
  margin: 0;
}
.settings-heading small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.65em;
}
.settings-heading button {
  aspect-ratio: 1;
  padding: 0.4em 0.7em;
  font-size: 1.4em;
}
.settings-layout {
  display: grid;
  grid-template-columns: 24% 1fr;
  gap: 2vw;
  height: 75svh;
}
.settings-layout nav {
  display: flex;
  flex-direction: column;
  gap: 1.2svh;
}
.settings-layout nav button {
  text-align: left;
  min-height: 7.2svh;
  padding: 0.6em 1.2em;
  border: 0;
  background: transparent;
  font-size: clamp(12px, 3svh, 32px);
  font-weight: 500;
}
.settings-layout nav [aria-pressed="true"] {
  background: var(--accent);
  color: white;
}
.settings-rows {
  background: var(--card);
  border-radius: 1.5svh;
  padding: 2svh 3vw;
  overflow: auto;
}
.settings-rows label,
.settings-rows p {
  font-size: clamp(13px, 2.5svh, 26px);
}
.settings-rows label {
  padding: 1.4svh 0;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) {
  #home {
    --dock-size: clamp(35px, 8.16svh, 12vw);
  }
  #menu-hint {
    display: none;
  }
  #date {
    display: none;
  }
}
@media (max-width: 600px) {
  .desktop-grid {
    padding-left: 2vw;
    padding-right: 2vw;
  }
  #games .tile {
    width: 92%;
    height: min(84%, 17vw);
  }
  #dock {
    gap: calc(var(--dock-size) * 0.5);
    padding-inline: 3vw;
  }
  #open-rom {
    bottom: 0.5svh;
  }
  .desktop-pill {
    padding-inline: 2vw;
  }
  .settings-layout {
    grid-template-columns: 32% 1fr;
  }
  .settings-rows label {
    flex-wrap: wrap;
  }
}
