body {
  background-color: #1a1a2e;
  color: #e94560;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

.layout-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* PANEL LATERAL PC BASE */
.pc-side-panel {
  display: flex;
  flex-direction: column;
  background: #16213e;
  padding: 1.5rem;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  border: 2px solid #e94560;
  width: 250px;
  height: 520px;
  color: white;
  animation: glowPanel 2s infinite alternate;
  box-sizing: border-box;
  position: absolute;
}

.left-panel {
  right: calc(100% + 50px);
}

.right-panel {
  left: calc(100% + 50px);
  width: calc(50vw - 312px);
  /* Toma todo el espacio sobrante hasta 30px del borde derecho */
  min-width: 280px;
  border-color: #bf00ff;
}

@keyframes glowPanel {
  from {
    box-shadow: 0 0 10px #e94560, inset 0 0 5px #e94560;
  }

  to {
    box-shadow: 0 0 25px #e94560, inset 0 0 15px #e94560;
  }
}

.pc-side-panel h2 {
  color: #00ffff;
  font-size: 18px;
  text-shadow: 0 0 10px #00ffff;
  margin: 0;
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pc-side-panel .separator {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #e94560, transparent);
  margin: 15px 0;
}

.pc-side-panel .separator.purple {
  background: linear-gradient(90deg, transparent, #bf00ff, transparent);
}

.pc-leaderboard-list {
  flex: 1;
  overflow-y: auto;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 5px;
}

.pc-leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.pc-leaderboard-list::-webkit-scrollbar-track,
.right-panel *::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.pc-leaderboard-list::-webkit-scrollbar-thumb {
  background: #e94560;
  border-radius: 10px;
  box-shadow: 0 0 10px #e94560;
}

/* Scrollbar personalizado para el panel derecho (Neón Morado/Cian) */
.right-panel *::-webkit-scrollbar {
  width: 6px;
}

.right-panel *::-webkit-scrollbar-thumb {
  background: rgba(191, 0, 255, 0.5);
  border-radius: 10px;
  border: 1px solid rgba(191, 0, 255, 0.8);
  box-shadow: 0 0 10px rgba(191, 0, 255, 0.5);
}

.right-panel *::-webkit-scrollbar-thumb:hover {
  background: #bf00ff;
  box-shadow: 0 0 15px #bf00ff;
}

.encyclopedia-list {
  flex: 1;
  overflow-y: auto;
  font-size: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 12px;
  padding-right: 5px;
}

.encyclopedia-list::-webkit-scrollbar {
  width: 6px;
}

.encyclopedia-list::-webkit-scrollbar-thumb {
  background: #e94560;
  border-radius: 10px;
}

.encyclopedia-item {
  display: flex;
  align-items: center;
  background: rgba(233, 69, 96, 0.1);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(233, 69, 96, 0.3);
  transition: all 0.2s;
  cursor: help;
}

.encyclopedia-item:hover {
  background: rgba(233, 69, 96, 0.2);
  border-color: #e94560;
}

.enc-icon {
  font-size: 24px;
  margin-right: 12px;
  filter: grayscale(100%);
  opacity: 0.5;
  transition: all 0.5s ease;
}

.encyclopedia-item.unlocked .enc-icon {
  filter: grayscale(0%);
  opacity: 1;
}

.enc-details {
  display: flex;
  flex-direction: column;
}

.enc-name {
  font-weight: bold;
  color: #fff;
  font-size: 13px;
}

.enc-desc {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.2;
  margin-top: 2px;
}

.encyclopedia-item:not(.unlocked) .enc-name {
  color: rgba(255, 255, 255, 0.4);
}

.encyclopedia-item:not(.unlocked) .enc-desc {
  visibility: hidden;
}

.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(233, 69, 96, 0.1);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(233, 69, 96, 0.3);
  transition: all 0.2s;
}

.rank-item:hover {
  background: rgba(233, 69, 96, 0.2);
  transform: translateX(5px);
  border-color: #e94560;
}

.rank-item.top-1 {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.rank-item.top-1 .rank-score {
  color: #ffd700;
  text-shadow: 0 0 5px #ffd700;
}

.rank-item.top-2 {
  border: 1px solid #c0c0c0;
}

.rank-item.top-2 .rank-score {
  color: #c0c0c0;
  text-shadow: 0 0 5px #c0c0c0;
}

.rank-item.top-3 {
  border: 1px solid #cd7f32;
}

.rank-item.top-3 .rank-score {
  color: #cd7f32;
  text-shadow: 0 0 5px #cd7f32;
}

.rank-name {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.rank-score {
  color: #e94560;
  font-weight: 800;
  text-shadow: 0 0 5px #e94560;
}

.legend-text {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 15px;
  font-style: italic;
}

/* --- REDISEÑO PANEL TABS --- */
.panel-tabs {
  display: flex !important;
  gap: 2px !important;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
  flex: 1;
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.5) !important;
  font-size: 10px !important;
  padding: 8px 5px !important;
  border-radius: 8px !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.tab-btn:hover {
  color: white !important;
  background: rgba(255, 255, 255, 0.1) !important;
  transform: none !important;
}

.tab-btn.active {
  background: rgba(191, 0, 255, 0.2) !important;
  color: #bf00ff !important;
  box-shadow: 0 0 15px rgba(191, 0, 255, 0.3) !important;
  border: 1px solid rgba(191, 0, 255, 0.5) !important;
}

/* Específicos para el estilo de las pestañas de estadísticas internas */
.stats-tabs-internal button {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px !important;
  padding: 6px !important;
  color: #ccc !important;
}

.stats-tabs-internal button.active-session {
  background: rgba(0, 255, 255, 0.2) !important;
  color: #00ffff !important;
  border-color: #00ffff !important;
}

.game-container {
  background: #16213e;
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  text-align: center;
  border: 1px solid #0f3460;
  position: relative;
  max-width: 90vw;
}

.score {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #e94560;
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

canvas {
  background-color: #0f3460;
  display: block;
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  border: 4px solid #e94560;
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

canvas.phantom-border {
  border-color: #00ffff !important;
  box-shadow: 0 0 20px #00ffff, inset 0 0 20px rgba(0, 255, 255, 0.5) !important;
  animation: phantomGlow 2s infinite alternate;
}

@keyframes phantomGlow {
  from {
    box-shadow: 0 0 10px #00ffff, inset 0 0 10px rgba(0, 255, 255, 0.3);
  }

  to {
    box-shadow: 0 0 25px #00ffff, inset 0 0 20px rgba(0, 255, 255, 0.6);
  }
}

.controls {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 15px;
}

button {
  background: #e94560;
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

button:hover {
  background: #ff5e78;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
}

.muted-btn {
  background: #4a4e69 !important;
  color: #9a9ab0 !important;
}

#playerNameInput:focus {
  border-color: #ffd700 !important;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}



.fruit-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 25px;
  background: rgba(15, 52, 96, 0.8);
  border-radius: 20px;
  border: 1px solid #e94560;
}

.dots-row {
  display: flex;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a1a2e;
  border: 1px solid #e94560;
  transition: all 0.3s ease;
}

.dot.active {
  background: #e94560;
  box-shadow: 0 0 10px #e94560;
  transform: scale(1.2);
}

.medals-row {
  display: flex;
  gap: 8px;
}

.medal {
  font-size: 16px;
  filter: grayscale(100%) opacity(0.3);
  transition: all 0.5s ease;
}

.medal.active {
  filter: grayscale(0%) opacity(1);
  transform: scale(1.3);
}

/* --- ROGUELIKE POWER SELECTION --- */
.power-cards-container {
  display: flex;
  gap: 20px;
  justify-content: center;
  perspective: 1000px;
}

.power-card {
  background: #1a1a2e;
  border: 2px solid #333;
  border-radius: 15px;
  padding: 20px;
  width: 160px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.power-card:hover,
.power-card.focused {
  transform: translateY(-15px) scale(1.05);
  border-color: #00ffff;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
  z-index: 100;
}

.power-card.focused::after {
  content: '🎮 SELECCIONAR';
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #00ffff;
  font-weight: bold;
  white-space: nowrap;
  text-shadow: 0 0 5px #000;
}

.power-card.rare {
  border-color: #3498db;
  box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.2);
}

.power-card.epic {
  border-color: #9b59b6;
  box-shadow: inset 0 0 20px rgba(155, 89, 182, 0.3);
}

.power-card.legendary {
  border-color: #f1c40f;
  box-shadow: inset 0 0 30px rgba(241, 196, 15, 0.4);
  animation: cardGlow 2s infinite alternate;
}

@keyframes cardGlow {
  0% {
    box-shadow: 0 0 5px #f1c40f;
  }

  100% {
    box-shadow: 0 0 25px #f1c40f;
  }
}

.power-card .rarity-tag {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
  background: #333;
  color: #fff;
}

.power-card .icon {
  font-size: 40px;
}

.power-card .name {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  text-align: center;
}

.power-card .desc {
  font-size: 11px;
  color: #ccc;
  line-height: 1.3;
}

/* MODALES */
.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.game-over-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.game-over-modal,
.power-selection-modal {
  background: #16213e;
  padding: 2.5rem;
  border-radius: 20px;
  border: 2px solid #e94560;
  box-shadow: 0 0 30px rgba(233, 69, 96, 0.3);
}

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

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.pulse-text {
  animation: pulse 1.5s infinite;
}

/* En móvil ocultamos el panel lateral de PC y preparamos contenedores */
@media screen and (max-width: 768px) {
  .pc-leaderboard-panel {
    display: none;
  }

  .layout-wrapper {
    display: block;
  }
}

/* Por defecto, ocultar controles móviles */
.mobile-controls,
.mobile-top-btn {
  display: none;
}

@media (max-width: 768px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    display: block;
    padding: 10px;
  }

  .game-container {
    padding: 10px;
    box-shadow: none;
    max-width: 100%;
    margin: 0 auto;
  }

  /* Ajustar Canvas al ancho de pantalla */
  canvas {
    width: 320px;
    height: 320px;
  }

  .instructions,
  .controls {
    display: none;
    /* Ocultar controles de PC en móvil */
  }

  .mobile-controls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    width: 100%;
    user-select: none;
    position: relative;
  }

  .mobile-top-btn {
    display: flex !important;
  }

  /* --- JOYSTICK ARCADE --- (Reducido) */
  .arcade-stick-container {
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, #222 0%, #000 70%);
    border: 4px solid #444;
    border-radius: 50%;
    position: relative;
    touch-action: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(0, 0, 0, 0.8);
  }

  .stick-base {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 35px;
    height: 35px;
    background: #111;
    border-radius: 50%;
  }

  .stick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #ff4d4d, #800000);
    border-radius: 50%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5), inset 0 -5px 10px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 10;
    transition: transform 0.1s ease;
    border: 2px solid #500;
  }

  /* --- BOTÓN ARCADE --- */
  .arcade-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }

  .arcade-btn-sprint {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffd700, #b8860b) !important;
    border: 4px solid #444;
    box-shadow: 0 8px 0 #b8860b, 0 10px 20px rgba(0, 0, 0, 0.4) !important;
    font-size: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.1s ease;
    cursor: pointer;
    touch-action: manipulation;
    transform: none !important;
  }

  .arcade-btn-sprint:hover {
    background: radial-gradient(circle at 30% 30%, #ffd700, #b8860b) !important;
    box-shadow: 0 8px 0 #b8860b, 0 10px 20px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(-2px) !important;
  }

  .arcade-btn-sprint:active {
    transform: translateY(4px) !important;
    box-shadow: 0 4px 0 #b8860b, 0 5px 10px rgba(0, 0, 0, 0.4) !important;
  }

  .arcade-label {
    color: #ffd700;
    font-weight: 800;
    font-size: 12px;
    text-shadow: 0 0 10px #ffd700;
  }

  .mobile-top-btn {
    position: absolute;
    width: auto;
    height: auto;
    background: none;
    border: none;
    color: #e94560;
    top: 5px;
    z-index: 1001;
    cursor: pointer;
    display: none;
    opacity: 0.8;
    /* Efecto Neón en SVG */
    filter: drop-shadow(0 0 3px #e94560);
    transition: all 0.2s ease;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    padding: 5px;
  }

  .mobile-top-btn svg {
    stroke: #e94560;
    filter: drop-shadow(0 0 2px #e94560);
  }

  .mobile-top-btn:hover,
  .mobile-top-btn:focus {
    background: none !important;
    box-shadow: none !important;
    outline: none !important;
    opacity: 1;
    filter: drop-shadow(0 0 5px #e94560);
  }

  .mobile-top-btn:active {
    background: none !important;
    box-shadow: none !important;
    transform: scale(0.9) !important;
    opacity: 1;
  }

  .muted-btn-mobile svg {
    stroke: #4a4e69 !important;
    filter: drop-shadow(0 0 3px #4a4e69) !important;
  }

  .top-left {
    left: 5px;
  }

  .top-right {
    right: 5px;
  }

  /* Ajustar puntos y récord para evitar desajustes */
  .score {
    font-size: 14px;
    letter-spacing: 1px;
    margin-bottom: 10px;
  }

  @keyframes streak {
    0% {
      transform: translateX(0);
      opacity: 0;
    }

    50% {
      opacity: 1;
    }

    100% {
      transform: translateX(10px);
      opacity: 0;
    }
  }

  /* Modales en móvil (verticales) */
  .power-cards-container {
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
  }

  .power-card {
    width: 90%;
    flex-direction: row;
    padding: 10px;
    gap: 15px;
    height: auto;
  }

  .power-card .icon {
    font-size: 30px;
  }

  .power-card .desc {
    display: none;
  }

  /* Ocultar descripción larga en móvil para ahorrar espacio */
}

@keyframes rainbowNeon {
  0% {
    border-color: #ff0000;
    box-shadow: 0 0 15px #ff0000;
  }

  17% {
    border-color: #ff7f00;
    box-shadow: 0 0 15px #ff7f00;
  }

  33% {
    border-color: #ffff00;
    box-shadow: 0 0 15px #ffff00;
  }

  50% {
    border-color: #00ff00;
    box-shadow: 0 0 15px #00ff00;
  }

  67% {
    border-color: #0000ff;
    box-shadow: 0 0 15px #0000ff;
  }

  83% {
    border-color: #4b0082;
    box-shadow: 0 0 15px #4b0082;
  }

  100% {
    border-color: #9400d3;
    box-shadow: 0 0 15px #9400d3;
  }
}

.rainbow-neon-border {
  animation: rainbowNeon 0.5s linear infinite !important;
}

/* VISUALIZADOR DE RADIO */
.v-bar {
  flex: 1;
  height: 3px;
  background: #00ffff;
  box-shadow: 0 0 8px #00ffff;
  border-radius: 2px;
  transition: height 0.15s ease, background 0.3s ease;
  opacity: 0.4;
}

.radio-active .v-bar {
  opacity: 1;
}

#countdownOverlay {
  transition: none !important;
  background: transparent;
  /* El fondo se controla por JS */
}

/* CUENTA ATRÁS */
.countdown-text {
  font-size: 120px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff;
  animation: countdownPulse 1s ease-in-out infinite;
  font-family: 'Arial Black', sans-serif;
  user-select: none;
}

@keyframes countdownPulse {
  0% {
    transform: scale(1.3);
    /* Bajado de 1.5 a 1.3 */
    opacity: 0.2;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(0.9);
    /* Subido de 0.8 a 0.9 para que no se vea tan pequeño al final */
    opacity: 0;
  }
}

.countdown-text.ya-text {
  font-size: 100px;
  /* Un poco más pequeño que el 120px de los números */
  color: #00ffff;
  text-shadow: 0 0 20px #fff;
}

/* RESALTADO DE TARJETAS EN NAVEGACIÓN */
.power-card.focused {
  border: 4px solid #fff !important;
  box-shadow: 0 0 30px #fff, inset 0 0 15px rgba(255, 255, 255, 0.5) !important;
  transform: scale(1.1) translateY(-15px) !important;
  z-index: 100 !important;
}

.power-card.focused::after {
  content: '🎮 SELECCIONAR (ESPACIO)';
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #fff;
  font-weight: bold;
  white-space: nowrap;
  text-shadow: 0 0 5px #000;
}