/* =====================================================================
   THEME + GLOBAL  (shared by both screens)
   ===================================================================== */
:root{
  --bg:#0A0512; --ink:#F3F1EC; --muted:#A899C4; --accent:#C084FC;
  --sans:'Inter', -apple-system, sans-serif; --display:'Space Grotesk', -apple-system, sans-serif;
}
*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%;}
body{
  background:var(--bg); color:var(--ink); font-family:var(--sans);
  overflow:hidden;
}

/* =====================================================================
   SHARED PARTICLE FIELD  (sits behind both screens)
   ===================================================================== */
#field{position:fixed; inset:0; width:100%; height:100%; display:block; pointer-events:none;}

/* =====================================================================
   SCREEN SWITCHING  (welcome <-> player crossfade)
   ===================================================================== */
.screen{
  position:fixed; inset:0; isolation:isolate;
  opacity:1; visibility:visible;
  transition:opacity .9s ease;
}
.screen.is-gone{display:none}
.screen.is-hidden{
  opacity:0; visibility:hidden; pointer-events:none;
  transition:opacity .9s ease, visibility 0s linear .9s;
}

/* =====================================================================
   WELCOME SCREEN  (rules unchanged; selectors scoped to #welcomeScreen)
   ===================================================================== */
#welcomeScreen{
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
#welcomeScreen .content{
  position:relative; z-index:2; text-align:center; padding:0 1.5rem;
  animation:rise 1.1s cubic-bezier(.19,1,.22,1) both;
}
@keyframes rise{
  from{opacity:0; transform:translateY(14px);}
  to{opacity:1; transform:translateY(0);}
}
#welcomeScreen .eyebrow{
  font-size:.85rem; color:var(--muted); letter-spacing:.02em; margin-bottom:1.1rem;
  min-height:1.2em; transition:opacity .3s ease, transform .3s ease;
}
#welcomeScreen .eyebrow.flash{ opacity:.55; transform:translateY(-2px); }

/* NEW: rainbow animation on the word "Player" in the eyebrow */
.rainbow-word{
  background:linear-gradient(90deg,#F87171,#FBBF24,#34D399,#60A5FA,#C084FC,#F87171);
  background-size:200% 100%;
  -webkit-background-clip:text; background-clip:text;
  -webkit-text-fill-color:transparent; color:transparent;
  animation:rainbowFlow 3s linear infinite;
}
@keyframes rainbowFlow{ to{background-position:200% 0;} }

#welcomeScreen h1{
  font-family:var(--display); font-weight:500;
  font-size:clamp(2.4rem, 7vw, 5rem); line-height:1.05;
}
#welcomeScreen h1 .accent{color:var(--accent);}
#welcomeScreen h1.shake{ animation:shake .45s ease; }
@keyframes shake{
  0%,100%{transform:translateX(0) rotate(0);}
  20%{transform:translateX(-10px) rotate(-2deg);}
  40%{transform:translateX(10px) rotate(2deg);}
  60%{transform:translateX(-5px) rotate(-1.5deg);}
  80%{transform:translateX(5px) rotate(1.5deg);}
}
#welcomeScreen h1.spin{ animation:spinIt .7s ease; }
@keyframes spinIt{
  0%{transform:rotate(0) scale(1);}
  50%{transform:rotate(180deg) scale(1.08);}
  100%{transform:rotate(360deg) scale(1);}
}
/* rainbow animates the white portion of the heading (h1's own inherited
   color), while the purple accent span keeps its explicit color untouched */
