/* Karaoke - estilos del módulo de karaoke */
:root {
  --bg-0: #0b0a1a;
  --bg-2: #1d1842;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f2ff;
  --muted: #a8a3c9;
  --dim: #77729b;
  --accent: #ff8a65;
  --accent-2: #ffd166;
  --lav: #9d8cff;
  --pink: #ff7aa8;
  --ok: #5ee6a8;
  --err: #ff7a8a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --top-h: 76px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Montserrat', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(40% 35% at 20% 15%, rgba(157, 140, 255, 0.22), transparent 70%),
    radial-gradient(35% 30% at 85% 25%, rgba(255, 122, 168, 0.16), transparent 70%),
    radial-gradient(45% 40% at 50% 100%, rgba(255, 138, 101, 0.14), transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
input { font: inherit; }

.screen { position: fixed; inset: 0; z-index: 2; display: none; }
.screen.active { display: block; animation: screenIn 0.45s ease; }

.eyebrow {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: #c9bfff;
}

.back-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 14px;
  border-radius: 999px;
  transition: 0.2s;
  white-space: nowrap;
}
.back-link:hover { color: var(--text); background: var(--glass); }

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--lav);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  display: none;
  flex: none;
}
.spinner.on { display: block; }

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-size: 1.25rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(255, 122, 168, 0.35);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.start-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(255, 122, 168, 0.5); }
.start-btn:disabled { opacity: 0.4; box-shadow: none; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  transition: 0.2s;
}
.ghost-btn:hover { background: var(--glass-strong); border-color: rgba(255, 255, 255, 0.22); }

/* ---------- 1. Búsqueda ---------- */
#screenSearch { display: none; flex-direction: column; }
#screenSearch.active { display: flex; }

.search-top {
  position: relative;
  z-index: 1;
  flex: none;
  height: var(--top-h);
  display: grid;
  grid-template-columns: 1fr minmax(0, 640px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.top-right { display: flex; justify-content: flex-end; }
.lite-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: 0.2s;
}
.lite-btn:hover { color: var(--text); background: var(--glass); }
.lite-btn.on { color: var(--accent-2); border-color: rgba(255, 209, 102, 0.5); background: rgba(255, 209, 102, 0.1); }

.search-box {
  display: flex;
  align-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 6px 3px 20px;
  box-shadow: var(--shadow);
  transition: 0.25s;
}
.search-box:focus-within { border-color: rgba(157, 140, 255, 0.6); box-shadow: 0 0 0 4px rgba(157, 140, 255, 0.15), var(--shadow); }
.search-box > i { color: var(--muted); font-size: 1.1rem; }
.search-box input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 1.05rem;
  padding: 12px;
}
.search-box input::placeholder { color: var(--dim); }
.search-box input::-webkit-search-cancel-button { display: none; }

.icon-btn { width: 38px; height: 38px; border-radius: 50%; color: var(--muted); display: grid; place-items: center; font-size: 1.05rem; flex: none; }
.icon-btn:hover { background: var(--glass); color: var(--text); }

.search-intro { position: relative; z-index: 1; text-align: center; margin: auto; padding: 0 16px 10vh; }
.search-intro h1 { font-family: 'Oswald', sans-serif; font-weight: 700; font-size: clamp(2rem, 5vw, 3.4rem); margin: 12px 0 8px; }
.search-intro h1 span {
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.search-intro p { color: var(--muted); margin: 0 0 22px; }
body.has-results .search-intro { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; margin: 0 auto; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  transition: 0.2s;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); transform: translateY(-1px); }

.search-status { position: relative; z-index: 1; text-align: center; color: var(--muted); flex: none; }
.search-status:empty { display: none; }
.search-status:not(:empty) { margin: auto; padding-bottom: 10vh; }

/* Las columnas y el tamaño de las tarjetas los calcula karaoke.js para que quepan sin scroll */
.results-grid {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 14px;
  justify-content: center;
  align-content: center;
  padding: 4px 16px 20px;
  overflow-y: auto;
}
.results-grid:empty { display: none; }

.song-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-2);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  animation: cardIn 0.4s ease both;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.song-card:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, 0.3); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5); }
.song-card:focus-visible { outline: 3px solid var(--lav); outline-offset: 2px; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } }

.song-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.song-card:hover img { transform: scale(1.05); }

