:root {
  --fondo: #06070b;
  --texto: #eef0f7;
  --tenue: #9aa0b4;
  --linea-panel: rgba(255, 255, 255, .09);
  --vidrio: rgba(12, 14, 22, .62);
  --acento: #ffd27a;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --curva: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.5 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#mapa {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  animation: aparecer 1.6s var(--curva) .2s forwards;
}
#mapa:active { cursor: grabbing; }

/* ---------- panel ---------- */
.panel {
  position: fixed; top: 24px; left: 24px;
  width: 340px;
  padding: 22px 22px 18px;
  background: var(--vidrio);
  border: 1px solid var(--linea-panel);
  border-radius: 20px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  clip-path: inset(0 0 100% 0 round 20px);
  animation: revelar 1s var(--curva) .1s forwards;
}
.panel > * { opacity: 0; transform: translateY(10px); animation: subir-suave .8s var(--curva) forwards; }
.panel > :nth-child(1) { animation-delay: .35s; }
.panel > :nth-child(2) { opacity: 1; transform: none; animation: none; }
.panel > :nth-child(3) { animation-delay: .9s; }
.panel > :nth-child(4) { animation-delay: 1.05s; }
.panel > :nth-child(5) { animation-delay: 1.2s; }

.antetitulo {
  margin: 0 0 6px;
  font: 600 11px/1 var(--mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--tenue);
  display: flex; align-items: center; gap: 8px;
}
.punto-vivo {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff4d5e;
  box-shadow: 0 0 0 0 rgba(255, 77, 94, .7);
  animation: latido 1.8s ease-out infinite;
}
.demo .punto-vivo { background: var(--acento); box-shadow: none; animation: none; }

.titulo {
  margin: 0;
  font: 400 44px/1 var(--serif);
  letter-spacing: -.01em;
}
.titulo em { color: var(--acento); }
.renglon { display: block; overflow: hidden; padding-bottom: .08em; }
.renglon > * {
  display: inline-block;
  transform: translateY(110%);
  animation: subir 1s var(--curva) forwards;
}
.renglon:nth-child(1) > * { animation-delay: .45s; }
.renglon:nth-child(2) > * { animation-delay: .6s; }

.bajada { margin: 12px 0 16px; color: var(--tenue); font-size: 14px; }

.contadores {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 0 0 16px;
}
.contadores div {
  padding: 10px 10px 8px;
  border: 1px solid var(--linea-panel);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.contadores dt { font-size: 10.5px; line-height: 1.2; color: var(--tenue); min-height: 2.4em; }
.contadores dd {
  margin: 4px 0 0;
  font: 600 20px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.lineas { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.lineas li {
  opacity: 0; transform: scale(.9);
  animation: chip .5s var(--curva) forwards;
  animation-delay: calc(1.3s + var(--i) * 70ms);
}
.lineas button {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px 5px 7px;
  border-radius: 999px;
  border: 1px solid var(--linea-panel);
  background: transparent; color: var(--texto);
  font: 600 12px/1 var(--mono);
  cursor: pointer;
  transition: border-color .25s, background .25s, box-shadow .25s, opacity .25s;
}
.lineas button:hover { border-color: color-mix(in srgb, var(--c) 60%, transparent); }
.lineas li i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}
.lineas li span { color: var(--tenue); font-weight: 400; }
.lineas li.brilla button { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent); transition-duration: .05s; }
.lineas li.mudo button { opacity: .38; }
.lineas li.mudo i { box-shadow: none; }
.lineas li.mudo button span { text-decoration: line-through; }

/* ---------- controles ---------- */
.controles {
  position: fixed; right: 24px; bottom: 44px;
  display: flex; gap: 10px; align-items: center;
}
.cuerda {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px 14px 16px;
  border: 0; border-radius: 999px;
  background: var(--acento); color: #1a1408;
  font: 600 15px/1 var(--sans);
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(255, 210, 122, .5), 0 10px 40px rgba(255, 190, 80, .25);
  clip-path: inset(0 100% 0 0 round 999px);
  animation: revelar-x .9s var(--curva) 1.5s forwards, invitar 2.4s ease-out 2.6s infinite;
  transition: transform .2s var(--curva), background .3s;
}
.cuerda:hover { transform: translateY(-2px); }
.cuerda:active { transform: scale(.97); }
.cuerda .manivela { width: 22px; height: 22px; }
.cuerda.sonando {
  background: rgba(255, 210, 122, .1); color: var(--acento);
  border: 1px solid rgba(255, 210, 122, .45);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: none; clip-path: none; box-shadow: 0 0 24px rgba(255, 210, 122, .18);
}
.cuerda.sonando .manivela { animation: girar 1.3s linear infinite; }
.volumen {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px;
  border-radius: 999px;
  background: var(--vidrio); color: var(--texto);
  border: 1px solid var(--linea-panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  clip-path: inset(0 0 0 100% round 999px);
  animation: revelar-izq .5s var(--curva) forwards;
}
.volumen[hidden] { display: none; }
.volumen svg { width: 18px; height: 18px; flex: none; }
.volumen input { width: 96px; accent-color: var(--acento); }
.redondo {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--vidrio); color: var(--texto);
  border: 1px solid var(--linea-panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: 0; animation: aparecer .6s ease 1.8s forwards;
}
.redondo svg { width: 20px; height: 20px; }

/* ---------- ventana «qué es esto» ---------- */
.acerca {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 26px 26px 22px;
  border: 1px solid var(--linea-panel);
  border-radius: 20px;
  background: rgba(12, 14, 22, .94);
  color: var(--texto);
  font-size: 14px;
  overflow: auto;
}
.acerca[open] { animation: ventana .5s var(--curva); }
.acerca::backdrop { background: rgba(3, 4, 8, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.acerca h2 { margin: 0 0 12px; font: 400 32px/1.05 var(--serif); }
.acerca h3 { margin: 18px 0 6px; font: 600 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--acento); }
.acerca p { margin: 0 0 10px; color: #c9cddb; }
.acerca ul { margin: 0; padding-left: 18px; color: #c9cddb; }
.acerca li { margin: 4px 0; }
.acerca b { color: var(--texto); font-weight: 600; }
.acerca .nota { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--linea-panel); font-size: 12px; color: var(--tenue); }
.acerca .cerrar {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .06); color: var(--texto);
  border: 0; cursor: pointer;
}
.acerca .cerrar svg { width: 16px; height: 16px; }
.acerca > * { animation: subir-suave .6s var(--curva) backwards; }
.acerca > :nth-child(2) { animation-delay: .08s; }
.acerca > :nth-child(3) { animation-delay: .14s; }
.acerca > :nth-child(4) { animation-delay: .2s; }
.acerca > :nth-child(n+5) { animation-delay: .26s; }

button:focus-visible, input:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; }

/* ---------- aviso, etiqueta, créditos ---------- */
.aviso {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 210, 122, .1);
  border: 1px solid rgba(255, 210, 122, .3);
  color: #ffe6b3; font-size: 12.5px; line-height: 1.4;
  animation: subir-suave .6s var(--curva) forwards;
}
.etiqueta {
  position: fixed; pointer-events: none;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(10, 12, 18, .92);
  border: 1px solid var(--linea-panel);
  font-size: 13px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 14px));
}
.etiqueta b { font-weight: 600; }
.etiqueta i {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 6px; background: var(--c); box-shadow: 0 0 8px var(--c);
}
.creditos {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 24px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  font-size: 11.5px; color: var(--tenue);
  background: linear-gradient(transparent, rgba(6, 7, 11, .85));
  pointer-events: none;
}
.creditos span:first-child { color: var(--texto); }

