  :root { --pink:#ff3fd0; --cyan:#3ff3ff; }
  * { box-sizing:border-box; }
  html,body { touch-action:manipulation; -webkit-text-size-adjust:100%; }
  html,body { margin:0; height:100%; background:#14052e; overflow:hidden; font-family:"Trebuchet MS","Segoe UI",system-ui,sans-serif; color:#fff; }
  canvas { display:block; position:fixed; inset:0; }
  #top { position:fixed; top:calc(14px + env(safe-area-inset-top)); left:calc(16px + env(safe-area-inset-left)); right:calc(16px + env(safe-area-inset-right)); display:flex; justify-content:space-between; align-items:flex-start; gap:16px; pointer-events:none; flex-wrap:wrap; z-index:2; }
  #logo { font-family:Impact,"Arial Black",sans-serif; font-size:44px; letter-spacing:3px; line-height:1;
    background:linear-gradient(180deg,#fff 0%,#ffe36e 45%,#ff7a3d 55%,#ff3fd0 100%); -webkit-background-clip:text; background-clip:text; color:transparent;
    filter:drop-shadow(3px 3px 0 #1a0b2e) drop-shadow(0 0 12px rgba(255,63,208,.6)); }
  #logo small { display:block; font-family:"Trebuchet MS",sans-serif; font-size:12px; letter-spacing:2px; color:#ffd6f6; -webkit-text-fill-color:#ffd6f6; margin-top:4px; filter:none; }
  #stats { display:flex; gap:14px; align-items:stretch; background:rgba(20,5,46,.6); border:2px solid rgba(63,243,255,.5); border-radius:12px; padding:8px 12px; backdrop-filter:blur(4px); pointer-events:auto; }
  .stat label { display:block; font-size:10px; letter-spacing:2px; text-transform:uppercase; color:#9fe9ff; margin-bottom:2px; }
  .stat b { font-size:17px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; }
  /* fixed widths: the panel never changes size when the text does */
  #tempoStat { width:100px; } #tempoStat label { white-space:nowrap; } #feelStat { width:122px; } #moveStat { width:156px; } #hatStat { width:138px; }
  #picks { display:flex; gap:14px; } #tapBtn { align-self:center; margin-left:-6px; }
  #bpm { width:82px; }
  .chip { font:inherit; font-size:14px; font-weight:bold; color:#fff; background:rgba(255,255,255,.12); border:2px solid rgba(255,255,255,.5); border-radius:999px; padding:4px 15px; min-width:58px; cursor:pointer; box-shadow:none; }
  .chip:hover { background:rgba(255,255,255,.25); } .chip:active { transform:scale(.92); box-shadow:none; background:rgba(255,255,255,.35); }
  .chip.locked { border-color:#ff3fd0; animation:tapLock .6s ease-in-out 4; }
  @keyframes tapLock { 0%,100% { box-shadow:0 0 0 0 rgba(255,63,208,0); border-color:#ff3fd0; } 50% { box-shadow:0 0 0 5px rgba(255,63,208,.55), 0 0 14px #ff3fd0; border-color:#ff9bea; } }
  #dancesBtn, #hatsBtn { display:flex; align-items:center; justify-content:space-between; gap:6px; width:100%; text-align:left; font:inherit; color:#fff; background:rgba(255,63,208,.2); border:1px solid rgba(255,63,208,.7);
    border-radius:8px; padding:1px 8px; cursor:pointer; box-shadow:none; }
  #dancesBtn:hover, #dancesBtn.active, #hatsBtn:hover, #hatsBtn.active { background:rgba(255,63,208,.4); } #dancesBtn:active, #hatsBtn:active { transform:none; box-shadow:none; } #dancesBtn span, #hatsBtn span { font-size:11px; opacity:.85; }
  #hats { width:300px; } .dance small { font-size:10px; color:#9fe9ff; white-space:nowrap; }
  #dots { display:inline-flex; gap:4px; align-items:center; margin-left:6px; vertical-align:middle; }
  #dots i { width:7px; height:7px; border-radius:50%; background:rgba(255,255,255,.18); transition:background .08s; }
  #dots i.on { background:var(--pink); box-shadow:0 0 10px var(--pink); }
  #dots i.on:first-child { background:#ffe36e; box-shadow:0 0 10px #ffe36e; }
  #controls { position:fixed; left:50%; bottom:calc(22px + env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:2; background:rgba(20,5,46,.65); border:2px solid rgba(255,63,208,.5); border-radius:14px; padding:9px 12px;
    backdrop-filter:blur(4px); max-width:calc(100vw - 24px); }
  #controls > div { display:flex; gap:10px; align-items:center; justify-content:center; } #controls > div[hidden] { display:none; }
  button, .btn { font:inherit; font-weight:bold; font-size:14px; color:#1a0b2e; background:linear-gradient(#fff,#d9d0ff); border:2px solid #1a0b2e; border-radius:10px; padding:8px 13px; cursor:pointer;
    box-shadow:3px 3px 0 #1a0b2e; transition:transform .05s, box-shadow .05s; user-select:none; white-space:nowrap; }
  button:active, .btn:active { transform:translate(2px,2px); box-shadow:1px 1px 0 #1a0b2e; }
  button.primary { background:linear-gradient(#fff6a8,#ffb23d); }
  #srcLabel { font-size:11px; letter-spacing:2px; text-transform:uppercase; color:#9fe9ff; }
  #liveLabel { font-weight:bold; font-size:15px; white-space:nowrap; }
  @keyframes pulse { 50% { opacity:.3; } }
  #meter { position:relative; width:84px; height:10px; border-radius:5px; background:rgba(255,255,255,.2); overflow:hidden; flex:none; }
  #meterMark { position:absolute; top:0; bottom:0; width:2px; margin-left:-1px; background:#fff; box-shadow:0 0 3px #000; }
  #meter.hot { box-shadow:0 0 8px #ff3fd0; } #meterFill { display:block; height:100%; width:0; background:linear-gradient(90deg,#3ff3ff,#ffe36e,#ff3fd0); }
  #sens { display:flex; align-items:center; gap:8px; font-size:12px; color:#ffd6f6; white-space:nowrap; }
  /* sliders drawn by hand so they look the same (and are visible) in Safari, Chrome and Firefox */
  input[type=range] { -webkit-appearance:none; appearance:none; height:6px; border-radius:3px; background:rgba(255,255,255,.35); outline:none; margin:0; cursor:pointer; }
  input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; appearance:none; width:16px; height:16px; border-radius:50%; background:#ff3fd0; border:2px solid #fff; box-shadow:0 0 4px rgba(0,0,0,.5); }
  input[type=range]::-moz-range-thumb { width:13px; height:13px; border-radius:50%; background:#ff3fd0; border:2px solid #fff; }
  #sensRange { width:110px; } #seek { flex:1; min-width:140px; }
  #player { min-width:min(560px, calc(100vw - 60px)); }
  #ppBtn { width:44px; padding:8px 0; text-align:center; font-size:13px; } #trackName { max-width:190px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:bold; font-size:14px; }
  #time { font-size:12px; color:#ffd6f6; font-variant-numeric:tabular-nums; white-space:nowrap; }
  #status { position:fixed; left:50%; bottom:92px; transform:translateX(-50%); font-size:13px; color:#ffd6f6; text-shadow:1px 1px 0 #1a0b2e; text-align:center; pointer-events:none; width:max-content; max-width:90vw; z-index:2; }
  #loading { position:fixed; inset:0; display:grid; place-items:center; font-family:Impact,sans-serif; font-size:28px; letter-spacing:2px; color:#ffd6f6; z-index:1; pointer-events:none; }
  #helpBtn { align-self:center; width:30px; height:30px; min-width:0; padding:0; border-radius:50%; font-size:16px; }
  #about { left:50%; right:auto; top:50% !important; transform:translate(-50%,-50%); width:min(460px, calc(100vw - 24px)); max-height:min(86vh, 640px); z-index:6; padding:14px 16px; }
  #aboutBody { overflow-y:auto; font-size:13.5px; line-height:1.45; color:#f3e6ff; padding-right:4px; }
  #aboutBody h3 { font-size:11px; letter-spacing:2px; text-transform:uppercase; color:#9fe9ff; margin:14px 0 4px; }
  #aboutBody p { margin:0 0 6px; } #aboutBody ul { margin:0; padding-left:18px; } #aboutBody li { margin:2px 0; }
  #aboutBody a { color:#ffd6f6; } #aboutBody kbd { font:inherit; font-size:12px; border:1px solid rgba(255,255,255,.5); border-radius:4px; padding:0 5px; }
  #aboutBody small { color:rgba(255,255,255,.6); }
  .menu { display:none; position:fixed; right:16px; top:92px; width:270px; max-height:calc(100vh - 240px); z-index:4; flex-direction:column;
    background:rgba(20,5,46,.88); border:2px solid rgba(63,243,255,.5); border-radius:12px; padding:10px; backdrop-filter:blur(6px); }
  .menu.open { display:flex; }
  #danceHead, .menuHead { display:flex; align-items:baseline; gap:8px; font-size:16px; } #danceCount { font-size:11px; color:#9fe9ff; flex:1; }
  .menu button { font-size:11px; padding:3px 8px; border-radius:7px; box-shadow:2px 2px 0 #1a0b2e; }
  #danceTools { display:flex; gap:6px; align-items:center; margin:8px 0; font-size:10px; color:#ffd6f6; }
  #danceList { overflow-y:auto; display:grid; gap:3px; padding-right:4px; }
  .dance { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:3px 6px; border-radius:7px; font-size:13px; color:rgba(255,255,255,.55); }
  .dance.on { background:rgba(255,63,208,.18); color:#fff; } .dance label { flex:1; cursor:pointer; } .dance input { accent-color:#ff3fd0; }
  #dropzone { position:fixed; inset:0; display:none; place-items:center; background:rgba(255,63,208,.25); border:6px dashed #fff; font-family:Impact,sans-serif; font-size:40px; letter-spacing:2px; z-index:5; }
  /* phones held sideways: logo and stats share one slim row */
  @media (max-height:520px) and (min-width:641px){
    #top{ flex-wrap:nowrap; align-items:center; gap:12px; top:calc(6px + env(safe-area-inset-top)); }
    #logo{ font-size:24px; letter-spacing:2px; flex:none; } #logo small{ font-size:8px; letter-spacing:1.5px; margin-top:2px; }
    #stats{ padding:4px 10px; gap:10px; } .stat label{ font-size:9px; margin-bottom:0; } .stat b{ font-size:14px; }
    #tempoStat{ width:84px; } #feelStat{ width:96px; } #moveStat{ width:132px; } #hatStat{ width:118px; } #bpm{ width:70px; }
    .chip{ font-size:12px; padding:3px 10px; min-width:46px; } #helpBtn{ width:26px; height:26px; font-size:13px; }
    #controls{ bottom:calc(8px + env(safe-area-inset-bottom)); padding:6px 10px; } button, .btn{ font-size:13px; padding:6px 10px; }
    #status{ font-size:12px; }
    .menu{ right:calc(12px + env(safe-area-inset-right)); width:min(360px, 44vw); max-height:calc(100vh - 110px); padding:8px 10px; }
    #danceList{ grid-template-columns:1fr 1fr; gap:3px 6px; } .dance{ font-size:12px; padding:2px 4px; } .menu .dance button{ font-size:10px; padding:1px 5px; }
    #danceTools{ margin:4px 0; } #danceTools span{ display:none; }
  }
  @media (max-height:520px) and (min-width:641px) and (max-width:820px){
    #logo small{ display:none; } #top{ gap:8px; } #stats{ gap:8px; }
    #tempoStat{ width:80px; } #bpm{ width:72px; } #feelStat{ width:70px; } #moveStat{ width:116px; } #hatStat{ width:104px; }
  }
  @media (max-width:640px){
    /* narrow screens: one slim card. Row 1: logo, ?, tempo, TAP. Row 2: the two pickers. */
    #top{ top:calc(6px + env(safe-area-inset-top)); left:calc(8px + env(safe-area-inset-left)); right:calc(8px + env(safe-area-inset-right)); display:grid;
      grid-template-columns:auto auto 1fr auto; grid-template-areas:"logo help tempo tap" "pick pick pick pick"; gap:6px 8px; align-items:center;
      background:rgba(20,5,46,.62); border:2px solid rgba(63,243,255,.45); border-radius:12px; padding:6px 8px; backdrop-filter:blur(4px); pointer-events:auto; }
    #stats{ display:contents; }
    #logo{ grid-area:logo; font-size:28px; letter-spacing:2px; line-height:.95; filter:drop-shadow(2px 2px 0 #1a0b2e) drop-shadow(0 0 10px rgba(255,63,208,.5)); }
    #logo small{ display:block; margin-top:3px; font-size:8px; letter-spacing:1.6px; white-space:nowrap; }
    #tempoStat{ grid-area:tempo; width:auto; justify-self:end; display:flex; align-items:center; gap:6px; } #tempoStat label{ font-size:0; margin:0; order:2; } #dots{ margin-left:0; }
    #bpm{ width:auto; min-width:0; text-align:right; font-size:17px; white-space:nowrap; } #top{ min-width:0; } #tempoStat{ min-width:0; }
    #feelStat{ display:none; }
    #tapBtn{ grid-area:tap; margin:0; width:74px; height:36px; min-width:0; padding:0; font-size:16px; letter-spacing:2px; text-transform:uppercase; border-radius:10px;
      background:rgba(255,63,208,.22); border-color:rgba(255,63,208,.8); touch-action:manipulation; }
    #picks{ grid-area:pick; display:grid; grid-template-columns:1fr 1fr; gap:6px; }
    #moveStat, #hatStat{ width:auto; min-width:0; } #moveStat label, #hatStat label{ display:none; }
    #dancesBtn, #hatsBtn{ padding:4px 8px; border-radius:8px; } #dancesBtn b, #hatsBtn b{ font-size:13px; flex:1; }
    #dancesBtn::before{ content:"DANCE"; } #hatsBtn::before{ content:"HATS"; }
    #dancesBtn::before, #hatsBtn::before{ font-size:8px; letter-spacing:1.2px; color:#9fe9ff; margin-right:2px; flex:none; }
    #helpBtn{ grid-area:help; justify-self:start; align-self:center; width:26px; height:26px; font-size:13px; }
    /* lists drop down from the card, stop well short of the baby's feet, and the scene re-frames the baby below them */
    .menu{ left:8px; right:8px; width:auto; max-height:38vh; padding:8px 10px; }
    #hats{ width:auto; } #danceHead, .menuHead{ font-size:14px; } #danceTools{ margin:6px 0; }
    #danceList{ grid-template-columns:1fr 1fr; gap:3px 6px; }
    .dance{ font-size:12px; padding:2px 4px; gap:3px; } .dance label{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .menu .dance button{ font-size:10px; padding:1px 5px; box-shadow:1px 1px 0 #1a0b2e; }
    #about{ max-height:min(80vh, 640px); }
    /* bottom bar: one row */
    #controls{ bottom:calc(10px + env(safe-area-inset-bottom)); width:calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding:6px 8px; } #controls > div{ flex-wrap:wrap; gap:8px; }
    #live{ flex-wrap:nowrap !important; } #liveLabel{ font-size:13px; } #liveLabel .lg{ display:none; } #sens{ font-size:11px; gap:6px; }
    #live{ justify-content:space-between !important; gap:8px !important; } #liveLabel{ white-space:nowrap; flex:none; }
    #meter{ width:48px; } #sensRange{ width:auto; flex:1; min-width:36px; } #sens{ flex:1; min-width:0; } #live button{ padding:6px 10px; font-size:13px; }
    #sources button, #sources .btn{ flex:1 1 28%; text-align:center; font-size:13px; padding:7px 6px; } #srcLabel{ display:none; }
    #player{ min-width:0; } #trackName{ max-width:120px; } #seek{ order:5; flex-basis:100%; } #status{font-size:12px}
  }  @media (max-width:370px){ #dots{ display:none; } #bpm{ font-size:15px; } #tempoStat{ overflow:hidden; } }


