:root { --ink: #111; --paper: #fbf8f1; --sun: #ffcf3a; --hot: #e8432d; --sky: #7fc8e8; --ground: #d9b27c; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font-family: "Arial Black", Impact, system-ui, sans-serif; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body { display: flex; flex-direction: column; }
button { font: inherit; color: var(--ink); cursor: pointer; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 50; background: var(--sun); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; border: 6px solid var(--ink); }
#title.gone { display: none; }
.logo { display: flex; flex-direction: column; align-items: center; transform: rotate(-4deg); }
.logo span { font-size: clamp(54px, 18vw, 110px); line-height: .9; color: var(--hot); -webkit-text-stroke: 3px var(--ink); text-shadow: 6px 6px 0 var(--ink); }
.logo span + span { color: #fff; }
.tag { font-family: system-ui, sans-serif; font-weight: 800; font-size: 14px; }
#loader { width: min(260px, 70vw); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.bar { width: 100%; height: 18px; border: 3px solid var(--ink); border-radius: 9px; background: #fff; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--hot); transition: width .25s; }
#menu { display: flex; flex-direction: column; gap: 14px; align-items: stretch; width: min(300px, 80vw); }
.hide { display: none !important; }
.mbtn { font-size: 22px; padding: 12px 16px; border: 4px solid var(--ink); border-radius: 14px; background: var(--hot); color: #fff; box-shadow: 5px 5px 0 var(--ink); display: flex; flex-direction: column; align-items: center; }
.mbtn small { font-family: system-ui, sans-serif; font-size: 12px; font-weight: 700; opacity: .9; }
.mbtn.alt { background: #fff; color: var(--ink); }
.mbtn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
#dice, #home { font-size: 18px; width: 38px; height: 38px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; padding: 0; }
#songtag { cursor: pointer; position: absolute; left: 10px; top: 8px; z-index: 2; font-size: 11px; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 3px 8px; font-family: system-ui, sans-serif; font-weight: 800; }
#songtag.mambo { background: var(--hot); color: #fff; }
#start { font-size: 24px; padding: 12px 34px; border: 4px solid var(--ink); border-radius: 14px; background: var(--hot); color: #fff; box-shadow: 5px 5px 0 var(--ink); }
#start:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.hint { text-align: center; font-family: system-ui, sans-serif; font-size: 12px; opacity: .7; }

/* ---------- header / nav ---------- */
header { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 4px solid var(--ink); background: var(--sun); }
.spot-name { font-size: 16px; letter-spacing: 1px; text-transform: uppercase; }
.sabor { margin-left: auto; font-size: 20px; }
.sabor small { font-size: 11px; }
#play { font-size: 15px; padding: 8px 14px; border: 3px solid var(--ink); border-radius: 10px; background: var(--hot); color: #fff; box-shadow: 3px 3px 0 var(--ink); }
#play.on { background: var(--ink); }
nav { display: flex; border-top: 4px solid var(--ink); background: var(--sun); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; border: 0; background: none; padding: 6px 0 8px; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button span { font-size: 11px; }
nav button.on { background: var(--ink); color: #fff; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.on { display: flex; }
#view-recruit > *, #view-spots > *, #view-library > *, #view-styles > * { flex-shrink: 0; }
#view-recruit, #view-spots, #view-library, #view-styles { overflow-y: auto; touch-action: pan-y; padding: 12px 16px 20px; }
h2 { margin: 0; font-size: 26px; }
.sub { margin: 4px 0 10px; font-family: system-ui, sans-serif; font-size: 13px; font-weight: 600; }

/* ---------- jam ---------- */
#stage { position: relative; flex: 1; overflow: hidden; }
.scene { position: absolute; inset: 0; background: var(--sky) center bottom / cover no-repeat; }

#slots { position: absolute; inset: 0; z-index: 1; }   /* own stacking context: figures z-sort by depth inside it */
.slot { position: absolute; width: var(--sw, 80px); height: var(--sh, 120px); transform: translate(-50%, -100%);
  border: 3px dashed rgba(17,17,17,.45); border-radius: 14px; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; }
.slot > .lbl { position: absolute; bottom: -20px; font-size: 9px; background: #fff; border: 2px solid var(--ink); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.slot.hot { border-color: var(--hot); background: rgba(232,67,45,.2); }
.slot.filled { border-color: transparent; cursor: default; }

.tray { border-top: 4px solid var(--ink); background: #fff; padding: 6px 0 8px; }
.tray-label { font-size: 11px; padding: 0 16px 4px; font-family: system-ui, sans-serif; font-weight: 700; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px 6px; touch-action: pan-x; }
#rcats { padding: 2px 0 8px; }
.cat { flex: 0 0 auto; font-size: 12px; padding: 5px 10px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.cat small { font-size: 10px; opacity: .6; }
.cat.on { background: var(--ink); color: #fff; }
#roster { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; touch-action: pan-x; min-height: 118px; }
.empty { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 600; padding: 30px 0; }
.card { flex: 0 0 78px; height: 118px; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); position: relative; display: flex; justify-content: center; align-items: flex-end; }
.card.used { opacity: .3; }
.card .nm, .placed .nm { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: 9px; line-height: 1.1; font-family: system-ui, sans-serif; font-weight: 800; }
.guy { width: 70px; height: 104px; object-fit: contain; object-position: bottom; pointer-events: none; -webkit-user-drag: none; }
.placed .guy { width: 130%; height: 100%; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.slot.free { border-color: rgba(255,255,255,.7); }
.slot.free > .lbl { background: var(--sun); }
.placed { position: absolute; width: var(--sw, 80px); height: var(--sh, 120px); transform: translate(-50%, -100%); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.placed .riff { position: absolute; top: -16px; font-size: 9px; background: var(--ink); color: #fff; border-radius: 6px; padding: 2px 6px; white-space: nowrap; font-family: system-ui, sans-serif; font-weight: 800; }
.placed .guy { transition: transform 70ms; }
.placed.hit .guy { transform: translateY(-5px) scale(1.04); }
.drag { position: fixed; z-index: 10; transform: translate(-50%, -60%) scale(1.15); pointer-events: none; }
.toast { position: fixed; left: 50%; top: 80px; z-index: 40; transform: translateX(-50%); background: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 6px 12px; font-size: 16px; box-shadow: 3px 3px 0 var(--ink); white-space: nowrap; }

/* ---------- recruit / spots lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding: 6px 10px 6px 6px; box-shadow: 3px 3px 0 var(--ink); }
.row .pic { flex: 0 0 64px; height: 84px; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.row .pic .guy { width: 58px; height: 86px; }
.row .info { flex: 1; min-width: 0; }
.row .nm2 { font-size: 15px; }
.row .meta { font-family: system-ui, sans-serif; font-size: 12px; font-weight: 600; opacity: .75; }
.row .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.btn { font-size: 13px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 9px; background: var(--hot); color: #fff; white-space: nowrap; }
.btn.alt { background: #fff; color: var(--ink); }
.btn:disabled { background: #ddd; color: #888; border-color: #999; }
.btn.owned { background: var(--ink); }
.swatch { flex: 0 0 64px; height: 64px; border: 2px solid var(--ink); border-radius: 8px; position: relative; overflow: hidden; }
.swatch i { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; border-top: 3px solid var(--ink); }

/* ---------- free-play controls ---------- */
#view-controls > * { flex-shrink: 0; }
#view-controls { overflow-y: auto; touch-action: pan-y; padding: 12px 16px 20px; }
.ctl { border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; box-shadow: 3px 3px 0 var(--ink); }
.ctl label { flex: 1 0 100%; font-size: 14px; }
.ctl label small { font-family: system-ui, sans-serif; font-weight: 600; opacity: .7; }
.ctl input[type=range] { flex: 1; accent-color: var(--hot); touch-action: pan-x; }
.stepper { display: flex; align-items: center; gap: 14px; font-size: 22px; }
.stepper .btn { font-size: 20px; width: 44px; }
.cats.wrap { flex-wrap: wrap; padding: 0; overflow: visible; }
.btn.small { font-size: 11px; padding: 4px 8px; }
.btn.on { background: var(--hot); color: #fff; }
body.free .camp, body:not(.free) .freeonly { display: none; }

/* ---------- perform ---------- */
#perform { position: absolute; right: 10px; top: 6px; z-index: 3; font-size: 13px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 10px; background: var(--sun); box-shadow: 3px 3px 0 var(--ink); }
#perfmodal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
#perfmodal .sheet { width: min(420px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 16px; box-shadow: 6px 6px 0 var(--ink); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
#perfaudio { width: 100%; }
.perfacts { display: flex; gap: 10px; justify-content: flex-end; }
a.btn { text-decoration: none; display: inline-block; }

.card .guy { height: 92px; margin-bottom: 2px; }
.drag .guy { width: 80px; height: 130px; }
.slot.filled, .slot.free.filled { border-color: transparent; background: none; }
.placed .tag { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font: 700 8px/1.2 system-ui, sans-serif; background: rgba(255,255,255,.92); border: 1.5px solid var(--ink); border-radius: 6px; padding: 1px 5px; }
.placed .tag b { font-weight: 900; }

/* ---------- library ---------- */
.mbtn.lib { background: var(--ink); color: #fff; }
#mainlib { position: fixed; inset: 0; z-index: 55; background: var(--paper); overflow-y: auto; touch-action: pan-y; padding: 14px 16px 30px; display: flex; flex-direction: column; gap: 10px; }
#mainlib > * { flex-shrink: 0; }
.libhead { display: flex; align-items: center; gap: 12px; }
.song .disc { flex: 0 0 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle, var(--sun) 0 18%, var(--ink) 19% 23%, #333 24%); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; }
.song.playing .disc { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.song .tagmode { font-size: 10px; border: 2px solid var(--ink); border-radius: 6px; padding: 0 5px; margin-left: 4px; vertical-align: 2px; }
.saved { font-family: system-ui, sans-serif; font-weight: 800; font-size: 13px; color: #1a7a33; align-self: center; margin-right: auto; }
.empty2 { font-family: system-ui, sans-serif; font-weight: 600; font-size: 14px; padding: 20px 0; opacity: .7; }
#clearstage { position: absolute; right: 10px; top: 48px; z-index: 3; font-size: 12px; padding: 4px 9px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; box-shadow: 3px 3px 0 var(--ink); }
body:not(.free) #clearstage { display: none; }
img { -webkit-touch-callout: none; -webkit-user-drag: none; user-select: none; }

/* ---------- styles + locks ---------- */
.row.locked { background: #eee; }
.row.locked .pic img, .row.style.locked .faces img { filter: grayscale(1) brightness(.75); }
.row .faces { flex: 0 0 76px; height: 84px; position: relative; border: 2px solid var(--ink); border-radius: 8px; background: var(--paper); overflow: hidden; }
.row .faces img { position: absolute; bottom: 0; height: 80px; }
.row .faces img:nth-child(1) { left: -6px; } .row .faces img:nth-child(2) { left: 14px; }
.row .faces img:nth-child(3) { left: 32px; } .row .faces img:nth-child(4) { left: 48px; }
nav button span { white-space: nowrap; }

/* ---------- key menu (drops down from the song tag) ---------- */
#keymenu { position: absolute; left: 10px; top: 34px; z-index: 5; width: 216px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
  background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 8px; box-shadow: 4px 4px 0 var(--ink); }
.kbtn { font-size: 13px; padding: 7px 0; border: 2px solid var(--ink); border-radius: 8px; background: var(--paper); }
.kbtn.wide { grid-column: span 2; font-size: 11px; }
.kbtn.now { background: var(--sun); }
.kbtn.on { background: var(--ink); color: #fff; }
