:root {
  color-scheme: dark;
  --bg: #12141a;
  --bg-raise: #1b1f29;
  --line: #2c3240;
  --text: #e7e4dc;
  --muted: #9a9386;
  --accent: #e4b15a;
  --accent-ink: #2a2112;
  --danger: #ff8d7a;
  --nes: #e06a4f;
  --gba: #7d9a62;
  --psx: #6f93d6;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(228, 177, 90, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
}

a { color: inherit; }

body.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-end;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.lede {
  margin: 0;
  max-width: 360px;
  color: var(--muted);
  line-height: 1.45;
}

.join-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 22px;
}

.join-bar label { color: var(--muted); font-size: 14px; }

.join-bar input, .netplay-panel input {
  width: 8.5rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  letter-spacing: 0.12em;
}

.join-bar button, .netplay-panel button[type="submit"] {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.join-bar .error { flex-basis: 100%; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  text-decoration: none;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card:hover { border-color: #4a4336; }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.cover {
  height: 168px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 42%),
    #141820;
  border-bottom: 3px solid var(--system, var(--accent));
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.monogram {
  font-size: 28px;
  letter-spacing: 0.08em;
  color: var(--system, var(--accent));
  font-weight: 700;
}

.card-body { padding: 14px 14px 16px; }

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.size {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--system, var(--accent));
}

.empty, .note {
  color: var(--muted);
  line-height: 1.5;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

code, kbd {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #222733;
}

.site-footer {
  margin-top: 36px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.player-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d0f14;
}

.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #161922;
}

.back {
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
}

.back:hover, .text-button:hover { border-color: var(--accent); }

.title-block { min-width: 0; flex: 1; }

.title-block h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions { display: flex; gap: 8px; align-items: center; }

.text-button, .controls-toggle {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#game, #remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

#remote-video { z-index: 1; }

#remote-video[hidden], #game[hidden] { display: none; }

#tap-start {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1206;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#tap-start[hidden] { display: none; }

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 15, 20, 0.94);
  z-index: 2;
}

.loader[hidden] { display: none; }

.loader-card {
  width: min(440px, calc(100% - 32px));
  padding: 22px;
  border-radius: 14px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
}

.loader-card h2 { margin: 0 0 8px; font-size: 18px; }
.loader-card p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }

.bar {
  height: 10px;
  border-radius: 999px;
  background: #2a303c;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #b9833a, var(--accent));
}

.meter {
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 14px;
}

.error { color: var(--danger); }

.controls-help {
  flex: none;
  max-height: 46vh;
  overflow: auto;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--line);
  background: #161922;
}

.controls-help[hidden] { display: none; }

.controls-help h2, .home-controls h2 { margin: 0 0 6px; font-size: 16px; }

.controls-note { margin: 0 0 8px; color: var(--muted); font-size: 14px; line-height: 1.45; }

#controls-art, #home-controls-art { overflow-x: auto; }

.controls-help svg, .home-controls svg { display: block; width: min(720px, 100%); height: auto; margin: 0 auto; }

.home-controls { margin: 28px 0 8px; }

.control-tabs { display: flex; gap: 8px; margin: 0 0 8px; }

.control-tabs button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}

.control-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }

.netplay-panel[hidden], #invite-result[hidden] { display: none; }

.netplay-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  width: min(360px, calc(100% - 24px));
  z-index: 3;
  padding: 16px;
  border-radius: 14px;
  background: #1b1f29;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.netplay-panel h2 { margin: 0 0 8px; font-size: 16px; }
.netplay-panel p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.netplay-panel form:not([hidden]) { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.netplay-panel .pin {
  margin: 8px 0 4px;
  color: var(--text);
  font-size: 32px;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
}
#invite-link { overflow-wrap: anywhere; }

.guest-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  padding: 15px 10px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
  color: #fff;
  transition: opacity .4s ease-in-out, transform .4s ease-in-out;
}

.guest-bar.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
}

.guest-bar-spacer { flex: 1; }

.guest-bar-button {
  position: relative;
  width: auto;
  margin-right: 2px;
  padding: 7px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.guest-bar-button[hidden] { display: none; }

.guest-bar-button:hover { background: var(--accent); color: #fff; }

.guest-bar-button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
  pointer-events: none;
}

.guest-bar-tip {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 10px;
  padding: 5px 7.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.9);
  color: #4f5b5f;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.8);
  transform-origin: 0 100%;
  transition: transform .2s .1s ease, opacity .2s .1s ease;
  z-index: 2;
}

.guest-bar-tip-right { left: auto; right: 0; transform-origin: 100% 100%; }

.guest-bar-button:hover .guest-bar-tip { opacity: 1; transform: translateY(0) scale(1); }

.guest-volume {
  display: flex;
  align-items: center;
  width: 150px;
  margin-right: 8px;
}

.guest-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 6px;
  margin: 0 0 0 5px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
}

.guest-volume input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, currentColor var(--value, 0%), rgba(255, 255, 255, 0.25) var(--value, 0%));
}

.guest-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border: 0;
  border-radius: 100%;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(47, 52, 61, 0.2);
}

.guest-volume input[type="range"]::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.guest-volume input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: currentColor;
}

.guest-volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 100%;
  background: #fff;
}

.stage:fullscreen { background: #000; }

.guest-settings {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}

.guest-settings[hidden] { display: none; }

.guest-settings-card {
  width: min(640px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1b1f29;
}

.guest-settings-card h2 { margin: 0 0 8px; font-size: 18px; }
.guest-settings-card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.45; }

.guest-settings svg { display: block; width: min(560px, 100%); height: auto; margin: 0 auto 8px; }

.guest-bind-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}

.guest-bind-row .text-button.is-listening { border-color: var(--accent); color: var(--accent); }

.guest-settings-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

