@font-face {
  font-family: OpenSans;
  src: url("assets/fonts/OpenSans-Regular.ttf") format("truetype");
}
@font-face {
  font-family: OpenSans;
  src: url("assets/fonts/OpenSans-Bold.ttf") format("truetype");
  font-weight: 700;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --accent-purple: #8b5cf6;
  --accent-purple-hover: #7c3aed;
  --accent-purple-glow: rgba(139, 92, 246, 0.5);
  --bg-dark: #1a1c1e;
  --header-bg: #1e2022;
  --card-bg: #27292c;
  --text-muted: #9ca3af;
}

body.menu-page {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
  background-image: url("assets/hex.png");
  background-repeat: repeat;
  color: #ffffff;
  font-family: OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

body.menu-page.pairing-lock {
  overflow: hidden;
}

body.menu-page.pairing-lock .menu-header,
body.menu-page.pairing-lock .menu-container {
  pointer-events: none;
  user-select: none;
  visibility: hidden !important;
  opacity: 0;
  visibility: hidden !important;
  opacity: 0;
}

/* =========================================================
   HEADER (Always visible / Top bar)
   ========================================================= */
.menu-header {
  position: relative;
  z-index: 50;
  height: 60px;
  flex-shrink: 0;
  background: #1d1d1d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.header-left {
  display: flex;
  align-items: center;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  background: #272727;
  border: 1px solid #3c3f44;
  border-radius: 8px;
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease;
}

.header-icon-btn:hover {
  background: #373a3e;
}

.header-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.header-brand {
  align-items: center;
  background: #272727;
  border-radius: 30px;
  display: flex;
  height: 48px;
  justify-content: center;
  padding: 0 20px;
  gap: 10px;
  cursor: default;
  user-select: none;
}

.brand-logo {
  width: 48px;
  height: auto;
  display: block;
}

.brand-name {
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
}

.add-players-btn {
  background: #272727;
  border: 1px solid #3c3f44;
  border-radius: 10px;
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-players-btn:hover {
  background: #373a3e;
}

.player-slots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-slot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2.5px solid var(--accent-purple);
  background: #fef3c7;
  color: #1e293b;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.player-slot-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.room-code-display {
  align-items: center;
  background-image: linear-gradient(180deg, #272727, #1d1d1d);
  border-bottom: 2px solid #ffffff;
  border-bottom-left-radius: 15px;
  border-left: 2px solid #ffffff;
  display: flex;
  justify-content: center;
  padding: 0 20px;
  height: 60px;
  color: #ffffff;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 2px;
}

/* =========================================================
   MENU CONTAINER & ALWAYS-VISIBLE HERO (TOP SECTION)
   ========================================================= */
.menu-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.menu-hero {
  position: relative;
  flex-shrink: 0;
  height: calc(52vh - 30px);
  min-height: 380px;
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.menu-game-copy {
  position: relative;
  z-index: 5;
  flex: 0 0 46%;
  max-width: 520px;
  padding: 20px 0 20px 60px;
}

.menu-game-copy h1 {
  margin: 0 0 10px;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.player-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 17px;
  color: #ffffff;
  font-weight: 600;
}

.player-icon {
  fill: #ffffff;
}

.menu-game-copy p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1.55;
  max-width: 440px;
}

.play-action-wrap {
  position: relative;
}

/* Purple PLAY NOW Button */
.menu-play-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(to right, #8b5cf6, #a78bfa);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  width: 230px;
  height: 60px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  box-shadow: 0 4px 20px var(--accent-purple-glow);
}

.menu-play-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 6px 24px var(--accent-purple-glow);
}

.play-btn-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
}

.play-btn-sub {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 2px;
}

/* Authentic Video Trailer Container */
.menu-feature-trailer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 58%;
  overflow: hidden;
  background: #000000;
}

