/* ProRetro - Estilos Compartidos de la Sala de Juego y Pantalla Completa */

/* Utilidades (antes estilos inline en el HTML, movidas aquí por seguridad/CSP) */
.file-input-hidden {
  display: none;
}

.hint-text {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.player-room-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 240px;
  min-width: 0;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
  flex-shrink: 0;
}

.back-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

/* Vista de Carga / Dropzone */
#upload-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto 0;
  animation: fadeIn 0.4s ease;
}

.dropzone-container {
  width: 100%;
  max-width: 680px;
  margin-bottom: 24px;
}

.dropzone {
  border: 2px dashed #3a456e;
  background: rgba(24, 29, 51, 0.7);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 50px 30px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  background: rgba(30, 37, 66, 0.9);
  transform: translateY(-2px);
}

.dropzone.dragover {
  border-color: var(--n64-green) !important;
}

.dropzone-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 2.2rem;
}

.dropzone-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.dropzone-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.format-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.format-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a7b7db;
}

.quick-options {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Vista del Reproductor de Emulación */
#player-view {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.mobile-orientation-banner {
  display: none;
  background: linear-gradient(90deg, rgba(229, 37, 33, 0.2), rgba(0, 114, 206, 0.2));
  border: 1px solid rgba(0, 114, 206, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  color: #f0f3fc;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: none;
}

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

.game-title-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
}

.game-format-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 158, 73, 0.2);
  color: #5cff9a;
  border: 1px solid rgba(0, 158, 73, 0.4);
}

.player-controls-bar {
  display: flex;
  gap: 8px;
}

/* ================================================= */
/* CONTENEDOR Y PANTALLA COMPLETA UNIVERSAL          */
/* ================================================= */

.emulator-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 720px;
  background: #000;
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

#game-container {
  width: 100%;
  height: 100%;
}

#game-container.emulator-load-error {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-main, #fff);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Pantalla Completa Nativa */
.emulator-wrapper:fullscreen,
.emulator-wrapper:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border: none !important;
  border-radius: 0 !important;
  background: #000 !important;
}

/* Pseudo-Pantalla Completa para Móviles (iOS Safari, Android) */
.emulator-wrapper.is-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  z-index: 9999999 !important;
  background: #000 !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Botón flotante para salir de pantalla completa */
.btn-exit-fullscreen {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10000000;
  background: rgba(18, 22, 38, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-exit-fullscreen:hover {
  background: rgba(229, 37, 33, 0.9);
  border-color: #ff4d4d;
}

.emulator-wrapper.is-fullscreen ~ .btn-exit-fullscreen,
body.has-fullscreen .btn-exit-fullscreen {
  display: flex !important;
}

/* Modal de Controles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 660px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.controls-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.controls-table th, .controls-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.9rem;
}

.controls-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
}

.key-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  background: #252b47;
  border: 1px solid #3d4773;
  color: #ffffff;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 0 #151829;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

/* Reglas Móviles */
@media (max-width: 768px) and (orientation: portrait) {
  .mobile-orientation-banner {
    display: flex;
  }
}

@media (max-width: 768px) {
  .dropzone {
    padding: 35px 20px;
  }
  .quick-options {
    flex-direction: column;
    width: 100%;
  }
  .quick-options .btn {
    width: 100%;
    justify-content: center;
  }
  .player-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .player-controls-bar {
    display: flex;
    justify-content: space-between;
  }
  .player-controls-bar .btn {
    flex: 1;
    justify-content: center;
  }
  .emulator-wrapper {
    aspect-ratio: 4 / 3;
    max-height: 75vh;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  main {
    padding: 8px;
  }
  .player-header {
    padding: 6px 12px;
  }
  .emulator-wrapper {
    aspect-ratio: unset;
    height: calc(100vh - 100px);
    max-height: unset;
  }
  .features-grid {
    display: none;
  }
}

