@font-face { font-family: 'Bungee'; src: url('fonts/bungee.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #0b0614;
  --panel: #160c26;
  --line: #2a1a45;
  --text: #f4ecff;
  --dim: #a596c2;
  --pink: #ff2e97;
  --cyan: #22e5ff;
  --lime: #b6ff2e;
  --yellow: #ffe14d;
  --pulse: 0;
  --build: 0;
  --display: 'Bungee', 'Arial Black', Impact, system-ui, sans-serif;
  --ui: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui); overflow: hidden; overscroll-behavior: none; }
body {
  background:
    radial-gradient(ellipse at 50% 110%, rgba(255, 46, 151, calc(0.12 + var(--pulse) * 0.35)), transparent 60%),
    radial-gradient(ellipse at 10% -10%, rgba(34, 229, 255, calc(0.08 + var(--pulse) * 0.18)), transparent 55%),
    radial-gradient(ellipse at 90% -10%, rgba(166, 107, 255, calc(0.1 + var(--pulse) * 0.2)), transparent 55%),
    var(--bg);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
kbd { font-family: var(--ui); font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.12); color: var(--dim); border: 1px solid rgba(255,255,255,.15); }

.neon {
  font-family: var(--display); color: #fff; letter-spacing: 1px;
  text-shadow: 0 0 4px #fff, 0 0 12px var(--pink), 0 0 26px var(--pink), 0 0 44px var(--pink);
}

