/* ============================================================
   Nostalgic Emulation — Main Stylesheet
   Dark retro/gaming aesthetic, Chrome-first, responsive.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323:wght@400&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #0a0a0f;
  --surface:     #111128;
  --surface-alt: #1a1a35;
  --border:      #2d2d5e;
  --primary:     #7c3aed;
  --primary-glow:#a855f7;
  --accent:      #10b981;
  --warn:        #f59e0b;
  --text:        #e2e8f0;
  --text-dim:    #94a3b8;
  --text-muted:  #64748b;
  --radius:      6px;
  --topbar-h:    56px;
  --font-pixel:  'Press Start 2P', monospace;
  --font-display:'VT323', monospace;
  --font-body:   'Courier New', Courier, monospace;
  /* Typography scale */
  --font-xs:     .65rem;
  --font-sm:     .75rem;
  --font-md:     .82rem;
  --font-lg:     .9rem;
  --font-xl:     1rem;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--primary-glow); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Scanlines overlay ──────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,.04) 2px,
    rgba(0,0,0,.04) 4px
  );
}

/* ── Typography helpers ─────────────────────────────────────── */
.pixel       { font-family: var(--font-pixel); }
.display     { font-family: var(--font-display); font-size: 2rem; letter-spacing: 2px; }
.text-accent { color: var(--accent); }
.text-primary{ color: var(--primary-glow); }
.text-dim    { color: var(--text-dim); }
.text-muted  { color: var(--text-muted); }

/* ── Sidebar ─────────────────────────────────────────────────── */

:root {
  --sidebar-w:        240px;
  --mobile-topbar-h:  52px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, .35) transparent;
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 24px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  z-index: 150;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar        { width: 4px; }
.sidebar::-webkit-scrollbar-track  { background: transparent; }
.sidebar::-webkit-scrollbar-thumb  {
  background: rgba(124, 58, 237, .35);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, .6);
}

/* Logo block */
.sidebar-logo-link {
  display: block;
  padding: 0;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  line-height: 0;
}

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

/* Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .75rem 0 .5rem;
  gap: 2px;
}

.sidebar-section-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: .44rem;
  color: var(--text-muted);
  letter-spacing: .1em;
  padding: .85rem 1.1rem .35rem;
}

/* NOW PLAYING — cyan gaming accent with subtle glow */
.sidebar-section-label--playing {
  color: #22d3ee;
  text-shadow: 0 0 10px rgba(34,211,238,.35);
  letter-spacing: .18em;
  font-size: .46rem;
}

/* In-game NAVIGATE section — smaller, understated */
.sidebar-section-label--nav {
  font-size: .38rem;
  letter-spacing: .08em;
  padding-top: .55rem;
  padding-bottom: .2rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: .6rem .85rem;
}

/* Lighter divider for internal sub-sections */
.sidebar-divider--subtle {
  opacity: .45;
  margin: .3rem .85rem;
}

/* Links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1.1rem;
  font-family: var(--font-pixel);
  font-size: .62rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color .1s, background .1s, border-color .1s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  letter-spacing: .02em;
  border-left: 3px solid transparent;
  line-height: 1.6;
  text-align: left;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
  border-left-color: var(--primary-glow);
}

.sidebar-link.active {
  color: var(--primary-glow);
  background: rgba(124,58,237,.13);
  border-left-color: var(--primary);
}

.sidebar-icon {
  font-size: 1.2em;
  line-height: 1;
  width: 1.25em;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Custom PNG icons — replaces emoji inside .sidebar-icon spans */
.sidebar-icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  opacity: .72;
  transition: opacity .15s ease, filter .15s ease;
  /* Slight brightness boost so dark icons read on the dark sidebar */
  filter: brightness(1.25);
}

.sidebar-link:hover .sidebar-icon-img {
  opacity: 1;
  filter: brightness(1.4);
}

.sidebar-link.active .sidebar-icon-img {
  opacity: 1;
  filter: brightness(1.35);
}

/* Fav icon: golden tint when game is already favorited */
.sidebar-link.fav-active .fav-icon {
  opacity: 1;
  filter: brightness(1.1) sepia(.5) saturate(2.5) hue-rotate(-15deg);
}

.sidebar-label {
  flex: 1;
  white-space: normal;
  word-break: break-word;
}

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: .5rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link-danger        { color: #fca5a5; }
.sidebar-link-danger:hover  { background: rgba(239,68,68,.12); color: #f87171; border-left-color: #f87171; }
/* Logout icon: warm red tint instead of the default brightness boost */
.sidebar-link-danger .sidebar-icon-img        { filter: brightness(1.1) sepia(.3) saturate(2) hue-rotate(310deg); }
.sidebar-link-danger:hover .sidebar-icon-img  { filter: brightness(1.2) sepia(.4) saturate(2.5) hue-rotate(310deg); }

.sidebar-link-accent        { color: var(--accent); }
.sidebar-link-accent:hover  { background: rgba(16,185,129,.1); border-left-color: var(--accent); }

/* ── User avatar — initials chip or image ───────────────────────────────────── */
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-family: var(--font-pixel);
  font-size: .5rem;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
  opacity: .95;
  vertical-align: middle;
}

/* Size variants */
.user-avatar--xs { width: 20px; height: 20px; font-size: .42rem; }
.user-avatar--sm { width: 24px; height: 24px; font-size: .5rem; }
.user-avatar--md { width: 40px; height: 40px; font-size: .8rem; border-radius: 10px; }
.user-avatar--lg { width: 64px; height: 64px; font-size: 1.4rem;
                   font-family: var(--font-sans, sans-serif); font-weight: 700; opacity: 1; }
.user-avatar--xl { width: 128px; height: 128px; font-size: 2.5rem;
                   font-family: var(--font-sans, sans-serif); font-weight: 700; opacity: 1; }

/* Image variant — replaces initials with the selected avatar photo */
.user-avatar--img {
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
  background: var(--surface-alt);
  display: block;
}
.user-avatar--img.user-avatar--xs { border-radius: 5px; border-width: 1px; }
.user-avatar--img.user-avatar--sm { border-radius: 7px; }
.user-avatar--img.user-avatar--md { border-radius: 10px; }
.user-avatar--img.user-avatar--lg { border-radius: 14px; }
.user-avatar--img.user-avatar--xl { border-radius: 22px; border-width: 3px;
                                     box-shadow: 0 6px 28px rgba(0, 0, 0, .6); }

.sidebar-link--admin        { color: var(--primary-glow, #a78bfa); }
.sidebar-link--admin:hover  { background: rgba(167,139,250,.1); border-left-color: var(--primary-glow, #a78bfa); }

.sidebar-link-muted         { color: var(--text-muted); }
.sidebar-link-muted:hover   { color: var(--text-dim); }

/* Close button (mobile only) */
.sidebar-close {
  display: none;
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  padding: .6rem .85rem .3rem;
  cursor: pointer;
}
.sidebar-close:hover { color: var(--text); }

/* ── Page body (right of sidebar) ────────────────────────────── */
.page-body {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.main-footer {
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-pixel);
  font-size: .5rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: .85rem;
  align-items: center;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-nav a {
  font-family: var(--font-pixel);
  font-size: .48rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: .04em;
  transition: color .12s;
}

.footer-nav a:hover { color: var(--primary-glow); }

.footer-legal { letter-spacing: .04em; }

.footer-credit {
  font-family: var(--font-body);
  font-size: .72rem;
  color: var(--text-muted);
  opacity: .6;
}

.footer-credit a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-credit a:hover { color: var(--accent); }

/* ── Mobile topbar ────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
}

.sidebar-hamburger {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .5rem .65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.sidebar-hamburger:hover {
  background: var(--surface-alt);
  border-color: var(--primary-glow);
}

.mobile-brand {
  font-family: var(--font-pixel);
  font-size: .7rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .04em;
  white-space: nowrap;
}
.mobile-brand .accent { color: var(--primary-glow); }

/* ── Sidebar overlay (mobile backdrop) ───────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 149;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── Section header ─────────────────────────────────────────── */
.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-header--left {
  text-align: left;
  margin-bottom: 1.75rem;
}

.section-title {
  font-family: var(--font-pixel);
  font-size: 1rem;
  color: var(--text);
  margin-bottom: .75rem;
  text-shadow: 0 0 20px var(--primary);
}

.section-subtitle {
  color: var(--text-dim);
  font-size: .85rem;
}

/* ── Console grid ───────────────────────────────────────────── */
.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.console-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.console-card.enabled:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 0 24px rgba(124,58,237,.35);
}

.console-card.disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.console-card .card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 90px;
  margin-bottom: 1.1rem;
}

.console-card .card-icon img {
  max-width: 100%;
  max-height: 90px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
  transition: filter .15s ease;
}

.console-card.enabled:hover .card-icon img {
  filter: drop-shadow(0 0 12px var(--primary-glow));
}

.console-card .card-icon span {
  font-size: 2.5rem;
  line-height: 1;
}

.console-card .card-name {
  font-family: var(--font-pixel);
  font-size: .6rem;
  color: var(--text);
  margin-bottom: .5rem;
  line-height: 1.6;
}

.console-card .card-desc {
  font-size: .75rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.badge {
  position: absolute;
  top: .6rem;
  right: .6rem;
  font-family: var(--font-pixel);
  font-size: .4rem;
  padding: .25rem .4rem;
  border-radius: 3px;
  background: var(--accent);
  color: #000;
  letter-spacing: .05em;
}

.badge.locked {
  background: var(--text-muted);
  color: var(--bg);
}

.badge.badge--online {
  top: auto;
  bottom: .6rem;
}

/* ── Game list ──────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-pixel);
  font-size: .55rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  text-decoration: none;
  transition: color .15s;
}

.back-link:hover { color: var(--accent); }

/* ── Game search bar ─────────────────────────────────────── */
.game-search-wrapper {
  margin-bottom: 1.5rem;
}

.game-search-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .85rem;
  padding: .6rem .9rem .6rem 2.2rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: .7rem center;
}

.game-search-input::placeholder { color: var(--text-muted); }

.game-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,.18);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c3aed' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
}

.game-search-input::-webkit-search-cancel-button {
  appearance: none;
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
}

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

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.game-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(124,58,237,.3);
}

/* ── Game card with cover art ───────────────────────────────── */
.game-card.has-cover {
  background-color: var(--surface);
  background-image:
    linear-gradient(
      to bottom,
      rgba(10,10,15,.82) 0%,
      rgba(10,10,15,.52) 45%,
      rgba(10,10,15,.78) 100%
    ),
    var(--cover-img);
  background-size: auto, cover;
  background-position: 0 0, center;
  background-repeat: no-repeat, no-repeat;
  transition: transform .12s ease, border-color .12s ease,
              box-shadow .12s ease, background-image .2s ease;
}

.game-card.has-cover:hover {
  background-image:
    linear-gradient(
      to bottom,
      rgba(10,10,15,.65) 0%,
      rgba(10,10,15,.35) 45%,
      rgba(10,10,15,.62) 100%
    ),
    var(--cover-img);
}

.game-card.has-cover .game-title { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.game-card.has-cover .game-meta  { color: rgba(255,255,255,.65); }

.game-card .game-title {
  font-family: var(--font-pixel);
  font-size: .55rem;
  line-height: 1.6;
  color: var(--text);
}

.game-card .game-meta {
  font-size: .72rem;
  color: var(--text-muted);
}

.game-card .play-hint {
  font-size: .7rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity .12s;
}

.game-card:hover .play-hint { opacity: 1; }

/* Loading / empty states */
.state-message {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
}

.state-message .icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.state-message p {
  font-family: var(--font-pixel);
  font-size: .6rem;
  line-height: 1.8;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .75rem 0;
}

.pagination-hidden { display: none; }

.pg-btn {
  font-family: var(--font-pixel);
  font-size: .44rem;
  line-height: 1;
  padding: .5rem .65rem;
  min-width: 2rem;
  background: var(--surface-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.pg-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-glow);
  box-shadow: 0 0 8px var(--primary-glow);
}

.pg-btn.pg-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-glow);
  box-shadow: 0 0 10px var(--primary-glow);
  cursor: default;
}

