/* ==========================================================================
   OTIKY TILES - ESTILOS Y SISTEMA DE DISEÑO
   Estándar de ingeniería UI, accesibilidad, alto contraste y rendimiento 60 FPS
   ========================================================================== */

:root {
  /* Paleta Tema Claro / Colorido (Pastel & Vivo) */
  --bg-primary: #F3F4F9;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F8FAFC;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-subtle: #E2E8F0;
  
  --lane-bg: #FFFFFF;
  --lane-divider: rgba(148, 163, 184, 0.25);
  --hit-zone-bg: #F1F5F9;
  --hit-line-color: #3B82F6;

  /* Acentos de carriles */
  --lane-0-accent: #3B82F6; /* Azul */
  --lane-1-accent: #10B981; /* Esmeralda */
  --lane-2-accent: #F59E0B; /* Ámbar */
  --lane-3-accent: #EC4899; /* Rosa */

  --accent-primary: #4F46E5;
  --accent-primary-hover: #4338CA;
  --accent-secondary: #06B6D4;
  --star-gold: #F59E0B;
  --danger: #EF4444;
  --success: #10B981;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --ease-snappy: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Tema Nocturno / Neón
   ========================================================================== */
[data-theme="neon"] {
  --bg-primary: #0A0D14;
  --bg-surface: #111625;
  --bg-elevated: #182035;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --border-subtle: #24304F;

  --lane-bg: #0D121F;
  --lane-divider: rgba(56, 189, 248, 0.16);
  --hit-zone-bg: #151D30;
  --hit-line-color: #06B6D4;

  --lane-0-accent: #38BDF8;
  --lane-1-accent: #34D399;
  --lane-2-accent: #FBBF24;
  --lane-3-accent: #F472B6;

  --accent-primary: #6366F1;
  --accent-primary-hover: #4F46E5;
  --accent-secondary: #22D3EE;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   Reseteo y Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Ocultar opciones exclusivas de escritorio cuando se abre desde un celular */
body.is-mobile-device .desktop-only-btn,
body.is-mobile-device .qr-desktop-wrapper {
  display: none !important;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* ==========================================================================
   Barra Superior Global y Control de Volumen
   ========================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 40;
  flex-shrink: 0;
}

.top-bar.hidden-in-game {
  display: none;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.logo-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 140ms var(--ease-snappy), background-color 140ms;
}

.icon-button:hover {
  transform: scale(1.05);
}

.icon-button:active {
  transform: scale(0.95);
}

.icon-button svg {
  display: block;
}

/* Control de Volumen Desplegable */
.volume-control-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.top-vol-mini {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
  background-color: var(--accent-primary);
  color: #FFFFFF;
  pointer-events: none;
  line-height: 1.1;
}

.volume-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: -20px;
  width: 245px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 160ms var(--ease-snappy), transform 160ms var(--ease-snappy);
  z-index: 100;
}

.volume-popover.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

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

.vol-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}

.vol-pct {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--accent-primary);
}

.vol-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-step-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.vol-step-btn:active {
  transform: scale(0.92);
  background-color: var(--accent-primary);
  color: #FFFFFF;
}

.vol-slider {
  flex: 1;
  accent-color: var(--accent-primary);
  height: 6px;
  cursor: pointer;
}

.vol-mute-btn {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.pause-volume-box {
  width: 100%;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   Escenario de Vistas (Debajo de la Barra Superior)
   ========================================================================== */
.views-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms var(--ease-snappy);
  z-index: 10;
}

.view.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   Vista 1: Bienvenida (Inicio)
   ========================================================================== */
.welcome-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 22px;
  text-align: center;
  gap: 14px;
  overflow-y: auto;
}

.hero-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-icon-bounce {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.35);
  animation: heroBounce 2.8s ease-in-out infinite;
}

.hero-icon-bounce svg {
  width: 48px;
  height: 48px;
}

@keyframes heroBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.03); }
}

.hero-title {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-main);
}

.hero-subtitle {
  font-size: 0.94rem;
  color: var(--text-muted);
  max-width: 430px;
  line-height: 1.45;
}

.rank-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(79, 70, 229, 0.14));
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.82rem;
  font-weight: 800;
}

.rank-stars-count {
  color: var(--star-gold);
}

.rank-divider {
  color: var(--text-muted);
}

.rank-title {
  color: var(--text-main);
}

.badges-banner {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--success);
}

.welcome-secondary-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  gap: 8px;
}

/* Botones Principales */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
  padding: 15px 24px;
  font-size: 1.08rem;
  font-weight: 800;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #4338CA 100%);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
  transition: transform 160ms var(--ease-snappy), box-shadow 160ms;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.45);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 140ms var(--ease-snappy);
}

