/* ========================================================
   ESTILOS 16-BIT SNES | RETAS MULTIPLAYER
   ======================================================== */

:root {
  --snes-bg: #151324;
  --snes-surface: #242038;
  --snes-surface-light: #373256;
  --snes-gray-body: #C8C5CE;
  --snes-gray-dark: #8F8B99;
  --snes-purple-main: #6D55A0;
  --snes-purple-dark: #49396D;
  --snes-purple-light: #9B7EDA;
  --snes-cyan: #4DEEEA;
  --snes-yellow: #FFE600;
  --snes-red: #FF3366;
  --snes-green: #33FF77;
  --snes-blue: #2E78FF;
  --snes-gold: #FFB300;
  --pixel-border: 4px solid #000;
  --pixel-shadow: 4px 4px 0px #000;
  --pixel-shadow-pressed: 2px 2px 0px #000;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

*:focus, *:focus-visible, *:active {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

button, a, input, select, textarea, div {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none;
}

input.pixel-input {
  user-select: text;
}

body {
  background-color: var(--snes-bg);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Scanlines sutiles estilo CRT */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 999;
  pointer-events: none;
  opacity: 0.7;
}

/* Efecto Vignette CRT */
.crt-filter::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 998;
}

/* ================= HEADER ================= */
.retro-header {
  background: var(--snes-surface);
  border-bottom: 4px solid #000;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  position: relative;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.snes-badge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #000;
  padding: 4px;
  border-radius: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.dot-red { background: var(--snes-red); }
.dot-yellow { background: var(--snes-yellow); }
.dot-blue { background: var(--snes-blue); }
.dot-green { background: var(--snes-green); }

.pixel-text {
  font-size: 18px;
  color: #fff;
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
  letter-spacing: 1px;
}

.tag-16bit {
  background: var(--snes-purple-main);
  color: var(--snes-yellow);
  padding: 4px 8px;
  font-size: 8px;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hud-item {
  background: var(--snes-surface-light);
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge .label {
  color: var(--snes-yellow);
  font-size: 9px;
}

.pixel-input {
  background: #110e1f;
  border: 2px solid var(--snes-purple-light);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 6px 10px;
  outline: none;
}

.pixel-input:focus {
  border-color: var(--snes-cyan);
  box-shadow: 0 0 8px var(--snes-cyan);
}

.gamepad-status {
  font-size: 9px;
}

.gamepad-icon {
  font-size: 14px;
}

.status-online {
  color: var(--snes-green);
  text-shadow: 0 0 5px var(--snes-green);
}

.status-offline {
  color: #999;
}

/* ================= CONTENEDOR PRINCIPAL ================= */
.main-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
  position: relative;
  z-index: 10;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ================= BOTONES Y CAJAS PIXEL ART ================= */
.pixel-box {
  background: var(--snes-surface);
  border: 4px solid #000;
  box-shadow: var(--pixel-shadow);
  padding: 20px;
}

.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 10px 16px;
  border: 3px solid #000;
  box-shadow: var(--pixel-shadow);
  cursor: pointer;
  background: var(--snes-gray-body);
  color: #000;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.pixel-btn:hover {
  filter: brightness(1.1);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px #000;
}

.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: var(--pixel-shadow-pressed);
}

.btn-small {
  padding: 6px 10px;
  font-size: 8px;
}

.btn-purple {
  background: var(--snes-purple-main);
  color: #fff;
  border-color: #000;
}

/* ================= PANEL DE FILTROS 16-BIT ================= */
.filters-panel {
  margin-bottom: 24px;
  background: var(--snes-surface);
  border: 4px solid var(--snes-purple-light);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.search-and-players {
  justify-content: space-between;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 250px;
}

.search-icon {
  font-size: 14px;
}

.search-box .pixel-input {
  flex: 1;
}

.filter-label {
  color: var(--snes-yellow);
  font-size: 9px;
  white-space: nowrap;
}

.filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.genre-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.pixel-filter-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 10px;
  background: var(--snes-surface-light);
  color: #fff;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
  transition: all 0.1s ease;
}

.pixel-filter-btn:hover {
  background: var(--snes-purple-main);
  transform: translate(-1px, -1px);
}

.pixel-filter-btn.active {
  background: var(--snes-yellow);
  color: #000;
  border-color: #000;
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 #000;
}

.menu-nav-hint {
  background: #110e1f;
  padding: 6px 10px;
  border: 2px solid #000;
  color: var(--snes-cyan);
  font-size: 8px;
  line-height: 1.5;
}

/* ================= BARRA ALFABÉTICA (A-Z) ================= */
.alphabet-bar {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.alphabet-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pixel-alpha-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 7px;
  background: var(--snes-surface-light);
  color: #DDD;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
}

.pixel-alpha-btn:hover {
  background: var(--snes-cyan);
  color: #000;
}

.pixel-alpha-btn.active {
  background: var(--snes-cyan);
  color: #000;
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 #000;
}

/* ================= CURSOR Y SELECCIÓN CON CONTROL / TECLADO ================= */
.game-card.game-selected {
  outline: 4px solid var(--snes-yellow);
  box-shadow: 0 0 15px var(--snes-yellow), 8px 8px 0 #000 !important;
  transform: translateY(-6px) scale(1.02);
  z-index: 5;
}

.game-card.game-selected::before {
  content: '▶';
  position: absolute;
  top: 18px;
  left: 6px;
  color: var(--snes-yellow);
  font-size: 14px;
  animation: blink 0.7s step-end infinite;
  z-index: 10;
  text-shadow: 2px 2px 0 #000;
}

.game-badge {
  position: absolute;
  top: 18px;
  right: 12px;
  padding: 3px 6px;
  font-size: 7px;
  border: 2px solid #000;
  z-index: 5;
}

.badge-multi {
  background: var(--snes-green);
  color: #000;
}

.badge-single {
  background: var(--snes-gray-dark);
  color: #fff;
}

.btn-green {
  background: var(--snes-green);
  color: #000;
}

.btn-red {
  background: var(--snes-red);
  color: #fff;
}

.btn-blue {
  background: var(--snes-blue);
  color: #fff;
}

/* ================= HERO BANNER ================= */
.hero-banner {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  background: linear-gradient(135deg, var(--snes-surface) 0%, var(--snes-surface-light) 100%);
  border: 4px solid var(--snes-purple-light);
}

.hero-content h2 {
  font-size: 14px;
  color: var(--snes-yellow);
  margin-bottom: 10px;
  text-shadow: 2px 2px 0 #000;
}

.hero-content p {
  color: #DDD;
  font-size: 9px;
  max-width: 600px;
}

.quick-join {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quick-join .pixel-input {
  width: 170px;
}

/* ================= SECCIÓN DE JUEGOS ================= */
.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--snes-purple-light);
}

.section-title-bar h3 {
  font-size: 12px;
  color: var(--snes-cyan);
}

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

.loading-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
}