.pg-btn.pg-disabled,
.pg-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.pg-ellipsis {
  font-family: var(--font-pixel);
  font-size: .44rem;
  color: var(--text-muted);
  padding: .5rem .2rem;
  user-select: none;
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem .75rem;
  margin-bottom: 1rem;
  padding: .65rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  flex: 1 1 auto;
  min-width: 0;
}

.filter-label {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);   /* .44rem */
  color: var(--text-muted);
  letter-spacing: .04em;
  white-space: nowrap;
  margin-right: .2rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-pixel);
  font-size: var(--font-xs);   /* .44rem */
  line-height: 1;
  padding: .5rem .7rem;
  background: var(--surface-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.filter-chip:hover:not(.active) {
  background: var(--surface-alt);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-glow);
  box-shadow: 0 0 8px var(--primary-glow);
}

.filter-chip-flag {
  font-size: 1.1em;
  line-height: 1;
}

.filter-chip-count {
  font-size: .85em;
  opacity: .65;
}

.filter-clear {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);   /* .44rem */
  padding: .5rem .75rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
  flex-shrink: 0;
}

.filter-clear:hover {
  color: var(--warn);
  border-color: var(--warn);
}

/* Inline clear inside empty-state */
.filter-clear-inline {
  display: block;
  margin: 1rem auto 0;
  font-size: var(--font-sm);   /* .55rem */
  padding: .6rem 1rem;
}

/* Result count */
.result-count {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);   /* .44rem */
  color: var(--text-muted);
  margin-bottom: .75rem;
  letter-spacing: .03em;
}

/* Mobile: chips scroll horizontally, don't wrap */
@media (max-width: 540px) {
  .filter-bar { padding: .5rem .6rem; gap: .5rem; }
  .filter-section { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .filter-chips { flex-wrap: nowrap; }
}

/* ── Collapsible genre filter ───────────────────────────────── */
.filter-section--genre {
  flex: 0 0 100%;          /* own row inside the filter bar */
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  margin-top: .1rem;
}

.genre-toggle-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  width: 100%;
}

.genre-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  padding: .45rem .7rem;
  background: var(--surface-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  flex-shrink: 0;
}
.genre-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.genre-toggle-btn.has-active {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.genre-toggle-label {
  color: var(--text-muted);
  letter-spacing: .04em;
}

.genre-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.3em;
  height: 1.3em;
  padding: 0 .3em;
  background: var(--primary);
  color: #fff;
  border-radius: 99px;
  font-size: .85em;
  line-height: 1;
}

.genre-arrow {
  font-size: .75em;
  display: inline-block;
  transition: transform .25s ease;
}
.genre-toggle-btn.expanded .genre-arrow { transform: rotate(180deg); }

/* Active genre pills — shown beside the toggle when panel is closed */
.genre-active-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.filter-section--genre.expanded .genre-active-pills { display: none; }

.genre-active-pill {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-family: var(--font-pixel);
  font-size: calc(var(--font-xs) * .85);
  padding: .28rem .5rem;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-glow);
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: 0 0 6px rgba(168, 85, 247, .25);
}
.genre-active-pill:hover {
  background: #dc2626;
  border-color: #ef4444;
  box-shadow: none;
}
.genre-pill-remove {
  font-size: 1.1em;
  line-height: 1;
  opacity: .8;
  font-family: monospace;
}

/* Expandable genre panel */
.genre-panel {
  width: 100%;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height .3s ease, opacity .2s ease, padding-top .3s ease;
  padding-top: 0;
}
.genre-panel.open {
  max-height: 28rem;
  opacity: 1;
  pointer-events: auto;
  padding-top: .5rem;
}

@media (max-width: 540px) {
  .filter-section--genre { padding-top: .45rem; }
  .genre-panel.open { max-height: 20rem; overflow-y: auto; }
}

/* ── Cover thumbnails (user area tables & cards) ────────────── */
.cover-thumb {
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* sm — compact table rows */
.cover-thumb--sm {
  width: 44px;
  height: 58px;
}

/* lg — featured area (unused currently, available for future use) */
.cover-thumb--lg {
  width: 90px;
  height: 120px;
}

/* Fallback — dashed placeholder shown after onerror fires */
.cover-thumb--empty {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-alt) 0px,
    var(--surface-alt) 4px,
    var(--border)      4px,
    var(--border)      5px
  );
}

/* Table column sizing */
.th-cover,
.td-cover {
  width: 50px;
  padding-right: .25rem !important;
}

/* Game title cell — wraps by word, max 2 lines */
.td-game-title {
  white-space: normal;
  max-width: 280px;
  min-width: 130px;
}

.td-game-title-inner {
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.5;
}

.td-cover {
  padding-top: .35rem !important;
  padding-bottom: .35rem !important;
  vertical-align: middle;
}

/* Stat card with cover background */
.stat-card.has-cover {
  background-image:
    linear-gradient(to bottom, rgba(10,10,15,.55) 0%, rgba(10,10,15,.82) 100%),
    var(--cover-img);
  background-size: cover;
  background-position: center;
  border-color: var(--primary);
}

/* Game name readable over the cover */
.stat-card.has-cover .stat-value {
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.85);
}

/* "MOST PLAYED" label — frosted pill so it reads cleanly over any cover art */
.stat-card.has-cover .stat-label {
  display: inline-block;
  background: rgba(10,10,15,.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,.78);
  padding: .22em .55em;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.1);
  letter-spacing: .12em;
  margin-top: .2rem;
}

/* Saves page: space between cover and text */
.cs-game-header-text {
  flex: 1 1 auto;
  min-width: 0;
}

.cs-game-header .cover-thumb {
  margin-right: .75rem;
}

/* Mobile adjustments */
@media (max-width: 540px) {
  .cover-thumb--sm { width: 36px; height: 48px; }
  .cover-thumb--lg { width: 72px; height: 96px; }
  .th-cover, .td-cover { width: 42px; }
}

/* ── Continue Playing section ───────────────────────────────── */
.cp-section {
  margin-top: 2.5rem;
  margin-bottom: .5rem;
}

.cp-track {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.cp-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex: 1 1 200px;
  max-width: 280px;
  padding: .6rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .12s;
}

.cp-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.cp-card-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cp-card-title {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Popular Games section ──────────────────────────────────── */
.pop-section {
  margin-top: 3rem;
}

.pop-console-block {
  margin-bottom: 2.25rem;
}

.pop-console-hdr {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .85rem;
}

.pop-console-badge {
  flex-shrink: 0;
  font-size: var(--font-sm);
  padding: .25rem .55rem;
}

.pop-console-title {
  font-family: var(--font-pixel);
  font-size: var(--font-md);
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
}

.pop-view-all {
  font-family: var(--font-pixel);
  font-size: var(--font-sm);
  color: var(--primary-glow);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .12s;
}

.pop-view-all:hover { color: var(--accent); }

/* Horizontal scroll strip */
.pop-track {
  display: flex;
  gap: .75rem;
  overflow-x: auto;
  padding-bottom: .6rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.pop-track::-webkit-scrollbar        { height: 4px; }
.pop-track::-webkit-scrollbar-track  { background: transparent; }
.pop-track::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }

/* Individual popular card */
.pop-card {
  flex: 0 0 128px;
  height: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: .55rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}

.pop-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(124,58,237,.35);
  color: inherit;
}

.pop-card.has-cover {
  background-color: var(--surface);
  background-image:
    linear-gradient(to bottom,
      rgba(10,10,15,.25) 0%,
      rgba(10,10,15,.55) 55%,
      rgba(10,10,15,.93) 100%),
    var(--cover-img);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

.pop-card.has-cover:hover {
  background-image:
    linear-gradient(to bottom,
      rgba(10,10,15,.10) 0%,
      rgba(10,10,15,.40) 55%,
      rgba(10,10,15,.88) 100%),
    var(--cover-img);
}

/* Pop-cards más grandes en desktop */
@media (min-width: 1025px) {
  .pop-card { flex: 0 0 150px; height: 200px; }
}

/* Rank badge — top-left corner */
.pop-rank {
  position: absolute;
  top: .35rem;
  left: .35rem;
  font-family: var(--font-pixel);
  font-size: .38rem;
  line-height: 1.2;
  padding: .2rem .38rem;
  background: var(--primary);
  color: #fff;
  border-radius: 3px;
  letter-spacing: .02em;
}

/* Game title at the bottom */
.pop-title {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: #fff;
  text-shadow: 0 1px 5px rgba(0,0,0,.95);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Fallback title color without cover */
.pop-card:not(.has-cover) .pop-title {
  color: var(--text);
  text-shadow: none;
}

/* Responsive: slightly smaller cards on very narrow screens */
@media (max-width: 400px) {
  .pop-card { flex: 0 0 110px; height: 148px; }
}

/* ── Game page ──────────────────────────────────────────────── */
body.game-page {
  height: 100vh;
  overflow: hidden;
}

/* When the guest controls panel is visible the layout becomes taller than 100vh.
   The sidebar is position:fixed so making the shell scrollable is safe. */
body.game-page.has-guest-controls {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
}
body.game-page.has-guest-controls .game-shell {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
}
body.game-page.has-guest-controls .game-content {
  overflow-y: visible;
  align-items: flex-start;  /* content starts at top, then scrolls */
}
/* Shrink the stream slightly so stream + controls fits near the viewport */
body.game-page.has-guest-controls #ejs-player {
  max-height: calc(100vh - 280px);
}
@media (max-width: 767px) {
  body.game-page.has-guest-controls #ejs-player {
    max-height: calc(100vh - var(--mobile-topbar-h) - 300px);
  }
}

/* Wrapper right of sidebar — holds mobile topbar + emulator */
.game-shell {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Context breadcrumb bar (desktop game page) */
.game-context-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.game-context-back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s;
}

.game-context-back:hover { color: var(--accent); }

.game-context-sep {
  color: var(--border);
  font-size: var(--font-xs);
  flex-shrink: 0;
}

