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

html, body {
  width: 100%;
  height: 100%;
  background: #0a0a0f;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

/* ===== MENÚ ===== */
#menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
  z-index: 30;
  padding: 24px 16px;
  overflow-y: auto;
}

#menu h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #57f287, #5865f2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#menu .subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-bottom: 28px;
  text-align: center;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  max-width: 680px;
  width: 100%;
}

.game-card {
  background: rgba(30, 30, 50, 0.9);
  border: 2px solid #2a2a45;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
}

.game-card:hover {
  border-color: #5865f2;
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(88, 101, 242, 0.25);
}

.game-card .cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: #111;
  overflow: hidden;
  margin-bottom: 8px;
}

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

.game-card .name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}

.game-card .meta {
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 4px;
  display: flex;
  justify-content: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ===== LOADING ===== */
#loading {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 40;
  gap: 14px;
  padding: 20px;
}

#loading .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid #222;
  border-top-color: #5865f2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  color: #e2e8f0;
  font-size: 1rem;
  text-align: center;
}

.progress-wrap {
  width: min(320px, 80vw);
  height: 10px;
  background: #1e1e2e;
  border-radius: 999px;
  overflow: hidden;
  display: none;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5865f2, #57f287);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.progress-label {
  color: #94a3b8;
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ===== EMULADOR ===== */
#game-container {
  position: absolute;
  inset: 0;
  display: none;
  background: #000;
}

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

#btn-back {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 9999 !important;
  background: rgba(88, 101, 242, 0.95);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
}

/* Controles móviles base */
.ejs_virtualGamepad_open {
  top: auto !important;
  bottom: 230px !important;
  right: 88px !important;
  left: auto !important;
  z-index: 100 !important;
}

.ejs_virtualGamepad_right {
  bottom: 55px !important;
  right: 88px !important;
}

.ejs_virtualGamepad_left {
  bottom: 50px !important;
  left: 12px !important;
}

.ejs_virtualGamepad_bottom {
  bottom: 10px !important;
}