/* Cartucho Retro 16-Bit */
.game-card {
  background: var(--snes-gray-body);
  border: 4px solid #000;
  box-shadow: var(--pixel-shadow);
  color: #000;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 6px 6px 0 #000;
}

/* Muescas de cartucho SNES */
.cartridge-top {
  height: 14px;
  background: var(--snes-gray-dark);
  border-bottom: 3px solid #000;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.cartridge-ridge {
  width: 20px;
  height: 4px;
  background: #444;
}

.cartridge-label {
  padding: 10px;
  background: #1a1a2e;
  color: #fff;
  border: 3px solid #000;
  margin: 10px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 200px;
  justify-content: space-between;
  position: relative;
}

.cartridge-cover-img {
  width: 100%;
  height: 125px;
  object-fit: contain;
  background: #000;
  border: 2px solid #000;
  margin-bottom: 8px;
  display: block;
}

.cartridge-placeholder-art {
  width: 100%;
  height: 110px;
  background: linear-gradient(135deg, #301b4e 0%, #150050 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #000;
  margin-bottom: 10px;
  position: relative;
}

.cartridge-placeholder-art .cart-icon {
  font-size: 36px;
  margin-bottom: 6px;
}

.game-title {
  font-size: 10px;
  text-align: center;
  color: var(--snes-yellow);
  line-height: 1.4;
  word-break: break-word;
  max-width: 100%;
}

.game-size {
  font-size: 8px;
  color: #aaa;
  margin-top: 4px;
}

.cartridge-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 10px 12px 10px;
}