.btn-secondary:hover {
  background-color: var(--bg-elevated);
}

.btn-compact {
  padding: 7px 14px;
  font-size: 0.84rem;
}

.btn-share-highlight {
  border-color: rgba(16, 185, 129, 0.45);
  background-color: rgba(16, 185, 129, 0.08);
}

.btn-pill-mobile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background-color: rgba(16, 185, 129, 0.14);
  border: 1px solid var(--success);
  color: var(--success);
  cursor: pointer;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  border-radius: var(--radius-full);
  background-color: #25D366;
  color: #FFFFFF;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.3);
}

.share-buttons-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;
}

/* ==========================================================================
   Vista 2: Selector de Canciones y Filtros
   ========================================================================== */
.song-select-header {
  padding: 12px 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.catalog-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.catalog-search-input {
  width: 100%;
  padding: 8px 34px 8px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 600;
  outline: none;
  transition: border-color 140ms;
}

.catalog-search-input:focus {
  border-color: var(--accent-primary);
}

.btn-clear-search {
  position: absolute;
  right: 22px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background-color: var(--border-subtle);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.catalog-pending-banner {
  margin: 8px 16px 0;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.38);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-filters-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  scrollbar-width: none;
}

.category-filters-container::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms var(--ease-snappy);
}

.cat-pill.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.song-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.song-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 160ms var(--ease-snappy), border-color 160ms, box-shadow 160ms;
}

.song-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.song-card:active {
  transform: scale(0.98);
}

.song-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.song-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.song-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.song-author {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.song-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.diff-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: #FFFFFF;
}

