/* ============================================================
   Piano Mágica — hoja de estilos
   Diseño infantil: colores alegres, botones grandes, mucho aire.
   ============================================================ */

:root {
  --violeta: #2563eb;
  --violeta-oscuro: #1e40af;
  --rosa: #06b6d4;
  --amarillo: #fbbf24;
  --verde: #22c55e;
  --celeste: #38bdf8;
  --naranja: #fb923c;
  --rojo: #ef4444;
  --fondo: #eff6ff;
  --fondo-2: #dbeafe;
  --texto: #1e3a8a;
  --texto-suave: #5b6b8c;
  --blanco: #ffffff;
  --sombra: 0 6px 20px rgba(37, 99, 235, 0.14);
  --radio: 22px;
  --fuente: "Comic Sans MS", "Chalkboard SE", "Segoe UI Rounded", "Baloo 2",
    system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--fuente);
  background: linear-gradient(160deg, #eff6ff 0%, #ecfeff 55%, #f0f9ff 100%);
  background-attachment: fixed;
  color: var(--texto);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Header ---------- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--violeta), var(--rosa));
  box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.brand-emoji { font-size: 1.6rem; }

.header-right { display: flex; align-items: center; gap: 10px; }

.stars-pill {
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.55);
  color: #fff;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 1rem;
  white-space: nowrap;
}

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.main-nav a:hover, .main-nav a.activo { background: rgba(255,255,255,0.25); }

/* ---------- Layout principal ---------- */

#app {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 90px;
}

.vista { animation: aparecer 0.25s ease-out; }
@keyframes aparecer {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1.titulo-vista {
  font-size: 1.7rem;
  text-align: center;
  margin: 8px 0 4px;
  color: var(--violeta-oscuro);
}
.subtitulo {
  text-align: center;
  color: var(--texto-suave);
  font-size: 1.05rem;
  margin-bottom: 18px;
}

/* ---------- Tarjetas ---------- */

.card {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
  margin-bottom: 16px;
}

.card-centro { text-align: center; }

.grid-lecciones, .grid-practica {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 16px;
  text-decoration: none;
  color: var(--texto);
  border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.lesson-card:hover { transform: translateY(-3px); border-color: var(--violeta); }
.lesson-card .lesson-emoji {
  font-size: 2.4rem;
  background: var(--fondo-2);
  border-radius: 18px;
  padding: 10px;
  line-height: 1;
}
.lesson-card h3 { font-size: 1.08rem; color: var(--violeta-oscuro); }
.lesson-card p { font-size: 0.88rem; color: var(--texto-suave); margin-top: 2px; }
.lesson-card .lesson-estado { margin-left: auto; font-size: 1.3rem; }
.lesson-card.completada { border-color: var(--verde); }
.lesson-card.completada .lesson-emoji { background: #dcfce7; }

.practice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 22px 14px;
  text-decoration: none;
  color: var(--texto);
  border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  text-align: center;
}
.practice-card:hover { transform: translateY(-3px); border-color: var(--rosa); }
.practice-card .p-emoji { font-size: 2.6rem; }
.practice-card h3 { color: var(--violeta-oscuro); font-size: 1.05rem; }
.practice-card p { font-size: 0.85rem; color: var(--texto-suave); }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--fuente);
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--violeta), var(--rosa));
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(91, 33, 182, 0.55);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  text-decoration: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(91,33,182,0.55); }
.btn:disabled { filter: grayscale(0.7) opacity(0.6); cursor: not-allowed; transform: none; }

