/* =====================================================
   MURPHY ARCADE - Premium Online Gaming Platform
   Design: Apple-quality. Clean, minimal, fluid.
   ===================================================== */

:root {
  --bg: #0A0A0A;
  --surface: #1A1A1A;
  --surface-hover: #222222;
  --surface-elevated: #242424;
  --glass: rgba(20, 20, 20, 0.85);
  --glass-border: rgba(255, 255, 255, 0.06);
  --accent: #2E7D52;
  --accent-hover: #36956A;
  --accent-glow: rgba(46, 125, 82, 0.3);
  --accent-subtle: rgba(46, 125, 82, 0.1);
  --copper: #B87333;
  --copper-hover: #D4884A;
  --copper-glow: rgba(184, 115, 51, 0.3);
  --copper-subtle: rgba(184, 115, 51, 0.1);
  --danger: #ff4757;
  --danger-subtle: rgba(255, 71, 87, 0.1);
  --text: #F5F5F5;
  --text-secondary: #888888;
  --text-dim: #555555;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  cursor: default;
}

#app {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============ UTILITIES ============ */

.hidden {
  display: none !important;
}

.text-secondary {
  color: var(--text-secondary);
}

/* ============ LOADING SCREEN ============ */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-logo {
  text-align: center;
}

.murphy-logo-svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
}

.logo-ring {
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  animation: ring-draw 2s ease-in-out infinite;
}

@keyframes ring-draw {
  0% { stroke-dashoffset: 283; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -283; }
}

.loading-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 13px;
  color: var(--text-secondary);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============ EMULATOR OVERLAY ============ */

#emulator-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  background: #000;
  animation: fadeIn 0.2s ease;
}

#emulator-overlay.hidden {
  display: none;
}

.emulator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #111;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
  z-index: 1;
}

.emulator-game-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emulator-exit {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 6px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: var(--transition);
}

.emulator-exit:hover {
  background: rgba(255, 71, 87, 0.2);
  border-color: rgba(255, 71, 87, 0.4);
  color: #ff4757;
}

.emulator-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
}

/* ============ LOGIN VIEW ============ */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  text-align: center;
}

.login-logo {
  margin-bottom: 24px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-error {
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--danger-subtle);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  text-align: left;
}

.login-sent {
  padding: 20px 0;
}

.login-sent svg {
  margin-bottom: 16px;
}

.login-sent h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-sent p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.login-sent strong {
  color: var(--text);
}

/* ============ HEADER ============ */

#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

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

