:root {
  color-scheme: dark;
  --night: #100f1b;
  --rail: #231b42;
  --panel: #1d1736;
  --inset: #151126;
  --cabinet: #2c244d;
  --tile: #221b3c;
  --selection: #3d3067;
  --filter: #493877;
  --border: #4b3d73;
  --edge: #5d4b8b;
  --screen: #08090d;
  --text: #f6f2ff;
  --secondary: #c8bedf;
  --muted: #a499bf;
  --accent: #dcf97d;
  --lavender: #bca7ff;
  --coral: #ffa2b4;
  --ice: #8fcee8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--night);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { min-width: 750px; min-height: 530px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:active { opacity: .8; }
button:disabled { opacity: .5; cursor: default; }
a { color: #57a7ff; }
.rail {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 20px;
  background: var(--rail);
  border-bottom: 1px solid var(--border);
}
.macos .rail { padding-left: 90px; }
.fullscreen .rail { padding-left: 20px; }
.wordmark {
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: .45px;
}
.wordmark img { width: 28px; height: 28px; margin-right: 5px; }
.wordmark span:last-child { color: var(--lavender); }
.rail-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#library .rail { gap: clamp(12px, 3vw, 24px); }
.ico { display: inline-grid; place-items: center; font-style: normal; width: 20px; height: 20px; font-size: 15px; flex: none; }
.button {
  align-items: center;
  background: var(--cabinet);
  border-radius: 9px;
  display: inline-flex;
  flex: none;
  gap: 9px;
  height: 40px;
  justify-content: center;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.button:hover { background: var(--selection); }
.button.primary { background: var(--accent); color: var(--night); }
.button.primary:hover { filter: brightness(1.08); }
.button.icon-only { width: 40px; padding: 0; }
.icon-only span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ico svg { width: 15px; height: 15px; }
.ico.star { color: var(--lavender); }
.ico.star svg { width: 19px; height: 19px; }
.ico.chevron { color: var(--accent); }
#library { height: max(100%, 530px); }
.library {
  display: grid;
  grid-template-columns: 302px minmax(0, 1fr);
  gap: 20px;
  height: calc(100% - 64px);
  padding: 16px 16px 0;
}
.shelf {
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 64px;
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 13px;
}
.shelf h1 { font-size: 27px; font-weight: 900; letter-spacing: -.7px; margin: 0 5px 12px; }
.search {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 37px;
  flex-shrink: 0;
  margin: 0 5px 10px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--inset);
}
.search input { min-width: 0; flex: 1; align-self: stretch; font-size: 13px; padding: 0 4px; color: var(--text); border: 0; background: transparent; }
.search input:focus-visible { outline: none; }
.search:focus-within { border-color: var(--lavender); }
.filters {
  display: flex;
  padding: 4px;
  gap: 1px;
  margin: 0 5px 12px;
  background: var(--inset);
  border-radius: 7px;
}
.filters button {
  flex: 1;
  padding: 0 4px;
  height: 28px;
  background: transparent;
  color: var(--secondary);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.filters button[aria-pressed="true"] { color: var(--accent); background: var(--filter); }
.games { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 7px; overflow: auto; scrollbar-width: thin; padding: 2px; }
.games > p { color: var(--muted); font-size: 13px; padding: 0 5px; }
.game {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 54px;
  padding: 0 10px;
  text-align: left;
  flex: none;
  border: 1px solid transparent;
  background: var(--tile);
  border-radius: 8px;
}
.game:hover { background: var(--cabinet); }
.game[aria-selected="true"] { background: var(--selection); border-color: var(--accent); }
.game[aria-selected="true"]::before { content: ""; position: absolute; width: 4px; height: 36px; left: 0; top: 8px; border-radius: 2px; background: var(--accent); }
.game strong, .game small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game strong { font-size: 14px; font-weight: 650; }
.game small { color: var(--secondary); font-size: 11px; margin-top: 4px; }
.game > span { flex: 1; min-width: 0; }
.status { flex: none; background: transparent; padding: 10px 5px 0; text-align: left; font-size: 11px; font-weight: 600; }
.status i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); }
.status i.connected { background: var(--accent); }
.detail { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cabinet {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--cabinet);
  border: 1px solid var(--edge);
  padding: 14px;
  border-radius: 18px;
}
.screen {
  display: grid;
  place-items: center;
  background: var(--screen);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  width: 100%;
  min-height: 0;
  position: relative;
  container-type: size;
}
.screen img {
  width: min(100cqw, calc(100cqh * 4 / 3));
  aspect-ratio: 4 / 3;
  object-fit: fill;
  image-rendering: pixelated;
}
.game-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.game-title h2 { margin: 0; text-transform: uppercase; font-weight: 900; font-size: 36px; letter-spacing: -.85px; line-height: 1.06; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.game-detail { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 13px 0 26px; }
.game-detail p { font-size: 15px; color: var(--secondary); margin: 0; }
.game-detail > div { display: flex; gap: 10px; }
.game-detail .button { height: 48px; }
.play-game { width: 150px; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.detail > .legend { border-top: 1px solid var(--border); padding: 13px 0; min-height: 53px; }
.detail > .legend > span[role="status"] { font-size: 12px; color: var(--secondary); }
.hint { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 13px; font-weight: 500; }
kbd {
  display: inline-grid; align-items: center; justify-content: center;
  background: var(--cabinet); border-radius: 6px; color: var(--text);
  min-width: 28px; min-height: 26px; padding: 0 5px; font: inherit; font-size: 12px; font-weight: 750;
}
.no-selection { flex: 1; display: grid; align-content: center; justify-items: center; }
.no-selection h2 { margin: 0; }
.no-selection p { color: var(--secondary); }
.dragging::after { content: ""; position: fixed; inset: 6px; pointer-events: none; border: 2px dashed var(--accent); border-radius: 14px; z-index: 20; }
.context { position: fixed; z-index: 5; display: grid; padding: 5px; border: 1px solid var(--edge); border-radius: 9px; background: var(--panel); }
.context .button { justify-content: flex-start; }
#player { height: 100vh; width: 100vw; min-width: 750px; min-height: 530px; position: relative; overflow: hidden; background: #000; display: grid; place-items: center; }
.frame { position: relative; width: min(100%, calc(100vh * 4 / 3)); aspect-ratio: 4 / 3; }
.frame canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.frame::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 3px, #100f1b21 3px 4px, transparent 4px 5px); }
#player.idle { cursor: none; }
.player-top, .player-bottom { position: absolute; z-index: 2; left: 0; right: 0; opacity: 0; pointer-events: none; transition: opacity 140ms ease-out; }
.player-top { top: 0; }
.player-bottom { bottom: 0; height: 44px; background: #100f1beb; display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.player-bottom > span[role="status"] { color: var(--muted); font-size: 11px; }
.player-bottom strong { margin-left: auto; color: var(--ice); font-size: 13px; }
.playing-title { font-size: 13px; color: var(--secondary); font-weight: 700; }
.show-rails .player-top, .show-rails .player-bottom, #player.paused .player-top, #player.paused .player-bottom, .player-top:focus-within { opacity: 1; pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: #100f1b94; display: flex; align-items: center; justify-content: center; padding: 64px 14px 44px; animation: reveal 160ms ease-out; }
@keyframes reveal { from { opacity: 0; } to { opacity: 1; } }
.pause-panel {
  display: flex; flex-direction: column; gap: 20px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--panel);
  max-width: 100%; max-height: 100%; overflow: auto; padding: 24px;
}
.main-pause { margin-right: auto; }
.main-pause, .replace-panel { width: 425px; }
.slot-panel { width: 802px; }
.play-guide { width: 672px; }
.pause-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.pause-heading h2 { margin: 0; text-transform: uppercase; font-size: 33px; font-weight: 900; letter-spacing: -.65px; line-height: 1.24; }
.pause-heading p { margin: 7px 0 0; color: var(--secondary); font-size: 13px; }
.pause-actions { display: grid; gap: 9px; }
.focus-button { height: 48px; justify-content: flex-start; text-align: left; }
.focus-button.danger { color: var(--coral); }
.focus-button[aria-current="true"] { background: var(--accent); color: var(--night); }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.slot {
  padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--cabinet); text-align: left;
  min-width: 0; display: flex; flex-direction: column; gap: 3px;
}
.slot[aria-selected="true"] { border-color: var(--accent); background: var(--filter); }
.slot[aria-disabled="true"] { opacity: .42; cursor: default; }
.slot strong { font-size: 14px; }
.slot small { font-size: 11px; color: var(--secondary); }
.thumbnail { display: grid; place-content: center; justify-items: center; width: 100%; height: 95px; background: var(--screen); border-radius: 6px; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumbnail img { display: block; height: 95px; max-width: 100%; aspect-ratio: 4 / 3; object-fit: fill; image-rendering: pixelated; }
dialog { color: var(--text); background: transparent; border: 0; padding: 0; max-width: calc(100vw - 28px); max-height: calc(100vh - 28px); overflow: auto; }
dialog::backdrop { background: #100f1b94; }
.sheet { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 480px; min-height: 0; }
.sheet.controls { width: 440px; padding: 25px; }
.sheet h2 { font-size: 18px; margin: 0 0 16px; font-weight: 760; }
.sheet h3, .play-guide h3 { color: var(--lavender); margin: 12px 0 4px; font-size: 13px; }
.sheet p, .play-guide p { color: var(--text); font-size: 13px; margin: 0 0 13px; }
.sheet.controls p { color: var(--secondary); }
.sheet.controls p:last-of-type { margin-bottom: 8px; }
.sheet a, .play-guide a { text-decoration: none; font-size: 13px; font-weight: 650; }
.sheet-footer { display: flex; justify-content: flex-end; margin-top: 9px; }
.sheet table { text-align: left; width: 100%; font-size: 13px; margin: 0 0 12px; table-layout: auto; border-spacing: 0 5px; }
.sheet .error { white-space: pre-line; }
.sheet .button { margin-bottom: 2px; }
.sheet.application-menu { width: min(440px, calc(100vw - 28px)); }
.menu-actions { display: grid; gap: 6px; }
.menu-actions .button { height: auto; min-height: 42px; justify-content: flex-start; text-align: left; margin: 0; }
.menu-actions .button span { white-space: normal; }
.application-menu .sheet-footer { margin-top: 16px; }
.settings {
  --settings-surface: var(--inset);
  --settings-control: var(--cabinet);
  --settings-divider: var(--border);
  --settings-selected: var(--selection);
  width: min(500px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  display: flex;
  flex-direction: column;
}
.settings-content { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.settings h2, .settings-footer { flex-shrink: 0; }
.settings-fields {
  border: 1px solid var(--settings-divider);
  border-radius: 9px;
  padding: 0 12px;
  margin-bottom: 12px;
  background: var(--settings-surface);
}
.settings-fields label, .setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 56%);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding-block: 4px;
  font-size: 13px;
}
.settings-fields label + label, .setting-row { border-top: 1px solid var(--settings-divider); }
.bindings .setting-row:first-child { border-top: 0; }
.settings select, .settings .mapping-button, .settings .toggle button {
  min-width: 0;
  min-height: 34px;
  padding: 5px 9px;
  background: var(--settings-control);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
}
.settings select, .settings .mapping-button { width: 100%; text-align: left; }
.settings .mapping-button { overflow-wrap: anywhere; }
.settings .mapping-button:not(:disabled):hover,
.settings .toggle button:hover { background: var(--settings-selected); }
.settings .mapping-button:disabled {
  opacity: 1;
  background: transparent;
  color: var(--secondary);
}
.settings .toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.settings .toggle button[aria-pressed="true"] {
  background: var(--settings-selected);
  border-color: var(--settings-divider);
  color: var(--accent);
}
.settings-connection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.settings .settings-connection p { flex: 1 1 10rem; margin: 0; color: var(--secondary); }
.settings-connection .button, .settings-reset { min-height: 34px; height: auto; font-size: 13px; }
.settings-footer { justify-content: space-between; gap: 8px; }
.settings-reset { background: transparent; border: 1px solid var(--settings-divider); }
@media (width < 1050px) {
  .library { grid-template-columns: 235px minmax(0, 1fr); gap: 12px; }
  .shelf { margin-bottom: 48px; }
  .filters button { font-size: 10px; }
  .cabinet { padding: 8px; }
  .screen { padding: 8px; }
  .game-title { margin-top: 8px; }
  .game-title h2 { font-size: 29px; }
  .game-detail { flex-wrap: wrap; margin-bottom: 14px; }
}
@media (width <= 850px) {
  .game-detail { align-items: flex-start; flex-direction: column; }
}
@media (height < 620px) {
  .pause-panel { padding: 16px; gap: 12px; }
  .pause-heading h2 { font-size: 25px; }
  .focus-button { height: 37px; }
  .pause-actions { gap: 5px; }
  .thumbnail, .thumbnail img { height: 55px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}

.desktop .web-only { display: none; }

/* The highlighted row or card already provides a visible focus indicator. */
.focus-button[aria-current="true"]:focus-visible,
.slot[aria-selected="true"]:focus-visible,
.game[aria-selected="true"]:focus-visible { outline: none; }

.native-settings { min-width: 0; min-height: 0; background: #282724; }
.native-settings #library { display: none; }
.native-settings dialog { max-width: 100%; max-height: 100%; margin: 0; width: 100%; height: 100%; }
.native-settings .settings {
  --settings-surface: #2e2d2a;
  --settings-control: #4a4946;
  --settings-divider: #4b4945;
  --settings-selected: #63625f;
  width: 100%; height: 100%; max-height: 100%; padding: 14px 16px 50px;
  background: #282724; border: 0; border-radius: 0;
}
.native-settings .settings h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.native-settings .settings .sheet-footer .primary { display: none; }
.native-settings .settings [data-act="defaults"] { position: fixed; bottom: 10px; left: 16px; }
