:root {
  color-scheme: dark;
  --ink: #10162b;
  --paper: #e9e5d6;
  --mono: "Cascadia Mono", Consolas, monospace;
  --crt-bg: #0f1526;
  --crt-surface: #162038;
  --crt-elevated: #1e2c4a;
  --crt-hover: #26365a;
  --crt-selected: #2e3d72;
  --crt-accent: #244b50;
  --crt-accent-hover: #2f6167;
  --crt-accent-border: rgba(154, 232, 200, 0.58);
  --crt-border: rgba(142, 166, 214, 0.24);
  --crt-border-strong: rgba(168, 194, 240, 0.44);
  --crt-text: #eef1f7;
  --crt-muted: #9eb0d0;
  --crt-gold: #f4d37e;
  --crt-mint: #9fe8ca;
  font: 16px/1.45 system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
html { overflow-x: hidden; overflow-y: auto; }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding-block: .6rem;
  background: radial-gradient(ellipse at 50% 10%, #333c40, #17191c 74%);
  color: var(--paper);
}

a { color: inherit; text-decoration: none; }
h1, h2, p, figure { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #b7b4ff; outline-offset: 2px; }

.wrap {
  width: min(98vw, 1680px, calc((100svh - 1.25rem) * 1.78));
  margin: 0 auto;
}
.skip { position: absolute; top: -10rem; }
.skip:focus { top: .5rem; left: .5rem; z-index: 5; padding: .5rem; background: var(--ink); }

.housing {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.78;
  overflow: clip;
  container-type: inline-size;
  filter: drop-shadow(0 14px 24px #08090b88);
}

/* Photorealistic cabinet slices */
.photo-slice {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
}
.photo-frame {
  inset: 0 0 22%;
  background-image: url('/cabinet-frame.webp');
  clip-path: inset(0 round .85cqw .85cqw 0 0);
}
.photo-frame::after {
  content: '';
  position: absolute;
  inset: 91% 68% 0 21%;
  background: url('/cabinet-frame.webp') -35.5cqw -39.87cqw / 100cqw 43.82cqw no-repeat;
}
.photo-controls {
  inset: 75.8% 0 0;
  background-image: url('/cabinet-deck.webp');
  clip-path: inset(0 round 0 0 .85cqw .85cqw);
  mask:
    linear-gradient(#000, #000) center / 84% 100% no-repeat,
    linear-gradient(transparent, #000 8.5%);
}

/* Marquee & hotspots */
.hotspot {
  position: absolute;
  z-index: 2;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: .4cqw;
  touch-action: manipulation;
}
.hotspot:not(:disabled):hover,
.hotspot:not(:disabled):active { background: transparent; }

.brand {
  left: 42.4%;
  top: 1.88%;
  width: 16.4%;
  height: 5.35%;
  display: grid;
  place-items: center;
  background: #252c47;
  color: #fff0d5;
  font: 950 2.4cqw/1 var(--mono);
  letter-spacing: -.065em;
  white-space: nowrap;
}
.brand.hotspot:not(:disabled):is(:hover, :active) { background: #252c47; }

.marquee-edition {
  position: absolute;
  z-index: 1;
  top: 4.18%;
  left: 66.25%;
  width: 7.2%;
  color: #f4e7cc;
  background: #222841;
  font: 750 .78cqw/1.9 var(--mono);
  text-align: center;
  white-space: nowrap;
}

/* Animated joystick (cross-browser polygon clip-path) */
.photo-stick, .stick-clean, .coin-motion { inset: 75.8% 0 0; }
.photo-stick, .coin-motion { background-image: url('/cabinet-deck.webp'); }
.stick-clean { z-index: 1; opacity: 1; }
.stick-clean::before, .stick-clean::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/cabinet-deck.webp');
  background-repeat: no-repeat;
}
.stick-clean::before {
  clip-path: inset(0 73.2% 56.2% 16.9%);
  background-size: 300% 100%;
  background-position: -68.1cqw 0;
}
.stick-clean::after {
  clip-path: polygon(20.1% 43.7%, 23.5% 43.7%, 23.25% 60.8%, 22.9% 62.7%, 20.45% 62.3%);
  background-size: 300% 100%;
  background-position: -50cqw 0;
}
.photo-stick {
  z-index: 1;
  clip-path: polygon(
    21.7% .5%, 24.1% 3%, 25.7% 9.5%, 26.34% 24.9%, 25.8% 34.5%,
    24.6% 39.5%, 23.23% 42%, 23.14% 59.8%, 22.7% 62.5%, 21.7% 63.6%,
    20.8% 62.5%, 20.49% 61.1%, 20.32% 42.5%, 18.9% 39.5%, 17.7% 34%,
    17.32% 24%, 17.9% 9.5%, 19.4% 3%
  );
  transform-origin: 21.7% 62.2%;
  transition: transform 95ms ease-out;
}
.housing[data-stick="left"] .photo-stick { transform: rotate(-10deg); }
.housing[data-stick="right"] .photo-stick { transform: rotate(10deg); }
.housing[data-stick="up"] .photo-stick { transform: scale(.98, 1.17); }
.housing[data-stick="down"] .photo-stick { transform: scale(1.025, .84); }

#stick-up { left: 17.2%; top: 75.8%; width: 9.3%; height: 5.5%; }
#stick-down { left: 17.2%; top: 81.3%; width: 9.3%; height: 11%; }
#stick-left, #stick-right { top: 81%; height: 7%; width: 4%; }
#stick-left { left: 13.1%; }
#stick-right { left: 26.6%; }

/* Arcade deck buttons */
.action { left: var(--button-x); top: 80.9%; width: 7.4%; height: 6.7%; border-radius: 50%; }
.action[data-input="8"] { --button-x: 32.55cqw; }
.action[data-input="0"] { --button-x: 41.05cqw; }
.action[data-input="9"] { --button-x: 49.55cqw; }
.action[data-input="1"] { --button-x: 31.65cqw; top: 87.05%; }
.action[data-input="10"] { --button-x: 40.65cqw; top: 87.05%; }
#arcade-start { --button-x: 49.6cqw; top: 87.05%; }

.action:not(:disabled):is(:active, .is-pressed)::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url('/cabinet-deck.webp');
  background-size: 100cqw 13.6cqw;
  background-position: calc(-1 * var(--button-x)) -2.87cqw;
  background-repeat: no-repeat;
  transform: translateY(.26cqw) scale(.94);
  filter: brightness(.8);
}
.action:not(:disabled):is(:active, .is-pressed):is([data-input="1"], [data-input="10"], #arcade-start)::before {
  background-position-y: -6.32cqw;
}

/* Coin acceptor */
#insert { left: 79.5%; top: 85%; width: 8.4%; height: 7.1%; border-radius: 50%; }
#slot-input { left: 64.9%; top: 82.45%; width: 3.65%; height: 8.8%; }
#spend { left: 70.2%; top: 84.9%; width: 7.2%; height: 6%; z-index: 3; }

.coin-motion, .coin-patch { z-index: 1; display: none; }
.coin-motion { clip-path: ellipse(3.75cqw 1.86cqw at 83.75% 50%); transform-origin: 83.75% 50%; }
.coin-patch {
  inset: 75.8% 0 0;
  background: url('/cabinet-deck.webp') 0 -13.2cqw / 100cqw 27.2cqw no-repeat;
  clip-path: ellipse(3.85cqw 2cqw at 83.75% 50%);
}
.slot.is-inserting ~ .coin-patch,
.slot.is-inserting ~ .coin-motion { display: block; }
.slot.is-inserting ~ .coin-motion { animation: slide-coin .56s ease-in both; }
.slot.is-read ~ #slot-input::after {
  content: '';
  position: absolute;
  left: 49%;
  top: 21%;
  width: 9%;
  height: 62%;
  background: #8dffbd;
  box-shadow: 0 0 .8cqw #8dffbd;
  border-radius: 50%;
}
@keyframes slide-coin {
  0% { transform: translateX(0); }
  73% { opacity: 1; transform: translateX(-15.8cqw) rotateY(78deg); }
  100% { opacity: 0; transform: translate(-17.15cqw, .25cqw) rotateY(89deg); }
}

/* Live CRT screen area */
.cabinet, .player {
  position: absolute;
  inset: 12.7% 6.55% 25.75% 6.45%;
  display: grid;
  overflow: hidden;
  border-radius: 1.1cqw;
  clip-path: polygon(1.6% 0, 98.4% 0, 100% 100%, 0 100%);
  color: var(--crt-text);
  font-family: var(--mono);
  background: radial-gradient(ellipse at 0 20%, #222b47, var(--crt-bg) 72%);
}
.cabinet {
  grid-template-columns: minmax(0, 1.92fr) minmax(0, 1.03fr);
  grid-template-rows: minmax(0, 1fr) auto;
  box-shadow: inset 0 0 2cqw rgba(5, 10, 22, 0.55);
}
.cabinet::after {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 0;
  background: repeating-linear-gradient(transparent 0 3px, rgba(3, 7, 16, 0.14) 3px 4px);
  box-shadow: inset 0 0 1.8cqw rgba(5, 7, 19, 0.48);
}
.housing.no-effects .cabinet::after { display: none; }
.cabinet:not([data-view="catalog"]) :is(.monitor, .catalog) { display: none; }

/* Tactile micro-interactions for UI buttons (excluding physical cabinet .hotspot controls) */
.menu-choices button,
.menu-audio,
.play-link,
.quick-filters button,
.button,
.player-actions button,
.player .back,
.dock-icon,
#control-dialog button {
  transition:
    background-color 140ms cubic-bezier(0.23, 1, 0.32, 1),
    border-color 140ms cubic-bezier(0.23, 1, 0.32, 1),
    color 140ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 110ms cubic-bezier(0.23, 1, 0.32, 1);
}
:is(.menu-choices button, .menu-audio, .play-link, .quick-filters button, .button, .player-actions button, .player .back, .dock-icon, #control-dialog button):not(:disabled):active {
  transform: scale(0.97);
}

/* Home menu & utility views */
.screen-panel { grid-column: 1 / -1; min-height: 0; position: relative; }
.home-menu {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  gap: 3cqw;
  padding: 2.1cqw 4cqw;
  background:
    linear-gradient(90deg, rgba(14, 19, 38, 0.92) 0%, rgba(18, 29, 55, 0.76) 44%, rgba(15, 21, 41, 0.92) 84%),
    url('/menu-attract.webp') center 46% / cover;
}
.menu-title h1 {
  max-width: 7ch;
  margin: .65cqw 0 0;
  font: 950 clamp(1.2rem, 6.9cqw, 7rem)/.9 var(--mono);
  letter-spacing: -.09em;
  color: #fff0ce;
  text-shadow: .22cqw .28cqw #294f50;
}
.menu-title .eyebrow { color: var(--crt-mint); font-size: 1.47cqw; letter-spacing: .26em; }
.menu-choices { display: grid; gap: .62cqw; }
.menu-choices button {
  padding: .66cqw .85cqw;
  border: 1px solid var(--crt-border-strong);
  border-radius: .22cqw;
  background: rgba(28, 37, 64, 0.9);
  color: var(--crt-text);
  font: 750 1.9cqw/1.25 var(--mono);
  text-align: left;
  text-transform: uppercase;
}
.menu-choices button.is-current,
.menu-choices button:hover {
  color: #fff4d8;
  background: var(--crt-accent);
  border-color: var(--crt-accent-border);
}
.menu-choices button::before { content: '▶'; display: inline-block; margin-right: .6cqw; opacity: 0; }
.menu-choices button.is-current::before,
.menu-choices button:hover::before { opacity: 1; }

.menu-audio {
  position: absolute;
  right: 3.9cqw;
  bottom: .85cqw;
  padding: .24cqw .65cqw;
  background: rgba(18, 26, 48, 0.9);
  color: var(--crt-mint);
  border: 1px solid var(--crt-border-strong);
  border-radius: .2cqw;
  font: 750 1.1cqw/1.35 var(--mono);
}
.menu-audio:hover { background: var(--crt-accent); border-color: var(--crt-accent-border); }

.utility {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 1.5cqw 3.2cqw;
  font-size: 1.38cqw;
}
.utility-card {
  width: min(48cqw, 100%);
  display: grid;
  justify-items: start;
  gap: .75cqw;
  padding: 1.4cqw 1.8cqw;
  border: 1px solid var(--crt-border-strong);
  border-radius: .35cqw;
  background: rgba(18, 26, 48, 0.88);
  box-shadow: 0 .6cqw 1.8cqw rgba(4, 7, 16, 0.45);
}
.utility h2 { color: #fff0ce; font-size: 2.35cqw; margin: 0 0 .15cqw; }
.utility h3 { color: var(--crt-mint); font-size: 1.45cqw; margin: 0; }
.utility p { margin: 0; color: var(--crt-text); line-height: 1.42; }
.utility .button { min-height: 0; padding: .42cqw .85cqw; font-size: 1.22cqw; }
.utility-actions { display: flex; flex-wrap: wrap; gap: .55cqw; margin-top: .2cqw; }
.music-row { display: flex; flex-wrap: wrap; align-items: center; gap: .65cqw; }
.music-name { color: var(--crt-mint); font-size: 1.12cqw; }

.room-shell {
  width: min(74cqw, 100%);
  display: grid;
  justify-items: start;
  gap: .9cqw;
}
.room-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15cqw;
  align-items: stretch;
}
.room-card {
  width: 100%;
  align-content: start;
  justify-items: stretch;
  gap: .65cqw;
  padding: 1.15cqw 1.3cqw;
}
.room-helper, #room-status { color: var(--crt-muted); font-size: 1.08cqw; min-height: 2.8em; }
#room-search, #room-join-input, #room-game {
  width: 100%;
  min-width: 0;
  min-height: 2.35cqw;
  padding: .28cqw .55cqw;
  border: 1px solid var(--crt-border-strong);
  border-radius: .2cqw;
  background: var(--crt-bg);
  color: var(--crt-text);
  font-size: 1.12cqw;
}
#room-search:focus, #room-join-input:focus, #room-game:focus {
  border-color: var(--crt-mint);
}
#room-form, #room-join-form {
  display: grid;
  gap: .55cqw;
  margin-top: auto;
}
#room-form .button, #room-join-form .button {
  width: 100%;
  text-align: center;
}
.form-error {
  margin: 0;
  color: #ff9c8a;
  font-size: 1.02cqw;
  line-height: 1.3;
}