.header-logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.header-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 999px;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.nav-admin {
  color: var(--copper) !important;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 7px 14px;
  transition: var(--transition);
  width: 180px;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  width: 260px;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-hint {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-time {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ============ BUTTONS ============ */

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-play:hover, .btn-play:focus-visible {
  background: var(--accent-hover);
  transform: scale(1.03);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-play:active {
  transform: scale(0.98);
}

.btn-copper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--copper);
  border: 1.5px solid var(--copper);
  border-radius: 999px;
  padding: 9px 22px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-copper:hover {
  background: var(--copper-subtle);
  border-color: var(--copper-hover);
  color: var(--copper-hover);
  box-shadow: 0 0 16px var(--copper-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-small {
  padding: 6px 16px;
  font-size: 12px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text);
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-icon-small {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(8px);
}

.btn-icon-small:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon-small.btn-danger:hover {
  color: var(--danger);
  background: var(--danger-subtle);
  border-color: rgba(255, 71, 87, 0.3);
}

.btn-fav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-fav:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-fav.active {
  color: var(--danger);
  background: var(--danger-subtle);
  border-color: rgba(255, 71, 87, 0.3);
}

.btn-fav.active svg {
  fill: var(--danger);
}

/* ============ PROFILE DROPDOWN ============ */

.profile-wrapper {
  position: relative;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.profile-btn:hover {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.profile-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.dropdown-danger:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

.dropdown-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 4px 0;
}

/* ============ HERO SECTION ============ */

#hero {
  position: relative;
  height: 420px;
  overflow: hidden;
  margin-top: 60px;
}

.hero-bg {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(40px) brightness(0.3) saturate(1.5);
  transition: background-image var(--transition-slow);
  transform: scale(1.1);
}

.hero-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px;
  height: 100%;
}

.hero-art {
  width: 220px;
  height: 293px;
  border-radius: var(--radius);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px var(--accent-glow);
  transition: background-image var(--transition-slow);
}

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

.hero-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.hero-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
}

.system-badge {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.hero-meta .rating {
  color: #FFD700;
}

.hero-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-bottom: 20px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ CAROUSEL ============ */

#carousel-section {
  padding: 0 32px;
  margin-top: -16px;
  position: relative;
  z-index: 10;
}

.carousel-wrapper {
  position: relative;
  overflow: hidden;
}

.carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 16px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.carousel::-webkit-scrollbar {
  display: none;
}

.carousel-card {
  flex-shrink: 0;
  width: 150px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.carousel-card:hover,
.carousel-card:focus-visible,
.carousel-card.selected {
  transform: scale(1.06);
}

.carousel-card.selected .card-thumb {
  box-shadow: 0 0 0 2.5px var(--accent), 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-thumb {
  width: 150px;
  height: 200px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  margin-bottom: 8px;
  transition: box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 40%);
  pointer-events: none;
}

.card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-system {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.card-thumb.no-art {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.card-thumb.no-art::before {
  content: attr(data-initial);
  position: relative;
  z-index: 1;
  font-weight: 700;
  font-size: 40px;
  color: var(--text-dim);
}

/* Multiplayer badge */
.multiplayer-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--copper);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
  letter-spacing: 0.5px;
}

/* Live badge */
.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 2;
  letter-spacing: 1px;
  animation: pulse 2s ease-in-out infinite;
}

/* ============ SYSTEM TABS ============ */

#system-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 32px;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text);
  background: var(--surface);
}

/* ============ GAME GRID ============ */

#game-grid-section {
  padding: 16px 32px 32px;
  max-height: calc(100vh - 580px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
}

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

.grid-card {
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.grid-card:hover,
.grid-card:focus-visible {
  transform: scale(1.05);
}

.grid-card .card-thumb {
  width: 100%;
  height: 0;
  padding-bottom: 133%;
  position: relative;
}

/* ============ DETAIL OVERLAY ============ */

#detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

#detail-overlay.hidden {
  display: none;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}

.detail-panel {
  position: relative;
  width: 90%;
  max-width: 860px;
  max-height: 85vh;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 36px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition);
}

.detail-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.detail-layout {
  display: flex;
  gap: 32px;
}

.detail-art {
  width: 260px;
  height: 347px;
  border-radius: var(--radius);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

.detail-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 12px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-meta .tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-secondary);
}

.detail-meta .tag.system {
  background: var(--accent-subtle);
  border-color: rgba(46, 125, 82, 0.2);
  color: var(--accent);
  font-weight: 600;
}

.detail-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ LOBBY VIEW ============ */

.lobby-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 80px 32px 32px;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.lobby-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.lobby-grid {
  display: grid;
  gap: 16px;
}

.lobby-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
}

.lobby-card:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.lobby-card-art {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-card-initial {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dim);
}

.lobby-card-info {
  flex: 1;
  min-width: 0;
}

.lobby-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.lobby-host {
  font-size: 12px;
  color: var(--text-secondary);
}

