/* OUT v5 — control hierarchy + dependency readability */

.controls{
  grid-template-columns:1.22fr .92fr .92fr 1.08fr;
  gap:8px;
}
.controls .button{
  position:relative;
  min-height:50px;
  overflow:hidden;
  border-color:rgba(255,255,255,.16);
  background:linear-gradient(180deg,rgba(14,27,45,.88),rgba(5,12,23,.9));
  box-shadow:inset 0 1px rgba(255,255,255,.06),0 10px 24px rgba(0,0,0,.2);
}
.controls .button:before{
  content:"";
  position:absolute;
  left:8px;right:8px;top:0;height:1px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.35),transparent);
  opacity:.7;
}
#rewind{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  border-color:rgba(255,214,112,.62);
  background:linear-gradient(135deg,rgba(83,58,13,.86),rgba(21,20,19,.92) 56%,rgba(11,17,27,.94));
  color:#fff4c2;
  box-shadow:inset 0 0 0 1px rgba(255,221,128,.10),0 0 24px rgba(255,194,66,.13),0 10px 24px rgba(0,0,0,.25);
  text-align:left;
}
#rewind:not(:disabled){
  box-shadow:inset 0 0 0 1px rgba(255,231,158,.18),0 0 28px rgba(255,198,72,.24),0 10px 24px rgba(0,0,0,.3);
}
#rewind:disabled{
  opacity:.48;
  filter:saturate(.55);
}
.rewind-glyph{
  width:31px;height:31px;flex:0 0 31px;
  display:grid;place-items:center;
  border-radius:10px;
  background:rgba(255,224,137,.12);
  border:1px solid rgba(255,225,142,.28);
}
.rewind-glyph svg{width:23px;height:23px;overflow:visible}
.rewind-glyph path{fill:none;stroke:#fff0ad;stroke-width:3.3;stroke-linecap:round;stroke-linejoin:round}
.rewind-copy{display:flex;flex-direction:column;line-height:1.02;min-width:0}
.rewind-copy b{font-size:11px;letter-spacing:.08em}
.rewind-copy small{font-size:7px;letter-spacing:.08em;margin-top:4px;color:#d8c79b;opacity:.82}

#sound{border-color:rgba(105,221,255,.26)}
#mixToggle{border-color:rgba(185,132,255,.32);background:linear-gradient(180deg,rgba(45,25,72,.76),rgba(8,13,25,.92))}
#newRun{border-color:rgba(118,239,185,.38);box-shadow:inset 0 1px rgba(255,255,255,.18),0 0 22px rgba(81,224,166,.10)}

/* A moved-but-not-out piece is a deliberate temporary state, not a failed tap. */
.piece.is-held{z-index:7}
.piece.is-held:after,
.piece.return-ready:after{
  position:absolute;
  left:50%;top:4px;
  transform:translateX(-50%);
  z-index:20;
  pointer-events:none;
  padding:3px 6px;
  border-radius:999px;
  font-size:7px;
  line-height:1;
  font-weight:1000;
  letter-spacing:.12em;
  color:#07101d;
  background:#ffd46f;
  border:1px solid rgba(255,255,255,.72);
  box-shadow:0 3px 12px rgba(0,0,0,.45),0 0 16px rgba(255,212,111,.34);
}
.piece.is-held:after{content:"HOLD"}
.piece.return-ready:after{content:"RETURN";background:#8ff4c7;color:#04140d;box-shadow:0 3px 12px rgba(0,0,0,.45),0 0 18px rgba(114,239,176,.38)}
.piece.hold-pulse svg{animation:hold-piece-pulse .62s ease-out}
.piece.dep-open svg{animation:open-piece-pulse .82s ease-out}
@keyframes hold-piece-pulse{0%{filter:brightness(1)}28%{filter:brightness(1.48)}100%{filter:brightness(1)}}
@keyframes open-piece-pulse{0%{filter:brightness(1)}25%{filter:brightness(1.58) saturate(1.28)}55%{filter:brightness(1.2)}100%{filter:brightness(1)}}

.dependency-links{
  position:absolute;
  inset:0;
  width:100%;height:100%;
  overflow:visible;
  pointer-events:none;
  z-index:28;
}
.dependency-links path{
  fill:none;
  stroke:#fff1a8;
  stroke-width:2.2;
  stroke-linecap:round;
  stroke-dasharray:7 7;
  filter:drop-shadow(0 0 5px rgba(255,212,111,.85));
  animation:dependency-dash .82s ease-out forwards;
}
.dependency-links circle{
  fill:#8ff4c7;
  stroke:white;
  stroke-width:1.4;
  filter:drop-shadow(0 0 5px rgba(114,239,176,.8));
  animation:dependency-dot .82s ease-out forwards;
}
@keyframes dependency-dash{0%{opacity:0;stroke-dashoffset:30}18%{opacity:1}100%{opacity:0;stroke-dashoffset:0}}
@keyframes dependency-dot{0%{opacity:0;transform:scale(.4);transform-origin:center}22%{opacity:1;transform:scale(1.35)}100%{opacity:0;transform:scale(1)}}

@media(max-width:760px){
  .controls{grid-template-columns:1.22fr .9fr .9fr 1.02fr!important;gap:4px!important}
  .controls .button{min-height:44px!important;padding:5px 4px!important;font-size:8px!important}
  #rewind{gap:5px!important;padding:4px 5px!important}
  .rewind-glyph{width:27px;height:27px;flex-basis:27px;border-radius:8px}
  .rewind-glyph svg{width:20px;height:20px}.rewind-glyph path{stroke-width:3.5}
  .rewind-copy b{font-size:8px}.rewind-copy small{font-size:5.5px;margin-top:3px}
  .piece.is-held:after,.piece.return-ready:after{font-size:5.5px;padding:2px 4px;top:2px}
  .dependency-links path{stroke-width:1.7;filter:none}
  .dependency-links circle{filter:none}
}

@media(max-width:390px){
  .rewind-copy small{display:none}
  .rewind-copy b{font-size:7.5px}
  .controls .button{font-size:7px!important}
}

@media(prefers-reduced-motion:reduce){
  .piece.hold-pulse svg,.piece.dep-open svg,.dependency-links path,.dependency-links circle{animation:none!important}
}