/* Monitor preview */
.monitor {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  display: grid;
}
.monitor::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 19, 36, 0.96) 0%, rgba(16, 24, 44, 0.90) 48%, rgba(12, 18, 34, 0.78) 100%),
    var(--preview-art, none) center / cover;
}
.preview {
  display: grid;
  grid-template-columns: minmax(0, .74fr) minmax(0, 1fr);
  align-items: center;
  gap: 1.3cqw;
  padding: 1.1cqw 1.5cqw 1.1cqw 1.9cqw;
}
.intro { min-width: 0; }
.intro h1 {
  margin: .4cqw 0 .5cqw;
  font: 900 2.6cqw/1.05 var(--mono);
  text-transform: uppercase;
  letter-spacing: -.07em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.eyebrow { font-size: 1.04cqw; color: var(--crt-mint); text-transform: uppercase; letter-spacing: .02em; }
.description { font-size: 1.38cqw; color: #dfe5f2; line-height: 1.42; }

.preview-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .36cqw;
  margin-top: .72cqw;
}
.play-link {
  display: inline-flex;
  align-items: center;
  gap: .25cqw;
  padding: .34cqw .58cqw;
  border: 1px solid var(--crt-accent-border);
  border-radius: .2cqw;
  color: #fff6dc;
  background: var(--crt-accent);
  font-size: 1.15cqw;
  font-weight: 700;
  white-space: nowrap;
}
.play-link:hover { background: var(--crt-accent-hover); }
.play-link.secondary {
  border-color: var(--crt-border-strong);
  background: var(--crt-surface);
  color: var(--crt-text);
  font-weight: 600;
}
.play-link.secondary:hover { background: var(--crt-hover); }
.play-link.secondary[aria-pressed="true"] {
  border-color: var(--crt-gold);
  color: #ffe99c;
  background: #332e20;
}
.controls-hint {
  margin: .52cqw 0 0;
  color: var(--crt-muted);
  font-size: .95cqw;
  line-height: 1.32;
}

.artwork {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--crt-border-strong);
  border-radius: .26cqw;
  background: #070b14;
  box-shadow: 0 .55cqw 1.6cqw rgba(4, 7, 16, 0.58);
}
.artwork img {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 180ms ease-out;
}
.artwork.preview-ready img { opacity: 1; }
.artwork figcaption {
  position: static;
  padding: .16cqw .45cqw;
  color: var(--crt-paper, #f4eddc);
  background: var(--crt-bg);
  font-size: .92cqw;
  text-align: right;
}
.artwork figcaption:empty { display: none; }

/* Catalog sidebar */
.catalog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  padding: .55cqw 1.55cqw .55cqw .7cqw;
  border-left: 1px solid var(--crt-border);
  background: rgba(11, 16, 30, 0.45);
}
.catalog-heading, .filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .34cqw;
}
.catalog-heading h2, #count { font: 700 1.2cqw/1.1 var(--mono); white-space: nowrap; text-transform: uppercase; }
#count { color: var(--crt-gold); font-variant-numeric: tabular-nums; }

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .24cqw;
  margin-top: .36cqw;
}
.quick-filters button {
  padding: .15cqw .42cqw;
  border: 1px solid var(--crt-border);
  border-radius: .18cqw;
  background: var(--crt-surface);
  color: var(--crt-muted);
  font-size: .96cqw;
  line-height: 1.3;
}
.quick-filters button:hover {
  border-color: var(--crt-border-strong);
  color: var(--crt-text);
  background: var(--crt-elevated);
}
.quick-filters button[aria-pressed="true"] {
  border-color: var(--crt-accent-border);
  background: var(--crt-accent);
  color: #fff6dc;
  font-weight: 700;
}
.quick-filters button.quick-random {
  margin-left: auto;
  border-color: rgba(244, 211, 126, 0.44);
  color: var(--crt-gold);
  background: rgba(48, 39, 18, 0.55);
}
.quick-filters button.quick-random:hover {
  border-color: var(--crt-gold);
  background: rgba(68, 54, 22, 0.78);
}

