@font-face { font-family: 'Aeonik Pro'; src: url('../assets/fonts/AeonikPro-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Aeonik Pro'; src: url('../assets/fonts/AeonikPro-Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Aeonik Pro'; src: url('../assets/fonts/AeonikPro-Bold.otf') format('opentype'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Aeonik Pro'; src: url('../assets/fonts/AeonikPro-Black.otf') format('opentype'); font-weight: 800 900; font-display: swap; }

:root {
  --bg: #07051a;
  --glass: rgba(20, 16, 50, 0.74);
  --glass-hi: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f5ff;
  --muted: #a9a6d6;
  --pink: #ff3d9a;
  --cyan: #35e0ff;
  --violet: #8786ee;
  --purple: #6057c7;
  --deep: #352f87;
  --green: #04c790;
  --red: #e72323;
  --r-sm: 14px;
  --r-lg: 24px;
  --deck-w: 360px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body {
  font: 400 15px/1.55 'Aeonik Pro', 'Inter', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; }
input { user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; display: block; touch-action: none; }
body.painting #stage { cursor: crosshair; }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* ---------- glass bits */
.pill, .card, #deck, .popover, #paintBar, #toast {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

button.icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-grid; place-items: center;
  background: var(--glass-hi); font-size: 16px; line-height: 1;
  transition: background .15s, transform .1s;
}
button.icon:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: scale(0.96); }

/* ---------- HUD */
#hud {
  position: fixed; top: 16px; left: 16px; right: calc(var(--deck-w) + 32px);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; z-index: 10;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--r-sm); }
.pill.tools { margin-left: auto; }
#beatDots { display: flex; gap: 5px; padding: 0 6px 0 8px; }
#beatDots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); transition: background .08s, box-shadow .08s; }
#beatDots i.on { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
#beatDots i.on:first-child { background: var(--pink); box-shadow: 0 0 12px var(--pink); }
.bpm { display: flex; align-items: baseline; gap: 4px; min-width: 76px; justify-content: center; }
.bpm span { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.bpm small { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; }
.tap {
  height: 34px; padding: 0 14px; border-radius: 10px; font-weight: 700; letter-spacing: 0.08em; font-size: 13px;
  background: linear-gradient(135deg, var(--purple), var(--deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.tap.hit { background: linear-gradient(135deg, var(--cyan), var(--violet)); color: #07051a; }
.more { display: flex; gap: 4px; padding-left: 4px; border-left: 1px solid var(--line); margin-left: 2px; }
.party {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px;
  font-weight: 600; background: var(--glass-hi);
}
.party.on { background: rgba(4, 199, 144, 0.16); color: #7dffd6; }
.party .ic { font-size: 13px; }
.drop {
  height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 800; letter-spacing: 0.06em;
  background: linear-gradient(135deg, var(--pink), #ff8a3d);
  box-shadow: 0 0 24px rgba(255, 61, 154, 0.45);
  color: #fff;
}
.drop.armed { animation: armed .25s infinite alternate; }
.callout { padding: 0 10px 0 6px; font-size: 13px; font-weight: 600; white-space: nowrap; min-width: 120px; }
.callout:empty { display: none; }
.callout.pop { animation: callout .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes callout { from { transform: scale(1.35); color: var(--cyan); } }
@keyframes armed { to { filter: brightness(1.5); transform: scale(1.05); } }

/* ---------- paint bar */
#paintBar {
  position: fixed; top: 72px; left: 16px; z-index: 11;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: var(--r-sm);
  border-color: rgba(53, 224, 255, 0.4);
}
#paintLabel { font-weight: 600; }

/* ---------- deck */
#deck {
  position: fixed; top: 16px; right: 16px; bottom: 16px; width: var(--deck-w);
  border-radius: var(--r-lg); z-index: 12;
  display: flex; flex-direction: column; overflow: hidden;
}
#deckHandle { display: none; }
#booth { border: 0; box-shadow: none; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--line); flex: none; }
.booth-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.booth-head h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.booth-head .state { margin-left: auto; font-size: 12px; color: var(--muted); }
.live { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); }
.live.on { background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
#spotifyWrap { border-radius: 12px; overflow: hidden; min-height: 152px; background: rgba(0, 0, 0, 0.3); }
#spotifyWrap iframe { display: block; border: 0; }
.sp-offline { padding: 20px; font-size: 13px; color: var(--muted); }
#spForm { display: flex; gap: 6px; margin: 10px 0 8px; }
#spForm input, #marqueeInput {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); outline: none;
}
#spForm input:focus, #marqueeInput:focus { border-color: var(--violet); }
#spForm button { height: 36px; padding: 0 14px; border-radius: 10px; background: var(--glass-hi); font-weight: 600; font-size: 13px; }
.booth-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 8px; }
.booth-row input[type=range] { width: 110px; }
.meter { width: 110px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--cyan), var(--pink)); transition: width .06s; }

#tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); flex: none; }
#tabs button {
  flex: 1; padding: 9px 4px 10px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
#tabs button.active { color: var(--text); border-bottom-color: var(--pink); }
.mobile-only { display: none; }

#deckBody { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.panel { display: none; padding: 14px 16px 20px; }
.panel.active { display: block; }
.panel h3 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
  margin: 18px 0 8px;
}
.panel h3:first-child { margin-top: 2px; }
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.hint { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-top: 10px; }
.hint b { color: var(--text); font-weight: 600; }

.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row button, .chips button, .seg button, .cc-actions button, .primary {
  height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13px; font-weight: 500;
  background: var(--glass-hi); border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.row button { flex: 1; }
.row button:hover, .chips button:hover, .seg button:hover, .cc-actions button:hover { background: rgba(255, 255, 255, 0.12); }
.row button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.primary { background: linear-gradient(135deg, var(--purple), var(--deep)) !important; font-weight: 600; padding: 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button.active, .seg button.active { background: rgba(135, 134, 238, 0.28); border-color: rgba(135, 134, 238, 0.6); }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); }
.seg button { flex: 1; height: 32px; padding: 0 6px; background: transparent; }
.seg.small button { height: 28px; font-size: 12px; }

/* roster */
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.roster button {
  position: relative; aspect-ratio: 0.82; border-radius: 12px; background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 4px 2px 6px; touch-action: manipulation; transition: transform .15s, background .15s;
  overflow: hidden;
}
.roster button::before {
  content: ''; position: absolute; inset: auto 10% 16% 10%; height: 30%; border-radius: 50%;
  background: var(--accent, #8786ee); opacity: .25; filter: blur(12px);
}
.roster button:hover { background: rgba(255, 255, 255, 0.09); transform: translateY(-2px); }
.roster img { width: 100%; flex: 1; min-height: 0; object-fit: contain; object-position: bottom; pointer-events: none; position: relative; -webkit-user-drag: none; }
.roster span { font-size: 11.5px; font-weight: 600; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.roster .count {
  position: absolute; top: 5px; right: 5px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--pink); font-size: 11px; font-weight: 700; display: grid; place-items: center;
}

/* moves */
.moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.moves button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px 7px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); font-size: 11.5px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.moves button .e { font-size: 20px; line-height: 1.2; }
.moves button:hover { background: rgba(255, 255, 255, 0.1); }
.moves button.active { background: rgba(255, 61, 154, 0.22); border-color: rgba(255, 61, 154, 0.7); }
.moves.compact { grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 230px; overflow-y: auto; }
.moves.compact button { padding: 5px 2px; font-size: 10.5px; }
.moves.compact button .e { font-size: 17px; }

/* light patterns */
.patterns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.patterns button {
  position: relative; height: 58px; border-radius: 12px; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 500; overflow: hidden; background: rgba(255, 255, 255, 0.04);
}
.patterns button canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; }
.patterns button .e, .patterns button .n { position: relative; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.patterns button .e { font-size: 17px; line-height: 1; }
.patterns button.active { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(53, 224, 255, 0.35); }

#marqueeInput { width: 100%; }
.slider { display: grid; grid-template-columns: 70px 1fr 28px; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
input[type=range] { accent-color: var(--violet); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.switch.line { display: flex; margin-top: 14px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 36px; height: 21px; border-radius: 11px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- chonk card */
.popover { position: fixed; z-index: 20; width: 300px; padding: 12px; border-radius: 18px; }
.cc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cc-head img { width: 44px; height: 44px; object-fit: contain; }
.cc-head strong { display: block; font-size: 17px; font-weight: 700; line-height: 1.2; }
.cc-head small { color: var(--muted); font-size: 12px; }
.cc-head .icon { margin-left: auto; }
.cc-actions { display: flex; gap: 4px; margin-top: 10px; }
.cc-actions button { flex: 1; padding: 0 6px; font-size: 12px; }
.cc-actions .danger { flex: 0 0 38px; background: rgba(231, 35, 35, 0.18); }

/* ---------- misc */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(3, 2, 12, 0.6); }
.modal .card { width: min(420px, calc(100vw - 32px)); padding: 24px; border-radius: var(--r-lg); }
.modal h2 { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.modal dl { display: grid; grid-template-columns: 70px 1fr; gap: 8px 12px; margin-bottom: 20px; font-size: 14px; }
.modal dt { font-weight: 700; color: var(--cyan); }
.modal .primary { width: 100%; height: 42px; font-size: 15px; }

#toast {
  position: fixed; left: 50%; top: 76px; z-index: 25; transform: translate(-50%, -12px);
  padding: 10px 16px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#ghost { position: fixed; z-index: 40; pointer-events: none; width: 110px; height: 110px; transform: translate(-50%, -80%) rotate(-8deg); }
#ghost img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.5)); animation: wiggle .3s infinite alternate ease-in-out; }
@keyframes wiggle { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }
#showUi {
  position: fixed; bottom: 16px; right: 16px; z-index: 12; height: 36px; padding: 0 14px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--line); font-size: 13px; opacity: .25; transition: opacity .2s;
}
#showUi:hover { opacity: 1; }
body.bare #hud, body.bare #paintBar, body.bare #chonkCard { display: none !important; }
/* moved off-screen rather than display:none so the Spotify iframe keeps playing */
body.bare #deck { transform: translateX(calc(100% + 40px)) !important; }

/* ---------- mobile: deck becomes a bottom sheet */
@media (max-width: 900px) {
  :root { --deck-w: 0px; }
  #hud { right: 16px; top: max(10px, env(safe-area-inset-top)); left: 10px; gap: 6px; }
  #hud .more, #fullBtn { display: none; }
  .pill { padding: 4px; }
  .pill.tools { margin-left: 0; }
  .bpm { min-width: 58px; }
  .bpm span { font-size: 18px; }
  .party .lbl, .callout { display: none; }
  #deck {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 64vh;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    transform: translateY(calc(100% - 64px - env(safe-area-inset-bottom)));
    transition: transform .3s cubic-bezier(.2, .9, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #deck.open { transform: none; }
  #deckHandle { display: block; height: 14px; flex: none; }
  #deckHandle span { display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); margin: 6px auto 0; }
  #tabs { order: 1; padding-top: 0; }
  #booth { order: 2; border-bottom: 0; }
  #deckBody { order: 3; }
  #booth.offstage { position: absolute; left: -10000px; top: 0; width: 340px; }
  #booth:not(.offstage) + #tabs + #deckBody { display: none; }
  .mobile-only { display: block; }
  #tabs button { font-size: 12px; }
  .roster { grid-template-columns: repeat(4, 1fr); }
  .moves { grid-template-columns: repeat(4, 1fr); }
  .patterns { grid-template-columns: repeat(4, 1fr); }
  .popover { width: min(300px, calc(100vw - 20px)); }
  #paintBar { top: auto; bottom: 76px; left: 50%; transform: translateX(-50%); padding-left: 12px; gap: 8px; white-space: nowrap; }
  #toast { top: 118px; }
}
@media (max-width: 420px) {
  .patterns, .moves { grid-template-columns: repeat(3, 1fr); }
  #tabs button { font-size: 11px; padding: 9px 2px 10px; }
}