#app {
  height: 100dvh; display: flex; flex-direction: column; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  transform: translate(calc((var(--build) * var(--build)) * (sin(var(--build) * 900deg)) * 4px), 0);
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
#djname { font-size: clamp(18px, 2.6vw, 34px); white-space: nowrap; margin-right: auto; padding: 4px 6px; animation: flicker 6s infinite; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
@keyframes flicker { 0%, 92%, 100% { opacity: 1 } 93% { opacity: .6 } 94% { opacity: 1 } 96% { opacity: .75 } }
.play {
  font-family: var(--display); font-size: 18px; padding: 10px 18px; border-radius: 14px;
  background: linear-gradient(180deg, #2cf58e, #10b968); color: #04210f; box-shadow: 0 4px 0 #0a7a45, 0 0 22px rgba(44,245,142,.35);
  min-width: 120px;
}
.play.on { background: linear-gradient(180deg, #ff6a6a, #e0284a); color: #fff; box-shadow: 0 4px 0 #8a1028, 0 0 22px rgba(255,80,80,.35); }
.play:active { transform: translateY(3px); box-shadow: none; }
.tempo { display: flex; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.tbtn { display: flex; flex-direction: column; align-items: center; padding: 4px 10px; border-radius: 10px; color: var(--dim); font-weight: 800; font-size: 12px; min-width: 58px; }
.tbtn .emo { font-size: 22px; line-height: 1.1; }
.tbtn.on { background: var(--cyan); color: #032; box-shadow: 0 0 14px rgba(34,229,255,.5); }
.iconbtn { font-size: 30px; width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--line); display: grid; place-items: center; }
.iconbtn.small { font-size: 22px; width: 44px; }
.iconbtn:active, .tbtn:active { transform: scale(.94); }
.dice { background: linear-gradient(180deg, #ffe14d, #ffb21c); box-shadow: 0 4px 0 #b06d00; }
.namebar { display: flex; justify-content: center; margin-top: -4px; }
#beatname { font-weight: 800; color: var(--dim); font-size: 14px; letter-spacing: .5px; padding: 2px 10px; border-radius: 8px; }
#beatname::before { content: '♫ '; color: var(--pink); }

/* ---------- grid ---------- */
.grid { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.row { display: flex; gap: 10px; align-items: stretch; flex: 1 1 0; max-height: 74px; min-height: 0; }
.row.muted { opacity: .3; }
.sticker {
  width: 116px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--c) 18%, #140a22); border: 2px solid color-mix(in srgb, var(--c) 60%, transparent);
  font-weight: 800; font-size: 13px; text-align: left; overflow: hidden;
}
.sticker .emo { font-size: 28px; line-height: 1; flex: none; }
.sticker .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cells { flex: 1; display: grid; grid-template-columns: repeat(16, 1fr); gap: 5px; min-width: 0; }
.cell {
  border-radius: 10px; cursor: pointer; position: relative;
  background: color-mix(in srgb, var(--c) 9%, #120920); border: 2px solid color-mix(in srgb, var(--c) 28%, transparent);
  transition: background .08s, box-shadow .08s;
}
.cell.alt { background: color-mix(in srgb, var(--c) 4%, #0d0618); }
.cell:nth-child(4n+1) { margin-left: 4px; }
.cell:nth-child(1) { margin-left: 0; }
.cell.on { background: var(--c); border-color: color-mix(in srgb, var(--c) 70%, #fff); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 70%, transparent), inset 0 -4px 0 rgba(0,0,0,.2); }
.cell.ph { border-color: #fff; }
.cell.ph:not(.on) { background: color-mix(in srgb, var(--c) 25%, #2a1a40); }
.addrow { align-self: flex-start; margin-left: 0; padding: 8px 16px; border-radius: 12px; border: 2px dashed var(--line); color: var(--dim); font-weight: 800; }
.addrow:hover { color: var(--text); border-color: var(--dim); }

/* ---------- deck ---------- */
.deck { display: flex; align-items: center; gap: 16px; }
.pads { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.pad {
  position: relative; height: 92px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 35%, #1b0f2e), color-mix(in srgb, var(--c) 12%, #12081f));
  border: 2px solid var(--c); box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 40%, #000), 0 0 18px color-mix(in srgb, var(--c) 30%, transparent);
  font-family: var(--display); font-size: 13px;
}
.pad .emo { font-size: 34px; line-height: 1; font-family: var(--ui); }
.pad kbd { position: absolute; top: 6px; right: 8px; }
.pad:active { transform: translateY(4px); box-shadow: 0 1px 0 #000; }
.pad.drop { font-size: 15px; }
.pad.drop.armed { animation: armed .25s infinite alternate; }
@keyframes armed { to { background: var(--pink); color: #fff; } }
.pad.empty { border-style: dashed; opacity: .75; }
.pad.empty .nm::after { content: ' ?'; }

.knobwrap, .recwrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lbl { font-weight: 800; font-size: 11px; color: var(--dim); letter-spacing: .5px; white-space: nowrap; }
.knob {
  --k: 1; width: 80px; height: 80px; border-radius: 50%; cursor: ns-resize; touch-action: none; position: relative;
  background: radial-gradient(circle at 35% 30%, #4a3a66, #1a1029 70%);
  border: 3px solid var(--cyan); box-shadow: 0 0 calc(10px + (1 - var(--k)) * 30px) var(--cyan);
}
.knob .dial { position: absolute; inset: 0; transform: rotate(calc(-135deg + var(--k) * 270deg)); }
.knob .dial::after { content: ''; position: absolute; left: 50%; top: 8px; width: 6px; height: 22px; margin-left: -3px; border-radius: 3px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.knob.active { background: radial-gradient(circle at 35% 30%, #2b6d7a, #0e2b33 70%); }
.rec {
  --lvl: 0; --time: 0; width: 80px; height: 80px; border-radius: 50%; position: relative; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c0122f 70%);
  box-shadow: 0 5px 0 #6b0718, 0 0 20px rgba(255,40,70,.45); display: grid; place-items: center;
}
.rec .emo { font-size: 34px; }
.rec .ring { position: absolute; inset: -8px; border-radius: 50%; background: conic-gradient(#fff calc(var(--time) * 360deg), transparent 0); -webkit-mask: radial-gradient(circle, transparent 46px, #000 47px); mask: radial-gradient(circle, transparent 46px, #000 47px); opacity: 0; }
.rec.live { transform: scale(calc(1.06 + var(--lvl) * 0.25)); box-shadow: 0 0 calc(20px + var(--lvl) * 60px) #ff2e4d; }
.rec.live .ring { opacity: 1; }

/* ---------- overlays ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 41; mix-blend-mode: screen; }
#bigname { position: fixed; left: 50%; top: 45%; transform: translate(-50%,-50%); font-size: clamp(40px, 9vw, 120px); white-space: nowrap; opacity: 0; pointer-events: none; z-index: 42; }
.pop { position: fixed; font-size: 34px; pointer-events: none; z-index: 30; filter: drop-shadow(0 0 8px rgba(255,255,255,.5)); }
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60;
  background: #24143c; border: 2px solid var(--cyan); border-radius: 16px; padding: 12px 18px; font-weight: 800; font-size: 16px;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 40px rgba(0,0,0,.5); transition: .25s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: var(--cyan); color: #032; padding: 6px 12px; border-radius: 10px; font-weight: 900; white-space: nowrap; }

/* ---------- splash ---------- */
.splash { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2a0f3f, var(--bg) 70%); transition: opacity .5s, transform .5s; padding: 16px; }
.splash.gone { opacity: 0; transform: scale(1.3); pointer-events: none; }
.load { --p: 0; position: absolute; top: 0; left: 0; height: 4px; width: calc(var(--p) * 100%); background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .2s; }
.step { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.logo { font-family: var(--display); font-size: clamp(56px, 12vw, 130px); line-height: .9; margin: 0; background: linear-gradient(180deg, #fff, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(255,46,151,.6)); }
.step label { font-size: 26px; font-weight: 900; }
.namerow { display: flex; align-items: center; gap: 10px; }
.namerow .dj { font-family: var(--display); font-size: 40px; color: var(--pink); }
#name-input { font-family: var(--display); font-size: 40px; width: min(420px, 70vw); padding: 10px 16px; border-radius: 16px; border: 3px solid var(--cyan); background: #12081f; color: #fff; text-transform: uppercase; outline: none; box-shadow: 0 0 22px rgba(34,229,255,.35); }
.go { font-family: var(--display); font-size: 22px; padding: 14px 26px; border-radius: 16px; background: linear-gradient(180deg, #2cf58e, #10b968); color: #04210f; box-shadow: 0 5px 0 #0a7a45; }
.go:active { transform: translateY(4px); box-shadow: none; }
.splashname { font-size: clamp(36px, 7vw, 80px); }
.dropit {
  font-family: var(--display); font-size: clamp(44px, 8vw, 84px); line-height: .95; color: #fff;
  width: clamp(200px, 34vmin, 320px); height: clamp(200px, 34vmin, 320px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff6fb7, var(--pink) 45%, #a3005a);
  box-shadow: 0 10px 0 #6b003b, 0 0 60px rgba(255,46,151,.7), 0 0 120px rgba(255,46,151,.4);
  animation: throb .9s ease-in-out infinite;
}
.dropit.loading { animation: throb .3s ease-in-out infinite; }
@keyframes throb { 50% { transform: scale(1.07); box-shadow: 0 10px 0 #6b003b, 0 0 90px rgba(255,46,151,.9), 0 0 160px rgba(255,46,151,.5); } }
.hint { color: var(--dim); font-weight: 700; margin: 0; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(5,2,10,.6); display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: .2s; }
.sheet.open { opacity: 1; pointer-events: auto; }
.panel { background: var(--panel); border: 2px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; width: min(1100px, 100%); max-height: 86dvh; display: flex; flex-direction: column; transform: translateY(40px); transition: .25s; padding-bottom: env(safe-area-inset-bottom); }
.panel.narrow { width: min(560px, 100%); }
.sheet.open .panel { transform: none; }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 6px; }
.phead h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 400; }
.done { background: var(--cyan); color: #032; font-weight: 900; padding: 10px 18px; border-radius: 12px; }
.pbody { overflow: auto; padding: 6px 20px 20px; -webkit-overflow-scrolling: touch; }
.pbody.center { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pbody h3 { margin: 14px 0 8px; font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px 10px; border-radius: 16px; background: #22143a; border: 2px solid transparent; font-weight: 800; font-size: 13px; }
.tile .emo { font-size: 40px; line-height: 1.1; }
.tile.on { border-color: var(--lime); box-shadow: 0 0 14px rgba(182,255,46,.4); }
.tile:active { transform: scale(.95); }
.tile .edit { position: absolute; top: 4px; right: 6px; font-size: 14px; }
.tile.rec-tile { background: #3a0f1e; border: 2px dashed #ff4d6d; }
.tray-actions, .recacts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: center; }
.ghost { padding: 12px 16px; border-radius: 12px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-weight: 800; }
.bigemo { font-size: 90px; width: 150px; height: 150px; border-radius: 50%; background: #22143a; border: 3px solid var(--yellow); box-shadow: 0 0 30px rgba(255,225,77,.35); }
.bigemo:active { transform: scale(.93); }
.recname { font-family: var(--display); font-size: 22px; }
.fx { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.fxbtn { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 14px; background: #22143a; font-weight: 800; font-size: 13px; border: 2px solid transparent; }
.fxbtn .emo { font-size: 32px; }
.fxbtn.on { border-color: var(--yellow); }
.discs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.disc { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 18px; background: #1d1131; border: 2px solid transparent; position: relative; }
.disc.on { border-color: var(--c); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 40%, transparent); }
.vinyl { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, var(--c) 0 16%, #111 17% 30%, #222 31% 33%, #111 34% 60%, #262626 61% 62%, #111 63%); display: grid; place-items: center; font-size: 0; }
.disc.on .vinyl { animation: spin 2s linear infinite; }
.vinyl.new { background: #22143a; border: 2px dashed var(--line); font-size: 30px; }
.vinyl.new span { font-size: 30px; }
@keyframes spin { to { transform: rotate(360deg); } }
.dname { font-weight: 900; font-size: 14px; text-align: center; }
.playing { font-size: 11px; color: var(--lime); font-weight: 800; }
.del { position: absolute; top: 6px; right: 8px; font-size: 16px; opacity: .6; }
.helpbody p { line-height: 1.45; }
.keys { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-weight: 700; }
.tiny { font-size: 12px; color: var(--dim); }
.tiny a { color: var(--cyan); }

.rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate { display: flex; position: fixed; inset: 0; z-index: 90; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; font-size: 22px; font-weight: 900; }
  .rotate div { font-size: 70px; animation: tilt 1.6s ease-in-out infinite; }
  @keyframes tilt { 50% { transform: rotate(-90deg); } }
  .splash .step { transform: scale(.85); }
}
/* the splash still works in portrait so the very first tap never meets a "turn your phone" wall */
@media (orientation: portrait) and (max-width: 700px) { body:has(.splash:not(.gone)) .rotate { display: none; } }

/* ---------- phone landscape: compact ---------- */
@media (max-height: 520px) {
  #app { gap: 5px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .top { gap: 6px; }
  #djname { font-size: 16px; }
  .play { font-size: 13px; padding: 6px 10px; min-width: 84px; border-radius: 10px; }
  .tbtn { min-width: 40px; padding: 2px 6px; font-size: 0; }
  .tbtn .emo { font-size: 18px; }
  .iconbtn { width: 38px; height: 38px; font-size: 20px; border-radius: 10px; }
  .iconbtn.small { width: 32px; font-size: 16px; }
  .namebar { display: none; }
  .grid { gap: 3px; }
  .row { gap: 5px; }
  .sticker { width: 46px; padding: 0; justify-content: center; border-radius: 10px; }
  .sticker .nm { display: none; }
  .sticker .emo { font-size: 20px; }
  .cells { gap: 3px; }
  .cell { border-radius: 6px; border-width: 1px; }
  .cell:nth-child(4n+1) { margin-left: 2px; }
  .cell:nth-child(1) { margin-left: 0; }
  .addrow { padding: 2px 10px; font-size: 12px; }
  .deck { gap: 8px; }
  .pads { gap: 6px; }
  .pad { height: 54px; border-radius: 12px; font-size: 9px; }
  .pad .emo { font-size: 22px; }
  .pad kbd, .lbl { display: none; }
  .knob, .rec { width: 54px; height: 54px; }
  .knob .dial::after { top: 5px; height: 14px; }
  .rec .emo { font-size: 24px; }
  .rec .ring { -webkit-mask: radial-gradient(circle, transparent 33px, #000 34px); mask: radial-gradient(circle, transparent 33px, #000 34px); }
  .toast { bottom: 76px; font-size: 14px; }
  .step { gap: 10px; }
  .logo { font-size: 44px; }
  .dropit { width: 170px; height: 170px; font-size: 40px; }
  .splashname { font-size: 30px; }
}
/* narrow desktop windows */
@media (max-width: 900px) and (min-height: 521px) {
  .tbtn .nm { display: none; }
  .tbtn { min-width: 44px; }
  .sticker { width: 64px; justify-content: center; }
  .sticker .nm { display: none; }
}