.filters {
  display: grid;
  gap: .28cqw;
  margin: .34cqw 0;
}
.filter-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .24cqw;
}
input[type="search"], select {
  min-width: 0;
  min-height: 2.08cqw;
  padding: .14cqw .36cqw;
  border: 1px solid var(--crt-border-strong);
  border-radius: .18cqw;
  background: rgba(14, 21, 38, 0.92);
  color: var(--crt-text);
  font-size: 1.02cqw;
}
input[type="search"]::placeholder { color: var(--crt-muted); opacity: 0.85; }
input[type="search"]:focus, select:focus { border-color: var(--crt-mint); outline: none; }
#search { width: 100%; }
.filter-selects select {
  width: 100%;
  font-size: .9cqw;
  text-overflow: ellipsis;
}

.games {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(132, 152, 200, 0.5) transparent;
  scrollbar-width: thin;
  outline-offset: -2px;
}
.game {
  display: grid;
  grid-template-columns: 1.95cqw minmax(0, 1fr) auto .72cqw;
  align-items: center;
  gap: .26cqw;
  min-height: 2.48cqw;
  padding: .16cqw .3cqw;
  border: 1px solid transparent;
  border-bottom-color: rgba(132, 154, 204, 0.14);
  border-radius: .16cqw;
  cursor: pointer;
}
.game[aria-selected="true"] {
  background: var(--crt-selected);
  border-color: rgba(190, 196, 252, 0.72);
  color: #fff9e8;
}
.game:hover:not([aria-selected="true"]) { background: var(--crt-hover); }
.game-marker, .game-arrow { font-size: 1.06cqw; color: var(--crt-muted); font-variant-numeric: tabular-nums; }
.game[aria-selected="true"] .game-marker { color: var(--crt-gold); }
.game-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.32cqw;
  font-weight: 700;
  letter-spacing: -.02em;
}
.game-badges {
  display: inline-flex;
  align-items: center;
  gap: .24cqw;
  flex: none;
}
.badge-fav {
  color: var(--crt-gold);
  font-size: .88cqw;
  line-height: 1;
}
.badge-sys {
  min-width: 2.65cqw;
  text-align: center;
  padding: .05cqw .22cqw;
  border: 1px solid var(--crt-border);
  border-radius: .15cqw;
  background: rgba(28, 39, 68, 0.85);
  color: #c8dbff;
  font-size: .72cqw;
  font-weight: 700;
  line-height: 1.25;
}
.badge-sys[data-sys="ng"] { border-color: rgba(244, 211, 126, 0.34); background: rgba(45, 36, 18, 0.72); color: #f6dc93; }
.badge-sys[data-sys="cps1"] { border-color: rgba(124, 198, 255, 0.38); background: rgba(22, 42, 68, 0.78); color: #bfe2ff; }
.badge-sys[data-sys="cps2"] { border-color: rgba(159, 232, 202, 0.4); background: rgba(20, 48, 46, 0.78); color: #b5f0d7; }
.badge-sys[data-sys="cps3"] { border-color: rgba(210, 165, 255, 0.42); background: rgba(43, 28, 66, 0.78); color: #e2c5ff; }
.badge-sys[data-sys="pgm"] { border-color: rgba(255, 178, 120, 0.4); background: rgba(56, 33, 18, 0.78); color: #ffd2ab; }
.badge-sys[data-sys="arc"] { border-color: rgba(168, 184, 216, 0.34); background: rgba(30, 38, 58, 0.78); color: #cfdcf4; }
.badge-rate {
  min-width: 2.45cqw;
  text-align: right;
  color: var(--crt-gold);
  font-size: .82cqw;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.game-arrow { opacity: 0; }
.game[aria-selected="true"] .game-arrow { opacity: 1; color: var(--crt-mint); }

.monitor-bottom {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1.5cqw;
  min-height: 2.65cqw;
  padding-inline: 1cqw;
  border-top: 1px solid var(--crt-border);
  background: rgba(9, 13, 24, 0.55);
  color: var(--crt-text);
  font-size: 1.16cqw;
}
#reader-status { margin-inline-start: auto; color: var(--crt-gold); }
.wallet { margin-left: .55cqw; }
.wallet strong { color: var(--crt-gold); font-variant-numeric: tabular-nums; }

/* Live player & online room */
.player { grid-template: minmax(0, 1fr) / 1fr; background: #050509; }
.player .back {
  position: absolute;
  z-index: 2;
  left: 2.05cqw;
  top: .65cqw;
  display: flex;
  align-items: center;
  gap: .42cqw;
  padding: .42cqw .68cqw;
  border: 1px solid var(--crt-accent-border);
  border-radius: .22cqw;
  background: rgba(22, 44, 48, 0.92);
  color: #f6efd8;
  font-size: 1.2cqw;
}
.player .back span { color: var(--crt-mint); }
.online-guest .player .back { display: none; }

.player-actions {
  position: absolute;
  z-index: 2;
  top: .65cqw;
  right: 4.9cqw;
  display: flex;
  gap: .42cqw;
}
.player-actions button {
  padding: .42cqw .68cqw;
  border: 1px solid var(--crt-accent-border);
  border-radius: .22cqw;
  background: rgba(22, 44, 48, 0.92);
  color: #f6efd8;
  font: inherit;
  font-size: 1.2cqw;
}
.player-actions button:hover, .player .back:hover { background: var(--crt-accent-hover); }

.player h1, .player #game-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.player #game-status:not(:empty) {
  z-index: 2;
  inset: .65cqw 0 auto;
  width: max-content;
  max-width: 48%;
  height: auto;
  margin-inline: auto;
  padding: .35cqw .65cqw;
  clip-path: none;
  border: 1px solid var(--crt-border-strong);
  border-radius: .22cqw;
  background: rgba(15, 21, 38, 0.92);
  color: #faf1d8;
  font-size: 1.15cqw;
  text-align: center;
  pointer-events: none;
}

#screen { min-width: 0; min-height: 0; width: 100%; height: 100%; }
#remote-screen {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  image-rendering: pixelated;
  background: #050509;
}

.button {
  min-height: 36px;
  padding: .3rem .65rem;
  border: 1px solid var(--crt-border-strong);
  border-radius: .23rem;
  background: var(--crt-elevated);
  color: var(--crt-text);
}
.button:hover:not(:disabled) { background: var(--crt-hover); }
.button.accent { border-color: var(--crt-accent-border); background: var(--crt-accent); color: #fff4d8; }
.button.accent:hover:not(:disabled) { background: var(--crt-accent-hover); }

/* Right-bezel 2P room dock */
.online-dock {
  position: absolute;
  z-index: 3;
  top: 3.45cqw;
  right: .85cqw;
  width: min(19.2cqw, 268px);
  border: 1px solid var(--crt-border-strong);
  border-radius: .38cqw;
  color: #f6efd8;
  background: rgba(15, 21, 38, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 .45cqw 1.4cqw rgba(0, 0, 0, 0.58);
  font-size: clamp(.66rem, 1cqw, .84rem);
  transition: opacity 280ms ease, width 150ms ease;
}
.online-dock[hidden] { display: none; }
.online-dock.is-collapsed {
  width: max-content;
  max-width: 24cqw;
}
.online-dock.is-collapsed .online-dock-body { display: none; }
.online-dock-head {
  display: flex;
  align-items: center;
  gap: .36rem;
  padding: .34rem .48rem;
  border-bottom: 1px solid var(--crt-border);
}
.online-dock.is-collapsed .online-dock-head { border-bottom-color: transparent; }
.online-dot {
  width: .52rem;
  height: .52rem;
  flex: none;
  border-radius: 50%;
  background: #8fa3c4;
  box-shadow: 0 0 .35rem currentColor;
}
.online-dock[data-state="idle"] .online-dot { background: #8fa3c4; color: #8fa3c4; }
.online-dock[data-state="waiting"] .online-dot { background: #f5cc66; color: #f5cc66; }
.online-dock[data-state="connected"] .online-dot { background: #55e39d; color: #55e39d; }
.online-dock[data-state="recovering"] .online-dot { background: #ff8e6b; color: #ff8e6b; }
#online-heading {
  font-size: 1em;
  letter-spacing: .02em;
  color: #fff2d2;
  white-space: nowrap;
}
#online-pill-stat {
  color: var(--crt-mint);
  font-size: .86em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.voice-pill {
  padding: .08rem .28rem;
  border: 1px solid var(--crt-border);
  border-radius: .2rem;
  background: var(--crt-surface);
  color: var(--crt-muted);
  font-size: .82em;
  white-space: nowrap;
}
.voice-pill.is-speaking {
  border-color: #55e39d;
  color: #a9f9cc;
  background: rgba(24, 64, 48, 0.85);
  box-shadow: 0 0 .45rem rgba(85, 227, 157, 0.38);
}
.dock-icon {
  margin-left: auto;
  min-width: 1.4rem;
  min-height: 1.4rem;
  padding: 0 .32rem;
  border: 1px solid var(--crt-border-strong);
  border-radius: .2rem;
  background: var(--crt-surface);
  color: #dce9ff;
  font: 700 .95em/1 var(--mono);
}
.dock-icon:hover { background: var(--crt-hover); }
.online-dock-body {
  display: grid;
  gap: .38rem;
  padding: .45rem .5rem .5rem;
}
#online-status {
  margin: 0;
  color: #dce7fa;
  line-height: 1.32;
  word-break: break-word;
}
.online-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .35rem;
}
.online-row label { color: var(--crt-muted); white-space: nowrap; }
#online-quality-preset {
  min-height: 1.7rem;
  width: 100%;
  font-size: .92em;
  padding: .1rem .25rem;
}
.online-check {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--crt-text);
  cursor: pointer;
}
.online-btn-row, .online-invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}
.online-dock .button {
  min-height: 1.75rem;
  padding: .22rem .48rem;
  font-size: .92em;
}
#online-start { flex: 1 1 auto; }
.online-invite-row[hidden] { display: none; }
#invite-link {
  flex: 1 1 0;
  min-width: 0;
  min-height: 1.75rem;
  padding: .18rem .35rem;
  color: #e8f7ed;
  background: var(--crt-surface);
  border: 1px solid var(--crt-border-strong);
  border-radius: .2rem;
  font-size: .88em;
}
#copy-invite.is-copied {
  border-color: var(--crt-mint);
  background: var(--crt-accent);
  color: #fff6dc;
}

/* Voice Chat panel in 2P Dock */
.online-voice {
  display: grid;
  gap: .32rem;
  padding-top: .36rem;
  border-top: 1px solid var(--crt-border);
}
.voice-row {
  display: flex;
  align-items: center;
  gap: .28rem;
}
.voice-mic { flex: 1 1 auto; text-align: center; }
.voice-mic.is-armed {
  border-color: rgba(244, 211, 126, 0.55);
  background: rgba(45, 38, 18, 0.72);
  color: #ffe8a8;
}
.voice-mic.is-live {
  border-color: var(--crt-accent-border);
  background: var(--crt-accent);
  color: #fff6dc;
}
.voice-mic.is-speaking {
  border-color: #55e39d;
  box-shadow: 0 0 .5rem rgba(85, 227, 157, 0.45);
}
.voice-mode { flex: none; font-size: .84em; }
.voice-mode[data-mode="ptt"] {
  border-color: rgba(159, 232, 202, 0.45);
  color: var(--crt-mint);
}
.voice-remote-row { gap: .38rem; }
.voice-mute {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  flex: none;
}
.voice-mute[aria-pressed="true"] {
  border-color: rgba(255, 142, 107, 0.55);
  color: #ffb49d;
}
.voice-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--crt-muted);
  flex: none;
}
.voice-dot.is-speaking {
  background: #55e39d;
  box-shadow: 0 0 .45rem #55e39d;
}
#voice-remote-vol {
  flex: 1 1 0;
  min-width: 0;
  height: 1.1rem;
  accent-color: var(--crt-mint);
  cursor: pointer;
}
.voice-status {
  margin: 0;
  color: var(--crt-muted);
  font-size: .84em;
  line-height: 1.28;
}
.online-keys-hint {
  margin: 0;
  padding-top: .28rem;
  border-top: 1px solid var(--crt-border);
  color: var(--crt-muted);
  font-size: .84em;
  line-height: 1.3;
}
#online-quality {
  padding-top: .25rem;
  border-top: 1px solid var(--crt-border);
  color: var(--crt-mint);
  font-size: .88em;
  font-variant-numeric: tabular-nums;
}
.player.controls-idle .online-dock.is-collapsed[data-state="connected"] {
  opacity: 0;
  pointer-events: none;
}

