/* Beat Bot — retro CRT DJ deck (no external fonts/assets) */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #140810;
  --panel: #1e1020;
  --panel-edge: #3d2048;
  --neon-pink: #ff4ecd;
  --neon-cyan: #3df0ff;
  --neon-lime: #b8ff3d;
  --neon-amber: #ffc14d;
  --neon-purple: #a78bfa;
  --text: #f3e8ff;
  --muted: #9b8aab;
  --cell: #2a1832;
  --cell-on: #ff4ecd;
  --cell-play: #3df0ff;
  --pixel: "Courier New", Courier, ui-monospace, monospace;
}

html,
body {
  min-height: 100%;
  background: #0a0508;
  color: var(--text);
  font-family: var(--pixel);
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 78, 205, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(61, 240, 255, 0.08), transparent 45%),
    #0a0508;
}

.crt {
  position: relative;
  width: min(56rem, 100%);
  margin: 0 auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.85rem max(1.25rem, env(safe-area-inset-bottom));
  min-height: calc(100vh - var(--rg-bar));
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: var(--rg-bar) 0 0 0;
  z-index: 50;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.home-link {
  color: var(--neon-cyan);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.home-link:hover {
  text-decoration: underline;
}

.logo {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: clamp(0.7rem, 2.8vw, 1rem);
  letter-spacing: 0.06em;
  color: var(--neon-amber);
  text-shadow: 0 0 12px rgba(255, 193, 77, 0.55);
}

.logo span {
  color: var(--neon-pink);
  text-shadow: 0 0 12px rgba(255, 78, 205, 0.55);
}

.version {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* DJ stage */
.dj-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.15rem;
  margin-bottom: 1rem;
  min-height: 7.25rem;
}

.stage-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.5rem;
}

.dj {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: transform 0.08s ease;
}

.dj.bounce {
  transform: translateY(-6px) scale(1.05);
}

/* ── Squipy on the stand ──────────────────────────── */
.squipy-dj {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  position: relative;
  z-index: 2;
}

.squipy-body {
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 0.5rem;
  background: linear-gradient(160deg, #c4b5fd, #7c3aed 55%, #5b21b6);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 0 16px rgba(167, 139, 250, 0.55),
    0 0 28px rgba(255, 78, 205, 0.2);
  display: grid;
  place-items: center;
  will-change: transform;
  transition: filter 0.12s ease, box-shadow 0.12s ease;
}

.squipy-dj .sq-face {
  position: relative;
  width: 1.65rem;
  height: 1.15rem;
}

.squipy-dj .brow {
  position: absolute;
  top: -0.05rem;
  width: 0.44rem;
  height: 0.1rem;
  background: #0a0508;
  border-radius: 2px;
  transition: transform 0.12s ease, top 0.12s ease;
}

.squipy-dj .brow.left {
  left: 0.12rem;
}
.squipy-dj .brow.right {
  right: 0.12rem;
}

.squipy-dj .eye {
  position: absolute;
  top: 0.14rem;
  width: 0.32rem;
  height: 0.32rem;
  background: #0a0508;
  border-radius: 50%;
  transition:
    width 0.12s ease,
    height 0.12s ease,
    top 0.12s ease,
    border-radius 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
}

.squipy-dj .eye.left {
  left: 0.14rem;
}
.squipy-dj .eye.right {
  right: 0.14rem;
}

.squipy-dj .eye::after {
  content: "";
  position: absolute;
  top: 0.04rem;
  right: 0.04rem;
  width: 0.09rem;
  height: 0.09rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.squipy-dj .mouth {
  position: absolute;
  left: 50%;
  bottom: 0.02rem;
  width: 0.68rem;
  height: 0.26rem;
  border-bottom: 2.5px solid #0a0508;
  border-radius: 0 0 50% 50%;
  transform: translateX(-50%);
  transition: width 0.12s ease, height 0.12s ease, border 0.12s ease, bottom 0.12s ease, background 0.12s ease;
}

.squipy-dj .cheek {
  position: absolute;
  bottom: 0.24rem;
  width: 0.24rem;
  height: 0.15rem;
  border-radius: 50%;
  background: rgba(244, 114, 182, 0.55);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.squipy-dj .cheek.left {
  left: -0.04rem;
}
.squipy-dj .cheek.right {
  right: -0.04rem;
}

.squipy-label {
  color: #c4b5fd !important;
  text-shadow: 0 0 8px rgba(167, 139, 250, 0.55);
  letter-spacing: 0.14em !important;
}

/* Moods */
.squipy-dj[data-mood="idle"] .cheek {
  opacity: 0.5;
}

.squipy-dj[data-mood="groove"] .brow.left,
.squipy-dj[data-mood="groove"] .brow.right {
  top: -0.08rem;
}
.squipy-dj[data-mood="groove"] .mouth {
  width: 0.9rem;
  height: 0.34rem;
  border-bottom-width: 3px;
}
.squipy-dj[data-mood="groove"] .cheek {
  opacity: 0.85;
}

.squipy-dj[data-mood="kick"] .brow.left {
  transform: rotate(12deg);
}
.squipy-dj[data-mood="kick"] .brow.right {
  transform: rotate(-12deg);
}
.squipy-dj[data-mood="kick"] .eye {
  width: 0.4rem;
  height: 0.4rem;
  top: 0.08rem;
}
.squipy-dj[data-mood="kick"] .mouth {
  width: 0.5rem;
  height: 0.48rem;
  border: 2.5px solid #0a0508;
  border-radius: 50%;
  bottom: -0.08rem;
  background: rgba(10, 5, 8, 0.12);
}

.squipy-dj[data-mood="snare"] .eye.left {
  height: 0.12rem;
  border-radius: 2px;
  top: 0.26rem;
}
.squipy-dj[data-mood="snare"] .eye.left::after {
  display: none;
}
.squipy-dj[data-mood="snare"] .mouth {
  width: 0.85rem;
  transform: translateX(-40%);
}
.squipy-dj[data-mood="snare"] .cheek {
  opacity: 0.9;
}

.squipy-dj[data-mood="hat"] .eye {
  height: 0.14rem;
  border-radius: 2px;
  top: 0.26rem;
}
.squipy-dj[data-mood="hat"] .eye::after {
  display: none;
}
.squipy-dj[data-mood="hat"] .mouth {
  width: 0.55rem;
  height: 0;
  border-radius: 0;
  bottom: 0.16rem;
}

.squipy-dj[data-mood="hype"] .brow.left,
.squipy-dj[data-mood="hype"] .brow.right {
  top: -0.16rem;
}
.squipy-dj[data-mood="hype"] .eye {
  width: 0.44rem;
  height: 0.44rem;
  top: 0.04rem;
  background: #fff;
  box-shadow: inset 0 0 0 0.1rem #0a0508;
}
.squipy-dj[data-mood="hype"] .eye::after {
  top: 0.12rem;
  right: 0.1rem;
  width: 0.12rem;
  height: 0.12rem;
  background: #0a0508;
}
.squipy-dj[data-mood="hype"] .mouth {
  width: 0.58rem;
  height: 0.55rem;
  border: 2.5px solid #0a0508;
  border-radius: 50%;
  bottom: -0.12rem;
  background: rgba(10, 5, 8, 0.1);
}
.squipy-dj[data-mood="hype"] .cheek {
  opacity: 0.75;
}

.squipy-dj[data-mood="chill"] .eye {
  height: 0.12rem;
  border-radius: 2px;
  top: 0.28rem;
}
.squipy-dj[data-mood="chill"] .eye::after {
  display: none;
}
.squipy-dj[data-mood="chill"] .mouth {
  width: 0.7rem;
  height: 0.28rem;
}

/* Continuous dance while pattern/loop is playing */
.squipy-dj.dancing .squipy-body {
  animation: squipy-dance 0.42s ease-in-out infinite;
  box-shadow:
    0 0 18px rgba(167, 139, 250, 0.7),
    0 0 32px rgba(255, 78, 205, 0.35);
}

.squipy-dj.beat-pop .squipy-body {
  animation: squipy-beat 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes squipy-dance {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg) scale(1);
  }
  25% {
    transform: translateY(-8px) rotate(5deg) scale(1.06);
  }
  50% {
    transform: translateY(-2px) rotate(-3deg) scale(1.02);
  }
  75% {
    transform: translateY(-9px) rotate(6deg) scale(1.08);
  }
}

@keyframes squipy-beat {
  0% {
    transform: scale(1) translateY(0);
  }
  40% {
    transform: scale(1.16) translateY(-10px) rotate(-6deg);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.squipy-dj.dancing.beat-pop .squipy-body {
  animation: squipy-beat 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.dj-body.tri {
  width: 0;
  height: 0;
  border-left: 1.35rem solid transparent;
  border-right: 1.35rem solid transparent;
  border-bottom: 2.2rem solid var(--neon-cyan);
  filter: drop-shadow(0 0 10px rgba(61, 240, 255, 0.55));
  position: relative;
}

.dj-body.cir {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e9d5ff, var(--neon-purple) 55%, #5b21b6);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.65);
}

.dj-face {
  position: relative;
  height: 0;
  width: 0;
  pointer-events: none;
}

.triangle-dj .dj-face {
  margin-top: -1.55rem;
  margin-left: 0.05rem;
}

.circle-dj .dj-face {
  margin-top: -1.65rem;
}

.dj-face .eye {
  position: absolute;
  width: 0.28rem;
  height: 0.28rem;
  background: #0a0508;
  border-radius: 50%;
}

.triangle-dj .eye:first-child {
  left: -0.55rem;
  top: 0;
}

.triangle-dj .eye:nth-child(2) {
  left: 0.28rem;
  top: 0;
}

.circle-dj .eye:first-child {
  left: -0.55rem;
  top: 0;
}

.circle-dj .eye:nth-child(2) {
  left: 0.28rem;
  top: 0;
}

.dj-face .mouth {
  position: absolute;
  left: -0.28rem;
  top: 0.45rem;
  width: 0.55rem;
  height: 0.2rem;
  border-bottom: 2px solid #0a0508;
  border-radius: 0 0 50% 50%;
}

.dj-face .mouth.smile {
  border-bottom-width: 2.5px;
  width: 0.65rem;
  left: -0.32rem;
}

.dj-name {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.45rem;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.deck-lights {
  display: flex;
  gap: 0.35rem;
  padding-bottom: 0.15rem;
}

.deck-lights span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #3a2038;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
}

.deck-lights span.on {
  background: var(--neon-lime);
  box-shadow: 0 0 10px var(--neon-lime);
}

.deck-lights span:nth-child(even).on {
  background: var(--neon-pink);
  box-shadow: 0 0 10px var(--neon-pink);
}

/* Panels */
.deck {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel {
  background: linear-gradient(165deg, #261428, var(--panel));
  border: 2px solid var(--panel-edge);
  border-radius: 0.65rem;
  padding: 0.75rem 0.85rem 0.9rem;
  box-shadow:
    0 0 0 1px rgba(255, 78, 205, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel-label {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.48rem;
  color: var(--neon-cyan);
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
  opacity: 0.9;
}

/* Transport */
.transport-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.transport-row.secondary {
  margin-top: 0.75rem;
  gap: 1rem;
}

.big-btn {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.55rem;
  padding: 0.7rem 0.85rem;
  border: 2px solid #4a3058;
  border-radius: 0.4rem;
  background: #2a1834;
  color: var(--text);
  cursor: pointer;
  min-width: 5.5rem;
  letter-spacing: 0.04em;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.1s ease;
}

.big-btn:hover {
  filter: brightness(1.1);
}

.big-btn:active {
  transform: scale(0.97);
}

.big-btn.play {
  border-color: var(--neon-lime);
  color: var(--neon-lime);
  box-shadow: 0 0 12px rgba(184, 255, 61, 0.2);
}

.big-btn.play.playing {
  background: rgba(184, 255, 61, 0.15);
  box-shadow: 0 0 18px rgba(184, 255, 61, 0.35);
}

.big-btn.stop {
  border-color: var(--neon-amber);
  color: var(--neon-amber);
}

.big-btn.loop {
  border-color: var(--neon-pink);
  color: var(--muted);
}

.big-btn.loop.active {
  color: var(--neon-pink);
  background: rgba(255, 78, 205, 0.12);
  box-shadow: 0 0 14px rgba(255, 78, 205, 0.3);
}

.knob-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.knob-wrap span {
  min-width: 1.8rem;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.42rem;
  color: var(--neon-amber);
}

.knob-wrap input[type="range"] {
  width: 7rem;
  accent-color: var(--neon-pink);
}

.knob-wrap output {
  min-width: 1.8rem;
  color: var(--neon-cyan);
  font-weight: 700;
}

.step-readout {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.step-readout .label {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.38rem;
  color: var(--muted);
}

#step-display {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--neon-lime);
  text-shadow: 0 0 10px rgba(184, 255, 61, 0.4);
}

/* Pads — compact tiles for 32 sounds */
.pad-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.28rem;
}

.pad {
  aspect-ratio: auto;
  height: 2.05rem;
  max-height: 2.05rem;
  min-height: 2.05rem;
  border: 2px solid #4a3058;
  border-radius: 0.3rem;
  background: linear-gradient(160deg, #3a2244, #221028);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 800;
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.15rem 0.35rem;
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.08s ease;
}

.pad .pad-name {
  line-height: 1;
  text-align: center;
  font-size: 1em;
}

.pad .key {
  opacity: 0.55;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: var(--pixel);
}

.pad:hover {
  border-color: var(--neon-cyan);
}

.pad:active,
.pad.hit {
  transform: scale(0.94);
  background: linear-gradient(160deg, #5a3068, #3a1848);
  box-shadow: 0 0 16px rgba(255, 78, 205, 0.45);
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}

.pad[data-sound="kick"] { border-bottom-color: var(--neon-amber); }
.pad[data-sound="snare"] { border-bottom-color: var(--neon-pink); }
.pad[data-sound="hat"] { border-bottom-color: var(--neon-cyan); }
.pad[data-sound="clap"] { border-bottom-color: var(--neon-lime); }
.pad[data-sound="tom"] { border-bottom-color: #f472b6; }
.pad[data-sound="bass"] { border-bottom-color: #818cf8; }
.pad[data-sound="lead"] { border-bottom-color: #34d399; }
.pad[data-sound="fx"] { border-bottom-color: #fbbf24; }
.pad[data-sound="ohat"] { border-bottom-color: #67e8f9; }
.pad[data-sound="rim"] { border-bottom-color: #fb7185; }
.pad[data-sound="cow"] { border-bottom-color: #fde047; }
.pad[data-sound="shaker"] { border-bottom-color: #c4b5fd; }
.pad[data-sound="perc"] { border-bottom-color: #fdba74; }
.pad[data-sound="chord"] { border-bottom-color: #6ee7b7; }
.pad[data-sound="laser"] { border-bottom-color: #f0abfc; }
.pad[data-sound="blip"] { border-bottom-color: #93c5fd; }
.pad[data-sound="zap"] { border-bottom-color: #f472b6; }
.pad[data-sound="noise"] { border-bottom-color: #a3e635; }
.pad[data-sound="sub"] { border-bottom-color: #38bdf8; }
.pad[data-sound="bell"] { border-bottom-color: #fcd34d; }
.pad[data-sound="crash"] { border-bottom-color: #fca5a5; }
.pad[data-sound="ride"] { border-bottom-color: #fde68a; }
.pad[data-sound="htom"] { border-bottom-color: #fda4af; }
.pad[data-sound="click"] { border-bottom-color: #e2e8f0; }
.pad[data-sound="glass"] { border-bottom-color: #a5f3fc; }
.pad[data-sound="pluck"] { border-bottom-color: #bbf7d0; }
.pad[data-sound="whoosh"] { border-bottom-color: #c4b5fd; }
.pad[data-sound="siren"] { border-bottom-color: #f9a8d4; }
.pad[data-sound="boom"] { border-bottom-color: #fdba74; }
.pad[data-sound="metal"] { border-bottom-color: #cbd5e1; }
.pad[data-sound="arp"] { border-bottom-color: #86efac; }
.pad[data-sound="squelch"] { border-bottom-color: #e879f9; }

/* Sequencer */
.seq-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.mini-btn {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.4rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #4a3058;
  border-radius: 0.3rem;
  background: #2a1834;
  color: var(--muted);
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

.seq-wrap {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.28rem;
  overflow-x: auto;
  max-height: min(28rem, 52vh);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.seq-track-labels {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.seq-track-labels span {
  height: 1.2rem;
  display: flex;
  align-items: center;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 0.34rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.seq-grid {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 18rem;
}

.seq-row {
  display: grid;
  grid-template-columns: repeat(16, minmax(1.05rem, 1fr));
  gap: 0.16rem;
}

.cell {
  border: 1px solid #3a2548;
  border-radius: 0.2rem;
  background: var(--cell);
  cursor: pointer;
  padding: 0;
  min-height: 1.2rem;
}

.cell:nth-child(4n + 1) {
  border-color: #4a3060;
}

.cell.on {
  background: var(--cell-on);
  box-shadow: 0 0 8px rgba(255, 78, 205, 0.55);
  border-color: #ff8ae0;
}

.cell.playhead {
  outline: 2px solid var(--cell-play);
  outline-offset: -1px;
  box-shadow: 0 0 10px rgba(61, 240, 255, 0.45);
}

.cell.on.playhead {
  background: var(--cell-play);
  box-shadow: 0 0 12px rgba(61, 240, 255, 0.65);
}

/* Master */
.master .vu {
  display: flex;
  gap: 0.4rem;
  height: 0.55rem;
  margin-bottom: 0.55rem;
}

.vu-bar {
  flex: 1;
  border-radius: 2px;
  background: linear-gradient(90deg, #1a1020 0%, #1a1020 100%);
  box-shadow: inset 0 0 0 1px #3a2548;
  overflow: hidden;
  position: relative;
}

.vu-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--lvl, 8%);
  background: linear-gradient(90deg, var(--neon-lime), var(--neon-amber), var(--neon-pink));
  transition: width 0.05s linear;
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .pad-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 720px) {
  .pad-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 520px) {
  .pad-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .pad {
    height: 1.9rem;
    max-height: 1.9rem;
    min-height: 1.9rem;
    font-size: clamp(0.78rem, 3.4vw, 0.95rem);
  }

  .big-btn {
    flex: 1;
    min-width: 0;
  }

  .step-readout {
    margin-left: 0;
  }

  .transport-row.secondary {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dj,
  .big-btn,
  .pad {
    transition: none;
  }

  .squipy-dj.dancing .squipy-body,
  .squipy-dj.beat-pop .squipy-body,
  .squipy-dj.dancing.beat-pop .squipy-body {
    animation: none;
  }

  .scanlines {
    display: none;
  }
}