.card-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 12px 12px;
  background: linear-gradient(transparent, rgba(8, 7, 20, 0.92));
}
.card-info h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-info p { margin: 2px 0 0; font-size: 0.82rem; color: var(--accent-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-info small { font-size: 0.72rem; color: var(--muted); }

.play-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(10, 8, 25, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  transition: 0.2s;
}
.play-preview:hover, .play-preview.playing { background: var(--accent); transform: scale(1.08); }

.preview-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.preview-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ---------- 2. Confirmar canción ---------- */
.detail-bg {
  position: fixed;
  inset: -60px;
  background-size: cover;
  background-position: center;
  filter: blur(50px) saturate(1.3) brightness(0.45);
  z-index: 0;
}

.detail-layout { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 0 24px 24px; }
.detail-top { flex: none; height: 64px; display: flex; align-items: center; }

.detail-main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: clamp(20px, 3vw, 44px);
  align-items: center;
  justify-content: center;
}

/* Portada cuadrada limitada por el alto disponible */
.detail-cover {
  position: relative;
  flex: none;
  width: min(calc(100vh - 120px), 42vw, 560px);
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-cover.playing img { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }

.big-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 4rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.25s;
}
.detail-cover:hover .big-play { opacity: 1; }

.detail-info {
  flex: 1;
  max-width: 620px;
  min-width: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.8vh, 18px);
  overflow-y: auto;
}
.detail-info h2 { font-family: 'Oswald', sans-serif; font-size: clamp(1.7rem, 3.4vw, 2.6rem); margin: 0 0 2px; line-height: 1.1; }
.detail-info .artist { color: var(--accent-2); font-weight: 700; font-size: 1.1rem; margin: 0; }
.detail-info .album { color: var(--muted); margin: 2px 0 0; font-size: 0.88rem; }

.preview-player {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 14px 8px 8px;
}
.round-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex: none;
  transition: 0.2s;
}
.round-btn:hover { transform: scale(1.07); }
.preview-track { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; cursor: pointer; }
.preview-track > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; }
#previewTime { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.check-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  min-width: 0;
}
.check-item > div { min-width: 0; }
.check-item strong { display: block; font-size: 0.88rem; }
.check-item small { color: var(--muted); font-size: 0.78rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-icon { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 0.9rem; }
.check-item[data-state="loading"] .check-icon { border: 2.5px solid rgba(255, 255, 255, 0.15); border-top-color: var(--lav); animation: spin 0.8s linear infinite; }
.check-item[data-state="ok"] .check-icon { background: rgba(94, 230, 168, 0.18); color: var(--ok); }
.check-item[data-state="warn"] .check-icon { background: rgba(255, 209, 102, 0.18); color: var(--accent-2); }
.check-item[data-state="error"] .check-icon { background: rgba(255, 122, 138, 0.18); color: var(--err); }
.check-item[data-state="info"] .check-icon { background: rgba(157, 140, 255, 0.2); color: #cfc6ff; }
.check-item > div { flex: 1; }

.mini-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: rgba(157, 140, 255, 0.18);
  color: #ddd6ff;
  font-size: 0.85rem;
  transition: 0.2s;
}
.mini-btn:hover { background: var(--lav); color: #120f2a; }
.mini-btn:disabled { opacity: 0.5; }

.detail-actions { display: flex; gap: 10px; }
.detail-actions .start-btn { flex: 1; }
.ghost-btn.on { background: rgba(94, 230, 168, 0.15); border-color: rgba(94, 230, 168, 0.5); color: var(--ok); }

.track-picker { display: flex; flex-direction: column; gap: 10px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.picker-controls { display: flex; align-items: center; gap: 12px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); transition: 0.25s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: 0.25s; }
.switch input:checked + .switch-track { background: var(--lav); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--lav); outline-offset: 2px; }
.switch:has(input:checked) { color: var(--text); }
.section-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); }
.segmented button { padding: 6px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 0.82rem; transition: 0.2s; }
.segmented button.active { background: var(--lav); color: #120f2a; }

/* Pistas en cuadritos */
.video-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; min-height: 60px; }
.video-options.loading::before {
  content: '';
  grid-column: 1 / -1;
  height: 100px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--glass) 0%, var(--glass-strong) 50%, var(--glass) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.video-opt {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-2);
  border: 2px solid transparent;
  text-align: left;
  transition: 0.2s;
}
.video-opt:hover { border-color: rgba(255, 255, 255, 0.3); }
.video-opt.active { border-color: var(--lav); box-shadow: 0 0 0 3px rgba(157, 140, 255, 0.25); }
.video-opt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-opt .opt-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 7px 6px;
  background: linear-gradient(transparent, rgba(8, 7, 20, 0.95));
}
.video-opt strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
}
.video-opt small { font-size: 0.65rem; color: var(--muted); }
.video-opt .opt-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--lav);
  color: #120f2a;
  display: none;
  place-items: center;
  font-size: 0.8rem;
}
.video-opt.active .opt-check { display: grid; }