.lobby-card-slots {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.slot {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.slot.filled {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(46, 125, 82, 0.2);
}

.slot.empty {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.lobby-card-counts {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.lobby-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.btn-join {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 18px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-join:hover {
  background: var(--accent-hover);
}

.btn-watch {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-watch:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-share-session {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-share-session:hover {
  color: var(--copper);
  border-color: var(--copper);
}

/* ============ PLAYER / SPECTATOR VIEW ============ */

.stream-container {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
}

.stream-area {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.stream-area video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stream-placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.view-only-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 71, 87, 0.2);
  border: 1px solid rgba(255, 71, 87, 0.4);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 999px;
  z-index: 10;
}

/* Player HUD */
.player-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.4s ease;
}

.player-hud.hud-hidden {
  opacity: 0;
}

.player-hud > * {
  pointer-events: auto;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
}

.hud-game-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-game-name {
  font-size: 15px;
  font-weight: 600;
}

.hud-badge {
  font-size: 10px;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
}

.hud-players {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 4px 12px 4px 6px;
  backdrop-filter: blur(8px);
}

.player-slot.me {
  border-color: var(--accent);
  background: rgba(46, 125, 82, 0.15);
}

.player-slot-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-slot-name {
  font-size: 12px;
  font-weight: 500;
}

.player-slot-you {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}

.spectator-count {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
}

.touch-area {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

/* ============ VIRTUAL CONTROLLER ============ */

.virtual-controller {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px;
  padding-bottom: 40px;
}

.virtual-controller > * {
  pointer-events: auto;
}

.vc-left, .vc-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.vc-dpad {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  gap: 2px;
}

.vc-up { grid-column: 2; grid-row: 1; }
.vc-left-btn { grid-column: 1; grid-row: 2; }
.vc-center { grid-column: 2; grid-row: 2; background: rgba(255, 255, 255, 0.03); border-radius: 8px; }
.vc-right-btn { grid-column: 3; grid-row: 2; }
.vc-down { grid-column: 2; grid-row: 3; }

.vc-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease;
}

.vc-btn.pressed {
  background: rgba(46, 125, 82, 0.4);
  border-color: var(--accent);
  color: #fff;
}

.vc-action-btns {
  display: grid;
  grid-template-columns: 48px 48px;
  grid-template-rows: 48px 48px;
  gap: 6px;
  transform: rotate(45deg);
}

.vc-action-btns .vc-action {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: rotate(-45deg);
}

.vc-x { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); }
.vc-y { background: rgba(251, 191, 36, 0.15); border-color: rgba(251, 191, 36, 0.3); }
.vc-a { background: rgba(46, 125, 82, 0.15); border-color: rgba(46, 125, 82, 0.3); }
.vc-b { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }

.vc-center-btns {
  display: flex;
  gap: 16px;
  align-self: flex-end;
  margin-bottom: 20px;
}

.vc-meta {
  padding: 6px 14px;
  font-size: 10px;
  letter-spacing: 1px;
  border-radius: 999px;
}

.vc-shoulder {
  padding: 8px 20px;
  font-size: 12px;
  border-radius: 8px;
}

.vc-shoulder-left, .vc-shoulder-right {
  display: flex;
  justify-content: center;
}

/* ============ ADMIN VIEW ============ */

.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 32px 32px;
}

.admin-container h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 32px;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.admin-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.admin-add-form input {
  flex: 1;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
}

.admin-table td {
  font-size: 13px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-badge {
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.admin-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px !important;
}

.btn-remove-user {
  background: none;
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: var(--danger);
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-remove-user:hover {
  background: var(--danger-subtle);
}

/* ============ MODALS ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 90%;
  max-width: 440px;
  background: var(--surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-wide {
  max-width: 560px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
}

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

/* ============ FORMS ============ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px !important;
  color: var(--text-secondary) !important;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ============ CONTROLLER SETUP ============ */

.controller-setup-body {
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
}

.setup-section {
  margin-bottom: 24px;
}

.setup-section:last-child {
  margin-bottom: 0;
}

.setup-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.controller-none {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.controller-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.controller-icon {
  color: var(--accent);
}

.controller-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controller-type {
  font-size: 11px;
  color: var(--text-dim);
}

.controller-test {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  border: 1px solid var(--glass-border);
  transition: var(--transition);
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.controller-test.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.keyboard-map {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.key-row {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 5px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.key-row kbd {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  min-width: 24px;
  text-align: center;
}

/* ============ EMPTY STATE ============ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-dim);
}

/* ============ ANIMATIONS ============ */

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Focus ring for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* System count badge */
.system-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
  #header {
    padding: 0 16px;
    height: 52px;
  }

  .header-nav {
    display: none;
  }

  .header-title {
    font-size: 12px;
    letter-spacing: 2px;
  }

  .search-box {
    width: 140px;
    padding: 6px 12px;
  }

  .search-box:focus-within {
    width: 180px;
  }

  .search-box input {
    font-size: 12px;
  }

  .header-time {
    display: none;
  }

  .profile-name {
    display: none;
  }

  /* Mobile nav - bottom bar */
  .mobile-nav {
    display: flex;
  }

  /* Hero */
  #hero {
    height: auto;
    min-height: 320px;
    margin-top: 52px;
  }

  .hero-content {
    flex-direction: column;
    text-align: center;
    padding: 24px 16px;
    gap: 20px;
  }

  .hero-art {
    width: 160px;
    height: 213px;
  }

  .hero-title {
    font-size: 22px;
    white-space: normal;
  }

  .hero-meta {
    justify-content: center;
  }

  .hero-desc {
    -webkit-line-clamp: 2;
    max-height: 45px;
  }

  .hero-actions {
    justify-content: center;
  }

  /* Carousel */
  #carousel-section {
    padding: 0 16px;
  }

  .carousel-card {
    width: 120px;
  }

  .card-thumb {
    width: 120px;
    height: 160px;
  }

  .card-name {
    font-size: 11px;
  }

  /* Tabs */
  #system-tabs {
    padding: 8px 16px;
    overflow-x: auto;
    justify-content: flex-start;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  #system-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    font-size: 11px;
    padding: 6px 12px;
    flex-shrink: 0;
  }

  /* Detail overlay */
  .detail-panel {
    width: 95%;
    padding: 24px;
  }

  .detail-layout {
    flex-direction: column;
    align-items: center;
  }

  .detail-art {
    width: 180px;
    height: 240px;
  }

  .detail-title {
    font-size: 20px;
    text-align: center;
  }

  .detail-meta {
    justify-content: center;
  }

  .detail-actions {
    justify-content: center;
  }

  /* Lobby */
  .lobby-container {
    padding: 68px 16px 16px;
  }

  .lobby-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .lobby-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }

  .lobby-card-art {
    width: 48px;
    height: 48px;
  }

  .lobby-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Modal */
  .modal-card {
    width: 95%;
    padding: 20px;
  }

  /* Admin */
  .admin-container {
    padding: 68px 16px 16px;
  }

  .admin-add-form {
    flex-direction: column;
  }

  /* Login */
  .login-card {
    padding: 32px 24px;
  }

  /* Player/Spectator - always fullscreen */
  .stream-container {
    height: 100vh;
    height: 100dvh;
  }

  /* Virtual controller sizing */
  .vc-dpad {
    grid-template-columns: 42px 42px 42px;
    grid-template-rows: 42px 42px 42px;
  }

  .vc-action-btns {
    grid-template-columns: 42px 42px;
    grid-template-rows: 42px 42px;
  }

  .vc-action-btns .vc-action {
    width: 42px;
    height: 42px;
  }

  .virtual-controller {
    padding: 12px;
    padding-bottom: 24px;
  }
}

/* Extra small screens */
@media (max-width: 375px) {
  .hero-art {
    width: 130px;
    height: 173px;
  }

  .hero-title {
    font-size: 20px;
  }

  .btn-play, .btn-copper {
    padding: 8px 16px;
    font-size: 12px;
  }

  .carousel-card {
    width: 100px;
  }

  .card-thumb {
    width: 100px;
    height: 133px;
  }

  .vc-dpad {
    grid-template-columns: 38px 38px 38px;
    grid-template-rows: 38px 38px 38px;
  }

  .vc-action-btns {
    grid-template-columns: 38px 38px;
    grid-template-rows: 38px 38px;
  }

  .vc-action-btns .vc-action {
    width: 38px;
    height: 38px;
  }
}

/* Landscape orientation for game views */
@media (max-width: 768px) and (orientation: landscape) {
  .virtual-controller {
    padding: 8px 20px;
    padding-bottom: 12px;
  }

  .vc-center-btns {
    margin-bottom: 8px;
  }

  .hud-top {
    padding: 8px 16px;
  }

  .hud-bottom {
    padding: 8px 16px;
  }
}

/* Game grid mobile */
@media (max-width: 768px) {
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}