.cartridge-actions.single-action {
  grid-template-columns: 1fr;
}

.cartridge-actions .pixel-btn {
  font-size: 8px;
  padding: 8px 4px;
}

.pixel-btn.full-width {
  width: 100%;
}

.pixel-btn:focus, .pixel-btn:focus-visible, .pixel-btn:active {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
  box-shadow: var(--pixel-shadow) !important;
}

/* ================= PANTALLA EMULADOR (CABINET) ================= */
.netplay-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

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

.badge-live {
  background: var(--snes-red);
  color: #fff;
  padding: 4px 8px;
  font-size: 8px;
  animation: pulse 1.5s infinite;
  border: 2px solid #000;
}

.netplay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.arcade-cabinet {
  background: #181528;
  border: 6px solid #000;
  box-shadow: 8px 8px 0 #000;
  padding: 16px;
  border-radius: 8px;
}

.cabinet-screen {
  background: #000;
  border: 4px solid var(--snes-purple-dark);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
  position: relative;
  min-height: 640px;
  height: 75vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: visible;
}

.game-viewport {
  width: 100%;
  height: 100%;
  min-height: 640px;
  position: relative;
  display: block;
}

.game-viewport iframe,
.game-viewport div {
  width: 100% !important;
  height: 100% !important;
}

/* ================= SALA DE ESPERA / LOBBY TIPO MEET ================= */
.meet-lobby {
  background: #19152b;
  border: 4px solid var(--snes-purple-light);
  box-shadow: 0 0 25px rgba(109, 85, 160, 0.4), var(--pixel-shadow);
  padding: 30px 20px;
  margin-bottom: 24px;
}

.lobby-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lobby-header {
  text-align: center;
  border-bottom: 2px dashed var(--snes-purple-light);
  padding-bottom: 14px;
}

.lobby-badge {
  background: var(--snes-yellow);
  color: #000;
  padding: 4px 8px;
  font-size: 8px;
  border: 2px solid #000;
  display: inline-block;
  margin-bottom: 8px;
}

.lobby-game-title {
  color: #fff;
  font-size: 14px;
  margin-top: 6px;
  text-shadow: 2px 2px 0 #000;
}

.lobby-share-box {
  background: #110e1f;
  border: 3px solid #000;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-link-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.share-link-input {
  flex: 1;
  background: #000;
  color: var(--snes-green);
  border: 2px solid var(--snes-purple-main);
  padding: 8px 10px;
  font-size: 9px;
  font-family: monospace;
}

.players-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.player-slot-card {
  background: var(--snes-surface-light);
  border: 3px solid #000;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.player-slot-card.ready {
  border-color: var(--snes-green);
  box-shadow: 0 0 10px rgba(51, 255, 119, 0.3);
}

.player-slot-card.waiting {
  border-color: var(--snes-yellow);
  opacity: 0.9;
}

.slot-role {
  font-size: 9px;
  color: var(--snes-yellow);
}

.slot-name {
  font-size: 11px;
  color: #fff;
}

.slot-status {
  font-size: 8px;
}

.status-ready {
  color: var(--snes-green);
}

.status-waiting {
  color: var(--snes-yellow);
}

.lobby-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
}

.arcade-cabinet {
  background: #090714;
  border: 4px solid var(--snes-purple-main);
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.9), var(--pixel-shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 14px;
}