.depurar {
  position: fixed; right: 24px; top: 24px;
  width: 300px; max-height: 50vh; overflow: auto;
  padding: 10px; border-radius: 10px;
  background: rgba(0, 0, 0, .75);
  font: 11px/1.4 var(--mono); color: #b7f7c4;
  white-space: pre-wrap;
}

/* ---------- animaciones ---------- */
@keyframes aparecer { to { opacity: 1; } }
@keyframes revelar { to { clip-path: inset(0 0 0 0 round 20px); } }
@keyframes revelar-izq { to { clip-path: inset(0 0 0 0 round 999px); } }
@keyframes revelar-x { to { clip-path: inset(0 0 0 0 round 999px); } }
@keyframes subir { to { transform: translateY(0); } }
@keyframes subir-suave { to { opacity: 1; transform: none; } }
@keyframes chip { to { opacity: 1; transform: none; } }
@keyframes ventana { from { opacity: 0; transform: translateY(14px) scale(.98); clip-path: inset(0 0 100% 0 round 20px); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0 round 20px); } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes latido {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 94, .7); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(255, 77, 94, 0); }
}
@keyframes invitar {
  0% { box-shadow: 0 0 0 0 rgba(255, 210, 122, .55), 0 10px 40px rgba(255, 190, 80, .25); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(255, 210, 122, 0), 0 10px 40px rgba(255, 190, 80, .25); }
}

/* ---------- móvil ---------- */
@media (max-width: 859px) {
  .panel {
    top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px;
    width: auto;
    padding: 14px 14px 12px;
    border-radius: 16px;
  }
  .titulo { font-size: 30px; }
  .renglon { display: inline-block; }
  .bajada { display: none; }
  .contadores { margin: 10px 0; }
  .contadores dt { min-height: 0; }
  .contadores dd { font-size: 16px; }
  .lineas { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .lineas li { flex: none; }
  .volumen input { width: 56px; }
  .volumen { padding: 0 12px; }
  .cuerda { padding: 12px 18px 12px 14px; }
  .controles { gap: 8px; }
  .acerca { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .controles { left: 0; right: 0; bottom: calc(34px + env(safe-area-inset-bottom)); justify-content: center; }
  .creditos { justify-content: center; padding-left: 12px; padding-right: 12px; font-size: 10.5px; }
  .creditos .sep, .creditos span:last-child { display: none; }
  .aviso { margin-top: 8px; padding: 6px 10px; font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}