.game-context-title {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Netplay status badge in context bar */
.netplay-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: #10b981;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Timer inside the netplay badge */
.np-badge-timer {
  color: var(--text-muted);
  cursor: help;
  font-variant-numeric: tabular-nums;
}
.np-badge-timer--low { color: #f87171; font-weight: 600; }
.np-badge-sep { color: var(--border); }

/* Fixed-position tooltip for the timer (escapes overflow:hidden parents) */
.np-timer-tip {
  position: fixed;
  z-index: 9000;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .78rem;
  line-height: 1.4;
  max-width: 240px;
  pointer-events: none;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.netplay-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: netplay-pulse 1.6s ease-in-out infinite;
}

@keyframes netplay-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* Game title in mobile topbar */
.game-title-mobile {
  font-family: var(--font-pixel);
  font-size: .52rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Game title label in sidebar — tied visually to NOW PLAYING cyan */
.sidebar-game-label {
  font-family: var(--font-pixel);
  font-size: .57rem;
  color: #22d3ee;
  padding: .3rem .9rem .65rem 1rem;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  border-left: 2px solid rgba(34,211,238,.22);
  margin: 0 .5rem 0 .85rem;
  padding-left: .6rem;
}

/* Fav button — smooth transition; distinct inactive vs active feel */
.sidebar-link.fav-btn {
  transition: color .22s ease, background .22s ease, border-left-color .22s ease;
}
.sidebar-link.fav-btn:not(.fav-active)              { color: var(--text-muted); }
.sidebar-link.fav-btn:not(.fav-active):hover        { color: var(--warn); background: rgba(245,158,11,.07); border-left-color: rgba(245,158,11,.35); }
.sidebar-link.fav-btn:not(.fav-active) .sidebar-icon { opacity: .6; transition: opacity .22s ease; }
.sidebar-link.fav-btn:not(.fav-active):hover .sidebar-icon { opacity: 1; }

.sidebar-link.fav-active        { color: var(--warn); border-left-color: var(--warn); }
.sidebar-link.fav-active:hover  { background: rgba(245,158,11,.1); }

/* Top bar buttons */
.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .95rem;
  min-height: 36px;
  font-family: var(--font-pixel);
  font-size: .55rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
  line-height: 1;
}

.tb-btn:hover {
  background: var(--primary);
  border-color: var(--primary-glow);
  box-shadow: 0 0 10px rgba(124,58,237,.4);
}

.tb-btn.accent-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.tb-btn.accent-btn:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 10px rgba(16,185,129,.4);
}

.tb-btn-sm {
  font-size: var(--font-sm);
  padding: .35rem .7rem;
}

/* Game content area */
.game-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: .5rem;
  background: #000;
}

/* EmulatorJS container */
.ejs-wrapper {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
}

#ejs-player {
  position: relative;   /* anchor for absolutely-positioned netplay overlays */
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: calc(100vh - 1rem);
  background: #000;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 0 40px rgba(124,58,237,.3);
  transform: scale(.95);
  transition: transform .2s;
}

.modal-overlay.open .modal { transform: scale(1); }

.modal h2 {
  font-family: var(--font-pixel);
  font-size: .75rem;
  color: var(--primary-glow);
  margin-bottom: 1.5rem;
  text-align: center;
}

.modal .close-btn {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  margin-top: -.25rem;
}

.modal .close-btn:hover { color: var(--text); }

/* Key mapping table */
.key-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}

.key-table th {
  font-family: var(--font-pixel);
  font-size: .45rem;
  color: var(--text-muted);
  text-align: left;
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
}

.key-table td {
  padding: .45rem .5rem;
  border-bottom: 1px solid rgba(45,45,94,.5);
  color: var(--text-dim);
}

.key-table td:first-child {
  color: var(--text);
}

kbd {
  display: inline-block;
  padding: .15rem .4rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: .75rem;
  color: var(--accent);
}

/* ── Buttons (generic) ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  font-family: var(--font-pixel);
  font-size: .55rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  border: none;
  line-height: 1.5;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 14px rgba(124,58,237,.35);
}

.btn-primary:hover {
  box-shadow: 0 0 24px rgba(124,58,237,.6);
}

/* ── Responsive — sidebar collapses to icon-rail (768–1024px) ── */
@media (min-width: 768px) and (max-width: 1024px) {
  :root { --sidebar-w: 58px; }

  .sidebar-logo-link { display: none; }

  .sidebar-nav { padding-top: .6rem; }

  .sidebar-label,
  .sidebar-section-label,
  .sidebar-game-label { display: none; }

  .sidebar-divider { margin: .3rem .5rem; }
  .sidebar-divider--subtle { display: none; }

  .sidebar-link {
    padding: .7rem 0;
    justify-content: center;
    gap: 0;
    border-left-width: 2px;
  }

  .sidebar-footer { padding: .3rem 0; }

  /* Hide About buttons (text-only, no icon) */
  .sidebar-link-muted { display: none; }
}

/* ── Responsive — sidebar collapses to drawer on mobile ──────── */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: min(var(--sidebar-w), 82vw);
    z-index: 151;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.65);
  }
  .sidebar-close {
    display: flex;
  }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 0 1.1rem;
    height: var(--mobile-topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
  }
  .page-body  { margin-left: 0; }
  .game-shell { margin-left: 0; }
  .game-context-bar { display: none; }
  body.sidebar-open { overflow: hidden; }
  #ejs-player { max-height: calc(100vh - var(--mobile-topbar-h) - 1rem); }

  /* Content tweaks */
  .section-title { font-size: .7rem; }
  .console-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-grid { grid-template-columns: 1fr; }
  .main-content { padding: 1.25rem 1rem; }
  .game-topbar { gap: .5rem; }
  .tb-btn { padding: .55rem .85rem; font-size: var(--font-sm); min-height: 44px; }
  .tb-btn-sm { font-size: var(--font-xs); padding: .55rem .7rem; min-height: 44px; }
  .filter-chip { min-height: 44px; padding: .6rem .9rem; }
  .pg-btn { min-height: 44px; min-width: 44px; }
  .btn { min-height: 44px; }
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select { min-height: 44px; }
  #ejs-player { aspect-ratio: 3 / 2; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .history-table th, .history-table td { font-size: .65rem; padding: .4rem .5rem; }
  .profile-row { grid-template-columns: 1fr; }
  .profile-card { padding: 1.5rem 1.25rem; }
}

/* ═══════════════════════════════════════════════════════════════
   Auth pages
   ═══════════════════════════════════════════════════════════════ */

.auth-container {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 30px rgba(124,58,237,.12);
}

.auth-title {
  font-family: var(--font-pixel);
  font-size: .75rem;
  color: var(--primary-glow);
  text-align: center;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 16px var(--primary);
}

.auth-subtitle {
  font-size: .78rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: -.75rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.form-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: .4rem;
}

.form-label-row .form-label { margin-bottom: 0; }

.form-label-link {
  font-size: .72rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}

.form-label-link:hover { color: var(--primary-glow); }

.auth-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .75rem;
  color: var(--text-dim);
}

.auth-sep { margin: 0 .5rem; color: var(--text-muted); }

.auth-note {
  margin-top: 1rem;
  font-size: .68rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: var(--text-muted);
  letter-spacing: .05em;
  margin-bottom: .45rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: .55rem .75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .85rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124,58,237,.25);
}

.pw-strength {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .7rem;
  list-style: none;
  padding: 0;
  margin-top: .45rem;
}

.pw-req {
  font-size: var(--font-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: color .18s;
}

.pw-req::before {
  content: '○';
  font-size: .8em;
}

.pw-req.met {
  color: var(--accent);
}

.pw-req.met::before {
  content: '✓';
}

.pw-match {
  font-size: var(--font-xs);
  margin-top: .4rem;
  transition: color .18s;
}

.pw-match--ok  { color: var(--accent); }
.pw-match--err { color: #f87171; }

.form-hint {
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: .35rem;
  line-height: 1.5;
}

/* ── Generic buttons (full-width variant) ───────────────────── */
.btn-full { width: 100%; justify-content: center; margin-top: .25rem; }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-dim);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .65rem .9rem;
  border-radius: var(--radius);
  font-size: .75rem;
  line-height: 1.5;
  margin-bottom: 1.1rem;
  border-width: 1px;
  border-style: solid;
}

.alert-error {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.35);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16,185,129,.1);
  border-color: rgba(16,185,129,.35);
  color: #6ee7b7;
}

/* ── Verify-pending inline box ──────────────────────────────── */
.verify-pending-box {
  background: var(--surface-alt);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .78rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

/* Icon in tb-btn buttons (game page topbar) — 25% larger than button font-size */
.bi {
  font-size: 1.25em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Dashboard
   ═══════════════════════════════════════════════════════════════ */

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color .15s;
}

.stat-card:hover { border-color: var(--primary); }

.stat-value {
  font-family: var(--font-pixel);
  font-size: .9rem;
  color: var(--primary-glow);
  margin-bottom: .5rem;
  text-shadow: 0 0 12px var(--primary);
  word-break: break-word;
  line-height: 1.5;
}

.stat-label {
  font-family: var(--font-pixel);
  font-size: .38rem;
  color: var(--text-muted);
  letter-spacing: .05em;
}

.dash-section { margin-bottom: 2.5rem; }

.dash-section-title {
  font-family: var(--font-pixel);
  font-size: .6rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: .05em;
}

/* ── History table ──────────────────────────────────────────── */
.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.history-table-wrap::-webkit-scrollbar        { height: 4px; }
.history-table-wrap::-webkit-scrollbar-track  { background: var(--surface); }
.history-table-wrap::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }
.history-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--primary-glow); }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .75rem;
}

.history-table th {
  font-family: var(--font-pixel);
  font-size: .56rem;
  color: var(--text-muted);
  text-align: left;
  padding: .6rem .75rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  letter-spacing: .04em;
  white-space: nowrap;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
}

.th-sortable:hover { color: var(--text); }

.sort-icon {
  opacity: .45;
  font-size: .6em;
  margin-left: .2em;
}

.th-sortable[data-sort-dir="asc"] .sort-icon,
.th-sortable[data-sort-dir="desc"] .sort-icon {
  opacity: 1;
  color: var(--accent);
}

.history-table td {
  padding: .55rem .75rem;
  border-bottom: 1px solid rgba(45,45,94,.4);
  color: var(--text-dim);
  white-space: nowrap;
}

.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface-alt); }

/* ── Console badge ──────────────────────────────────────────── */
.console-badge {
  display: inline-block;
  padding: .15rem .4rem;
  font-family: var(--font-pixel);
  font-size: .46rem;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--primary-glow);
  letter-spacing: .04em;
}

/* ── Verified / unverified badge ────────────────────────────── */
.verified-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: .42rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: .1rem .35rem;
  margin-left: .4rem;
}

.unverified-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: .42rem;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 3px;
  padding: .1rem .35rem;
  margin-left: .4rem;
}

/* ── Empty state (dashboard) ────────────────────────────────── */
.state-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.state-empty span {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .75rem;
  opacity: .4;
}

.state-empty p {
  font-family: var(--font-pixel);
  font-size: .55rem;
  line-height: 1.8;
}

/* ── Favorite star button (game list) ───────────────────────── */
.fav-star {
  position: absolute;
  top: .55rem;
  right: .55rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color .12s, transform .12s;
  padding: .1rem .25rem;
  line-height: 1;
  z-index: 1;
}

.fav-star:hover,
.fav-star.active { color: var(--warn); transform: scale(1.25); }

/* Ensure game-card has relative positioning for the star */
.game-card { position: relative; }

/* ── Favorite button (game page topbar) ─────────────────────── */
.tb-btn.fav-btn.fav-active {
  border-color: var(--warn);
  color: var(--warn);
}

.tb-btn.fav-btn.fav-active:hover {
  background: rgba(245,158,11,.15);
  box-shadow: 0 0 10px rgba(245,158,11,.35);
}