.manual-row { display: flex; gap: 8px; }
.manual-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 9px 14px;
  font-size: 0.88rem;
  outline: 0;
}
.manual-row input::placeholder { color: var(--dim); }
.manual-row input:focus { border-color: rgba(157, 140, 255, 0.6); }
.manual-row button { padding: 9px 18px; border-radius: 12px; background: var(--glass-strong); font-weight: 600; font-size: 0.88rem; }

@media (max-width: 1100px) {
  .check-row { grid-template-columns: 1fr 1fr; }
  .check-row .check-item:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  #screenDetail.active { overflow-y: auto; }
  .detail-layout { height: auto; min-height: 100%; padding: 0 16px 24px; }
  .detail-main { flex-direction: column; }
  .detail-cover { width: min(70vw, 340px); }
  .detail-info { max-height: none; overflow: visible; width: 100%; }
  .video-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- 3. Escenario ---------- */
.stage-video {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.8s;
}
body.in-game .stage-video { opacity: 1; z-index: 1; }
/* Sin video: el iframe sigue sonando pero invisible, y se muestra la portada animada */
body.in-game.no-video .stage-video { opacity: 0; }
/* Oculto y chico: YouTube baja la calidad y el equipo deja de decodificar video en HD */
body.in-game.no-video .stage-video iframe { width: 240px; height: 240px; min-width: 0; min-height: 0; }
body.in-game::before { display: none; }

.stage-art {
  position: absolute;
  inset: -80px;
  background-size: cover;
  background-position: center;
  filter: blur(60px) saturate(1.4) brightness(0.55);
  opacity: 0;
  transition: opacity 0.8s;
  animation: artDrift 30s ease-in-out infinite alternate;
}
body.no-video .stage-art { opacity: 1; }
@keyframes artDrift {
  from { transform: scale(1.05) rotate(0deg); }
  to { transform: scale(1.25) rotate(6deg); }
}
.stage-video iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw;
  min-height: 100vh;
  min-width: 177.78vh;
  transform: translate(-50%, -50%);
}

#screenGame { z-index: 3; overflow: hidden; }

.stage-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 10, 26, 0.7) 0%, rgba(11, 10, 26, 0.1) 22%, rgba(11, 10, 26, 0.35) 50%, rgba(11, 10, 26, 0.88) 100%);
}

#pitchCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 3; }

.game-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  z-index: 5;
}
.hud-song { display: flex; gap: 12px; align-items: center; min-width: 0; }
.hud-song img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.hud-song div { min-width: 0; }
.hud-song strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-song span { color: var(--muted); font-size: 0.85rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hud-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.score-line { display: flex; align-items: center; gap: 12px; }
.score-bar { width: clamp(140px, 22vw, 300px); height: 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; border: 1px solid var(--line); }
.score-bar div { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--accent-2), var(--ok)); transition: width 0.3s; }
.score-value { font-family: 'Oswald', sans-serif; font-size: 1.7rem; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; min-width: 70px; }
.melody-badge { font-size: 0.7rem; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

.hud-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.hud-btn.on { color: var(--ok); border-color: rgba(94, 230, 168, 0.5); }
.hud-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  backdrop-filter: blur(10px);
  transition: 0.2s;
}
.hud-btn:hover { background: rgba(255, 255, 255, 0.16); }

.offset-ctl { display: flex; align-items: center; gap: 2px; background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 3px; border: 1px solid var(--line); backdrop-filter: blur(10px); }
.offset-ctl button { width: 32px; height: 32px; border-radius: 50%; font-size: 1.1rem; }
.offset-ctl button:hover { background: rgba(255, 255, 255, 0.1); }
.offset-ctl span { font-size: 0.75rem; color: var(--muted); min-width: 78px; text-align: center; font-variant-numeric: tabular-nums; }