.online-guest .control-deck,
.online-guest #insert,
.online-guest #spend,
.online-guest #slot-input { pointer-events: none; }

/* Fullscreen & expanded player */
.player:is(:fullscreen, .is-expanded) {
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: none;
  border-radius: 0;
  background: #000;
}
.player.is-expanded { position: fixed; z-index: 20; height: 100dvh; }
.player:is(:fullscreen, .is-expanded) .back,
.player:is(:fullscreen, .is-expanded) .player-actions button { font-size: clamp(.8rem, 1.25vw, 1.2rem); }
.player:is(:fullscreen, .is-expanded) :is(.back, .player-actions, #game-title) { transition: opacity 350ms ease; }
.player:is(:fullscreen, .is-expanded) #game-title {
  inset: .65cqw 0 auto;
  z-index: 2;
  width: max-content;
  max-width: 36%;
  height: auto;
  margin-inline: auto;
  padding: .42em .68em;
  clip-path: none;
  background: #10162be6;
  color: #f6efd8;
  font: 700 clamp(.8rem, 1.25vw, 1.2rem)/1.4 var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.player:is(:fullscreen, .is-expanded) #game-status:not(:empty) { inset-block-start: 3.4rem; }
.player:is(:fullscreen, .is-expanded).controls-idle:not(:has(.back:focus-visible, .player-actions button:focus-visible)) :is(.back, .player-actions, #game-title) {
  opacity: 0;
  pointer-events: none;
}
.player:is(:fullscreen, .is-expanded) .online-dock {
  top: 3.15rem;
  right: .9rem;
  width: min(265px, 26vw);
  font-size: .82rem;
}
.player:is(:fullscreen, .is-expanded) .online-dock.is-collapsed {
  width: max-content;
}

/* Control bindings dialog */
#control-dialog {
  width: min(42rem, 94vw);
  max-height: 92dvh;
  padding: clamp(.85rem, 2.5vw, 1.45rem);
  border: 1px solid var(--crt-accent-border);
  border-radius: .4rem;
  color: #f6efd8;
  background: var(--crt-surface);
  box-shadow: 0 1rem 2.6rem rgba(3, 6, 16, 0.72);
  font: .86rem/1.4 var(--mono);
}
#control-dialog::backdrop { background: rgba(6, 10, 20, 0.8); }
#control-dialog h2 { margin-block: 0 .45em; color: #fff2d2; font-size: 1.25em; }
#control-dialog h3 {
  margin-block: 0 .4em;
  color: var(--crt-mint);
  font-size: .92em;
  text-transform: uppercase;
  letter-spacing: .04em;
}
#key-bindings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.55rem, 2vw, 1.05rem);
}
#key-bindings section { display: grid; gap: .26rem; align-content: start; }
.key-profiles { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .5rem; }
.key-profiles + p { margin-bottom: .65rem; color: var(--crt-muted); }
#control-dialog button {
  padding: .36em .65em;
  border: 1px solid var(--crt-border-strong);
  border-radius: .24rem;
  color: var(--crt-text);
  background: var(--crt-elevated);
  font: inherit;
  text-align: left;
}
#key-bindings button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.key-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keycap {
  flex: none;
  min-width: 2.15em;
  padding: .08em .42em;
  border: 1px solid var(--crt-border-strong);
  border-radius: .2rem;
  background: rgba(9, 14, 28, 0.85);
  color: var(--crt-gold);
  font-family: inherit;
  font-weight: 700;
  font-size: .92em;
  text-align: center;
}
#key-bindings button.is-listening {
  border-color: var(--crt-gold);
  background: rgba(52, 42, 18, 0.85);
}
#key-bindings button.is-listening .keycap {
  border-color: var(--crt-gold);
  color: #fff6dc;
}
#control-dialog button:disabled { opacity: .5; cursor: not-allowed; }
#control-dialog button:not(:disabled):is(:hover, :focus-visible),
#control-dialog .key-profiles button[aria-pressed="true"] {
  border-color: var(--crt-accent-border);
  background: var(--crt-accent);
}
#key-hint { margin: .65rem 0 0; color: var(--crt-mint); min-height: 1.4em; }
.control-actions { display: flex; justify-content: space-between; margin-top: .75rem; }