/* ── Login hint on console page ─────────────────────────────── */
.login-hint {
  margin-top: 2rem;
  text-align: center;
  font-size: .72rem;
  color: var(--text-muted);
  padding: .75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════════════════════════════
   Profile page
   ═══════════════════════════════════════════════════════════════ */

.profile-wrap {
  display: flex;
  justify-content: center;
  padding: .5rem 1rem 2rem;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 0 30px rgba(124,58,237,.12);
}

.profile-card--wide {
  max-width: 860px;
  padding: 0;
  overflow: hidden;
}

.profile-section {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.profile-section-last {
  border-bottom: none;
  margin-bottom: 1.25rem;
}

.profile-section-title {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: var(--text-muted);
  letter-spacing: .05em;
  margin-bottom: 1rem;
}

.profile-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.form-textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.6;
}

/* ── Profile read-only view ─────────────────────────────────── */
.profile-view-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem 1.5rem;
}

.profile-field-label {
  font-family: var(--font-pixel);
  font-size: var(--font-xs);
  color: var(--text-muted);
  letter-spacing: .05em;
  margin-bottom: .45rem;
}

.profile-field-value {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.profile-edit-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* ── Profile edit layout ───────────────────────────────────── */
.profile-edit-hd {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.profile-edit-section {
  padding: 1.75rem 2rem;
  border-bottom: 1px solid var(--border);
}

.profile-edit-alert {
  padding: 1rem 2rem 0;
}

.profile-edit-footer {
  padding: 1.25rem 2rem 1.75rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .profile-body { grid-template-columns: 1fr; }
  .profile-col + .profile-col { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 600px) {
  .profile-hero { padding: 1.25rem; }
  .profile-col  { padding: 1.25rem; }
  .profile-edit-hd { padding: 1.25rem; }
  .profile-edit-section { padding: 1.25rem; }
  .profile-edit-footer { padding: 1rem 1.25rem 1.5rem; }
  .profile-view-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   Storage meter — /me/saves + /me/save-states
   ═══════════════════════════════════════════════════════════════ */

.stg-meter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  transition: border-color .25s;
}
.stg-meter--warn     { border-color: rgba(245,158,11,.45); }
.stg-meter--critical { border-color: rgba(239,68,68,.45); }

.stg-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .55rem;
}

.stg-meter-title {
  font-family: var(--font-pixel);
  font-size: .45rem;
  letter-spacing: .12em;
  color: var(--text-muted);
}

.stg-meter-pct {
  font-family: var(--font-pixel);
  font-size: .6rem;
  color: var(--text-dim);
  transition: color .25s;
}
.stg-meter-pct--warn     { color: var(--warn); }
.stg-meter-pct--critical { color: #ef4444; }

/* Progress bar */
.stg-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .7rem;
}

/* Color is set inline by the macro/JS based on usage percentage.
   Green < 75%, orange 75-89%, red >= 90%. */
.stg-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
  transition: width .6s ease, background-color .5s ease;
  min-width: 0;
}

.stg-meter-stats {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .65rem;
  color: var(--text-dim);
  margin-bottom: .5rem;
  gap: .5rem;
  flex-wrap: wrap;
}

.stg-meter-of {
  color: var(--text-muted);
  margin: 0 .2em;
}

.stg-meter-free { color: var(--text-muted); }

.stg-meter-msg {
  font-size: .6rem;
  margin: 0;
  color: var(--text-muted);
}
.stg-meter-msg--warn     { color: var(--warn); }
.stg-meter-msg--critical { color: #fca5a5; }

/* ═══════════════════════════════════════════════════════════════
   Cloud Saves — modal (game page) + management page (/me/saves)
   ═══════════════════════════════════════════════════════════════ */

/* ── Wider modal variant for cloud saves ─────────────────────── */
.cs-modal-inner {
  max-width: 560px;
  padding: 1.5rem 1.75rem 1.75rem;
}

.cs-modal-inner h2 {
  margin-bottom: .6rem;
}

.cs-game-label {
  font-size: .84rem;
  color: var(--text-dim);
  margin-bottom: .75rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Status bar ──────────────────────────────────────────────── */
.cs-status-bar {
  font-family: var(--font-pixel);
  font-size: .50rem;
  min-height: 1.4rem;
  margin-bottom: .85rem;
  padding: .3rem .5rem;
  border-radius: 3px;
  transition: background .15s, color .15s;
}

.cs-status-bar:empty { display: none; }

.cs-syncing {
  color: var(--warn);
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.3);
}

.cs-saved {
  color: var(--accent);
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.3);
}

.cs-error {
  color: #fca5a5;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
}

/* Animated spinner shown before syncing status text (SRAM modal + slot feedback) */
.cs-status-bar.cs-syncing::before,
.ss-slot-fb--syncing::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid rgba(245,158,11,.25);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .45em;
}

/* ── Upload row ──────────────────────────────────────────────── */
.cs-upload-row {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.cs-upload-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: .5rem;
}

.cs-upload-hint {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

/* ── Saves list header ───────────────────────────────────────── */
.cs-list-header {
  font-family: var(--font-pixel);
  font-size: .48rem;
  color: var(--text-muted);
  letter-spacing: .07em;
  margin-bottom: .65rem;
}

/* ── Loading / empty states ──────────────────────────────────── */
.cs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  font-size: .86rem;
  color: var(--text-muted);
  padding: 1rem 0;
}

.cs-empty {
  text-align: center;
  font-size: .84rem;
  color: var(--text-muted);
  padding: 1rem 0;
  line-height: 1.8;
}

/* ── Individual save item (in modal) ─────────────────────────── */
.cs-save-list { display: flex; flex-direction: column; gap: .55rem; }

.cs-save-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .85rem;
  transition: border-color .12s;
}

.cs-save-item:hover { border-color: var(--primary); }

.cs-save-item-info { flex: 1; min-width: 0; }

.cs-save-item-title {
  font-family: var(--font-pixel);
  font-size: .53rem;
  color: var(--text);
  margin-bottom: .25rem;
  line-height: 1.5;
}

.cs-save-item-meta {
  font-size: .82rem;
  color: var(--text-muted);
}

.cs-save-item-actions {
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
}

/* ── Detail box (shown below status bar on failure) ─────────── */
.cs-detail-box {
  background: rgba(0,0,0,.35);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .5rem .7rem;
  margin-bottom: .85rem;
  max-height: 130px;
  overflow-y: auto;
}

.cs-detail-line {
  font-family: var(--font-body);
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Footer hint ─────────────────────────────────────────────── */
.cs-footer-hint {
  margin-top: 1rem;
  text-align: right;
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .3rem;
  flex-wrap: wrap;
}

.cs-footer-hint a { color: var(--text-dim); }
.cs-footer-hint a:hover { color: var(--accent); }

.cs-diag-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .78rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cs-diag-link:hover { color: var(--accent); }

/* ── Cloud Saves auto-sync indicator (cloud icon colour on topbar button) ─ */
#cs-cloud-icon {
  transition: color .35s;
}

#btn-cloud.cs-sync-syncing #cs-cloud-icon {
  color: var(--warn);
  animation: cs-sync-pulse .9s ease-in-out infinite;
}

#btn-cloud.cs-sync-synced #cs-cloud-icon { color: var(--accent); }
#btn-cloud.cs-sync-error  #cs-cloud-icon { color: #f87171; }

@keyframes cs-sync-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* ── Auto-sync note (inside Cloud Saves modal) ───────────── */
.cs-autosync-note {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
  padding: .45rem .7rem;
  border-left: 2px solid var(--primary);
  border-radius: 0 3px 3px 0;
  background: rgba(124,58,237,.06);
}

/* ── Restore confirm modal ───────────────────────────────── */
.cs-confirm-overlay { z-index: 201; }  /* sits on top of the cloud saves modal */

.cs-confirm-body {
  font-size: .78rem;
  color: var(--text-dim);
  line-height: 1.75;
  margin-bottom: 1.5rem;
}

.cs-confirm-body p { margin-bottom: .4rem; }
.cs-confirm-body p:last-child { margin-bottom: 0; }

.cs-confirm-warn {
  color: var(--warn);
  font-size: .73rem;
}

.cs-confirm-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  align-items: center;
}

/* ── Global NE.confirm / NE.alert modal ──────────────────────── */
.ne-confirm-inner {
  max-width: 400px;
  width: 100%;
}

.ne-confirm-title {
  margin-bottom: 1rem;
}

.ne-confirm-body {
  font-size: .76rem;
  color: var(--text-dim);
  line-height: 1.75;
  margin-bottom: 1.75rem;
  white-space: pre-line;
}

.ne-confirm-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  align-items: center;
}

/* Danger variant for the OK button (delete / irreversible actions) */
.ne-btn-danger {
  color: #fca5a5;
  border: 1px solid rgba(252,165,165,.45);
  background: rgba(252,165,165,.07);
  border-radius: var(--radius);
  padding: .45rem 1rem;
  font-family: var(--font-pixel);
  font-size: .55rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ne-btn-danger:hover  { background: rgba(252,165,165,.15); border-color: rgba(252,165,165,.7); }
.ne-btn-danger:focus-visible { outline: 2px solid #fca5a5; outline-offset: 2px; }

/* ── Auto-load / restore toast ───────────────────────────── */
.cs-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem 1.25rem;
  font-size: .86rem;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: min(460px, calc(100vw - 2rem));
  text-align: center;
  z-index: 300;
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

.cs-toast.cs-toast-ok    { border-color: rgba(16,185,129,.4); color: var(--accent); }
.cs-toast.cs-toast-error { border-color: rgba(239,68,68,.35); color: #fca5a5; }
.cs-toast.cs-toast-info  { border-color: rgba(245,158,11,.35); color: var(--warn); }
.cs-toast.cs-toast-show  { opacity: 1; pointer-events: auto; }

/* ── Global toast system (NE.showToast) ──────────────────────── */
#ne-toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  pointer-events: none;
}

.ne-toast {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .8rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left-width: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
  pointer-events: auto;
  max-width: 280px;
  word-break: break-word;
  opacity: 0;
  transform: translateX(.75rem);
  transition: opacity .2s ease, transform .2s ease;
}

.ne-toast.ne-visible      { opacity: 1; transform: translateX(0); }
.ne-toast--success        { border-left-color: var(--accent); }
.ne-toast--error          { border-left-color: #f87171; }
.ne-toast--info           { border-left-color: var(--primary-glow); }

@media (max-width: 767px) {
  #ne-toast-container { right: .75rem; bottom: .75rem; left: .75rem; }
  .ne-toast { max-width: 100%; }
}

/* ── /me/saves management page ───────────────────────────────── */
.cs-game-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .85rem;
  overflow: hidden;
  transition: border-color .12s;
}

.cs-game-group:hover { border-color: var(--primary); }

.cs-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface-alt);
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.cs-game-title {
  font-family: var(--font-pixel);
  font-size: .6rem;
  color: var(--text);
  line-height: 1.5;
}

.cs-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .65rem;
  padding: .85rem 1rem 1rem;
}

/* ── Slot card ───────────────────────────────────────────────── */
.cs-slot-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,.015);
  transition: border-color .18s, transform .18s, box-shadow .18s;
  cursor: default;
}

.cs-slot-card:hover {
  border-color: rgba(124,58,237,.5);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}

