:root{
  color-scheme:dark;
  --bg:#2D1B5E; --ink:#F6F2FF; --soft:#C2B8E6; --faint:#4D3B8A; --sheet:#3A2675; --palma:#7B5CFF; --chasquido:#E0479A;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
*,*::before,*::after{box-sizing:inherit}
html,body{margin:0;height:100%}
body{background:var(--bg);color:var(--ink);font-family:"Figtree",system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-tap-highlight-color:transparent;overflow:hidden}
button{font-family:inherit;color:inherit}
button:focus-visible,input:focus-visible{outline:3px solid var(--palma);outline-offset:3px}

.app{height:100%;display:flex;flex-direction:column;max-width:560px;margin:0 auto;padding:0 20px}
body.palma{background:var(--palma);color:#fff}
body.chasquido{background:var(--chasquido);color:#fff}
body.palma,body.chasquido{--soft:rgba(255,255,255,.75);--faint:rgba(255,255,255,.35)}

header{display:flex;align-items:center;gap:8px;padding:16px 0 0}
header .mark{width:30px;height:30px;flex:none}
header h1{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:800;font-size:22px;letter-spacing:-0.03em;margin:0;margin-right:auto}
.ghost{border:none;background:transparent;font-size:15px;font-weight:600;padding:8px 10px;border-radius:999px;cursor:pointer;display:flex;align-items:center;gap:6px}
.ghost svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
#patBtn{box-shadow:inset 0 0 0 1.5px var(--faint)}

.stage{flex:1;border:none;background:transparent;display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-user-select:none;position:relative;padding:0}
.big{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:800;font-size:clamp(88px,27vw,170px);line-height:.9;letter-spacing:-0.05em}
.big.art{display:block;line-height:0}
.big.art svg{width:min(62vw,300px);height:auto;display:block}
.pop .big.art .spark{animation:spark .2s ease-out}
@keyframes spark{from{opacity:0}to{opacity:1}}
.big.msg{font-size:clamp(30px,9vw,44px);letter-spacing:-0.02em;line-height:1.1;text-align:center}
.sub{font-size:16px;color:var(--soft);margin-top:14px;min-height:1.4em;text-align:center}
.pop .big{animation:pop .15s ease-out}
@keyframes pop{from{transform:scale(1.1)}to{transform:scale(1)}}
.fb{position:absolute;top:8%;left:0;right:0;text-align:center;font-weight:600;font-size:17px;min-height:1.4em}

.dots{display:flex;justify-content:center;gap:14px;padding:6px 0 4px}
.dots i{width:10px;height:10px;border-radius:50%;background:var(--faint);transition:transform .08s}
.dots i.on{background:var(--ink)}
body.palma .dots i.on,body.chasquido .dots i.on{background:#fff}
.dots i.now{transform:scale(1.7)}

footer{display:flex;flex-direction:column;align-items:center;gap:10px;padding:18px 0 28px}
.status{font-size:15px;color:var(--soft);min-height:1.4em;text-align:center}
.main{width:84px;height:84px;border-radius:50%;border:none;background:var(--ink);color:var(--bg);cursor:pointer;display:grid;place-items:center}
.main svg{width:32px;height:32px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.main.on{background:var(--palma);color:#fff;box-shadow:0 0 0 8px color-mix(in srgb,var(--palma) 22%,transparent)}
body.palma .main.on,body.chasquido .main.on{background:#fff;color:#14172B;box-shadow:none}
.link{border:none;background:none;font-size:14px;font-weight:600;color:var(--soft);text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:4px}

dialog{border:none;border-radius:24px 24px 0 0;margin:auto auto 0;width:100%;max-width:560px;padding:20px 20px calc(24px + env(safe-area-inset-bottom,0px));background:var(--sheet);color:var(--ink)}
dialog::backdrop{background:rgba(10,12,24,.45)}
dialog h2{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-size:20px;margin:0 0 12px;letter-spacing:-0.01em}
.list{display:grid;gap:2px;max-height:60vh;overflow-y:auto}
.opt{display:flex;justify-content:space-between;align-items:center;gap:10px;border:none;background:transparent;text-align:left;padding:12px 10px;border-radius:12px;cursor:pointer;font-size:16px}
.opt[aria-pressed="true"]{background:var(--bg);font-weight:600}
.opt .pat{display:flex;gap:5px;flex:none}
.opt .pat i{width:7px;height:7px;border-radius:50%;background:var(--faint)}
.opt .pat i.p{background:var(--palma)}.opt .pat i.c{background:var(--chasquido)}
.desc{font-size:14px;color:var(--soft);margin:12px 4px 0}
.rng{display:flex;align-items:center;gap:12px;margin:6px 0}
.rng input{flex:1;accent-color:var(--palma)}
.rng span{font-size:14px;color:var(--soft);min-width:70px;text-align:right;font-variant-numeric:tabular-nums}
.note{font-size:14px;color:var(--soft);margin:4px 0 16px}
.wide{width:100%;border:none;border-radius:14px;padding:14px;font-size:16px;font-weight:600;background:var(--bg);cursor:pointer}
.close{float:right;border:none;background:none;font-size:15px;font-weight:600;color:var(--soft);cursor:pointer;padding:4px}
/* inicio y escuchando: un solo botón grande, como un identificador de canciones */
body[data-state="home"] .stage,body[data-state="listening"] .stage,
body[data-state="home"] .dots,body[data-state="listening"] .dots{display:none}
body[data-state="home"] footer,body[data-state="listening"] footer{flex:1;justify-content:center;gap:22px;padding-bottom:12vh}
body[data-state="home"] .main,body[data-state="listening"] .main{width:min(58vw,230px);height:min(58vw,230px);background:linear-gradient(135deg,#7B5CFF,#D6338A);border-radius:28%;color:#fff;box-shadow:0 18px 50px rgba(123,92,255,.45)}
body[data-state="home"] .main svg,body[data-state="listening"] .main svg{width:70%;height:auto}
.main{position:relative;transition:width .25s ease,height .25s ease}
.main::before,.main::after{content:"";position:absolute;inset:0;border-radius:inherit;background:var(--palma);opacity:0;z-index:-1}
body[data-state="listening"] .main::before{animation:ring 1.8s ease-out infinite}
body[data-state="listening"] .main::after{animation:ring 1.8s ease-out .9s infinite}
@keyframes ring{from{transform:scale(1);opacity:.35}to{transform:scale(1.7);opacity:0}}
.label{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:700;font-size:24px;letter-spacing:-0.02em;text-align:center;margin:0}
body[data-state="beats"] .label{display:none}
.logo rect{fill:currentColor;stroke:none}
@media (prefers-reduced-motion: reduce){.main::before,.main::after{animation:none!important}.main{transition:none}}
[hidden]{display:none!important}
@media (prefers-reduced-motion: reduce){.pop .big{animation:none}.dots i{transition:none}}

/* ===== Estética 80s Los Ángeles (synthwave) ===== */
:root{--palma:#FF2E97;--chasquido:#0FB5D6;--neon:#5CF6FF;--soft:#D6C2F0;--faint:rgba(255,255,255,.22);--sheet:#1C0A3A}
body{background:linear-gradient(180deg,#120428 0%,#2A0A57 42%,#5A1470 72%,#8C1C6E 100%)}
.app{position:relative;z-index:1}
.scene{position:fixed;left:0;right:0;bottom:0;height:40vh;pointer-events:none;z-index:0;overflow:visible;transition:opacity .1s}
body.palma .scene,body.chasquido .scene{opacity:.3}
.sun{position:absolute;left:50%;bottom:50%;width:min(54vw,290px);aspect-ratio:1;border-radius:50%;transform:translate(-50%,50%);background:linear-gradient(180deg,#FFE66D 0%,#FF9A3D 22%,#FF2E97 48%,#B21FA0 70%);box-shadow:0 0 60px rgba(255,46,151,.55);
 -webkit-mask-image:linear-gradient(180deg,#000 0,#000 30%,transparent 30%,transparent 32%,#000 32%,#000 37%,transparent 37%,transparent 40%,#000 40%,#000 44%,transparent 44%,transparent 48%,#000 48%);
 mask-image:linear-gradient(180deg,#000 0,#000 30%,transparent 30%,transparent 32%,#000 32%,#000 37%,transparent 37%,transparent 40%,#000 40%,#000 44%,transparent 44%,transparent 48%,#000 48%)}
.palm{position:absolute;bottom:calc(50% - 2px);height:min(23vh,210px);fill:#10031F}
.palm.l{left:max(2vw,calc(50% - 300px))}
.palm.r{right:max(2vw,calc(50% - 300px));transform:scaleX(-1)}
.floor{position:absolute;left:0;right:0;bottom:0;height:50%;background:linear-gradient(180deg,#24073F,#0C0220);border-top:2px solid #FF2E97;box-shadow:0 -6px 24px rgba(255,46,151,.6);overflow:hidden;perspective:200px}
.floor::before{content:"";position:absolute;left:-60%;right:-60%;top:0;height:240%;will-change:transform;transform-origin:top center;transform:rotateX(62deg);
 background-image:linear-gradient(rgba(255,46,151,.85) 2px,transparent 2px),linear-gradient(90deg,rgba(255,46,151,.85) 2px,transparent 2px);background-size:56px 36px;animation:roll 1.1s linear infinite}
@keyframes roll{from{transform:rotateX(62deg) translateY(-36px)}to{transform:rotateX(62deg) translateY(0)}}
.big{font-family:"Monoton","Bricolage Grotesque",sans-serif;font-weight:400;letter-spacing:0;color:var(--neon);text-shadow:0 0 10px rgba(92,246,255,.9),0 0 34px rgba(24,231,255,.6)}
.big.msg{font-family:"Mr Dafoe","Bricolage Grotesque",cursive;color:#FF6FBF;text-shadow:0 0 8px rgba(255,46,151,.9),0 0 26px rgba(255,46,151,.6)}
.big.art{color:#fff;text-shadow:none}
.big.amp{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:800;letter-spacing:-0.03em}
.big.art svg{filter:drop-shadow(0 0 8px rgba(255,255,255,.85)) drop-shadow(0 0 22px rgba(255,255,255,.45))}
body.palma{background:#FF2E97}
body.chasquido{background:#0FB5D6}
.label{font-family:"Mr Dafoe","Bricolage Grotesque",cursive;font-weight:400;font-size:44px;letter-spacing:0;color:#FF6FBF;text-shadow:0 0 8px rgba(255,46,151,.95),0 0 28px rgba(255,46,151,.6)}
.status{color:var(--soft)}
.dots i{background:rgba(255,255,255,.18)}
.dots i.on{background:var(--neon);box-shadow:0 0 8px var(--neon)}
body.palma .dots i.on,body.chasquido .dots i.on{background:#fff;box-shadow:0 0 8px #fff}
#patBtn{box-shadow:inset 0 0 0 1.5px var(--neon),0 0 10px rgba(92,246,255,.35);color:#E9FDFF}
body[data-state="home"] .main,body[data-state="listening"] .main{background:linear-gradient(135deg,#FF2E97,#7B2FF7);box-shadow:0 0 0 2px rgba(255,255,255,.15),0 0 40px rgba(255,46,151,.65),0 0 90px rgba(123,47,247,.45)}
.main::before,.main::after{background:#FF2E97}
dialog{background:var(--sheet);box-shadow:0 -2px 0 #FF2E97,0 -10px 40px rgba(255,46,151,.35)}
dialog h2{font-family:"Mr Dafoe","Bricolage Grotesque",cursive;font-weight:400;font-size:34px;color:#FF6FBF;text-shadow:0 0 10px rgba(255,46,151,.7)}
.opt[aria-pressed="true"]{background:rgba(92,246,255,.12);box-shadow:inset 0 0 0 1px rgba(92,246,255,.5)}
.opt .pat i.p{background:#FF2E97}.opt .pat i.c{background:var(--neon)}
.wide{background:rgba(255,255,255,.08)}
.link{color:#F6E9FF}
body[data-state="home"] footer,body[data-state="listening"] footer{padding-bottom:calc(20vh + min(27vw,145px) + 14px)}
@media (prefers-reduced-motion: reduce){.floor::before{animation:none}}
.big.art img{width:min(64vw,300px);height:auto;display:block;filter:drop-shadow(0 12px 26px rgba(60,0,40,.45))}
.pop .big.art img{animation:clap .2s ease-out}
@keyframes clap{0%{transform:scale(1.18) rotate(-7deg)}60%{transform:scale(.97) rotate(2deg)}100%{transform:scale(1) rotate(0)}}
@media (prefers-reduced-motion: reduce){.pop .big.art img{animation:none}}
/* pantalla tranquila: conteo + manos que aplauden en el golpe */
body.palma,body.chasquido{background:linear-gradient(180deg,#120428 0%,#2A0A57 42%,#5A1470 72%,#8C1C6E 100%)!important}
body.palma .scene,body.chasquido .scene{opacity:1}
.big.count{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:800;font-size:clamp(72px,22vw,120px);color:#D6C2F0;text-shadow:none;letter-spacing:-0.03em}
.big.count.hit.palma{color:#FF6FBF;text-shadow:0 0 22px rgba(255,46,151,.55)}
.big.count.hit.chasquido{color:#5CF6FF;text-shadow:0 0 22px rgba(92,246,255,.5)}
.pop .big.count{animation:pop .16s ease-out}
.hands{display:none;position:relative;width:min(80vw,340px);height:calc(min(80vw,340px) * 0.625);margin-top:-6px}
.clapsprite{position:absolute;inset:0;overflow:visible}
/* el lienzo es 16 % más grande que el cuadro para que el resplandor de neón no se corte */
.hands .clapsprite canvas{position:absolute;inset:-8%;width:116%;height:116%;display:block}
.hands::before{content:"";position:absolute;inset:8% 4% 0;background:radial-gradient(closest-side,rgba(255,46,151,.28),rgba(255,46,151,0));pointer-events:none}
body[data-state="beats"] .hands{display:block}
.hands .spark{position:absolute;left:50%;top:-6px;width:0;height:0;opacity:0}
.hands .spark i{position:absolute;width:5px;height:18px;border-radius:3px;background:#FF6FBF;left:-2.5px;top:-20px;transform-origin:2.5px 40px}
.hands .spark.chasquido i{background:#5CF6FF}
.hands .spark i:nth-child(1){transform:rotate(-35deg)}.hands .spark i:nth-child(3){transform:rotate(35deg)}
@media (prefers-reduced-motion: reduce){.big.count{transition:none}.pop .big.count{animation:none}}
/* selector de modo y metrónomo */
.modes{display:flex;gap:2px;padding:3px;border-radius:999px;background:rgba(255,255,255,.08);margin-right:auto}
.modes button{border:none;background:transparent;color:var(--soft);font-size:13px;font-weight:600;padding:6px 12px;border-radius:999px;cursor:pointer}
.modes button[aria-pressed="true"]{background:rgba(92,246,255,.16);color:#E9FDFF;box-shadow:inset 0 0 0 1px rgba(92,246,255,.5)}
.metro{display:none;flex-direction:column;align-items:center;gap:14px;margin-top:4px}
body[data-mode="metro"] .metro{display:flex}
.bpmrow{display:flex;align-items:center;gap:18px}
.round{width:44px;height:44px;border-radius:50%;border:none;background:rgba(255,255,255,.1);color:#F6F2FF;font-size:24px;line-height:1;cursor:pointer}
.bpmval{border:none;background:transparent;color:#F6F2FF;cursor:pointer;display:flex;flex-direction:column;align-items:center;min-width:110px;padding:4px}
.bpmval b{font-family:"Bricolage Grotesque","Figtree",sans-serif;font-weight:800;font-size:46px;line-height:1;letter-spacing:-0.02em}
.bpmval span{font-size:12px;color:var(--soft);margin-top:4px}
.msig{display:flex;gap:2px;padding:4px;border-radius:999px;background:rgba(18,4,40,.82);box-shadow:0 0 0 1px rgba(255,255,255,.14),0 6px 18px rgba(10,0,30,.45);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);position:relative;z-index:2}
.msig button{border:none;background:transparent;color:#D9CCF5;font-size:15px;font-weight:700;padding:7px 18px;border-radius:999px;cursor:pointer}
.msig button[aria-pressed="true"]{background:#FF2E97;color:#fff;box-shadow:0 0 12px rgba(255,46,151,.6)}
body[data-mode="metro"][data-state="home"] footer{padding-bottom:calc(20vh + min(27vw,145px) + 10px);gap:14px}
body[data-mode="metro"][data-state="home"] .main{width:min(42vw,170px);height:min(42vw,170px)}
body[data-mode="metro"][data-state="beats"] .status{display:none}
body[data-mode="metro"] .liveFix,body[data-mode="metro"] #liveFix{display:none!important}
/* ayuda de la primera vez, sobre la pantalla real */
#coach{position:fixed;inset:0;z-index:40;background:rgba(8,2,24,.64);cursor:pointer}
body.coaching .main{margin-top:104px}
#coach .chint{position:absolute;left:0;right:0;bottom:calc(12vh + env(safe-area-inset-bottom,0px));text-align:center;color:#F6F2FF;font-size:16px;font-weight:600;text-shadow:0 0 12px rgba(255,46,151,.8)}
/* puntos de página (como Shazam) */
.pager{display:flex;gap:10px;align-items:center;margin-right:auto;padding:10px 6px}
.pdot{width:9px;height:9px;padding:0;border:none;border-radius:50%;background:rgba(255,255,255,.28);cursor:pointer;transition:transform .2s,background-color .2s}
.pdot[aria-selected="true"]{background:#5CF6FF;box-shadow:0 0 10px rgba(92,246,255,.8);transform:scale(1.25)}
.pdot::after{content:"";position:absolute;inset:-14px -5px}
.pdot{position:relative}
footer.slide-l{animation:slideL .28s ease-out}footer.slide-r{animation:slideR .28s ease-out}
@keyframes slideL{from{transform:translateX(40px);opacity:0}to{transform:none;opacity:1}}
@keyframes slideR{from{transform:translateX(-40px);opacity:0}to{transform:none;opacity:1}}
/* el mensaje de estado no se pierde contra el sol */
body[data-state="listening"] .status,body[data-state="home"] .status{background:rgba(18,4,40,.6);padding:6px 14px;border-radius:999px;color:#F2E9FF;backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
body[data-state="listening"] .status:empty,body[data-state="home"] .status:empty{display:none}
body[data-state="listening"] footer{padding-bottom:calc(20vh + min(27vw,145px) + 40px)!important}
@media (prefers-reduced-motion: reduce){footer.slide-l,footer.slide-r{animation:none}}
#coach .gtxt{position:absolute;font-family:"Permanent Marker","Bricolage Grotesque",cursive;font-size:21px;line-height:1.15;color:#FFE9F6;letter-spacing:.3px;text-shadow:0 0 6px #FF2E97,0 0 16px rgba(255,46,151,.85),0 0 30px rgba(255,46,151,.45);white-space:nowrap}
#coach .gtxt.c{color:#E9FDFF;text-shadow:0 0 6px #18E7FF,0 0 16px rgba(24,231,255,.85),0 0 30px rgba(24,231,255,.45)}
#coach svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}
#coach svg path{fill:none;stroke-linecap:round;stroke-linejoin:round}
#coach .chint{font-family:"Permanent Marker","Bricolage Grotesque",cursive;font-size:17px;letter-spacing:.3px}
/* elegir manos en Ajustes */
.rowset{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:4px 0 16px;font-size:15px;color:var(--soft)}
.pick{display:flex;gap:2px;padding:4px;border-radius:999px;background:rgba(255,255,255,.08)}
.pick button{border:none;background:transparent;color:#D9CCF5;font-size:15px;font-weight:700;padding:7px 18px;border-radius:999px;cursor:pointer}
.pick button[aria-pressed="true"]{background:#FF2E97;color:#fff;box-shadow:0 0 12px rgba(255,46,151,.6)}
