:root {
  --bg: #07040f;
  --ink: #f6f1ff;
  --muted: #b9a8d6;
  --pink: #ff4d9a;
  --lime: #d6ff3f;
  --violet: #7c5cff;
  --card: rgb(22 12 40 / 0.72);
  --line: rgb(255 255 255 / 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: Outfit, system-ui, sans-serif; }
body { padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); }
#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, rgb(255 77 154 / 0.28), transparent 55%),
    radial-gradient(800px 480px at 110% 0%, rgb(124 92 255 / 0.32), transparent 50%),
    radial-gradient(700px 500px at 50% 110%, rgb(214 255 63 / 0.1), transparent 55%),
    var(--bg);
}
#app { max-width: 760px; margin: 0 auto; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-family: Syne, Outfit, sans-serif; font-size: 22px; letter-spacing: -0.03em; }
.brand small { color: var(--muted); }
.pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 0 rgb(255 77 154 / 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 12px rgb(255 77 154 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(255 77 154 / 0); }
}

h1, h2 { font-family: Syne, Outfit, sans-serif; letter-spacing: -0.04em; margin: 0; }
h1 { font-size: clamp(36px, 8vw, 56px); line-height: 0.95; }
.panel { padding: 28px 0 12px; }
.panel p { color: var(--muted); line-height: 1.5; }

#code-form, .search { display: flex; gap: 8px; margin: 22px 0 10px; }
input, button { font: inherit; }
input[type="search"], #code-input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: rgb(255 255 255 / 0.08);
  color: var(--ink);
  outline: 2px solid transparent;
}
input:focus { outline-color: var(--violet); }
#code-input { text-transform: uppercase; letter-spacing: 0.18em; font-weight: 800; text-align: center; }
button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
}
#code-form button, .vote {
  background: var(--lime);
  color: #141000;
  font-weight: 800;
}
.ghost, .tabish {
  background: rgb(255 255 255 / 0.08);
  color: var(--ink);
}
.ghost.connected { background: rgb(214 255 63 / 0.16); color: var(--lime); }
.msg { color: var(--pink); min-height: 1.2em; }
.hidden { display: none !important; }

.now {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.28);
}
.now img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 16px;
  background: #221635;
  box-shadow: 0 0 30px rgb(255 77 154 / 0.25);
}
.card img:not([src]), .plist img:not([src]), .now img:not([src]) {
  background: linear-gradient(135deg, #7c5cff, #ff4d9a);
}
.kicker {
  margin: 0 0 4px;
  color: var(--lime);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
#now-title { font-size: 24px; line-height: 1.1; }
#now-artist { margin: 6px 0 0; color: var(--muted); }

.tabs { display: flex; gap: 8px; margin: 18px 0 12px; }
.tabs button {
  background: rgb(255 255 255 / 0.06);
  color: var(--muted);
  font-weight: 700;
}
.tabs button.on { background: var(--ink); color: #120818; }

.results, .list { display: flex; flex-direction: column; gap: 8px; }
.card {
  display: grid;
  grid-template-columns: auto 56px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
}
.card.hot { box-shadow: inset 0 0 0 1px rgb(255 77 154 / 0.45); }
.rank {
  width: 28px;
  text-align: center;
  font-family: Syne, sans-serif;
  font-weight: 800;
  color: var(--pink);
}
.card img, .plist img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  background: #221635;
}
.card .name, .plist .name { font-weight: 700; }
.card .sub, .plist .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.votes {
  display: block;
  font-weight: 800;
  color: var(--lime);
  font-size: 12px;
  text-align: center;
  margin-bottom: 6px;
}
.vote { min-width: 84px; }
.vote.on {
  background: rgb(255 255 255 / 0.12);
  color: var(--ink);
}
.vote.burst { animation: burst 0.45s ease; }
@keyframes burst {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 18px;
}
.section-title {
  margin: 8px 2px 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plist {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  color: inherit;
  border-radius: 18px;
  padding: 10px;
}
.back {
  background: transparent;
  color: var(--ink);
  padding: 0 0 12px;
}

@media (max-width: 520px) {
  .now { grid-template-columns: 72px 1fr; }
  .now img { width: 72px; height: 72px; }
  #now-title { font-size: 20px; }
  .card { grid-template-columns: auto 48px 1fr auto; }
}

/* v5: tap-to-add search, name join sheet, toasts */
.card.tap { cursor: pointer; transition: transform 0.12s ease, background 0.2s ease; -webkit-tap-highlight-color: transparent; }
.card.tap:active { transform: scale(0.985); }
.card.tap.added { background: rgb(214 255 63 / 0.12); }
.card.tap .vote { pointer-events: none; }
.card.burst { animation: cardpop 0.45s ease; }
@keyframes cardpop { 40% { transform: scale(1.03); } }
.linkish { background: none; color: var(--muted); padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; background: rgb(4 2 10 / 0.62); backdrop-filter: blur(6px); padding: 16px; }
.sheet.hidden { display: none; }
.sheet-card { position: relative; width: min(520px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 26px 22px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px; background: #170c2b; border: 1px solid var(--line); box-shadow: 0 30px 80px rgb(0 0 0 / 0.5); animation: sheetup 0.22s ease; }
@keyframes sheetup { from { transform: translateY(30px); opacity: 0; } }
.sheet-card h2 { font-size: 28px; }
.sheet-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.sheet-card input { border: 0; border-radius: 16px; padding: 16px 18px; font-size: 18px; background: rgb(255 255 255 / 0.08); color: var(--ink); outline: 2px solid transparent; }
.sheet-card .primary { background: var(--lime); color: #141000; font-weight: 800; padding: 15px; font-size: 17px; }
.sheet-x { position: absolute; right: 12px; top: 10px; background: none; color: var(--muted); font-size: 26px; padding: 4px 10px; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; max-width: min(92vw, 560px); padding: 13px 18px; border-radius: 16px; background: #24143f; color: var(--ink); font-weight: 600; box-shadow: 0 16px 40px rgb(0 0 0 / 0.45); transition: transform 0.22s ease, opacity 0.22s ease; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { background: #2f4a00; color: #eaffb0; }
.toast.warn { background: #4a1230; color: #ffd6e8; }