/* ── Thumbnail wrapper (hero image) ──────────────────────────── */
.cs-slot-thumb-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: #07070d;
  overflow: hidden;
  flex-shrink: 0;
}

.cs-slot-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease;
}

.cs-slot-card:hover .cs-slot-thumb-wrap img {
  transform: scale(1.04);
}

/* Placeholder when no screenshot exists */
.cs-slot-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  color: rgba(255,255,255,.1);
}

.cs-slot-thumb-placeholder svg {
  width: 32px; height: 32px;
  opacity: .18;
}

/* Slot number badge — overlay on top of image */
.cs-slot-badge {
  position: absolute;
  top: .45rem; left: .45rem;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  padding: .18rem .45rem;
  font-family: var(--font-pixel);
  font-size: .42rem;
  letter-spacing: .1em;
  color: rgba(255,255,255,.7);
  line-height: 1;
}

/* ── Card body ───────────────────────────────────────────────── */
.cs-slot-body {
  padding: .6rem .7rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
}

.cs-slot-date {
  font-size: .72rem;
  color: var(--text);
  font-weight: 500;
}

.cs-slot-size {
  font-size: .62rem;
  color: var(--text-muted);
}

.cs-slot-actions {
  display: flex;
  gap: .3rem;
  margin-top: .55rem;
}

.cs-slot-actions .tb-btn-sm {
  flex: 1;
  justify-content: center;
  padding: .32rem .3rem;
  font-size: .48rem;
}

@media (max-width: 600px) {
  .cs-modal-inner { padding: 1.25rem 1rem 1.5rem; }
  .cs-slots { grid-template-columns: repeat(2, 1fr); gap: .5rem; padding: .65rem .75rem .75rem; }
}

/* ============================================================
   Netplay / Online Multiplayer UI
   ============================================================ */

/* ── Play Online sidebar button ───────────────────────────── */
.np-play-online-btn { color: var(--primary-glow); }
.np-play-online-btn:hover { background: rgba(124,58,237,.15); }

/* Netplay modals must sit above EmulatorJS injected UI elements.
   EJS controls/settings hover above z-index 200 (the generic .modal-overlay),
   so pin these two modals above the EJS layer but below np-confirm (9000). */
#np-modal-main,
#np-modal-lobby { z-index: 8500; }

/* ── Modals ────────────────────────────────────────────────── */
.np-modal {
  max-width: 480px;
  width: 96vw;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.np-modal--lobby { max-width: 540px; }

/* ── Game info strip ───────────────────────────────────────── */
.np-game-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: .75rem;
}
.np-console-badge {
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .05em;
  padding: .15rem .4rem;
  border-radius: 3px;
}
.np-game-title-small {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Form section ──────────────────────────────────────────── */
.np-section { display: flex; flex-direction: column; gap: .45rem; }
.np-login-notice { opacity: .85; }
.np-login-msg { font-size: .75rem; color: var(--text-dim); line-height: 1.5; margin: 0; }
.np-section-title {
  font-size: .7rem;
  letter-spacing: .08em;
  color: var(--primary-glow);
  text-transform: uppercase;
  font-weight: 700;
}
.np-label { font-size: .72rem; color: var(--text-dim); }
.np-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .45rem .7rem;
  font-size: .82rem;
  outline: none;
  transition: border-color .15s;
  width: 100%;
  box-sizing: border-box;
}
.np-input:focus { border-color: var(--primary); }
.np-input--code {
  font-family: var(--font-mono, monospace);
  letter-spacing: .15em;
  text-transform: uppercase;
  font-size: 1rem;
}
.np-btn-full { width: 100%; }
.np-btn-half { flex: 1; text-align: center; }
.np-asm-actions { display: flex; gap: .6rem; margin-top: .25rem; }

/* Active session summary */
.np-asm-meta {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: .65rem .75rem;
  margin: .6rem 0 .8rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.np-asm-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
}
.np-asm-label {
  color: var(--text-muted);
  flex-shrink: 0;
}
.np-asm-value {
  display: flex;
  align-items: center;
  gap: .3rem;
  min-width: 0;
  overflow: hidden;
}
.np-asm-link {
  font-size: .68rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}
.np-asm-players-header {
  font-family: var(--font-pixel);
  font-size: .5rem;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.np-asm-players-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .8rem;
}
.np-asm-player {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 8px;
  padding: .4rem .5rem;
}
.np-asm-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.np-asm-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.np-asm-avatar-initials { font-size: .75rem; font-weight: 700; color: var(--text); }
.np-asm-player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.np-asm-player-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.np-asm-player-status {
  font-size: .62rem;
}
.np-asm-player-slot {
  font-family: var(--font-pixel);
  font-size: .5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.np-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: .72rem;
  padding: .15rem 0;
}
.np-error {
  font-size: .72rem;
  color: var(--danger, #f87171);
  min-height: 1em;
}

/* ── Lobby ─────────────────────────────────────────────────── */
.np-lobby-game {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--text-dim);
}
.np-code-row, .np-invite-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
}
.np-code-label, .np-invite-label { color: var(--text-muted); flex-shrink: 0; }
.np-code-value {
  font-family: var(--font-mono, monospace);
  font-size: 1.1rem;
  letter-spacing: .12em;
  color: var(--primary-glow);
  font-weight: 700;
}
.np-invite-link {
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .72rem;
  max-width: 240px;
}
.np-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  padding: .15rem .3rem;
  border-radius: 3px;
  color: var(--text-dim);
  transition: color .15s, background .15s;
}
.np-copy-btn:hover { color: var(--text); background: var(--surface-2); }