.stars-display {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.song-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.score-badge {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
}

.play-action-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Modal: Ficha de Canción, Ranking Top y Selector de Dificultad
   ========================================================================== */
.modal-song-card {
  max-width: 430px;
  padding: 20px;
}

.song-details-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.song-avatar-large {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.song-details-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

/* Barra compacta de apodo del jugador en el catálogo */
.player-name-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 16px;
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.player-name-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
}

.player-name-label-muted {
  color: var(--text-muted);
  font-weight: 700;
}

.player-name-value {
  flex: 1;
  color: var(--text-main);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-name-pill,
.song-lb-player-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--accent-primary);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.player-name-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.player-name-input {
  flex: 1;
  min-width: 0;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 600;
  outline: none;
}

.player-name-input:focus {
  border-color: var(--accent-primary);
}

.btn-name-save {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

/* Ranking Top Jugadores dentro del Modal de Canción */
.song-leaderboard-box {
  width: 100%;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.song-lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.song-lb-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.song-lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 152px;
  overflow-y: auto;
  padding-right: 2px;
}

.song-lb-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.77rem;
}

.song-lb-row.is-me {
  border-color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.song-lb-rank {
  font-weight: 900;
  text-align: center;
  color: var(--text-muted);
}

.song-lb-name {
  font-weight: 800;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-lb-score {
  font-weight: 900;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.song-lb-combo {
  font-weight: 800;
  color: #F59E0B;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
}

.song-lb-pct {
  font-weight: 800;
  color: var(--success);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
}

.song-lb-empty {
  text-align: center;
  padding: 10px 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Caja de estado / ingreso rápido de nombre en Game Over y Victoria */
.run-lb-box {
  width: 100%;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  font-size: 0.80rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.run-lb-status {
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-player-name-card {
  max-width: 390px;
}

.welcome-name-input {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.96rem;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius-md);
}

.welcome-name-error {
  width: 100%;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--danger);
  text-align: center;
}

.modal-diff-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.mode-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mode-card {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 12px;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 150ms var(--ease-snappy);
  text-align: left;
  gap: 10px;
}

.mode-card:hover {
  border-color: var(--accent-primary);
}

.mode-card.selected {
  border-color: var(--accent-primary);
  background-color: rgba(79, 70, 229, 0.09);
}

[data-theme="neon"] .mode-card.selected {
  background-color: rgba(99, 102, 241, 0.18);
  border-color: var(--accent-secondary);
}

.mode-icon-svg {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.mode-card-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.mode-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
}

.mode-desc {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.diff-score-preview {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent-primary);
  white-space: nowrap;
}

/* ==========================================================================
   Vista 3: Pantalla de Juego (HUD & Canvas 4 Carriles)
   ========================================================================== */
#view-game {
  background-color: var(--lane-bg);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  pointer-events: none;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: linear-gradient(180deg, rgba(9,13,24,0.97) 0%, rgba(9,13,24,0.88) 76%, rgba(9,13,24,0) 100%);
  padding-bottom: 10px;
}

.game-hud-top {
  display: grid;
  grid-template-columns: 34px minmax(0, 1.35fr) auto minmax(0, 0.85fr);
  align-items: center;
  gap: 6px;
  padding: 6px 10px 4px;
  pointer-events: auto;
  width: 100%;
  min-width: 0;
}

.game-hud-top * {
  white-space: nowrap;
}

.hud-pause-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  flex-shrink: 0;
}

.hud-score-cluster {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.hud-score {
  font-size: clamp(0.92rem, 3.8vw, 1.25rem);
  font-weight: 900;
  color: #FFFFFF;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hud-combo-tag {
  font-size: clamp(0.68rem, 2.5vw, 0.78rem);
  font-weight: 800;
  color: #FCD34D;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  flex-shrink: 0;
}

.hud-mode-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background-color: rgba(255,255,255,0.10);
  color: #E2E8F0;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.song-progress-bar {
  position: relative;
  width: 100%;
  height: 7px;
  margin-top: 2px;
  background-color: rgba(255,255,255,0.22);
  overflow: visible;
}

.song-progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

.progress-milestones {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ms-badge {
  position: absolute;
  top: -3px;
  transform: translateX(-50%) scale(0.82);
  font-size: 0.78rem;
  filter: grayscale(1) opacity(0.5);
  transition: transform 240ms var(--ease-snappy), filter 240ms;
}

.ms-badge.unlocked {
  filter: grayscale(0) opacity(1) drop-shadow(0 0 6px rgba(245, 158, 11, 0.9));
  transform: translateX(-50%) scale(1.22);
}

.sync-calib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sync-calib-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.countdown-song-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #F8FAFC;
  margin-top: 10px;
}

.countdown-diff-badge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #FFFFFF;
  margin-top: 6px;
}

/* ==========================================================================
   Modales
   ========================================================================== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms var(--ease-snappy);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  max-height: 92vh;
  overflow-y: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-lg);
  gap: 12px;
  transform: translateY(15px);
  transition: transform 240ms var(--ease-snappy);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.modal-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;
}

.qr-desktop-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.qr-box {
  width: 170px;
  height: 170px;
  background-color: #FFFFFF;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-box svg {
  width: 100%;
  height: 100%;
}

.mobile-url-box {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.mobile-url-text {
  flex: 1;
  background: transparent;
  border: none;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-main);
  outline: none;
}

.results-stars {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
}

.results-stars svg {
  width: 44px;
  height: 44px;
}

.results-stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text-main);
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

/* ==========================================================================
   Indicador de Velocidad Progresiva y Banner en Juego
   ========================================================================== */
.hud-speed-pill {
  font-size: clamp(0.68rem, 2.4vw, 0.74rem);
  font-weight: 800;
  padding: 4px 7px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.90), rgba(239, 68, 68, 0.90));
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.speed-banner-overlay {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms var(--ease-snappy), transform 220ms var(--ease-snappy);
}

.speed-banner-overlay.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* ==========================================================================
   Modal: Agregar Canción (Buscador Online + Subir Archivo MP3)
   ========================================================================== */
.btn-pill-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
}

.btn-add-highlight {
  border-color: var(--accent-secondary);
  background-color: rgba(6, 182, 212, 0.1);
}

.add-song-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.search-bar-row {
  display: flex;
  gap: 6px;
  width: 100%;
}

.search-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-primary);
}

.btn-search-go {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: none;
  background-color: var(--accent-primary);
  color: #FFFFFF;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}

.search-results-list {
  width: 100%;
  max-height: min(42vh, 330px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0;
}

.search-empty-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 8px;
  background-color: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.search-result-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--bg-surface);
}

.search-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-result-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-artist {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-add-result {
  padding: 6px 11px;
  border-radius: var(--radius-full);
  border: none;
  background-color: var(--success);
  color: #FFFFFF;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--accent-primary);
  background-color: rgba(79, 70, 229, 0.08);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.upload-status-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}


/* ==========================================================================
   Contador 3 - 2 - 1 antes de iniciar o reanudar (GPU-accelerated)
   ========================================================================== */
.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: rgba(8, 12, 24, 0.42);
  transition: opacity 150ms ease, visibility 150ms ease;
}

.countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.countdown-number {
  font-size: clamp(4.2rem, 18vw, 6.2rem);
  font-weight: 900;
  color: #FFFFFF;
  letter-spacing: -0.04em;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  will-change: transform, opacity;
  transform: scale(0.7);
  opacity: 0;
}