#welcomeScreen h1.rainbow{ animation:rainbow 1.2s linear; }
@keyframes rainbow{
  0%{color:var(--ink);} 20%{color:#F87171;} 40%{color:#FBBF24;}
  60%{color:#34D399;} 80%{color:#60A5FA;} 100%{color:var(--ink);}
}
#welcomeScreen h1.bounce{ animation:bounceIt .65s cubic-bezier(.36,.07,.19,.97); }
@keyframes bounceIt{
  0%,100%{transform:translateY(0);}
  20%{transform:translateY(-10px);}
  40%{transform:translateY(0);}
  55%{transform:translateY(-16px);}
  70%{transform:translateY(0);}
  85%{transform:translateY(-6px);}
  95%{transform:translateY(0);}
}
#welcomeScreen h1.glitch{ animation:glitchIt .5s steps(2,end); }
@keyframes glitchIt{
  0%{ transform:translate(0,0); text-shadow:none; }
  10%{ transform:translate(-3px,2px); text-shadow:2px 0 #F87171,-2px 0 #60A5FA; }
  20%{ transform:translate(3px,-2px); text-shadow:-2px 0 #34D399,2px 0 #C084FC; }
  30%{ transform:translate(-2px,1px); text-shadow:2px 0 #FBBF24,-2px 0 #60A5FA; }
  40%{ transform:translate(2px,-1px); text-shadow:-2px 0 #F87171,2px 0 #34D399; }
  50%{ transform:translate(-3px,0); text-shadow:2px 0 #60A5FA,-2px 0 #FBBF24; }
  60%{ transform:translate(3px,1px); text-shadow:-2px 0 #C084FC,2px 0 #F87171; }
  70%{ transform:translate(-1px,-2px); text-shadow:2px 0 #34D399,-2px 0 #60A5FA; }
  85%{ transform:translate(1px,1px); text-shadow:-1px 0 #FBBF24,1px 0 #C084FC; }
  100%{ transform:translate(0,0); text-shadow:none; }
}
#welcomeScreen h1.zoom{ animation:zoomIt .5s ease; }
@keyframes zoomIt{
  0%{ transform:scale(1); }
  50%{ transform:scale(1.35); }
  100%{ transform:scale(1); }
}

#welcomeScreen .go-btn{
  margin-top:2.2rem; font-family:var(--display); font-size:1.05rem;
  letter-spacing:.03em; color:var(--accent); background:transparent;
  border:2px solid var(--accent); padding:.8rem 2.4rem; border-radius:999px; cursor:pointer;
  transition:transform .15s ease, box-shadow .3s ease, background .2s ease, color .2s ease;
  /* invisible: stops the mobile long-press menu / text selection while holding */
  -webkit-touch-callout:none; user-select:none; -webkit-user-select:none;
}
#welcomeScreen .go-btn:hover{ transform:translateY(-2px); background:rgba(192,132,252,0.1); }
#welcomeScreen .go-btn:active{ transform:translateY(0) scale(.96); }
#welcomeScreen .go-btn.pulse{ animation:btnPulse .5s ease; }
@keyframes btnPulse{
  0%{ box-shadow:0 0 0 0 rgba(192,132,252,0.65); }
  100%{ box-shadow:0 0 0 26px rgba(192,132,252,0); }
}
/* NEW: the button charges up while you hold it (added after a short delay,
   so ordinary clicks never show it) */
#welcomeScreen .go-btn.holding{ animation:holdCharge .65s ease-in forwards; }
@keyframes holdCharge{
  from{ background:rgba(192,132,252,.1);  box-shadow:0 0 0 0 rgba(192,132,252,0); transform:scale(1); }
  to  { background:rgba(192,132,252,.28); box-shadow:0 0 34px 6px rgba(192,132,252,.6); transform:scale(1.05); }
}

#welcomeScreen .glow{
  position:fixed; inset:0; z-index:1; pointer-events:none;
  background:radial-gradient(circle at 50% 45%, rgba(168,85,247,0.14), transparent 55%);
}
/* separate layer for the click pulse so its opacity can fade smoothly
   in and back out without ever hard-cutting */
#welcomeScreen .glow-burst{
  position:fixed; inset:0; z-index:1; pointer-events:none;
  background:radial-gradient(circle at 50% 45%, rgba(192,132,252,0.4), transparent 60%);
  opacity:0;
}
@media (prefers-reduced-motion: reduce){
  #welcomeScreen .content{animation:none;}
  .rainbow-word{animation:none;}
  #slhint .arr{animation:none;}
}

/* =====================================================================
   PLAYER SCREEN  (rules unchanged; selectors scoped to #playerScreen)
   ===================================================================== */
#playerScreen,#playerScreen *{-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}
#playerScreen{
  --g:0;
  padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);
  display:flex;flex-direction:column;
  overflow:hidden;touch-action:none;
}
#playerScreen .pill{font-family:var(--display);letter-spacing:.03em;color:var(--accent);border:1.5px solid var(--accent);
  border-radius:999px;padding:.55rem 1.4rem;font-size:.9rem;transition:transform .15s ease,background .2s ease,opacity .4s ease}
#playerScreen .eyebrow{font-size:.85rem;color:var(--muted);letter-spacing:.02em}
#playerScreen .glow,#playerScreen .aura{position:fixed;inset:0;pointer-events:none}
#playerScreen .glow{background:radial-gradient(circle at 50% 48%,rgba(168,85,247,.14),transparent 55%)}
#playerScreen .aura{background:radial-gradient(circle at 50% 48%,rgba(192,132,252,.38),transparent 58%);opacity:0;will-change:opacity}
#playerScreen .top,#playerScreen .mid,#playerScreen .bot{position:relative;z-index:2}
#playerScreen .top{display:flex;height:24%;min-height:90px}
/* five buttons share the row: each one is as wide as its label, the spare room is split evenly */
#playerScreen .top button{flex:1 1 auto;min-width:0;padding:0 .1rem;background:none;border:0;display:flex;align-items:center;justify-content:center;cursor:pointer}
#playerScreen .top .pill{opacity:.35}
#playerScreen.touch .top .pill,#playerScreen.hint .top .pill{opacity:1}
#playerScreen .top button:active .pill{background:rgba(192,132,252,.15);transform:scale(.96)}
#playerScreen .mid{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:0;gap:6px}
#playerScreen .disc-wrap{position:relative;width:min(78vw,46vh);height:auto;aspect-ratio:1;margin-bottom:16px}
/* static shadow + a glow whose opacity follows the wheel speed (replaces the per-frame CSS drop-shadow filters) */
#playerScreen .disc-shadow,#playerScreen .disc-glow{position:absolute;inset:1.65%;border-radius:50%;pointer-events:none}
#playerScreen .disc-shadow{box-shadow:0 18px 28px rgba(0,0,0,.3)}
#playerScreen .disc-glow{box-shadow:0 0 34px 6px rgba(192,132,252,.4);opacity:0;will-change:opacity}
#disc{position:relative;display:block;width:100%;height:100%;overflow:visible;cursor:grab;touch-action:none}
/* the duration ring turns red while the tape is being written (recording or changing it) */
#ring{transition:stroke .35s ease}
#ring.rec{stroke:#F87171}
/* the turning part is its own layer, rotated by the GPU */
#rotSvg{--b:0;position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;will-change:transform}
#rotSvg .plate{fill:#F3F1EC;fill-opacity:calc(.06 + var(--b)*.05);stroke:#F3F1EC;stroke-opacity:.22;stroke-width:1.5}
#rotSvg .seg{fill:#C084FC;fill-opacity:calc(.22 + var(--b)*.3)}
#segBlur{fill:none;stroke-opacity:calc(.14 + var(--b)*.2)}
#rotSvg .hub{fill:#C084FC;fill-opacity:calc(.34 + var(--b)*.3)}
#eyebrow{min-height:1.2em}
#eyebrow,#title{opacity:.4}
#title{font-family:var(--display);font-weight:500;font-size:clamp(1.1rem,4.5vw,1.6rem);line-height:1.15;
  max-width:84vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}
#playerScreen .bot{height:20%;min-height:110px;display:flex;flex-direction:column;justify-content:flex-end;padding:0 9vw 20px}
#time{font-family:var(--display);font-size:.85rem;color:var(--muted);letter-spacing:.06em;font-variant-numeric:tabular-nums;text-align:center;margin-bottom:12px}
/* "<- slide ->" hint: stays until the user slides once, then turns into the wheel speed readout */
#slhint{position:absolute;left:0;right:0;bottom:56px;height:2.4rem;display:flex;justify-content:center;align-items:center;
  font-family:var(--display);font-weight:500;font-size:1.35rem;color:var(--ink);letter-spacing:.1em;pointer-events:none}
#slhint .slwords{display:flex;align-items:center;gap:1.4rem;opacity:.85;transition:opacity .5s ease}
/* once slid, the words fade out and the wheel speed fades in at the same spot (minus = backwards) */
#spd{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  font-variant-numeric:tabular-nums;opacity:0;transition:opacity .5s ease}
#slhint .arr{display:inline-block;font-size:2.1rem;line-height:1;color:var(--accent);animation:slNudgeL 1.6s ease-in-out infinite}
#slhint .arr.r{animation-name:slNudgeR}
@keyframes slNudgeL{0%,100%{transform:translateX(0)}50%{transform:translateX(-10px)}}
@keyframes slNudgeR{0%,100%{transform:translateX(0)}50%{transform:translateX(10px)}}
#playerScreen.slid #slhint .slwords{opacity:0}
#playerScreen.slid #spd{opacity:.85}
#drop{position:fixed;inset:0;z-index:5;border:2px dashed var(--accent);display:none;align-items:center;justify-content:center;
  background:rgba(10,5,18,.88);font-family:var(--display);color:var(--accent)}
#drop.on{display:flex}

/* NEW: "Open" window (file / drop / link) */
#playerScreen .modal{
  position:fixed;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;padding:1.5rem;
  background:rgba(10,5,18,.7);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity .25s ease, visibility 0s linear .25s;
}
#playerScreen .modal.is-open{opacity:1;visibility:visible;pointer-events:auto;transition:opacity .25s ease}
#playerScreen .modal-card{
  width:min(92vw,400px);padding:1.2rem 1.2rem 1.1rem;border-radius:22px;
  background:rgba(20,10,34,.94);border:1.5px solid rgba(192,132,252,.45);
  box-shadow:0 20px 60px rgba(0,0,0,.55),0 0 40px rgba(168,85,247,.15);
  transform:translateY(10px) scale(.98);transition:transform .25s ease;
  max-height:100%;overflow-y:auto;touch-action:pan-y;overscroll-behavior:contain;
}
#playerScreen .modal.is-open .modal-card{transform:none}
#playerScreen .modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:.9rem}
#playerScreen .modal-title{font-family:var(--display);font-weight:500;font-size:1.05rem}
#playerScreen .modal-x{background:none;border:0;color:var(--muted);font-size:1.6rem;line-height:1;cursor:pointer;padding:.1rem .5rem;border-radius:8px}
#playerScreen .modal-x:hover{color:var(--ink)}
#playerScreen .dropzone{
  display:flex;flex-direction:column;align-items:center;gap:.8rem;text-align:center;
  padding:1.3rem 1rem;border:1.5px dashed rgba(192,132,252,.5);border-radius:16px;
  color:var(--muted);font-size:.85rem;transition:background .2s ease,border-color .2s ease;
}
#playerScreen .dropzone.over{background:rgba(192,132,252,.12);border-color:var(--accent)}
#playerScreen .modal-or{text-align:center;color:var(--muted);font-size:.7rem;letter-spacing:.12em;margin:.9rem 0 .6rem}
#playerScreen .linkrow{display:flex;gap:.6rem}
#playerScreen .linkrow input{
  flex:1;min-width:0;font:inherit;font-size:1rem;color:var(--ink);outline:none;
  background:rgba(243,241,236,.06);border:1.5px solid rgba(192,132,252,.35);border-radius:999px;padding:.55rem 1rem;
  user-select:text;-webkit-user-select:text;transition:border-color .2s ease;
}
#playerScreen .linkrow input:focus{border-color:var(--accent)}
#playerScreen .linkrow input::placeholder{color:rgba(168,153,196,.6)}
#playerScreen button.pill{background:none;cursor:pointer}
#playerScreen button.pill:hover{background:rgba(192,132,252,.12)}
#playerScreen button.pill:active{transform:scale(.96)}
#playerScreen .modal-msg{min-height:1.1em;margin-top:.6rem;font-size:.78rem;color:#F87171;text-align:center}