/* ── Status chip ───────────────────────────────────────────── */
.np-status-row { display: flex; align-items: center; }
.np-status-chip {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: .2rem .55rem;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.np-status-chip--ready    { background: rgba(34,197,94,.15); color: #4ade80; border-color: #4ade80; }
.np-status-chip--in_game  { background: rgba(124,58,237,.2); color: var(--primary-glow); border-color: var(--primary); }
.np-status-chip--closed   { background: rgba(239,68,68,.1);  color: #f87171; border-color: #f87171; }

/* ── Players ───────────────────────────────────────────────── */
.np-players {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}
.np-player-slot { flex: 1; }

/* 2×2 grid layout for 3–4 player consoles */
.np-players--grid4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  align-items: unset;
  justify-content: unset;
}
.np-players--grid4 .np-player-slot { flex: unset; }

.np-slot-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .35rem; }
.np-slot-badge {
  display: inline-block;
  font-size: .55rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1rem .3rem;
  margin-bottom: .3rem;
  line-height: 1.4;
}
.np-slot-badge--host { color: var(--primary-glow); border-color: var(--primary); }
.np-vs { color: var(--primary-glow); font-weight: 900; font-size: 1rem; align-self: center; padding: 0 .25rem; }
.np-player-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 48px;
}
.np-player-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-3, #333);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.np-player-avatar--host         { background: var(--primary); color: #fff; }
.np-player-avatar--empty        { background: var(--surface-2); color: var(--text-muted); border: 1px dashed var(--border); }
.np-player-avatar--disconnected { background: var(--surface-2); color: var(--text-muted); opacity: .55; }
.np-player-avatar--img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.np-player-name   { font-size: .75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-player-status { font-size: .65rem; margin-top: .1rem; }
.np-ready                      { color: #4ade80; }
.np-not-ready                  { color: var(--text-muted); }
.np-player-status--disconnected { color: #f59e0b; }
.np-player-status--kicked       { color: #f87171; }
.np-you-badge { font-weight: 400; color: var(--text-muted); font-size: .68rem; display: block; }
.np-text-dim  { color: var(--text-muted); }

/* ── Kick button ───────────────────────────────────────────── */
.np-kick-btn {
  margin-left: auto;
  align-self: center;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: .15rem .45rem;
  font-size: .7rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color .15s, color .15s, background .15s;
}
.np-kick-btn:hover { border-color: #f87171; color: #f87171; background: rgba(248,113,113,.08); }

/* ── Join-request overlay (host approval, fullscreen-safe) ─ */
.np-join-req-overlay {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.55);
  min-width: 220px;
  max-width: 300px;
  animation: np-slide-in .2s ease;
}
@keyframes np-slide-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.np-join-req-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .25rem; }
.np-join-req-avatar { display: flex; justify-content: center; margin-bottom: .5rem; }
.np-join-req-avatar--img {
  width: 52px; height: 52px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--primary);
}
.np-join-req-avatar--initials {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700;
}
.np-join-req-name  { font-size: .95rem; font-weight: 700; color: var(--primary-glow); margin-bottom: .15rem; text-align: center; }
.np-join-req-sub   { font-size: .75rem; color: var(--text-muted); margin-bottom: .75rem; text-align: center; }
.np-join-req-btns  { display: flex; gap: .5rem; }
.np-join-req-approve { flex: 1; font-size: .78rem; padding: .35rem .6rem; }
.np-join-req-reject  { flex: 1; font-size: .78rem; padding: .35rem .6rem; background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, color .15s; }
.np-join-req-reject:hover { border-color: #f87171; color: #f87171; }

/* ── Waiting-for-approval screen ───────────────────────────── */
.np-waiting-screen {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center;
}
.np-waiting-inner { text-align: center; }
.np-waiting-spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--primary-glow);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: np-spin 1s linear infinite;
}
@keyframes np-spin { to { transform: rotate(360deg); } }
.np-waiting-title { font-size: 1.1rem; font-weight: 700; color: var(--primary-glow); margin-bottom: .4rem; }
.np-waiting-sub   { font-size: .85rem; color: var(--text-muted); }

/* ── Kicked screen ─────────────────────────────────────────── */
.np-kicked-screen {
  position: fixed; inset: 0; z-index: 8001;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
}
.np-kicked-inner { text-align: center; }
.np-kicked-icon  { font-size: 3rem; margin-bottom: .6rem; }
.np-kicked-title { font-size: 1.2rem; font-weight: 700; color: #f87171; margin-bottom: .4rem; }
.np-kicked-sub   { font-size: .85rem; color: var(--text-muted); margin-bottom: 1.25rem; }

/* .np-free-timer removed — timer now lives in the top netplay badge */

/* ── Kick confirmation dialog ──────────────────────────────── */
.np-confirm-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
}
.np-confirm-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 300px;
  width: 90%;
  text-align: center;
}
.np-confirm-title { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.np-confirm-msg   { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }
.np-confirm-btns  { display: flex; gap: .6rem; justify-content: center; }
.np-confirm-yes   { font-size: .82rem; padding: .4rem .9rem; background: #dc2626; border-color: #dc2626; }
.np-confirm-yes:hover { background: #b91c1c; border-color: #b91c1c; }
.np-confirm-no    { font-size: .82rem; padding: .4rem .9rem; background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, color .15s; }
.np-confirm-no:hover { border-color: var(--primary); color: var(--primary-glow); }

/* ── Password field label ──────────────────────────────────── */
.np-label--optional { display: flex; align-items: center; gap: .35rem; }
.np-optional-hint   { font-size: .68rem; color: var(--text-muted); font-weight: 400; }

/* ── Lobby actions ─────────────────────────────────────────── */
.np-lobby-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
}
.np-btn-ready {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .5rem 1rem;
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.np-btn-ready:hover { border-color: var(--primary); color: var(--primary-glow); }
.np-btn-ready.np-btn--active { background: rgba(34,197,94,.15); border-color: #4ade80; color: #4ade80; }
.np-btn-start     { flex: 1; }
.np-btn-start:disabled { opacity: .45; cursor: not-allowed; }
.np-btn-join-game { flex: 1; }

/* ── In-game lobby context ─────────────────────────────────── */
.np-lobby-context {
  font-size: .8rem;
  color: var(--primary-glow);
  text-align: center;
  padding: .45rem 0 .15rem;
  font-weight: 500;
}
.np-lobby-context--hidden { display: none; }
.np-player-assign {
  font-size: .72rem;
  color: var(--text-muted);
  text-align: center;
  padding: .1rem 0 .35rem;
}

/* ── Connection status indicators ──────────────────────────── */
.np-conn-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .35rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .75rem;
  font-size: .72rem;
}
.np-conn-item { display: flex; align-items: center; justify-content: space-between; gap: .35rem; }
.np-conn-label { color: var(--text-muted); }
.np-indicator {
  font-size: .68rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 99px;
  background: var(--surface-3, #333);
  color: var(--text-muted);
}
.np-indicator--ok   { background: rgba(34,197,94,.15);  color: #4ade80; }
.np-indicator--warn { background: rgba(234,179,8,.12);  color: #facc15; }
.np-indicator--err  { background: rgba(239,68,68,.12);  color: #f87171; }

/* ── Debug panel ───────────────────────────────────────────── */
.np-debug-panel { border-top: 1px solid var(--border); padding-top: .5rem; }
.np-debug-toggle {
  background: none; border: none; cursor: pointer;
  font-size: .68rem; color: var(--text-muted);
  padding: 0; display: flex; align-items: center; gap: .25rem;
}
.np-debug-toggle:hover { color: var(--text); }
.np-debug-body {
  margin-top: .4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .15rem .75rem;
  font-size: .68rem;
  font-family: var(--font-mono, monospace);
}
.np-debug-key  { color: var(--text-muted); white-space: nowrap; }
.np-debug-val  { color: var(--primary-glow); word-break: break-all; }

/* ── Toast ─────────────────────────────────────────────────── */
.np-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem 1.1rem;
  border-radius: 99px;
  font-size: .78rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  white-space: nowrap;
}
.np-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.np-toast--ok   { border-color: #4ade80; color: #4ade80; }
.np-toast--warn { border-color: #facc15; color: #facc15; }
.np-toast--err  { border-color: #f87171; color: #f87171; }

/* ── Netplay HUD (shown during play) ──────────────────────── */
.np-hud {
  position: fixed;
  bottom: .75rem;
  right: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .25rem .65rem;
  font-size: .68rem;
  font-family: var(--font-mono, monospace);
  z-index: 8000;
}
.np-hud-item { color: var(--text-dim); }
.np-hud-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .8rem; line-height: 1;
  padding: 0 .1rem;
}
.np-hud-close:hover { color: var(--danger, #f87171); }

/* ── In-session player panel ──────────────────────────────── */
/*
  Desktop: absolutely positioned overlay — the panel floats over the left
  edge of the game area without displacing or re-centering the game screen.
  Mobile: reverts to in-flow horizontal strip above the game.
*/
.game-content.has-np-session {
  position: relative;
  padding-left: 160px;
}

#np-session-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 160px;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, .82);
  border-right: 1px solid rgba(255, 255, 255, .08);
  overflow: hidden;
}
.np-sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem .7rem .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
}
.np-sp-title {
  font-family: var(--font-pixel);
  font-size: .55rem;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.np-sp-count {
  font-size: .65rem;
  font-weight: 700;
  color: var(--primary-glow);
}
.np-sp-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem .45rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .12) transparent;
}
.np-sp-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .45rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
  position: relative;
  transition: background .15s;
}
.np-sp-item--disc { opacity: .45; }
.np-sp-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #1e1e3a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.np-sp-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.np-sp-avatar-initials {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  background: var(--primary);
}
.np-sp-info { flex: 1; min-width: 0; }
.np-sp-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.np-sp-status {
  font-size: .6rem;
  margin-top: .15rem;
  line-height: 1;
}
.np-sp-s--host { color: #a78bfa; }
.np-sp-s--ok   { color: #4ade80; }
.np-sp-s--disc { color: #f59e0b; }
.np-sp-kick {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: .62rem;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: opacity .15s, border-color .15s, color .15s, background .15s;
}
.np-sp-item:hover .np-sp-kick,
.np-sp-item:focus-within .np-sp-kick { opacity: 1; border-color: var(--border); }
.np-sp-kick:hover { color: #f87171; border-color: #f87171; background: rgba(248, 113, 113, .1); }
.np-sp-kick:focus-visible { opacity: 1; outline: 2px solid var(--primary); outline-offset: 1px; }

/* Mobile: in-flow horizontal strip above the game */
@media (max-width: 767px) {
  .game-content.has-np-session {
    flex-direction: column;
    align-items: center;
    padding: 0;
  }
  #np-session-panel {
    position: relative;
    top: auto; left: auto; bottom: auto;
    width: 100%;
    max-height: 76px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
  }
  .np-sp-header { display: none; }
  .np-sp-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: .35rem .5rem;
    gap: .4rem;
    align-items: center;
    scrollbar-width: none;
  }
  .np-sp-list::-webkit-scrollbar { display: none; }
  .np-sp-item {
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .3rem .35rem;
    min-width: 52px;
    max-width: 64px;
    border-radius: 7px;
  }
  .np-sp-item--disc { opacity: .35; }
  .np-sp-avatar { width: 36px; height: 36px; border-radius: 7px; }
  .np-sp-avatar-initials { font-size: .95rem; }
  .np-sp-info { text-align: center; min-width: 0; width: 100%; }
  .np-sp-name { font-size: .58rem; }
  .np-sp-status { display: none; }
  .np-sp-kick   { display: none; }
}

@media (max-width: 540px) {
  .np-players:not(.np-players--grid4) { flex-direction: column; }
  .np-players:not(.np-players--grid4) .np-vs { align-self: flex-start; transform: rotate(90deg); }
  .np-conn-status { grid-template-columns: 1fr; }
  .np-invite-link { max-width: 160px; }
}

/* ── Remote video stream (guest view) ──────────────────────── */
/* Both elements are appended inside #ejs-player and overlay it exactly. */
.np-remote-video,
.np-stream-placeholder {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 5;
}

.np-remote-video {
  display: block;
  object-fit: contain;
  background: #000;
}

.np-stream-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: var(--text-muted);
  font-size: .85rem;
  letter-spacing: .05em;
}

/* ── Guest stream overlay toolbar ────────────────────────── */
.np-guest-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.np-guest-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,.06);
  transform: translateY(100%);
  transition: transform .18s ease;
  pointer-events: all;
}
.np-guest-overlay:hover .np-guest-toolbar,
.np-guest-toolbar:focus-within { transform: translateY(0); }
.np-guest-toolbar-title {
  font-size: .58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex: 1;
}
.np-guest-toolbar-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .25rem .6rem;
  font-size: .62rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.np-guest-toolbar-btn:hover { border-color: var(--primary); color: var(--primary-glow); }

/* ── Guest controls mapping panel (modal) ────────────────── */
.np-ctrls-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.np-ctrls-overlay--open {
  opacity: 1;
  pointer-events: all;
}
.np-ctrls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  width: min(520px, 94vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.np-ctrls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.np-ctrls-title {
  font-family: var(--font-pixel);
  font-size: .55rem;
  color: var(--primary-glow);
  letter-spacing: .04em;
}
.np-ctrls-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem; line-height: 1;
  padding: .1rem .3rem;
}
.np-ctrls-close:hover { color: var(--danger, #f87171); }
.np-ctrls-hint {
  padding: .5rem 1rem;
  font-size: .65rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.np-ctrls-body { overflow-y: auto; padding: .75rem 1rem; flex: 1; }
.np-ctrls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
}
.np-ctrls-cell {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .3rem;
  transition: border-color .12s;
  min-height: 38px;
}
.np-ctrls-cell:hover { border-color: var(--primary); }
.np-ctrls-cell--listening {
  border-color: var(--accent);
  background: rgba(16,185,129,.08);
  animation: np-pulse 1s ease infinite;
}
@keyframes np-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50%      { box-shadow: 0 0 0 4px rgba(16,185,129,.0); }
}
.np-ctrls-btn-name {
  font-family: var(--font-pixel);
  font-size: .48rem;
  color: var(--text);
  white-space: nowrap;
}
.np-ctrls-binding {
  font-size: .6rem;
  color: var(--accent);
  background: rgba(16,185,129,.1);
  border: 1px solid rgba(16,185,129,.25);
  border-radius: 3px;
  padding: .05rem .3rem;
  white-space: nowrap;
  min-width: 2rem;
  text-align: center;
}
.np-ctrls-cell--listening .np-ctrls-binding {
  color: var(--accent);
  border-color: var(--accent);
  animation: np-blink .6s step-end infinite;
}
@keyframes np-blink { 50% { opacity: 0; } }
.np-ctrls-footer {
  padding: .65rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.np-ctrls-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: .3rem .75rem;
  font-size: .65rem;
  font-family: var(--font-body);
  cursor: pointer;
}
.np-ctrls-reset:hover { border-color: var(--warn); color: var(--warn); }

/* ── Guest controls panel (below stream) ───────────────────────────────────── */
.np-controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;          /* flush with #ejs-player's bottom border */
  border-radius: 0 0 calc(var(--radius) * 1.5) calc(var(--radius) * 1.5);
  overflow: hidden;
  width: 100%;
}
.np-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1rem;
  background: linear-gradient(135deg, rgba(124,58,237,.08) 0%, rgba(0,0,0,.15) 100%);
  border-bottom: 1px solid var(--border);
}
.np-controls-title-row {
  display: flex;
  align-items: center;
  gap: .45rem;
}
.np-controls-icon {
  font-size: .9rem;
  line-height: 1;
}
.np-controls-title {
  font-family: var(--font-pixel);
  font-size: .5rem;
  color: var(--primary-glow);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.np-controls-header-actions {
  display: flex;
  align-items: center;
  gap: .3rem;
}
.np-ctrl-action-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: .18rem .45rem;
  font-size: .75rem;
  cursor: pointer;
  line-height: 1;
  transition: color .12s, border-color .12s, background .12s;
}
.np-ctrl-action-btn:hover {
  color: var(--primary-glow);
  border-color: var(--primary);
  background: rgba(124,58,237,.1);
}
.np-ctrl-inner {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .28s cubic-bezier(.4,0,.2,1);
}
.np-ctrl-inner--collapsed { max-height: 0 !important; }

.np-gp-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .38rem 1rem;
  font-size: .65rem;
  color: var(--text-dim);
  background: rgba(0,0,0,.18);
  border-bottom: 1px solid var(--border);
}
.np-gp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  flex-shrink: 0;
  transition: background .25s, box-shadow .25s;
}
.np-gp-dot--on {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.np-gp-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-size: .65rem;
}

/* Tabs */
.np-ctrl-tabs {
  display: flex;
  padding: .45rem 1rem .28rem;
  gap: .1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.1);
}
.np-ctrl-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .7rem;
  padding: .28rem .8rem .38rem;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color .12s, border-color .12s;
  letter-spacing: .02em;
}
.np-ctrl-tab:hover { color: var(--text); }
.np-ctrl-tab--active {
  color: var(--primary-glow);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Body + grid */
.np-ctrl-body {
  padding: .7rem 1rem;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.np-ctrl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: .4rem;
}

/* Cards */
.np-ctrl-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .22rem;
  transition: border-color .12s, background .12s, transform .08s, box-shadow .12s;
  min-height: 52px;
  user-select: none;
  position: relative;
}
.np-ctrl-card:hover {
  border-color: var(--primary);
  background: rgba(124,58,237,.07);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124,58,237,.15);
}
.np-ctrl-card:active { transform: translateY(0); box-shadow: none; }
.np-ctrl-card--listening {
  border-color: var(--accent);
  background: rgba(16,185,129,.07);
  animation: np-pulse 1.2s ease infinite;
}
.np-ctrl-card-label {
  font-family: var(--font-pixel);
  font-size: .42rem;
  color: var(--text-dim);
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.np-ctrl-card-binding {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
  margin-top: .06rem;
}
.np-ctrl-chip {
  display: inline-block;
  background: rgba(124,58,237,.13);
  border: 1px solid rgba(124,58,237,.32);
  color: var(--primary-glow);
  border-radius: 3px;
  padding: .1rem .42rem;
  font-size: .68rem;
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: .02em;
  min-width: 1.6rem;
  text-align: center;
}
.np-ctrl-card--listening .np-ctrl-chip {
  background: rgba(16,185,129,.12);
  border-color: rgba(16,185,129,.45);
  color: var(--accent);
  animation: np-blink .6s step-end infinite;
}

/* Footer */
.np-ctrl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1rem .6rem;
  border-top: 1px solid var(--border);
  gap: .5rem;
  flex-wrap: wrap;
  background: rgba(0,0,0,.12);
}
.np-ctrl-presets {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.np-ctrl-presets-label {
  font-size: .62rem;
  color: var(--text-muted);
}
.np-ctrl-preset-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: .22rem .6rem;
  font-size: .63rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.np-ctrl-preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary-glow);
  background: rgba(124,58,237,.08);
}
.np-ctrl-reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: .22rem .65rem;
  font-size: .63rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.np-ctrl-reset-btn:hover { border-color: #f87171; color: #f87171; }

/* Responsive */
@media (max-width: 500px) {
  .np-ctrl-grid { grid-template-columns: repeat(3, 1fr); }
  .np-ctrl-body { max-height: 260px; }
  .np-ctrl-preset-btn { padding: .2rem .45rem; font-size: .6rem; }
}

/* ── Controls panel: section groupings (e.g. N64 D-Pad / Analog / C-Buttons) */
.np-ctrl-section { margin-bottom: .75rem; }
.np-ctrl-section:last-child { margin-bottom: 0; }
.np-ctrl-section-title {
  font-family: var(--font-pixel);
  font-size: .4rem;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .18rem 0 .32rem;
  border-bottom: 1px solid rgba(45,45,94,.5);
  margin-bottom: .35rem;
}

/* ── Volume popover (anchored to trigger in PLAYER CONTROLS header) ─────── */

/* Keep ejs-player relative so the Enable Audio overlay stays positioned */
#ejs-player { position: relative; }

/* Wrapper gives the popover its anchor point */
.np-vol-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Popover — invisible by default, animated in via --open modifier */
.np-vol-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .7rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.55), 0 0 0 1px rgba(124,58,237,.14);
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px) scale(.95);
  transform-origin: top right;
  transition: opacity .14s ease, transform .14s ease;
}
.np-vol-popover--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Upward caret pointing at the trigger button */
.np-vol-popover::after {
  content: '';
  position: absolute;
  top: -6px;
  right: 9px;
  width: 10px;
  height: 6px;
  background: var(--surface-alt);
  clip-path: polygon(50% 0%, 0 100%, 100% 100%);
}