.countdown-number.pop {
  animation: countdownPop 620ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.countdown-number.go {
  font-size: clamp(3rem, 13vw, 4.4rem);
  color: #34D399;
}

@keyframes countdownPop {
  0% {
    transform: scale(1.45);
    opacity: 0;
  }
  25% {
    transform: scale(1.0);
    opacity: 1;
  }
  80% {
    transform: scale(0.96);
    opacity: 1;
  }
  100% {
    transform: scale(0.84);
    opacity: 0;
  }
}

/* ==========================================================================
   Overlay "Analizando canción…", Calibrador Metrónomo y Debug Audit
   ========================================================================== */
.analyzing-overlay {
  position: absolute;
  inset: 0;
  z-index: 48;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 13, 24, 0.92);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.analyzing-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.analyzing-card {
  width: 100%;
  max-width: 310px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
}

.modal-song-pill {
  display: inline-block;
  max-width: 100%;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.piano-loader {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 44px;
  padding: 4px 8px;
}

.piano-key {
  width: 11px;
  height: 36px;
  border-radius: 3px 3px 5px 5px;
  background: linear-gradient(180deg, #38BDF8 0%, #6366F1 100%);
  transform-origin: top center;
  animation: pianoWave 1.05s infinite ease-in-out;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35);
}

.piano-key:nth-child(1) { animation-delay: 0s; background: linear-gradient(180deg, #38BDF8, #0284C7); }
.piano-key:nth-child(2) { animation-delay: 0.14s; background: linear-gradient(180deg, #34D399, #059669); }
.piano-key:nth-child(3) { animation-delay: 0.28s; background: linear-gradient(180deg, #FBBF24, #D97706); }
.piano-key:nth-child(4) { animation-delay: 0.42s; background: linear-gradient(180deg, #F472B6, #DB2777); }
.piano-key:nth-child(5) { animation-delay: 0.56s; background: linear-gradient(180deg, #A78BFA, #6366F1); }

@keyframes pianoWave {
  0%, 100% { transform: scaleY(0.58) translateY(0); opacity: 0.65; }
  45% { transform: scaleY(1.0) translateY(-3px); opacity: 1; }
}

.analyzing-progress-track {
  width: 100%;
  height: 9px;
  border-radius: 99px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.analyzing-progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 90ms linear;
}

.debug-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  padding: 4px 2px;
}

.calib-beat-dot {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 3px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  transition: transform 90ms ease, background-color 90ms ease, color 90ms ease;
}

.calib-beat-dot.flash {
  transform: scale(1.22);
  background: var(--accent-primary);
  border-color: #FFFFFF;
  color: #FFFFFF;
}

.audit-table-wrap {
  width: 100%;
  max-height: 250px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  text-align: left;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
}

.audit-table th, .audit-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  font-weight: 800;
}

.sr-haptic-hook {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

#view-game.climax-fire-active .hud-score {
  color: #FEF08A;
  text-shadow: 0 0 14px rgba(251, 146, 60, 0.9), 0 2px 8px rgba(0, 0, 0, 0.75);
}

#view-game.climax-fire-active .hud-combo-tag {
  color: #FB923C;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.85);
}

#view-game.climax-fire-active .song-progress-fill {
  background: linear-gradient(90deg, #F97316, #FBBF24, #EF4444);
  box-shadow: 0 0 12px rgba(251, 146, 60, 0.75);
}

#view-game.climax-fire-active .hud-speed-badge {
  border-color: rgba(251, 146, 60, 0.85);
  background-color: rgba(234, 88, 12, 0.30);
  color: #FEF08A;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.55);
  animation: hudFirePulse 0.68s infinite alternate ease-in-out;
}

@keyframes hudFirePulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* Notificación flotante no intrusiva de descarga / canción lista */
.song-request-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 68px);
  left: 50%;
  transform: translateX(-50%) translateY(-18px);
  width: min(92vw, 430px);
  z-index: 260;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #F8FAFC;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms var(--ease-snappy);
}

.song-request-toast.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.song-request-toast.ready {
  border-color: rgba(52, 211, 153, 0.85);
  box-shadow: 0 14px 36px rgba(16, 185, 129, 0.32);
}

.song-toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.song-toast-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.song-toast-text-wrap {
  flex: 1;
  min-width: 0;
}

.song-toast-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.25;
}

.song-toast-sub {
  font-size: 0.76rem;
  color: #CBD5E1;
  line-height: 1.3;
  margin-top: 2px;
}

.song-toast-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-toast-play {
  padding: 6px 13px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  font-size: 0.80rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-toast-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
