/* 1. VARIABLES Y RESET */
:root {
  --bg-dark: #0c0d14;
  --bg-card: #151723;
  --primary-red: #e63946;
  --primary-hover: #ff3d3d;
  --primary-dark: #b02121;
  --text-white: #ffffff;
  --text-gray: #8e92a4;
  --gold: #ffcc00;
  --glass: rgba(255, 255, 255, 0.05);
  --transition: 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Focus accesible (solo cuando navegas con teclado) */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Permite que el scroll del nav fijo no tape los anchors */
html {
  scroll-behavior: smooth;
}

#rankingCard,
#gameScreen {
  scroll-margin-top: 70px;
}

/* Reset para usar un <button> con la clase .nav-item del top nav */
button.nav-item {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-white);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  padding-top: 52px; /* Espacio para la barra de navegación fija */
}

/* 2. NAVEGACIÓN Y ESTRUCTURA GLOBAL */
.game-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background: linear-gradient(180deg, #151723 0%, #0c0d14 100%);
  border-bottom: 1px solid #2d2d44;
}

.game-nav .nav-logo {
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.game-nav .nav-logo img {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

.game-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.game-nav .nav-item i {
  font-size: 0.9rem;
}

.game-nav .nav-item:hover {
  color: #fff;
  background: rgba(230, 57, 70, 0.3);
}

.game-nav .nav-item.active {
  color: #fff;
  background: var(--primary-red);
}

.dashboard-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 3. HEADER */
.app-header {
  display: flex;
  flex-direction: column;
  padding: 15px 20px;
  gap: 10px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  color: var(--primary-red);
  font-size: 1.2rem;
  font-weight: 900;
  text-transform: uppercase;
}

.weather-info,
.location-top {
  font-size: 0.8rem;
  color: var(--text-gray);
}

/* 4. ÁREA DE JUEGO */
.game-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 500px;
  height: 70vh;
  margin: 0 15px;
  background: radial-gradient(circle, #1a1c2c 0%, #05050a 100%);
  border-radius: 40px;
  border: 1px solid var(--glass);
  overflow: hidden;
}

/* TOLDO */
.toldo {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: 30px 30px 0 0;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 10;
}

.rayas {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--primary-dark) 0px,
    var(--primary-red) 40px,
    var(--primary-dark) 80px,
    #d1d1d1 80px,
    #ffffff 120px,
    #d1d1d1 160px
  );
}

.toldo::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background-image:
    radial-gradient(
      circle at 40px 0,
      var(--primary-dark) 40px,
      transparent 41px
    ),
    radial-gradient(circle at 120px 0, #d1d1d1 40px, transparent 41px);
  background-size: 160px 40px;
  background-repeat: repeat-x;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.5));
}

/* 5. GRID Y CARDS DE INFO */
.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  padding: 20px;
}

.card {
  background: var(--bg-card);
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--glass);
  display: flex;
  flex-direction: column;
  min-height: 380px;
  transition: transform var(--transition);
}

.card:hover {
  transform: translateY(-4px);
}

.card-label {
  color: var(--text-gray);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
}

.card-sub-info {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: bold;
}

/* === CARD: CLIMA === */
.weather-display {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  padding: 10px 5px 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 204, 0, 0.08), transparent 65%),
    radial-gradient(circle at 50% 100%, rgba(230, 57, 70, 0.06), transparent 70%);
  border-radius: 12px;
}

.weather-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.weather-empty {
  color: var(--text-gray);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: auto 0;
}

.weather-empty i {
  color: var(--gold);
  margin: 0 2px;
}

.weather-icon {
  width: 88px;
  height: 88px;
  margin-bottom: -8px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.weather-temp {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1;
}

.weather-city {
  font-size: 0.95rem;
  color: var(--gold);
  font-weight: 600;
  margin-top: 4px;
}

.weather-desc {
  font-size: 0.75rem;
  color: var(--text-gray);
  text-transform: capitalize;
}

.weather-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 12px;
  padding: 8px 4px;
  border-top: 1px solid var(--glass);
}

.weather-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 8px;
  transition: background var(--transition);
}

.weather-stat:hover {
  background: rgba(255, 255, 255, 0.04);
}

.weather-stat i {
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.weather-stat-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1;
}

.weather-stat-label {
  font-size: 0.6rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.weather-form {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.weather-input {
  flex-grow: 1;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass);
  border-radius: 10px;
  color: var(--text-white);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition);
}

.weather-input:focus {
  border-color: var(--primary-red);
}

.weather-input::placeholder {
  color: var(--text-gray);
}

.weather-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--primary-red);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background var(--transition), transform var(--transition);
}

.weather-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.weather-btn--gold {
  background: var(--gold);
  color: var(--bg-dark);
}

.weather-btn--gold:hover {
  background: #ffe055;
}