.np-vol-pop-icon {
  font-size: .95rem;
  flex-shrink: 0;
  line-height: 1;
  min-width: 1.2rem;
  text-align: center;
}

.np-vol-pop-slider {
  width: 110px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,.18);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  transition: background .12s;
}
.np-vol-pop-slider:hover { background: rgba(255,255,255,.28); }
.np-vol-pop-slider:focus-visible {
  outline: 2px solid var(--primary-glow);
  outline-offset: 3px;
  border-radius: 2px;
}
.np-vol-pop-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-glow);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(168,85,247,.5);
  transition: transform .1s;
}
.np-vol-pop-slider::-webkit-slider-thumb:hover { transform: scale(1.18); }
.np-vol-pop-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: none;
  cursor: pointer;
}
.np-vol-pop-pct {
  font-family: var(--font-body);
  font-size: .62rem;
  color: var(--text-dim);
  min-width: 2.3rem;
  text-align: right;
  flex-shrink: 0;
}

@media (max-width: 500px) {
  .np-vol-pop-slider { width: 88px; }
  .np-vol-popover    { right: -4px; }
}

/* ── "Enable Audio" button (shown when autoplay policy blocks audio) ──────── */
.np-enable-audio-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(124,58,237,.92);
  color: #e2e8f0;
  border: 2px solid var(--primary-glow);
  border-radius: 8px;
  padding: .65rem 1.4rem;
  font-family: var(--font-body);
  font-size: .9rem;
  cursor: pointer;
  z-index: 20;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.np-enable-audio-btn:hover {
  background: var(--primary-glow);
  border-color: #c084fc;
}


/* ── Avatar picker grid ─────────────────────────────────────────────────────── */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .75rem;
  max-height: 480px;
  overflow-y: auto;
  padding: .6rem .3rem .75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.avatar-picker::-webkit-scrollbar { width: 4px; }
.avatar-picker::-webkit-scrollbar-track { background: transparent; }
.avatar-picker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.avatar-picker-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .6rem .4rem .5rem;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, transform .12s;
  position: relative;
  user-select: none;
}

.avatar-picker-card:hover {
  border-color: rgba(124, 58, 237, .55);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}

.avatar-picker-card--selected,
.avatar-picker-card:has(.avatar-picker-radio:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
  transform: translateY(-2px);
}

.avatar-picker-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.avatar-picker-img {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  background: var(--surface-alt);
}

.avatar-picker-none-thumb {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-family: var(--font-body);
  font-weight: 700;
  border: 2px dashed var(--border);
}

.avatar-picker-label {
  font-size: .58rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  letter-spacing: .02em;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-body);
}

/* Collapsible picker (register form) */
.avatar-picker-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.avatar-picker-summary {
  padding: .6rem .9rem;
  cursor: pointer;
  font-size: .7rem;
  color: var(--text-dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .55rem;
  background: var(--surface);
  transition: background .15s;
}
.avatar-picker-summary:hover { background: var(--surface-alt); }
.avatar-picker-summary::-webkit-details-marker { display: none; }
.avatar-picker-summary::before {
  content: '▸';
  font-size: .75rem;
  color: var(--text-muted);
  transition: transform .15s;
  flex-shrink: 0;
}
details[open] .avatar-picker-summary::before { transform: rotate(90deg); }
.avatar-picker-details .avatar-picker {
  border-top: 1px solid var(--border);
  padding: .6rem .6rem .7rem;
  max-height: 380px;
}

.avatar-picker-preview-sm {
  font-size: .7rem;
  color: var(--text-dim);
}

/* Profile hero (view page) */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.75rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(124,58,237,.1) 0%, transparent 55%);
  flex-wrap: wrap;
}

.profile-hero-info {
  flex: 1;
  min-width: 0;
}

.profile-hero-name {
  font-family: var(--font-pixel);
  font-size: .75rem;
  color: var(--primary-glow);
  margin-bottom: .45rem;
  line-height: 1.5;
  word-break: break-word;
}

.profile-hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem .6rem;
  font-size: .82rem;
  margin-bottom: .4rem;
}

.profile-hero-since {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.profile-hero-since .profile-field-label {
  display: inline;
  margin-bottom: 0;
  margin-right: .3rem;
}

.profile-hero-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  text-decoration: none;
  color: var(--text-muted);
  transition: color .15s;
}

.profile-hero-link:hover { color: var(--text-dim); }

.profile-hero-actions {
  flex-shrink: 0;
  align-self: flex-start;
}

/* Profile body: 2-column layout */
.profile-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.profile-col {
  padding: 1.75rem 2rem;
}

.profile-col + .profile-col {
  border-left: 1px solid var(--border);
}

.profile-body .profile-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar-edit-hint {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  text-decoration: none;
  border: 2px solid var(--bg);
  transition: background .15s, transform .12s;
}
.profile-avatar-edit-hint:hover {
  background: var(--primary-glow);
  color: #fff;
  transform: scale(1.15);
}

/* Preview in profile edit page */
.profile-avatar-preview {
  flex-shrink: 0;
}

/* Dashboard profile button */
.dash-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding-left: .5rem !important;
}

/* ── prefers-reduced-motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ── Navigation leave warning modal ─────────────────────────── */
.nav-warn-inner {
  max-width: 380px;
}
.nav-warn-body {
  font-size: .82rem;
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: .9rem;
}
.nav-warn-dest {
  font-size: .75rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .8rem;
  margin-bottom: 1.25rem;
}
#nav-warn-dest-label {
  color: var(--text);
  font-weight: 600;
}
.nav-warn-actions {
  display: flex;
  gap: .75rem;
}
.nav-warn-actions .btn,
.nav-warn-actions .tb-btn {
  flex: 1;
  justify-content: center;
  text-align: center;
  min-width: 0;
  white-space: normal;
  line-height: 1.3;
}

/* ── Variant-versions badge on pop-card ─────────────────────── */
.pop-versions {
  position: absolute;
  top: .35rem;
  right: .35rem;
  font-family: var(--font-pixel);
  font-size: .36rem;
  line-height: 1.2;
  padding: .2rem .38rem;
  background: rgba(124,58,237,.8);
  color: #fff;
  border-radius: 3px;
  letter-spacing: .02em;
  pointer-events: none;
}

/* ── Variant picker modal ────────────────────────────────────── */
.variant-modal-inner {
  max-width: 660px;
}

.variant-modal-hint {
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  margin: -.75rem 0 1.25rem;
}

.variant-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.variant-list::-webkit-scrollbar       { width: 4px; }
.variant-list::-webkit-scrollbar-track { background: transparent; }
.variant-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.variant-option {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}

.variant-option:hover,
.variant-option:focus-visible {
  border-color: var(--primary);
  background: rgba(124,58,237,.08);
  color: var(--text);
  outline: none;
}

.variant-cover {
  height: 96px;
  width: auto;
  min-width: 56px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}

.variant-cover img {
  height: 100%;
  width: auto;
  display: block;
}

.variant-cover--empty {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-alt) 0px, var(--surface-alt) 4px,
    var(--border) 4px, var(--border) 5px
  );
}

.variant-info {
  flex: 1 1 auto;
  min-width: 0;
}

