:root {
  --bg: #0a0718;
  --panel: rgba(20, 12, 44, 0.84);
  --line: rgba(196, 181, 253, 0.25);
  --text: #ede9fe;
  --dim: #a78bfa;
  --hot: #f472b6;
  --gold: #fbbf24;
  --strip: 34px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; overscroll-behavior: none; }
#stage, #stage canvas { position: fixed; inset: 0; display: block; touch-action: none; }
#labels, #tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; writing-mode: vertical-rl; white-space: nowrap; color: #c4b5fd; text-shadow: 0 0 3px #000; line-height: 1; }
.label.claimed { font-weight: 800; }
.tag { position: absolute; transform: translate(-50%, -100%); font: 700 13px Inter, sans-serif; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.6); white-space: nowrap; }

#strip { position: fixed; top: 0; left: 0; width: 100%; height: var(--strip); cursor: pointer; border-bottom: 1px solid var(--line); background: #000; touch-action: none; }

button { font: 600 13px Inter, sans-serif; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #1e1440; color: var(--text); cursor: pointer; touch-action: manipulation; }
button:hover { border-color: var(--dim); }
input { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #110a26; color: var(--text); width: 100%; }
input.shake { animation: shake .4s; border-color: var(--hot); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.panel { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); display: flex; flex-direction: column; overflow: hidden; }
.panel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; cursor: pointer; }
.panel .body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.panel.collapsed .body { display: none; }
.fold { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1; flex: none; }
.fold::after { content: "\2212"; }
.panel.collapsed .fold::after { content: "+"; }

#panel { left: 16px; bottom: 16px; width: 290px; }
h1 { margin: 0; font: 20px Bungee, sans-serif; color: var(--gold); text-shadow: 0 0 12px rgba(251,191,36,.6); line-height: 1; }
h1 span { color: var(--hot); text-shadow: 0 0 12px rgba(244,114,182,.6); margin-left: 6px; }
.hint { font-size: 12px; color: var(--dim); }
.row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.row button { font-size: 11px; padding: 6px 2px; }

#results { right: 16px; top: calc(var(--strip) + 16px); width: 300px; max-height: calc(100vh - var(--strip) - 330px); }
h2 { margin: 0; font: 15px Bungee, sans-serif; color: var(--gold); }
#count { color: var(--dim); }
#resultList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#resultList li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; cursor: pointer; padding: 6px; border-radius: 10px; background: rgba(255,255,255,.04); animation: slidein .5s ease-out; }
#resultList li:hover { background: rgba(255,255,255,.09); }
#resultList img { width: 64px; height: 47px; object-fit: cover; border-radius: 6px; }
#resultList .p { font-weight: 800; font-size: 13px; }
#resultList .c { font-size: 13px; }
#resultList .m { font-size: 11px; color: var(--dim); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#resultList .m button { font-size: 10px; padding: 2px 6px; }
#resetBtn { font-size: 11px; opacity: .7; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

#uiToggle { position: fixed; left: 50%; top: calc(var(--strip) + 8px); transform: translateX(-50%); font-size: 11px; padding: 4px 10px; opacity: .8; z-index: 5; }
body.noui .panel, body.noui #status, body.noui #strip { display: none; }
body.noui #uiToggle { top: 8px; }

#plunger { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); user-select: none; z-index: 4; }
#gauge { width: 72px; height: 72px; }
.launcher { display: flex; gap: 8px; align-items: stretch; }
#meter { width: 12px; height: 210px; border-radius: 6px; background: #110a26; border: 1px solid var(--line); position: relative; overflow: hidden; }
#meterFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, #22c55e, #fbbf24 60%, #ef4444); box-shadow: 0 0 12px #fbbf24; }
#track { position: relative; width: 58px; height: 210px; border-radius: 10px; background: linear-gradient(90deg, #120a28, #241750, #120a28); border: 1px solid var(--line); touch-action: none; cursor: grab; }
#spring { position: absolute; left: 0; width: 100%; bottom: 4px; }
#knob { position: absolute; left: 4px; right: 4px; top: 4px; height: 40px; border-radius: 10px; background: radial-gradient(circle at 40% 30%, #f9a8d4, #db2777 60%, #831843); box-shadow: 0 0 16px rgba(219,39,119,.7); display: flex; align-items: center; justify-content: center; font: 11px Bungee, sans-serif; color: #fff; touch-action: none; }
#track.snap #knob { transition: transform .12s cubic-bezier(.3, 1.8, .5, 1); }
#track.cool { opacity: .5; }

#banner { position: fixed; left: 50%; top: 22%; transform: translate(-50%, -50%); font: 44px Bungee, sans-serif; text-align: center; pointer-events: none; text-shadow: 0 0 20px currentColor; opacity: 0; transition: opacity .2s; white-space: nowrap; }
#banner.show { opacity: 1; }
#banner.wobble { animation: wobble .4s ease-out; }
@keyframes wobble { 0% { transform: translate(-50%, -50%) scale(1.6) rotate(-8deg); } 60% { transform: translate(-50%, -50%) scale(.9) rotate(4deg); } 100% { transform: translate(-50%, -50%) scale(1); } }

#tip { position: fixed; pointer-events: none; display: none; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; max-width: 200px; z-index: 6; }
#tip img { width: 180px; display: block; border-radius: 8px; margin-top: 4px; }

#popup { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(124,58,237,.35), rgba(0,0,0,.55)); cursor: pointer; z-index: 10; }
#popup.show { display: flex; }
#popup .card { text-align: center; animation: pop .9s cubic-bezier(.2, 1.6, .4, 1); padding: 16px; }
#popup img { width: min(330px, 70vw); border-radius: 16px; box-shadow: 0 0 60px var(--glow, #f472b6), 0 0 120px rgba(251,191,36,.4); }
#popup .who { font: 22px Bungee, sans-serif; margin-top: 14px; }
#popup .cname { font: 800 20px Inter, sans-serif; }
#popup .bumps { font: 14px Bungee, sans-serif; color: var(--gold); }
@keyframes pop { 0% { transform: scale(.1) rotateY(540deg); opacity: 0; } 100% { transform: scale(1) rotateY(0); opacity: 1; } }

#status { position: fixed; left: 16px; top: calc(var(--strip) + 8px); font-size: 11px; color: var(--dim); }

@media (max-width: 760px) {
  :root { --strip: 26px; }
  #status { display: none; }
  #panel { left: 8px; top: calc(var(--strip) + 8px); bottom: auto; width: calc(50% - 12px); max-height: 60vh; }
  #results { right: 8px; top: calc(var(--strip) + 8px); width: calc(50% - 12px); max-height: 60vh; }
  #panel:not(.collapsed), #results:not(.collapsed) { width: calc(100% - 16px); left: 8px; right: 8px; z-index: 7; }
  .panel header { padding: 6px 8px; }
  h1 { font-size: 13px; }
  h1 span { display: none; }
  h2 { font-size: 12px; }
  .fold { width: 26px; height: 26px; }
  #uiToggle { top: auto; bottom: 12px; left: 12px; transform: none; }
  body.noui #uiToggle { top: auto; }
  #plunger { right: 8px; bottom: 8px; padding: 6px; gap: 4px; }
  #gauge { width: 48px; height: 48px; }
  #meter, #track { height: 150px; }
  #track { width: 48px; }
  #knob { height: 32px; font-size: 9px; }
  #banner { font-size: 24px; }
}