/* === CARD: RANKING (podio) === */
.ranking-subtitle {
  text-align: center;
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.ranking-empty {
  color: var(--text-gray);
  font-size: 0.85rem;
  text-align: center;
  margin: auto 0;
  line-height: 1.5;
  grid-column: 1 / -1;
  align-self: center;
}

.podium {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 6px;
  padding-top: 8px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  min-width: 0;
}

/* Visualmente: 2º a la izq, 1º al centro, 3º a la der */
.podium-slot--first  { order: 2; }
.podium-slot--second { order: 1; }
.podium-slot--third  { order: 3; }

.podium-medal {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.podium-slot--first .podium-medal {
  font-size: 2rem;
  animation: podium-bounce 2.4s ease-in-out infinite;
}

@keyframes podium-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

.podium-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.podium-score {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.podium-meta {
  font-size: 0.6rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.podium-dash {
  font-size: 1.4rem;
  color: var(--text-gray);
  opacity: 0.4;
}

.podium-step {
  width: 100%;
  margin-top: 6px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-weight: 900;
  font-size: 1.2rem;
  color: rgba(0, 0, 0, 0.55);
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.podium-step::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0) 40%
  );
  pointer-events: none;
}

.podium-slot--first .podium-step {
  height: 100px;
  background: linear-gradient(180deg, #ffe055 0%, var(--gold) 50%, #b88a00 100%);
  box-shadow: 0 -4px 14px rgba(255, 204, 0, 0.35);
}

.podium-slot--second .podium-step {
  height: 70px;
  background: linear-gradient(180deg, #ececec 0%, #b8b8b8 60%, #707070 100%);
}

.podium-slot--third .podium-step {
  height: 45px;
  background: linear-gradient(180deg, #d99764 0%, #cd7f32 60%, #6e4116 100%);
}

.podium-slot--empty .podium-step {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
  color: var(--text-gray);
  box-shadow: none;
}

/* 6. FOOTER */
footer {
  margin-top: auto;
  background: linear-gradient(180deg, #1a1a2e 0%, #0c0d14 100%);
  border-radius: 20px 20px 0 0;
  padding: 15px 0;
  border-top: 2px solid #e63946;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 15px;
}

.footer-nav button,
.footer-nav a {
  background: linear-gradient(145deg, #1e1e32 0%, #151723 100%);
  height: 50px;
  width: 55px;
  border: 1px solid #2d2d44;
  color: #9ca3af;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 500;
  text-decoration: none;
}

.footer-nav button:hover,
.footer-nav a:hover {
  background: linear-gradient(145deg, #e63946 0%, #c62828 100%);
  border-color: #e63946;
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(230, 57, 70, 0.3);
}

.nav-footer {
  font-size: 0.7rem;
  text-align: center;
  margin-top: 12px;
  padding: 10px 15px;
  color: #6b7280;
}

.nav-footer .legal-links {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 8px;
}

.nav-footer a {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.65rem;
  transition: color 0.2s;
}

.nav-footer a:hover {
  color: #e63946;
}

/* 7. RESPONSIVE Y NIVELES */
@media (min-width: 700px) {
  .info-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .toldo {
    height: 160px;
  }
}

.level-select {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 90%;
  max-width: 320px;
  background: linear-gradient(
    145deg,
    rgba(30, 32, 48, 0.95),
    rgba(20, 22, 35, 0.98)
  );
  border-radius: 20px;
  padding: 25px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.level-select h2 {
  font-size: 1.1rem;
  letter-spacing: 2px;
  margin-bottom: 20px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(230, 57, 70, 0.5);
}

.level-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.level-btn {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  background: linear-gradient(
    135deg,
    rgba(45, 45, 68, 0.8),
    rgba(30, 30, 50, 0.9)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-white);
  cursor: pointer;
  transition: all 0.25s ease;
}

.level-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(60, 60, 90, 0.9),
    rgba(40, 40, 65, 0.95)
  );
  border-color: var(--primary-red);
  transform: translateX(5px);
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.2);
}

.level-btn:active {
  transform: scale(0.96);
}

.level-btn.selected {
  background: linear-gradient(135deg, var(--primary-red), #c62833);
  border-color: var(--primary-red);
  box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4),
              0 0 0 3px rgba(255, 204, 0, 0.25);
}

.level-number {
  font-size: 1.1rem;
  font-weight: bold;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-red);
  border-radius: 8px;
  margin-right: 12px;
}

.level-btn.selected .level-number {
  background: rgba(255, 255, 255, 0.3);
}

.level-name {
  font-size: 0.9rem;
  font-weight: 500;
  flex: 1;
  text-align: left;
}

.name-input-container {
    margin-bottom: 15px;
}

.name-input-container input {
    width: 100%;
    padding: 10px 15px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

.name-input-container input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.name-input-container input:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.3);
}

/* =========================================================
   MODAL DE AJUSTES (<dialog>)
   ========================================================= */

.settings-modal {
  border: none;
  padding: 0;
  background: transparent;
  margin: auto;
  max-width: 400px;
  width: calc(100% - 40px);
  color: #333;
}

.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.settings-card {
  background: #fff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: card-pop 0.25s ease-out;
}

.settings-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  padding-bottom: 12px;
}

.settings-card__title {
  font-size: 1.2rem;
  color: var(--primary-red);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.settings-card__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f1f3f5;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.settings-card__close:hover {
  background: var(--primary-red);
  color: #fff;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row__label {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.settings-input {
  flex: 1;
  max-width: 200px;
  padding: 8px 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  text-align: right;
  color: #333;
  transition: border-color 0.2s;
}

.settings-input:focus {
  border-color: var(--primary-red);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #333;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.settings-toggle[aria-pressed='true'] {
  background: #ffe4e6;
  color: #b02121;
  border-color: var(--primary-red);
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.settings-btn {
  flex: 1;
  min-width: 130px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s, opacity 0.15s, background 0.2s;
}

.settings-btn:active {
  transform: scale(0.97);
}

.settings-btn--primary {
  background: linear-gradient(135deg, #32cd32, #228b22);
  color: #fff;
}

.settings-btn--primary:hover {
  background: linear-gradient(135deg, #3dd73d, #2ea82e);
}

.settings-btn--danger {
  background: #fff;
  color: #b02121;
  border: 1px solid #fcc;
}

.settings-btn--danger:hover {
  background: #fff5f5;
}