/* Letra: línea actual y siguiente, como en Karaoke Party */
.lyrics-panel {
  position: absolute;
  left: 50%;
  bottom: 5vh;
  transform: translateX(-50%);
  width: min(1100px, calc(100% - 32px));
  min-height: 150px;
  z-index: 4;
  text-align: center;
}

.lyric-wait { display: flex; gap: 14px; justify-content: center; height: 16px; margin-bottom: 10px; opacity: 0; transition: opacity 0.3s; }
.lyric-wait.show { opacity: 1; }
.lyric-wait i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); transition: 0.25s; }
.lyric-wait i.on { background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); transform: scale(1.2); }

.lyric-current {
  font-weight: 800;
  font-size: clamp(1.5rem, 3.4vw, 2.8rem);
  line-height: 1.25;
  min-height: 1.25em;
}
.lyric-current.line-in { animation: lineIn 0.35s ease; }
@keyframes lineIn { from { opacity: 0; transform: translateY(10px); } }
.lyric-current .w {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent-2) 0, var(--accent-2) var(--p, 0%), #fff var(--p, 0%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.75));
  transition: transform 0.2s ease;
  white-space: pre;
}
.lyric-current .w.now { transform: translateY(-3px); }
.lyric-next {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  font-size: clamp(1rem, 2vw, 1.4rem);
  min-height: 1.4em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.lyrics-empty { font-size: 1.3rem; color: var(--muted); }

/* ---------- Intro épica ---------- */
.intro {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(40, 30, 90, 0.92), rgba(5, 4, 14, 0.98) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.intro.active { opacity: 1; pointer-events: auto; }
.intro.leaving { opacity: 0; transition: opacity 0.7s ease 0.15s; }

.intro-rays, .finale-rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220vmax;
  height: 220vmax;
  margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(from 0deg, rgba(157, 140, 255, 0.13) 0deg 6deg, transparent 6deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  animation: raysSpin 26s linear infinite;
  opacity: 0;
  transition: opacity 1s;
}
.intro.active .intro-rays { opacity: 1; }
@keyframes raysSpin { to { transform: rotate(360deg); } }

.intro-stage { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 26px; text-align: center; padding: 16px; transition: opacity 0.5s, transform 0.6s; }
.intro.counting .intro-stage { opacity: 0; transform: scale(1.15); filter: blur(6px); }

.intro-cover {
  width: min(38vh, 320px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 90px rgba(157, 140, 255, 0.45);
  opacity: 0;
}
.intro.play .intro-cover { animation: coverIn 1.1s cubic-bezier(0.2, 0.9, 0.25, 1.2) forwards; }
@keyframes coverIn {
  from { opacity: 0; transform: scale(0.4) rotate(-12deg); filter: blur(10px); }
  to { opacity: 1; transform: scale(1) rotate(0); filter: blur(0); }
}

.intro-text > * { opacity: 0; }
.intro-eyebrow { font-family: 'Oswald', sans-serif; letter-spacing: 6px; text-transform: uppercase; color: #cfc6ff; font-size: 0.95rem; }
.intro-text h1 {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  margin: 8px 0 4px;
  line-height: 1.05;
  background: linear-gradient(90deg, #fff, var(--accent-2), var(--pink), #fff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.intro-text p { margin: 0; font-size: clamp(1.1rem, 2.4vw, 1.6rem); color: var(--accent-2); font-weight: 700; }
.intro.play .intro-eyebrow { animation: slideUp 0.6s ease 0.45s forwards; }
.intro.play .intro-text h1 { animation: slideUp 0.7s ease 0.6s forwards, shine 2.6s linear 0.6s infinite; }
.intro.play .intro-text p { animation: slideUp 0.6s ease 0.85s forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); letter-spacing: 0.3em; } to { opacity: 1; transform: none; } }
@keyframes shine { to { background-position: -300% 0; } }

.intro-count {
  position: absolute;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(7rem, 22vw, 14rem);
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-2), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  white-space: nowrap;
}
.intro-count.go { font-size: clamp(3.5rem, 11vw, 8rem); }
.intro-count.tick { animation: countSlam 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.3) forwards; }
@keyframes countSlam {
  0% { opacity: 0; transform: scale(2.6); filter: blur(12px); }
  35% { opacity: 1; transform: scale(1); filter: blur(0); }
  80% { opacity: 1; transform: scale(0.96); }
  100% { opacity: 0; transform: scale(0.7); }
}
.intro-count::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1em;
  height: 1em;
  margin: -0.5em 0 0 -0.5em;
  border-radius: 50%;
  border: 3px solid rgba(255, 209, 102, 0.6);
  opacity: 0;
}
.intro-count.tick::after { animation: ring 0.8s ease-out forwards; }
@keyframes ring { from { opacity: 0.9; transform: scale(0.3); } to { opacity: 0; transform: scale(1.6); } }

.intro-msg { position: absolute; bottom: 14vh; color: var(--muted); margin: 0; opacity: 0; transition: opacity 0.4s; text-align: center; padding: 0 16px; }
.intro.counting .intro-msg { opacity: 1; }

.intro-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.intro.leaving .intro-flash { animation: flash 0.7s ease-out; }
@keyframes flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }

/* ---------- Final épico ---------- */
.finale {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 16px;
  background: rgba(6, 5, 16, 0.78);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
.finale.active { opacity: 1; pointer-events: auto; }
.finale.active .finale-rays { opacity: 1; }
.finale-rays { background: repeating-conic-gradient(from 0deg, rgba(255, 209, 102, 0.12) 0deg 6deg, transparent 6deg 18deg); }

.finale-card {
  position: relative;
  width: min(520px, 100%);
  text-align: center;
  padding: 26px 24px;
  border-radius: 30px;
  background: rgba(20, 17, 48, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), 0 0 120px rgba(157, 140, 255, 0.25);
  opacity: 0;
}
.finale.active .finale-card { animation: cardRise 0.8s cubic-bezier(0.2, 0.9, 0.25, 1.15) 0.25s forwards; }
@keyframes cardRise { from { opacity: 0; transform: translateY(60px) scale(0.85); } to { opacity: 1; transform: none; } }

.finale-song { margin: 4px 0 6px; color: var(--muted); font-size: 0.95rem; }

.grade {
  --g1: #fff;
  --g2: var(--lav);
  font-family: 'Oswald', sans-serif;
  font-size: clamp(6rem, 18vh, 9rem);
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(160deg, var(--g1), var(--g2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 30px var(--g2));
  opacity: 0;
}
.grade.slam { animation: gradeSlam 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.4) forwards, gradePulse 2.4s ease-in-out 0.7s infinite; }
@keyframes gradeSlam {
  0% { opacity: 0; transform: scale(3.5) rotate(-15deg); filter: blur(14px) drop-shadow(0 0 30px var(--g2)); }
  60% { opacity: 1; transform: scale(0.92) rotate(2deg); filter: blur(0) drop-shadow(0 0 60px var(--g2)); }
  100% { opacity: 1; transform: scale(1) rotate(0); filter: drop-shadow(0 0 30px var(--g2)); }
}
@keyframes gradePulse { 50% { filter: drop-shadow(0 0 50px var(--g2)); } }
.grade.g-S { --g1: #fff6c2; --g2: #ffb703; }
.grade.g-A { --g1: #ffd6e5; --g2: var(--pink); }
.grade.g-B { --g1: #e4dfff; --g2: var(--lav); }
.grade.g-C { --g1: #d6ecff; --g2: #6cb6ff; }
.grade.g-D { --g1: #eeeeee; --g2: #8a87a6; }

.finale.active .finale-card.shake { opacity: 1; animation: shake 0.45s ease; }
@keyframes shake {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}

.grade-label, .nota, .stars, .end-stats, .end-note, .finale-actions { opacity: 0; transform: translateY(12px); transition: opacity 0.45s, transform 0.45s; }
.finale-card.revealed .grade-label,
.finale-card.revealed .nota,
.finale-card.revealed .stars { opacity: 1; transform: none; }
.finale-card.done .end-stats,
.finale-card.done .end-note,
.finale-card.done .finale-actions { opacity: 1; transform: none; }

.grade-label { font-family: 'Oswald', sans-serif; font-size: 1.6rem; letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }
.nota { margin: 6px 0 10px; color: var(--muted); font-size: 1rem; }
.nota strong { font-family: 'Oswald', sans-serif; font-size: 2rem; color: var(--text); margin: 0 6px; }

.stars { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.stars i { font-size: 2rem; color: rgba(255, 255, 255, 0.15); transform: scale(0.4); transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.6), color 0.3s; }
.finale-card.revealed .stars i { transform: scale(1); }
.stars i.on { color: var(--accent-2); filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.6)); }

.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.end-stats div { background: var(--glass); border-radius: 14px; padding: 10px 6px; }
.end-stats strong { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.end-stats small { color: var(--muted); font-size: 0.72rem; }
.end-note { font-size: 0.85rem; color: var(--muted); margin: 0 0 14px; }
.end-note:empty { display: none; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  background: var(--c);
  left: var(--x);
  animation: fall var(--d) cubic-bezier(0.25, 0.6, 0.4, 1) var(--delay) forwards;
}
@keyframes fall {
  from { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); opacity: 0.9; }
}

.song-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.08); z-index: 5; }
.song-progress div { height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--lav), var(--pink), var(--accent-2)); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  background: rgba(8, 7, 20, 0.72);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.overlay h2 { font-family: 'Oswald', sans-serif; font-size: 2.6rem; margin: 0; letter-spacing: 2px; }
.overlay p { color: var(--muted); margin: 0; text-align: center; }
.overlay-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.count {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(6rem, 18vw, 11rem);
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-2), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.count.tick { animation: countTick 0.85s ease; }
@keyframes countTick { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; transform: scale(1); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(20, 17, 45, 0.95);
  border: 1px solid var(--line);
  padding: 12px 20px;
  border-radius: 14px;
  opacity: 0;
  transition: 0.3s;
  z-index: 50;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .search-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .search-top .back-link span, .lite-btn span { display: none; }
  .hud-song, .offset-ctl span, .melody-badge { display: none; }
  .game-top { grid-template-columns: auto minmax(0, 1fr); }
  .score-bar { width: 90px; }
  .hud-btn { width: 38px; height: 38px; }
}

/* ---------- Modo ligero (Smart TV y equipos lentos) ----------
   Quita difuminados, sombras con filtro y animaciones de pantalla completa,
   que son lo que más le cuesta a los navegadores de las teles. */
body.lite::before { animation: none; }
body.lite *,
body.lite *::before,
body.lite *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }

body.lite .detail-bg { filter: none; inset: 0; opacity: 0.25; }
body.lite .detail-card,
body.lite .overlay,
body.lite .finale { background: rgba(10, 9, 24, 0.94); }
body.lite .stage-art { filter: none; animation: none; inset: 0; }
body.lite.no-video .stage-art { opacity: 0.22; }
body.lite .intro-rays,
body.lite .finale-rays,
body.lite .confetti { display: none; }

body.lite .song-card,
body.lite .song-card img,
body.lite .song-card:hover { transition: none; transform: none; }

body.lite .lyric-current .w {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #fff;
  filter: none;
  text-shadow: 0 2px 6px #000;
  transition: none;
}
body.lite .lyric-current .w.sung,
body.lite .lyric-current .w.now { color: var(--accent-2); }
body.lite .lyric-current .w.now { transform: none; }

body.lite .intro.play .intro-cover { animation: fadeIn 0.6s ease forwards; }
body.lite .intro-cover { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); }
body.lite .intro.play .intro-text h1 { animation: fadeIn 0.6s ease 0.4s forwards; }
body.lite .intro.play .intro-eyebrow,
body.lite .intro.play .intro-text p { animation: fadeIn 0.6s ease 0.3s forwards; }
body.lite .intro.counting .intro-stage { filter: none; transform: none; }
body.lite .intro-count.tick { animation: countLite 0.8s ease forwards; }
body.lite .intro-count::after { display: none; }
body.lite .intro.leaving .intro-flash { animation: none; }
body.lite .grade { filter: none; }
body.lite .grade.slam { animation: gradeLite 0.6s ease forwards; }
body.lite .stars i.on { filter: none; }
body.lite .finale.active .finale-card { animation: fadeIn 0.5s ease 0.2s forwards; }
body.lite .finale.active .finale-card.shake { animation: none; opacity: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes countLite {
  0% { opacity: 0; transform: scale(1.4); }
  30% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes gradeLite { from { opacity: 0; transform: scale(1.6); } to { opacity: 1; transform: scale(1); } }