.variant-title {
  font-family: var(--font-pixel);
  font-size: var(--font-sm);
  color: var(--text);
  margin-bottom: .45rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.variant-region {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.variant-region-badge {
  font-size: .48rem;
  padding: .25rem .5rem;
}

.variant-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: color .15s;
}

.variant-option:hover .variant-arrow,
.variant-option:focus-visible .variant-arrow { color: var(--primary-glow); }

@media (max-width: 720px) {
  .variant-modal-inner { max-width: 96vw; }
}

@media (max-width: 480px) {
  .variant-option { padding: .85rem 1rem; gap: .9rem; }
  .variant-cover  { height: 72px; min-width: 44px; }
  .variant-title  { font-size: var(--font-xs); }
}

/* ── Language selector ──────────────────────────────────────── */
.ne-lang-row {
  display: flex;
  gap: .35rem;
  padding: .35rem .6rem;
}

.ne-lang-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .28rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-pixel);
  font-size: .55rem;
  letter-spacing: .04em;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.ne-lang-btn:hover {
  border-color: var(--primary-glow);
  color: var(--text);
}

.ne-lang-btn.active {
  border-color: var(--primary-glow);
  color: var(--text);
  background: rgba(124, 58, 237, .12);
}

.ne-lang-flag {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  flex-shrink: 0;
}

.ne-lang-label {
  font-size: .55rem;
}

.ne-lang-btn:focus-visible {
  outline: 2px solid var(--primary-glow);
  outline-offset: 1px;
}


/* ═══════════════════════════════════════════════════════════════
   CHECKOUT & BILLING
   ═══════════════════════════════════════════════════════════════ */

/* ── Checkout two-column grid ──────────────────────────────────── */
.co-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 320px;
  gap: 2rem;
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
}
@media (max-width: 720px) {
  .co-grid { grid-template-columns: 1fr; }
  .co-summary { order: -1; }
}

/* ── Cards ─────────────────────────────────────────────────────── */
.co-card {
  background: var(--surface, #1a1a2e);
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.co-card-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin: 0 0 1rem;
}

/* ── Form fields ───────────────────────────────────────────────── */
.co-field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.co-label { font-size: .72rem; color: var(--text-dim); font-weight: 500; }
.co-label-opt { font-size: .65rem; color: var(--text-muted); margin-left: .25rem; }
.co-input {
  background: var(--input-bg, #111);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .75rem;
  color: var(--text);
  font-size: .82rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.co-input:focus { outline: 2px solid rgba(168,85,247,.45); border-color: transparent; }
.co-input--error { border-color: #f87171 !important; }
.co-input[readonly] { opacity: .65; cursor: default; }
.co-error { font-size: .68rem; color: #f87171; margin-top: .1rem; }

/* ── Two half-width fields side by side ────────────────────────── */
.co-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Terms checkbox ─────────────────────────────────────────────── */
.co-terms {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: .5rem 0 1rem;
}
.co-terms input[type=checkbox] { margin-top: .15rem; flex-shrink: 0; accent-color: #a855f7; }

/* ── Sandbox banner ─────────────────────────────────────────────── */
.co-sandbox {
  background: rgba(234,179,8,.07);
  border: 1px solid rgba(234,179,8,.25);
  border-radius: 8px;
  padding: .65rem 1rem;
  margin-bottom: 1rem;
  font-size: .72rem;
  color: #ca8a04;
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* ── Payment buttons ────────────────────────────────────────────── */
.co-pay-row { display: flex; flex-direction: column; gap: .5rem; }
.co-btn-pay {
  width: 100%;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  padding: .7rem 1rem;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.co-btn-pay:disabled { opacity: .5; cursor: default; }
.co-btn-pay:hover:not(:disabled) { opacity: .87; }
.co-btn-pay--success { background: #16a34a; color: #fff; }
.co-btn-pay--failure {
  background: transparent;
  border: 1px solid rgba(248,113,113,.5);
  color: #f87171;
}
.co-btn-pay--failure:hover:not(:disabled) { background: rgba(248,113,113,.07); opacity: 1; }

/* ── Processing state ──────────────────────────────────────────── */
.co-processing { text-align: center; padding: .75rem; font-size: .78rem; color: var(--text-dim); }

/* ── Order summary ──────────────────────────────────────────────── */
.co-summary-plan { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .25rem; }
.co-summary-price { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.co-summary-cycle { font-size: .72rem; color: var(--text-dim); margin-bottom: 1rem; }
.co-summary-feature {
  font-size: .72rem;
  color: var(--text-dim);
  display: flex;
  gap: .4rem;
  align-items: flex-start;
  margin-bottom: .4rem;
  line-height: 1.4;
}
.co-check { color: #22c55e; flex-shrink: 0; }
.co-divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.co-total-row { display: flex; justify-content: space-between; align-items: center; }
.co-total-label { font-size: .75rem; color: var(--text-dim); }
.co-total-amount { font-size: 1rem; font-weight: 700; }

/* ── Result pages (success / failed) ───────────────────────────── */
.co-result {
  text-align: center;
  max-width: 480px;
  margin: 3rem auto;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.co-result-icon { font-size: 3rem; margin-bottom: .75rem; }
.co-result-title { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
.co-result-sub { font-size: .82rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 1.25rem; }
.co-result-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* ── Billing page ───────────────────────────────────────────────── */
.co-billing-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(168,85,247,.12);
  border: 1px solid rgba(168,85,247,.3);
  border-radius: 20px;
  padding: .2rem .75rem;
  font-size: .72rem;
  color: #a855f7;
  font-weight: 600;
}
.co-billing-meta { font-size: .75rem; color: var(--text-dim); margin: .25rem 0; }
.co-billing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.co-billing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 2rem;
  gap: 1rem;
}
.co-billing-row + .co-billing-row { border-top: 1px solid rgba(255,255,255,.04); }
.co-billing-label {
  font-size: .68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.co-history-table { width: 100%; border-collapse: collapse; font-size: .72rem; }
.co-history-table thead th {
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.co-history-table tbody td {
  padding: .6rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text-dim);
  font-size: .78rem;
  vertical-align: middle;
}
.co-history-table tbody tr:last-child td { border-bottom: none; }
.co-history-table tbody tr:hover td { background: rgba(255,255,255,.02); }
.co-history-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.co-status-chip {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.co-status-chip--succeeded  { background: rgba(34,197,94,.15); color: #22c55e; }
.co-status-chip--failed     { background: rgba(248,113,113,.15); color: #f87171; }
.co-status-chip--pending    { background: rgba(234,179,8,.15); color: #ca8a04; }
.co-status-chip--created    { background: rgba(255,255,255,.07); color: var(--text-muted); }
.co-status-chip--cancelled  { background: rgba(156,163,175,.12); color: #9ca3af; }
.co-result--pending { border-color: rgba(234,179,8,.35); }

/* ── Payment method selector ────────────────────────────────────── */
.co-pm-list { display: flex; flex-direction: column; gap: .5rem; }
.co-pm-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.co-pm-item:hover { border-color: rgba(168,85,247,.4); background: rgba(168,85,247,.03); }
.co-pm-item--selected { border-color: rgba(168,85,247,.55); background: rgba(168,85,247,.06); }
.co-pm-item--disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.co-pm-radio {
  flex-shrink: 0;
  accent-color: #a855f7;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
.co-pm-logo {
  width: 40px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: .68rem;
  letter-spacing: .02em;
}
.co-pm-logo--mp { background: #fff; width: auto; height: auto; padding: 5px 10px; border-radius: 7px; }
.co-pm-logo--mp img { height: 32px; width: auto; display: block; }
.co-pm-info { flex: 1; min-width: 0; }
.co-pm-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.co-pm-desc  { display: block; font-size: .68rem; color: var(--text-muted); margin-top: .1rem; line-height: 1.4; }
.co-pm-badge {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  background: rgba(168,85,247,.12);
  color: #a855f7;
  border: 1px solid rgba(168,85,247,.3);
  border-radius: 4px;
  padding: .15rem .45rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.co-pm-coming-soon {
  font-size: .58rem;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Security / trust notice ────────────────────────────────────── */
.co-trust {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .68rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: .6rem .75rem;
  background: rgba(34,197,94,.04);
  border: 1px solid rgba(34,197,94,.12);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.co-trust-icon { color: #22c55e; flex-shrink: 0; font-size: .85rem; }

/* ── Upgrade promo card ─────────────────────────────────────────── */
.up-promo {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(168,85,247,.3);
  margin-bottom: 1.5rem;
  background: var(--surface);
}
.up-promo--pro {
  border-color: rgba(59,130,246,.35);
}
.up-promo-header {
  padding: 1rem 1.25rem .85rem;
  background: linear-gradient(135deg,rgba(124,58,237,.22) 0%,rgba(168,85,247,.15) 55%,rgba(59,130,246,.1) 100%);
  border-bottom: 1px solid rgba(168,85,247,.15);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
}
.up-promo--pro .up-promo-header {
  background: linear-gradient(135deg,rgba(37,99,235,.2) 0%,rgba(59,130,246,.14) 55%,rgba(124,58,237,.1) 100%);
  border-bottom-color: rgba(59,130,246,.15);
}
.up-promo-header-text {
  flex: 1;
  min-width: 0;
}
.up-promo-badges {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .5rem;
}
.up-promo-badge {
  display: inline-block;
  background: linear-gradient(90deg,#7c3aed,#a855f7);
  color: #fff;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .14rem .55rem;
  border-radius: 20px;
}
.up-promo-badge--pro {
  background: linear-gradient(90deg,#1d4ed8,#3b82f6);
}
.up-promo-title {
  margin: 0 0 .2rem;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.up-promo-sub {
  margin: 0;
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.55;
}
/* benefits: 3-column grid row */
.up-promo-benefits {
  list-style: none;
  margin: 0;
  padding: .65rem 1.25rem .75rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem .75rem;
  border-top: 1px solid rgba(255,255,255,.04);
}
.up-promo-benefit {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.up-promo-check {
  color: #22c55e;
  font-size: .78rem;
  flex-shrink: 0;
}
/* price + cta stacked in the header (right side) */
.up-promo-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
  flex-shrink: 0;
  padding-top: .1rem;
}
.up-promo-price {
  font-size: .68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.up-promo-price strong {
  color: var(--text);
  font-size: .82rem;
}
.up-promo-cta {
  display: inline-block;
  background: linear-gradient(90deg,#7c3aed,#a855f7);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .46rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s;
}
.up-promo-cta--pro { background: linear-gradient(90deg,#1d4ed8,#3b82f6); }
.up-promo-cta:hover { opacity: .85; }
/* tablet: 2 benefits per row */
@media (max-width:680px) {
  .up-promo-benefits { grid-template-columns: repeat(2, 1fr); }
}
/* mobile: header stacks, 1 benefit per row */
@media (max-width:480px) {
  .up-promo-header { flex-direction: column; gap: .75rem; }
  .up-promo-action {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    padding-top: 0;
  }
  .up-promo-benefits { grid-template-columns: 1fr; }
}

/* ── Upgrade promo card — in-game fixed overlay ──────────────────── */
.up-promo-game-wrap {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 1.5rem));
  z-index: 200;
}
.up-promo-game-wrap .up-promo {
  margin-bottom: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
}
.up-promo-game-close {
  position: absolute;
  top: .45rem;
  right: .5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: .2rem .35rem;
  cursor: pointer;
  z-index: 1;
  transition: color .12s;
}
.up-promo-game-close:hover { color: var(--text); }
/* homepage: balanced gap between console grid and promo card */
.up-promo-home-wrap { margin-top: 1.75rem; }
.up-promo-home-wrap .up-promo { margin-bottom: 0; }