.btn-grande { font-size: 1.3rem; padding: 18px 36px; }
.btn-verde { background: linear-gradient(135deg, #16a34a, #22c55e); box-shadow: 0 5px 0 rgba(21,101,52,0.55); }
.btn-amarillo { background: linear-gradient(135deg, #d97706, var(--amarillo)); box-shadow: 0 5px 0 rgba(146,64,14,0.55); }
.btn-celeste { background: linear-gradient(135deg, #0284c7, var(--celeste)); box-shadow: 0 5px 0 rgba(7,89,133,0.55); }
.btn-rojo { background: linear-gradient(135deg, #dc2626, var(--rojo)); box-shadow: 0 5px 0 rgba(153,27,27,0.55); }
.btn-fantasma {
  background: #fff;
  color: var(--violeta-oscuro);
  border: 3px solid var(--violeta);
  box-shadow: 0 5px 0 rgba(124,58,237,0.3);
}

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

/* ---------- Texto e instrucciones ---------- */

.instruccion {
  font-size: 1.35rem;
  text-align: center;
  line-height: 1.6;
  color: var(--texto);
  margin: 12px 0 18px;
}
.instruccion strong { color: var(--violeta-oscuro); }

.texto-suave { color: var(--texto-suave); font-size: 0.95rem; text-align: center; }

.aviso-privacidad {
  background: #ecfeff;
  border: 2px solid var(--celeste);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: #155e75;
  margin: 12px 0;
  line-height: 1.45;
}

/* ---------- Motor de lecciones ---------- */

.lesson-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.lesson-topbar .btn-atras {
  background: #fff;
  border: 2px solid var(--violeta);
  color: var(--violeta-oscuro);
  border-radius: 999px;
  font-family: var(--fuente);
  font-weight: 800;
  font-size: 1rem;
  padding: 8px 16px;
  cursor: pointer;
}
.btn-escuchar {
  background: linear-gradient(135deg, var(--amarillo), var(--naranja));
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(146, 64, 14, 0.5);
  transition: transform 0.1s;
  flex-shrink: 0;
}
.btn-escuchar:active { transform: scale(0.92); }
.lesson-puntos { display: flex; gap: 6px; flex: 1; justify-content: center; }
.lesson-puntos .punto {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #ddd6fe;
  border: 2px solid #c4b5fd;
}
.lesson-puntos .punto.actual { background: var(--violeta); border-color: var(--violeta-oscuro); transform: scale(1.25); }
.lesson-puntos .punto.hecho { background: var(--verde); border-color: #15803d; }

.step-footer { display: flex; justify-content: center; margin-top: 20px; }

.pregunta-quiz {
  text-align: center;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--violeta-oscuro);
  margin: 12px 0;
  min-height: 2.2rem;
}

.feedback-linea {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  min-height: 1.8rem;
  margin: 8px 0;
}
.feedback-linea.bien { color: var(--verde); }
.feedback-linea.mal { color: var(--rojo); }

.opciones-quiz { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

.marcador-rondas { text-align: center; color: var(--texto-suave); font-weight: 700; margin-bottom: 4px; }

/* ---------- Componentes SVG de guitarra ---------- */

.svg-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0;
  overflow-x: auto;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-radius: 20px;
  border: 3px solid #fde68a;
  padding: 14px 10px;
}
.svg-wrap svg { max-width: 100%; height: auto; }

/* Icono de paso en burbuja de color */
.paso-icono {
  width: 88px;
  height: 88px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fde68a, #fbcfe8);
  border: 4px solid #fff;
  box-shadow: 0 6px 16px rgba(236, 72, 153, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  line-height: 1;
}

.cuerda-zona { cursor: pointer; }
.cuerda-zona:hover .cuerda-linea { filter: brightness(1.4); }
.cuerda-vibrando { animation: vibrar 0.4s linear; }
@keyframes vibrar {
  0%,100% { transform: translateY(0); }
  25% { transform: translateY(-2.5px); }
  75% { transform: translateY(2.5px); }
}

/* ---------- Afinador ---------- */

.tuner-panel { text-align: center; }

.tuner-nota-grande {
  font-size: 4.2rem;
  font-weight: 900;
  color: var(--violeta-oscuro);
  line-height: 1.1;
}
.tuner-hz { font-size: 1.3rem; color: var(--texto-suave); font-weight: 700; margin-bottom: 10px; }

.gauge {
  position: relative;
  height: 74px;
  margin: 18px auto 6px;
  max-width: 460px;
}
.gauge-barra {
  position: absolute;
  left: 0; right: 0; top: 30px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--rojo) 0%, var(--naranja) 22%, var(--amarillo) 38%,
    var(--verde) 47%, var(--verde) 53%,
    var(--amarillo) 62%, var(--naranja) 78%, var(--rojo) 100%);
}
.gauge-centro {
  position: absolute;
  left: 50%; top: 22px;
  width: 4px; height: 30px;
  margin-left: -2px;
  background: var(--violeta-oscuro);
  border-radius: 2px;
}
.gauge-aguja {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 34px; height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--violeta);
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  transition: left 0.12s ease-out, border-color 0.2s, background 0.2s;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.gauge-aguja.afinada { border-color: var(--verde); background: #dcfce7; }
.gauge-labels {
  display: flex; justify-content: space-between;
  max-width: 460px; margin: 4px auto 0;
  font-size: 0.78rem; font-weight: 800; color: var(--texto-suave);
}
.gauge-labels .ok { color: var(--verde); }

.tuner-cuerdas-botones { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.tuner-cuerda-btn {
  font-family: var(--fuente);
  font-weight: 800;
  font-size: 1rem;
  border-radius: 14px;
  border: 3px solid var(--violeta);
  background: #fff;
  color: var(--violeta-oscuro);
  padding: 8px 12px;
  cursor: pointer;
  min-width: 64px;
}
.tuner-cuerda-btn .sub { display: block; font-size: 0.7rem; color: var(--texto-suave); }
.tuner-cuerda-btn.activa { background: var(--violeta); color: #fff; }
.tuner-cuerda-btn.activa .sub { color: #e9d5ff; }
.tuner-cuerda-btn.afinada { border-color: var(--verde); background: #dcfce7; color: #14532d; }

.tuner-estado { font-size: 1.25rem; font-weight: 800; min-height: 1.9rem; margin-top: 6px; }
.tuner-estado.bajo { color: var(--naranja); }
.tuner-estado.alto { color: var(--rojo); }
.tuner-estado.perfecto { color: var(--verde); }

/* Medidor de nivel de micrófono: "te estoy escuchando" */
.mic-nivel { display: flex; align-items: center; gap: 10px; margin: 10px auto 0; max-width: 320px; }
.mic-nivel-ico { font-size: 1.3rem; }
.mic-nivel-barra {
  position: relative; flex: 1; height: 14px; border-radius: 999px;
  background: #ede9fe; border: 2px solid #ddd6fe; overflow: hidden;
}
.mic-nivel-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  transition: width 90ms linear;
}
.mic-nivel-fill.activo { background: linear-gradient(90deg, #34d399, #10b981); }
.mic-nivel-min {
  position: absolute; top: -2px; bottom: -2px; left: 5%; width: 2px;
  background: rgba(124, 58, 237, 0.45);
}

/* ---------- Canción (timeline) ---------- */

.song-timeline {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px 0;
}
.song-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: 3px solid #ddd6fe;
  border-radius: 16px;
  padding: 10px 12px;
  min-width: 76px;
  font-weight: 800;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.song-step .s-icon { font-size: 1.6rem; }
.song-step .s-name { font-size: 1.05rem; color: var(--violeta-oscuro); }
.song-step .s-pos { font-size: 0.72rem; color: var(--texto-suave); font-weight: 700; }
.song-step.actual {
  border-color: var(--rosa);
  background: #fdf2f8;
  transform: scale(1.12);
  box-shadow: 0 6px 16px rgba(236,72,153,0.3);
}
.song-step.hecho { border-color: var(--verde); background: #f0fdf4; }
.song-flecha { align-self: center; font-size: 1.3rem; color: var(--texto-suave); }

/* ---------- Metrónomo / ritmo ---------- */

.metro-circulo {
  width: 150px; height: 150px;
  margin: 16px auto;
  border-radius: 50%;
  background: var(--fondo-2);
  border: 6px solid var(--violeta);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem;
  transition: transform 0.07s;
}
.metro-circulo.pulso { transform: scale(1.14); background: #fbcfe8; border-color: var(--rosa); }
.metro-bpm { text-align: center; font-weight: 800; font-size: 1.2rem; color: var(--violeta-oscuro); }

input[type="range"].slider-bpm {
  width: 100%;
  max-width: 320px;
  accent-color: var(--violeta);
  height: 34px;
}

/* ---------- Progreso / gamificación ---------- */

.progress-resumen {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px 0;
}
.progress-item {
  background: var(--blanco);
  border-radius: 18px;
  box-shadow: var(--sombra);
  padding: 14px 20px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--violeta-oscuro);
  text-align: center;
}
.progress-item .pi-icon { display: block; font-size: 1.8rem; }

.badges-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.badge-chip {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid var(--amarillo);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 0.9rem;
  color: #92400e;
}

/* ---------- Dificultad ---------- */

.dificultad-row { display: flex; gap: 8px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.dif-btn {
  font-family: var(--fuente);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 999px;
  border: 3px solid #c4b5fd;
  background: #fff;
  color: var(--violeta-oscuro);
  padding: 8px 16px;
  cursor: pointer;
}
.dif-btn.activa { background: var(--violeta); border-color: var(--violeta); color: #fff; }

/* ---------- Celebración ---------- */

.celebracion-box { text-align: center; padding: 20px 0; }
.celebracion-box .c-emoji { font-size: 4.5rem; display: block; animation: rebote 0.9s ease infinite alternate; }
@keyframes rebote { from { transform: translateY(0) scale(1);} to { transform: translateY(-12px) scale(1.08);} }
.celebracion-box h2 { color: var(--violeta-oscuro); font-size: 1.8rem; margin: 10px 0; }
.celebracion-box .estrellas-ganadas { font-size: 2rem; letter-spacing: 6px; }

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}
.confetto {
  position: absolute;
  top: -40px;
  font-size: 1.6rem;
  animation: caer linear forwards;
}
@keyframes caer {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(80px);
  background: var(--violeta-oscuro);
  color: #fff;
  font-weight: 800;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 998;
  max-width: 90vw;
  text-align: center;
}
#toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- Ilustración "cómo sostener" ---------- */

.postura-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.postura-item {
  background: var(--fondo-2);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
}
.postura-item .p-emoji { font-size: 2.2rem; display: block; margin-bottom: 6px; }

/* ---------- Instalar PWA ---------- */

.install-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, #fdf4ff, #eff6ff);
  border: 2px dashed var(--violeta);
  border-radius: var(--radio);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.install-banner p { flex: 1; font-size: 0.92rem; font-weight: 700; color: var(--violeta-oscuro); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .brand-name { display: none; }
  .nav-label { display: none; }
  .main-nav a { font-size: 1.25rem; padding: 7px 10px; }
  h1.titulo-vista { font-size: 1.4rem; }
  .tuner-nota-grande { font-size: 3.2rem; }
  .btn { font-size: 1rem; padding: 13px 22px; }
  .btn-grande { font-size: 1.15rem; padding: 16px 28px; }
  #app { padding: 14px 10px 80px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   Piano Mágica — estilos específicos del teclado
   ============================================================ */

.teclado-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 4px;
  border-radius: var(--radio);
  background: linear-gradient(180deg, #334155, #1e293b);
  box-shadow: var(--sombra);
}

.teclado { display: block; width: 100%; min-width: 560px; height: auto; }

.tecla-blanca, .tecla-negra { transition: fill 120ms ease, filter 120ms ease; }
.tecla-pulsada { filter: brightness(0.82) saturate(1.4); }

.tecla-hl { animation: tecla-brillo 1.1s ease-in-out infinite; }
@keyframes tecla-brillo {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.9)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 255, 255, 1)); }
}

/* Chip de nota con color (para canciones y listas) */
.nota-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; background: #fff;
  border: 3px solid var(--chip-color, #cbd5e1);
  font-weight: 800; color: var(--texto);
}
.nota-chip .punto-color {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--chip-color, #cbd5e1);
}

/* Línea de tiempo de canción (reutiliza .song-timeline y .song-step del tema base) */
.song-step .s-color {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
}

/* Leyenda de colores de notas */
.leyenda-notas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }

/* Mano con dedos numerados */
.mano-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 12px 0; }
.mano-dedo {
  background: #fff; border-radius: 16px; padding: 10px; text-align: center;
  box-shadow: var(--sombra); font-weight: 700; color: var(--texto);
}
.mano-dedo .d-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; margin-bottom: 4px;
  color: #fff; font-weight: 900; font-size: 1.1rem;
}