@media (max-width: 780px) {
  .online-dock { width: min(240px, 84vw); }
}
@media (max-width: 720px) {
  .player:is(:fullscreen, .is-expanded) #game-title { inset-block-start: 2.7rem; max-width: 85%; }
}
@media (max-width: 630px) {
  .home-menu { gap: 1.3cqw; }
  .menu-choices button { font-size: 2.34cqw; }
  .menu-audio { font-size: 1.8cqw; }
  .utility { font-size: 2cqw; padding: 1cqw 2cqw; }
  .utility .button { font-size: 1.75cqw; }
  .room-grid { gap: .8cqw; }
  .catalog-heading h2 { font-size: 1.55cqw; }
  #count { font-size: 1.45cqw; }
  .quick-filters button { font-size: 1.35cqw; padding: .2cqw .42cqw; }
  input[type="search"], select { min-height: 3.1cqw; font-size: 1.5cqw; }
  .filter-selects select { font-size: 1.35cqw; }
  .game { min-height: 3.6cqw; }
  .game-name { font-size: 1.75cqw; }
  .badge-sys { font-size: 1cqw; min-width: 3.2cqw; }
  .badge-rate { font-size: 1.15cqw; min-width: 3cqw; }
  .intro h1 { font-size: 3.1cqw; }
  .description { font-size: 1.58cqw; }
  .controls-hint { display: none; }
  .monitor-bottom > span:nth-child(2) { display: none; }
  .player .back, .player-actions button { font-size: 2cqw; }
  #key-bindings { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .coin-motion { animation-duration: .001ms !important; }
  .photo-stick,
  .artwork img,
  .menu-choices button,
  .menu-audio,
  .play-link,
  .quick-filters button,
  .button,
  .player-actions button,
  .player .back,
  .dock-icon,
  #control-dialog button { transition: none !important; }
  :is(.menu-choices button, .menu-audio, .play-link, .quick-filters button, .button, .player-actions button, .player .back, .dock-icon, #control-dialog button):not(:disabled):active {
    transform: none;
  }
  .player:is(:fullscreen, .is-expanded) :is(.back, .player-actions, #game-title) { transition: none; }
}