.menu-feature-trailer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.trailer-fade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to right, #1a1c1e 0%, rgba(26, 28, 30, 0.95) 12%, rgba(26, 28, 30, 0) 48%),
              linear-gradient(to bottom, rgba(26, 28, 30, 0.4) 0%, transparent 15%, transparent 85%, #1a1c1e 100%);
}

/* Floating QR card on right edge */
.floating-qr-card {
  position: absolute;
  right: 0;
  bottom: 20px;
  z-index: 15;
  background: #ffffff;
  padding: 10px 10px 10px 14px;
  border-radius: 20px 0 0 20px;
  box-shadow: -8px 8px 24px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.floating-qr-card:hover {
  transform: translateX(-4px);
  box-shadow: -8px 8px 24px var(--accent-purple-glow);
}

.floating-qr-card img {
  display: block;
  width: 155px;
  height: 155px;
}

/* =========================================================
   SCROLLABLE CATEGORIES AREA
   ========================================================= */
.categories-scroll-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.4) transparent;
  padding: 14px 0 24px;
}

.categories-scroll-wrapper::-webkit-scrollbar {
  width: 6px;
}

.categories-scroll-wrapper::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.4);
  border-radius: 9999px;
}

.game-menu-section {
  margin-bottom: 18px;
}

.menu-section-heading {
  margin: 0 0 14px 60px;
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.game-menu-grid {
  display: flex;
  gap: 22px;
  padding: 6px 60px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.game-menu-grid::-webkit-scrollbar {
  display: none;
}

.menu-game-card {
  flex: 0 0 264px;
  height: 152px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  border: 3.5px solid transparent;
  background: var(--card-bg);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.menu-game-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.5);
}

.menu-game-card.selected {
  border-color: var(--accent-purple);
  box-shadow: 0 0 18px var(--accent-purple-glow);
  transform: translateY(-3px);
}

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

.game-card-new-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-bottom-left-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.game-card-recode-badge {
  background: #22b8a6;
}

.menu-game-card.unimplemented {
  filter: grayscale(1) brightness(0.55);
  opacity: 0.6;
  cursor: not-allowed;
}

.menu-game-card.unimplemented:hover {
  opacity: 0.82;
  filter: grayscale(1) brightness(0.7);
  border-color: rgba(255, 255, 255, 0.25);
}

.menu-game-card.unimplemented.selected {
  opacity: 0.85;
  filter: grayscale(1) brightness(0.75);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
}

.game-card-soon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-4deg);
  background: rgba(12, 14, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 6px 13px;
  white-space: nowrap;
  pointer-events: none;
}

/* =========================================================
   PAIRING MODAL (1:1 with d962d459 reference)
   ========================================================= */
.pairing-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.pairing-backdrop[hidden] {
  display: none !important;
}

.pairing-modal-card {
  position: relative;
  width: min(92vw, 680px);
  background: #2b2d30;
  border-radius: 24px;
  padding: 26px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  color: #ffffff;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: #3c3f44;
  border: none;
  border-radius: 50%;
  color: #ffffff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-close-btn:hover {
  background: #4b4f55;
}

.pairing-top-banner {
  background: #202225;
  border-radius: 16px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.pairing-top-banner p {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  color: #e5e7eb;
  max-width: 380px;
}

.modal-controller-gif {
  flex: 0 0 180px;
  width: 180px;
  height: auto;
  border-radius: 8px;
  display: block;
}

.pairing-bottom-row {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}

.pairing-qr-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 10px;
  flex: 0 0 220px;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}

.pairing-qr-box img {
  width: 100%;
  height: 100%;
  display: block;
}

.pairing-info-col {
  flex: 1;
}

.pairing-step-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.pairing-step-list li {
  font-size: 15px;
  line-height: 1.45;
  color: #d1d5db;
  margin-bottom: 6px;
}