.cabinet-screen {
  background: #000;
  position: relative;
  width: 100%;
  min-height: 640px;
  height: 78vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.game-viewport {
  width: 100%;
  height: 100%;
  min-height: 640px;
  position: relative;
}

#game {
  width: 100% !important;
  height: 100% !important;
}

#gameIframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.cabinet-footer {
  margin-top: 0;
  padding: 12px;
  background: #0d0a17;
  border-top: 3px solid #000;
}

.controls-hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 8px;
  color: #BBB;
}

/* ================= TOAST 16-BIT ================= */
.pixel-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--snes-yellow);
  color: #000;
  border: 4px solid #000;
  box-shadow: var(--pixel-shadow);
  padding: 12px 18px;
  font-size: 10px;
  z-index: 10000;
  transform: translateY(150px);
  transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.pixel-toast.show {
  transform: translateY(0);
}

/* ================= FOOTER ================= */
.retro-footer {
  text-align: center;
  padding: 16px;
  font-size: 8px;
  color: #777;
  border-top: 2px dashed #332d4d;
  margin-top: auto;
  position: relative;
  z-index: 10;
}

/* ================= ANIMACIONES ================= */
.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ================= LOADER ARCADE 16-BITS ================= */
.arcade-loader {
  background: #19152b;
  border: 4px solid var(--snes-yellow);
  box-shadow: 0 0 20px rgba(255, 230, 0, 0.2), var(--pixel-shadow);
  padding: 40px 20px;
  text-align: center;
  margin-bottom: 24px;
}

.loader-inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.coin-insert {
  font-size: 14px;
  color: var(--snes-yellow);
  text-shadow: 2px 2px 0 #000;
  letter-spacing: 2px;
}

.loader-title {
  font-size: 12px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.loader-sub {
  font-size: 9px;
  color: var(--snes-cyan);
}

.pixel-progress-track {
  width: 100%;
  height: 22px;
  background: #0d0a17;
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.8);
  position: relative;
  overflow: hidden;
}

.pixel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--snes-green) 0%, var(--snes-yellow) 100%);
  width: 0%;
  transition: width 0.25s ease-out;
  box-shadow: 2px 0 0 #000;
}

.loader-percent {
  font-size: 10px;
  color: var(--snes-green);
}

@media (max-width: 768px) {
  .retro-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-join {
    flex-direction: column;
  }
  .quick-join .pixel-input {
    width: 100%;
  }
  .cabinet-screen, .game-viewport {
    min-height: 320px;
    height: 320px;
  }
}

/* ================= MODAL DE BLOQUEO POR TOKEN 16-BIT ================= */
.auth-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 8, 20, 0.94);
  backdrop-filter: blur(8px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-gate-box {
  max-width: 480px;
  width: 100%;
  background: #19152b;
  border: 4px solid var(--snes-yellow);
  box-shadow: 0 0 30px rgba(255, 230, 0, 0.3), var(--pixel-shadow);
  padding: 30px 24px;
  text-align: center;
  animation: pulse 3s infinite ease-in-out;
}

.auth-title {
  font-size: 15px;
  color: var(--snes-yellow);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.auth-subtitle {
  font-size: 8px;
  color: var(--snes-cyan);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.auth-form-card {
  background: #0f0c1b;
  border: 3px solid #000;
  padding: 20px 16px;
}

.auth-hint {
  font-size: 8px;
  color: #ccc;
  line-height: 1.6;
  margin-bottom: 16px;
}

.auth-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.auth-input {
  flex: 1;
  font-size: 10px;
  text-align: center;
  letter-spacing: 2px;
  padding: 10px;
}

.auth-submit-btn {
  font-size: 9px;
  padding: 10px 16px;
  white-space: nowrap;
}

.auth-error {
  font-size: 8px;
  color: var(--snes-red);
  margin-top: 14px;
  font-weight: bold;
}