/* NEW: scrollable song list in the Open window */
#playerScreen .modal-label{color:var(--muted);font-size:.7rem;letter-spacing:.12em;margin-bottom:.5rem}
#playerScreen .songlist{
  max-height:min(30vh,220px);overflow-y:auto;touch-action:pan-y;overscroll-behavior:contain;
  padding:.25rem;border:1.5px solid rgba(192,132,252,.25);border-radius:16px;
  scrollbar-width:thin;scrollbar-color:rgba(192,132,252,.5) transparent;
}
#playerScreen .songlist:empty{display:none}
#playerScreen .songlist::-webkit-scrollbar{width:6px}
#playerScreen .songlist::-webkit-scrollbar-thumb{background:rgba(192,132,252,.45);border-radius:6px}
#playerScreen .song{
  display:block;width:100%;text-align:left;background:none;border:0;cursor:pointer;
  font:inherit;font-size:.92rem;color:var(--ink);padding:.55rem .8rem;border-radius:11px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
#playerScreen .song:hover,#playerScreen .song:focus-visible{background:rgba(192,132,252,.14);outline:none}
#playerScreen .song:active{background:rgba(192,132,252,.24)}
#playerScreen .modal-note{margin-top:.4rem;font-size:.78rem;color:var(--muted);text-align:center}
#playerScreen .modal-note:empty{display:none}

/* Top row: five pills (Open, Record, Play / Stop, Unload, Rewind). Labels stay on one line and
   the pills shrink with the screen width, so all five fit a 320-360px phone. */
#playerScreen .top .pill{
  white-space:nowrap;
  font-size:clamp(.62rem,3.1vw,.9rem);
  padding:.55rem clamp(.4rem,2.35vw,1.4rem);
}

/* NEW: record mode. The Record pill turns red while armed and glows while the tape is being written. */
#playerScreen #bRec.on .pill,
#playerScreen #bUnload.arm .pill{color:#F87171;border-color:#F87171;opacity:1}
#playerScreen #bRec.live .pill{background:rgba(248,113,113,.12);animation:recPulse 1.4s ease-in-out infinite}
@keyframes recPulse{
  0%,100%{box-shadow:0 0 0 0 rgba(248,113,113,0)}
  50%{box-shadow:0 0 18px 2px rgba(248,113,113,.55)}
}
@media (prefers-reduced-motion: reduce){
  #playerScreen #bRec.live .pill{animation:none;box-shadow:0 0 14px 2px rgba(248,113,113,.45)}
}