.pairing-code-badge {
  background: #1a1c1e;
  border-radius: 16px;
  padding: 10px 18px;
  text-align: center;
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #ffffff;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pairing-controller-url-box a {
  display: inline-block;
  color: var(--accent-purple);
  font-size: 13px;
  text-decoration: underline;
  margin-bottom: 12px;
  word-break: break-all;
}

.pairing-hdmi-note {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.4;
  color: #9ca3af;
}

.connected-players-list {
  font-size: 14px;
  color: #9ca3af;
}


/* =========================================================
   RESPONSIVE (Top section and header ALWAYS remain visible)
   ========================================================= */
@media (max-width: 960px) {
  .menu-hero {
    min-height: 320px;
    height: 48vh;
  }
  .menu-game-copy {
    padding-left: 28px;
    flex: 0 0 52%;
  }
  .menu-section-heading {
    margin-left: 28px;
  }
  .game-menu-grid {
    padding-left: 28px;
    padding-right: 28px;
  }
}

@media (max-width: 768px) {
  /* Pinned top section: never allow page scroll to hide top section */
  body.menu-page {
    overflow: hidden;
    height: 100vh;
  }
  .menu-header {
    padding: 0 0 0 16px;
  }
  .brand-name {
    font-size: 20px;
  }
  .header-brand {
    padding: 0 14px;
    height: 42px;
  }
  .brand-logo {
    width: 38px;
  }
  .room-code-display {
    font-size: 24px;
    padding: 0 14px;
  }
  .menu-hero {
    height: 44vh;
    min-height: 260px;
  }
  .menu-game-copy {
    padding: 14px 20px;
    flex: 0 0 54%;
  }
  .menu-game-copy h1 {
    font-size: 28px;
    margin-bottom: 6px;
  }
  .player-range {
    margin-bottom: 10px;
  }
  .menu-game-copy p {
    font-size: 13px;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .menu-play-btn {
    width: 180px;
    height: 48px;
  }
  .play-btn-title {
    font-size: 16px;
  }
  .play-btn-sub {
    font-size: 9px;
  }
  .floating-qr-card img {
    width: 100px;
    height: 100px;
  }
  .menu-section-heading {
    margin-left: 20px;
  }
  .game-menu-grid {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Keyboard Player 1 Toggle (Disabled for now) */
.keyboard-toggle-btn,
.pairing-keyboard-option {
  display: none !important;
}

.keyboard-toggle-btn:hover {
  background: #373a3e;
  border-color: #4b5563;
}

.keyboard-toggle-btn.active,
.keyboard-toggle-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.45);
}

.keyboard-toggle-btn .keyboard-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.keyboard-toggle-btn .keyboard-toggle-status {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.keyboard-toggle-btn.active .keyboard-toggle-status,
.keyboard-toggle-btn[aria-pressed="true"] .keyboard-toggle-status {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.pairing-keyboard-option {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pairing-keyboard-text {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 500;
}

/* =========================================================
   POLISH PASS
   ========================================================= */
:root {
  --menu-surface: #202326;
  --menu-surface-raised: #2a2e33;
  --menu-border: rgba(255, 255, 255, 0.1);
  --menu-text-soft: #c7ccd4;
  --menu-accent: #9b7aff;
  --menu-accent-strong: #7c5ce8;
}

.menu-header {
  height: 68px;
  padding-left: 28px;
  background: rgba(24, 26, 29, 0.96);
  border-bottom: 1px solid var(--menu-border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.header-icon-btn,
.add-players-btn,
.keyboard-toggle-btn {
  background: var(--menu-surface);
  border-color: var(--menu-border);
}

.header-icon-btn:hover,
.add-players-btn:hover,
.keyboard-toggle-btn:hover {
  background: var(--menu-surface-raised);
  border-color: rgba(155, 122, 255, 0.55);
}

.header-icon-btn:focus-visible,
.add-players-btn:focus-visible,
.keyboard-toggle-btn:focus-visible,
.menu-play-btn:focus-visible,
.menu-game-card:focus-visible,
.floating-qr-card:focus-visible,
.modal-close-btn:focus-visible {
  outline: 3px solid rgba(155, 122, 255, 0.8);
  outline-offset: 3px;
}

.header-brand {
  height: 50px;
  padding: 0 22px 0 16px;
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  border-radius: 14px;
}

.brand-logo {
  width: 42px;
}

.brand-name {
  font-size: 22px;
}

.header-right {
  gap: 10px;
}

.room-code-display {
  min-width: 144px;
  height: 68px;
  padding: 0 24px;
  background: var(--menu-accent-strong);
  border: 0;
  border-radius: 18px 0 0 18px;
  font-size: 28px;
  letter-spacing: 3px;
}

.menu-hero {
  height: calc(54vh - 34px);
  min-height: 390px;
  max-height: 510px;
  background: #1a1c1f;
  border-bottom: 1px solid var(--menu-border);
}

.menu-game-copy {
  flex-basis: 48%;
  max-width: 560px;
  padding-left: 72px;
}

.menu-game-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(42px, 4vw, 58px);
  line-height: 1.02;
  letter-spacing: -1.6px;
}

.player-range {
  margin-bottom: 18px;
  color: var(--menu-text-soft);
  font-size: 15px;
}

.player-icon {
  color: var(--menu-accent);
  fill: currentColor;
}

.menu-game-copy p {
  color: var(--menu-text-soft);
  font-size: 16px;
  line-height: 1.6;
}

.menu-play-btn {
  width: 236px;
  height: 62px;
  background: var(--menu-accent);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(124, 92, 232, 0.24);
}

.menu-play-btn:hover {
  background: #ad96ff;
  box-shadow: 0 14px 30px rgba(124, 92, 232, 0.34);
}

.play-btn-title {
  font-size: 18px;
  letter-spacing: 0.8px;
}

.play-btn-sub {
  color: rgba(30, 24, 48, 0.72);
}

.menu-feature-trailer {
  width: 60%;
  background: #0f1113;
}

.trailer-fade {
  background: linear-gradient(to right, #1a1c1f 0%, rgba(26, 28, 31, 0.86) 13%, rgba(26, 28, 31, 0) 48%),
    linear-gradient(to bottom, rgba(26, 28, 31, 0.2) 0%, transparent 20%, transparent 82%, #1a1c1f 100%);
}

.floating-qr-card {
  right: 24px;
  bottom: 24px;
  padding: 9px;
  border-radius: 14px;
  background: #f8f7ff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.floating-qr-card img {
  width: 132px;
  height: 132px;
}

.categories-scroll-wrapper {
  padding-top: 24px;
  scrollbar-color: rgba(155, 122, 255, 0.55) transparent;
}

.game-menu-section {
  margin-bottom: 28px;
}

.menu-section-heading {
  margin-bottom: 16px;
  font-size: 21px;
  letter-spacing: -0.4px;
}

.game-menu-grid {
  gap: 18px;
  padding-top: 4px;
  padding-bottom: 12px;
}

.menu-game-card {
  flex-basis: 276px;
  height: 158px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--menu-surface);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.menu-game-card:hover {
  border-color: rgba(155, 122, 255, 0.55);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.menu-game-card.selected {
  border-color: var(--menu-accent);
  box-shadow: 0 0 0 3px rgba(155, 122, 255, 0.16), 0 12px 26px rgba(0, 0, 0, 0.3);
}

.game-card-new-badge {
  top: 10px;
  right: 10px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 10px;
}

.game-card-soon {
  background: rgba(17, 19, 22, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}

.pairing-modal-card {
  background: #25282c;
  border: 1px solid var(--menu-border);
  border-radius: 18px;
}

.modal-close-btn {
  background: var(--menu-surface-raised);
}

.modal-close-btn:hover {
  background: var(--menu-accent-strong);
}

@media (max-width: 960px) {
  .menu-game-copy {
    padding-left: 36px;
  }
}

@media (max-width: 768px) {
  .menu-header {
    height: 60px;
    padding-left: 16px;
  }

  .header-brand {
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
  }

  .brand-logo {
    width: 34px;
  }

  .brand-name {
    font-size: 19px;
  }

  .header-right {
    gap: 6px;
  }

  .keyboard-toggle-label,
  .add-players-btn {
    display: none;
  }

  .keyboard-toggle-btn {
    padding: 8px;
  }

  .room-code-display {
    min-width: 86px;
    height: 60px;
    padding: 0 12px;
    border-radius: 12px 0 0 12px;
    font-size: 20px;
  }

  .menu-hero {
    height: 45vh;
    min-height: 280px;
  }

  .menu-game-copy {
    padding: 18px 20px;
  }

  .menu-game-copy h1 {
    font-size: 32px;
  }

  .menu-feature-trailer {
    width: 64%;
  }

  .floating-qr-card {
    right: 14px;
    bottom: 14px;
  }

  .floating-qr-card img {
    width: 92px;
    height: 92px;
  }
}

/* Full-screen controller waiting room */
.pairing-backdrop.empty-controller-state {
  display: grid;
  place-items: stretch;
  padding: 0;
  overflow: hidden;
  background-color: #0c1118;
  background: transparent;
  backdrop-filter: none;
}

.pairing-backdrop.empty-controller-state::before {
  position: fixed;
  inset: 0;
  content: "";
  z-index: 0;
  background:
    linear-gradient(
      90deg,
      #10253a 0%,
      #10253a 42%,
      rgba(16, 37, 58, 0.92) 49%,
      rgba(16, 37, 58, 0.48) 57%,
      transparent 68%
    ),
    url("assets/pairing-background.jpg") right center / auto 100% no-repeat;
  opacity: 1;
  pointer-events: none;
}

.pairing-backdrop.empty-controller-state::after {
  content: none;
}

.empty-controller-state .pairing-modal-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: 58%;
  max-width: 820px;
  height: 100vh;
  min-height: 0;
  margin: 0;
  padding: clamp(28px, 5vh, 56px) clamp(32px, 5vw, 72px);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.empty-controller-state .modal-close-btn {
  display: none;
}

.empty-controller-state .pairing-top-banner {
  display: block;
  flex: 0 0 auto;
  margin: 0 0 clamp(18px, 3vh, 30px);
  padding: 0;
  background: transparent;
}

.empty-controller-state .pairing-top-banner::before {
  display: block;
  width: 52px;
  height: 5px;
  margin-bottom: 22px;
  content: "";
  background: var(--menu-accent);
  border-radius: 999px;
}

.empty-controller-state .pairing-top-banner p {
  max-width: 620px;
  color: #ffffff;
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -1.4px;
}

.empty-controller-state .modal-controller-gif {
  display: none;
}

.empty-controller-state .pairing-bottom-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 3vw, 44px);
  min-height: 0;
  max-width: 720px;
}

.empty-controller-state .pairing-qr-box {
  width: 160px;
  height: auto;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 18px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

.empty-controller-state .pairing-step-list {
  margin-bottom: 20px;
}

.empty-controller-state .pairing-step-list li {
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.45;
}

.empty-controller-state .pairing-code-badge {
  width: fit-content;
  min-width: 210px;
  margin-bottom: 12px;
  padding: 8px 20px;
  background: rgba(7, 11, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  font-size: clamp(32px, 3.2vw, 46px);
  letter-spacing: 6px;
}

.empty-controller-state .pairing-controller-url-box a {
  color: #c4b5fd;
  font-size: 14px;
}

.empty-controller-state .pairing-hdmi-note {
  max-width: 360px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 15px;
}

.empty-controller-state .connected-players-list {
  display: none;
}

.empty-controller-state .pairing-keyboard-option {
  display: none;
}

@media (max-width: 680px) {
  .empty-controller-state .pairing-modal-card {
    justify-content: flex-start;
    overflow-y: auto;
    width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
    padding: 28px 22px;
  }

  .empty-controller-state .pairing-top-banner p {
    font-size: 32px;
    letter-spacing: -1px;
  }

  .empty-controller-state .pairing-bottom-row {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .empty-controller-state .pairing-qr-box {
    width: 170px;
  }

  .empty-controller-state .pairing-code-badge {
    min-width: 0;
    width: 100%;
    font-size: 44px;
    letter-spacing: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pairing-backdrop.empty-controller-state,
  .pairing-backdrop.empty-controller-state::after {
    animation: none;
  }

  .pairing-backdrop.empty-controller-state::before {
    animation: none;
    opacity: 1;
  }
}

/* =========================================================
   RECLOUD ACCOUNT SYSTEM (Google Sign-In & User Profile)
   ========================================================= */
.account-container {
  position: relative;
  display: flex;
  align-items: center;
}

.google-signin-btn {
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
  user-select: none;
}

.google-signin-btn:hover {
  background: #f8fafd;
  border-color: #d2e3fc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.google-signin-btn:active {
  transform: translateY(0);
}

.google-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.user-profile-pill {
  background: #272727;
  border: 1px solid #3c3f44;
  border-radius: 24px;
  padding: 4px 12px 4px 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.user-profile-pill:hover,
.user-profile-pill.active {
  background: #373a3e;
  border-color: #555a62;
}

.user-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #181a20;
}

.user-name-text {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-chevron {
  color: #9ca3af;
  transition: transform 0.2s ease;
}

.user-profile-pill.active .dropdown-chevron {
  transform: rotate(180deg);
}

/* Account Dropdown */
.account-dropdown-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background: #22252a;
  border: 1px solid #373b42;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  padding: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeInDown 0.15s ease;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-user-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropdown-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #181a20;
  border: 2px solid var(--accent-purple);
}

.dropdown-user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dropdown-user-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-email {
  color: #94a3b8;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-divider {
  height: 1px;
  background: #33373e;
  margin: 2px 0;
}

.dropdown-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #94a3b8;
  padding: 2px 4px;
}

.dropdown-info-row strong {
  color: #38bdf8;
}

.dropdown-btn {
  background: #2c3036;
  border: 1px solid #3d424b;
  border-radius: 8px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.dropdown-btn:hover {
  background: #373c44;
  color: #ffffff;
}

.dropdown-signout {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.dropdown-signout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
}

/* Recently Played Header & Badge */
.section-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-cloud-badge {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Firebase Modal */
.firebase-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.firebase-modal-card {
  position: relative;
  background: #1e2228;
  border: 1px solid #383d47;
  border-radius: 16px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  color: #ffffff;
}

.firebase-modal-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.modal-desc {
  font-size: 13px;
  color: #94a3b8;
  margin: 0 0 18px;
  line-height: 1.4;
}

.firebase-modal-field {
  margin-bottom: 12px;
}

.firebase-modal-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.firebase-modal-field input {
  width: 100%;
  background: #14161b;
  border: 1px solid #373b44;
  border-radius: 8px;
  color: #ffffff;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 12px;
  box-sizing: border-box;
}

.firebase-modal-field input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.modal-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-primary-btn {
  flex: 1;
  background: var(--accent-purple);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.modal-secondary-btn {
  flex: 1;
  background: #2b2f38;
  color: #e2e8f0;
  border: 1px solid #434854;
  border-radius: 8px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.modal-notice {
  font-size: 11px;
  color: #64748b;
  margin-top: 14px;
  margin-bottom: 0;
  line-height: 1.4;
}

/* Hide Netlify Drawer & Preview Badges */
#netlify-drawer-container,
[id^="netlify-drawer"],
iframe[src*="netlify.com"] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
