/* ---- Karaoke Party — shared styles ---- */
:root {
  --bg: #0b0716;
  --bg2: #140d2b;
  --panel: #1b1238;
  --panel2: #241a4a;
  --line: #37296b;
  --text: #f4efff;
  --muted: #a99cd6;
  --pink: #ff2d78;
  --pink-soft: #ff5c97;
  --cyan: #2de2ff;
  --gold: #ffd166;
  --green: #3ddc84;
  --radius: 16px;
  --font: "Baloo 2", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #2a1560 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }
a { color: var(--cyan); }

.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--pink), #b3125a);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.85em 1.8em;
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(255, 45, 120, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn.secondary { background: var(--panel2); border: 2px solid var(--line); box-shadow: none; }
.btn.small { font-size: 0.95rem; padding: 0.55em 1.2em; }
.btn:disabled { opacity: 0.45; cursor: default; }

.pill {
  display: inline-flex; align-items: center; gap: 0.4em;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.3em 0.9em; font-size: 0.9rem; color: var(--muted);
}

.toast {
  position: fixed; left: 50%; bottom: 5vh; transform: translateX(-50%);
  background: #2b1c5e; border: 1px solid var(--line); color: var(--text);
  padding: 0.8em 1.4em; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* ---- Landing page ---- */
.landing {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2.2rem; padding: 2rem; text-align: center;
}
.landing h1 {
  font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1.05;
  background: linear-gradient(120deg, var(--pink) 10%, var(--gold) 50%, var(--cyan) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 30px rgba(255, 45, 120, 0.35));
}
.landing p.tag { color: var(--muted); font-size: 1.15rem; max-width: 34rem; }
.landing .joinbox { display: flex; gap: 0.6rem; }
.landing .joinbox input {
  width: 9.5rem; text-align: center; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.35em;
  text-transform: uppercase; background: var(--panel); color: var(--text);
  border: 2px solid var(--line); border-radius: 14px; padding: 0.5em 0.2em; outline: none;
}
.landing .joinbox input:focus { border-color: var(--cyan); }
.landing .or { color: var(--muted); font-weight: 600; }
.landing .err { color: var(--pink-soft); font-weight: 600; min-height: 1.4em; }

/* ---- Host (stage) ---- */
.stage { display: grid; grid-template-columns: 1fr 340px; grid-template-rows: 1fr auto; height: 100vh; }
.stage-main { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.stage-side {
  grid-row: 1 / 3; grid-column: 2; background: var(--bg2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.stage-bar {
  grid-column: 1; display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.4rem;
  background: var(--bg2); border-top: 1px solid var(--line);
}
.stage-bar .spacer { flex: 1; }
.stage-bar .now { font-size: 1.15rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar .now .who { color: var(--gold); }

#playerWrap { position: absolute; inset: 0; background: #000; }
#playerWrap iframe { width: 100%; height: 100%; }

.idle-screen { text-align: center; padding: 2rem; max-width: 780px; }
.idle-screen h1 { font-size: clamp(2rem, 5vw, 3.6rem); margin-bottom: 0.4em;
  background: linear-gradient(120deg, var(--pink), var(--gold), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.idle-screen .code {
  font-size: clamp(3.4rem, 9vw, 6.5rem); font-weight: 800; letter-spacing: 0.22em;
  color: var(--gold); text-shadow: 0 0 40px rgba(255, 209, 102, 0.45); margin: 0.1em 0 0.3em;
}
.idle-screen .joinurl { color: var(--muted); font-size: 1.25rem; margin-bottom: 1.2rem; }
.idle-screen .joinurl b { color: var(--cyan); }
#qr { display: inline-block; padding: 14px; background: #fff; border-radius: 18px; }
#qr img, #qr canvas { display: block; }

.result-screen { text-align: center; padding: 2rem; }
.result-screen .who { font-size: 2rem; color: var(--gold); font-weight: 800; }
.result-screen .song { color: var(--muted); font-size: 1.2rem; margin-bottom: 0.8rem; max-width: 60vw; margin-inline: auto; }
.result-screen .big-score { font-size: clamp(4rem, 12vw, 8rem); font-weight: 800; color: var(--cyan);
  text-shadow: 0 0 60px rgba(45, 226, 255, 0.5); line-height: 1; }
.result-screen .stars { font-size: 2.2rem; letter-spacing: 0.12em; margin: 0.4rem 0 0.2rem; }
.result-screen .votes { color: var(--muted); }

.rating-screen { text-align: center; padding: 2rem; }
.rating-screen h2 { font-size: 2.4rem; margin-bottom: 0.3em; }
.rating-screen .who { color: var(--gold); }
.rating-screen .count { font-size: 4rem; font-weight: 800; color: var(--pink-soft); }
.rating-screen .hint { color: var(--muted); font-size: 1.1rem; margin-top: 0.5rem; }

.side-section { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.side-section h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 0.6rem; }
.side-scroll { overflow-y: auto; flex: 1; }

.player-row { display: flex; align-items: center; gap: 0.55rem; padding: 0.32rem 0; font-weight: 600; }
.player-row .em { font-size: 1.3rem; }
.player-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .sc { color: var(--gold); font-weight: 800; }
.player-row.off { opacity: 0.4; }
.player-row .medal { font-size: 1rem; }

.queue-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px dashed rgba(255,255,255,0.06); }
.queue-row img { width: 62px; height: 35px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.queue-row .meta { flex: 1; min-width: 0; }
.queue-row .t { font-size: 0.86rem; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.queue-row .s { font-size: 0.8rem; color: var(--muted); }
.queue-row.next { background: rgba(255, 209, 102, 0.07); border-radius: 8px; padding: 0.45rem 0.4rem; }
.queue-row .x { background: none; color: var(--muted); font-size: 1.1rem; padding: 0.2rem 0.4rem; }
.queue-row .x:hover { color: var(--pink-soft); }

.empty-note { color: var(--muted); font-size: 0.9rem; padding: 0.4rem 0; }

/* ---- Join (phone) ---- */
.phone { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; max-width: 560px; margin: 0 auto; }

.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1.3rem; padding: 1.6rem; text-align: center; }
.gate h1 { font-size: 2rem; }
.gate h1 .code { color: var(--gold); letter-spacing: 0.15em; }
.gate input#nameInput {
  font-size: 1.3rem; padding: 0.7em 1em; border-radius: 14px; border: 2px solid var(--line);
  background: var(--panel); color: var(--text); text-align: center; outline: none; width: 100%;
}
.gate input#nameInput:focus { border-color: var(--cyan); }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.5rem; }
.emoji-grid button {
  font-size: 1.7rem; background: var(--panel); border: 2px solid transparent; border-radius: 12px;
  padding: 0.35em 0; transition: transform 0.1s ease;
}
.emoji-grid button.sel { border-color: var(--pink); background: var(--panel2); transform: scale(1.08); }

.phone-head {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.phone-head .me { font-size: 1.4rem; }
.phone-head .name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-head .conn { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); }
.phone-head .conn.on { background: var(--green); }

.now-banner {
  padding: 0.65rem 1rem; background: linear-gradient(90deg, rgba(255,45,120,0.18), rgba(45,226,255,0.12));
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 0.95rem;
}
.now-banner .who { color: var(--gold); }
.now-banner.you { background: linear-gradient(90deg, rgba(255,209,102,0.25), rgba(255,45,120,0.18)); }

.tabs { display: flex; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 9; }
.tabs button {
  flex: 1; background: none; color: var(--muted); font-weight: 700; font-size: 0.95rem;
  padding: 0.75rem 0; border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--pink); }

.tabpane { flex: 1; padding: 1rem; }

.searchbox { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.searchbox input {
  flex: 1; font-size: 1.05rem; padding: 0.65em 1em; border-radius: 12px;
  border: 2px solid var(--line); background: var(--panel); color: var(--text); outline: none; min-width: 0;
}
.searchbox input:focus { border-color: var(--cyan); }

.result-row { display: flex; gap: 0.7rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px dashed rgba(255,255,255,0.07); }
.result-row img { width: 92px; height: 52px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.result-row .meta { flex: 1; min-width: 0; }
.result-row .t { font-size: 0.92rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-row .c { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.result-row .add {
  background: var(--panel2); border: 2px solid var(--pink); color: var(--pink-soft);
  font-size: 1.4rem; font-weight: 700; width: 2.4rem; height: 2.4rem; border-radius: 50%; flex-shrink: 0;
  line-height: 1;
}
.result-row .add:disabled { border-color: var(--line); color: var(--muted); }

.lb-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.4rem; border-radius: 10px; }
.lb-row .rank { width: 1.6rem; text-align: center; font-weight: 800; color: var(--muted); }
.lb-row .em { font-size: 1.5rem; }
.lb-row .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .pts { font-weight: 800; color: var(--gold); }
.lb-row .sub { font-size: 0.75rem; color: var(--muted); }
.lb-row.top1 { background: rgba(255, 209, 102, 0.12); }
.lb-row.me { outline: 2px solid var(--line); }

/* rating overlay (phone) */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 4, 20, 0.94); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.4rem; padding: 2rem; text-align: center;
}
.overlay h2 { font-size: 1.7rem; }
.overlay .who { color: var(--gold); }
.overlay .song { color: var(--muted); }
.star-picker { display: flex; gap: 0.5rem; }
.star-picker button { background: none; font-size: 3rem; filter: grayscale(1) opacity(0.45); transition: transform 0.1s ease, filter 0.1s ease; }
.star-picker button.lit { filter: none; transform: scale(1.12); }
.overlay .sub { color: var(--muted); }
.overlay .big-emoji { font-size: 4.5rem; }
.overlay .big-score { font-size: 5.5rem; font-weight: 800; color: var(--cyan); line-height: 1; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; }
  .stage-side { grid-row: auto; grid-column: 1; max-height: 34vh; border-left: none; border-top: 1px solid var(--line); }
  .stage-bar { grid-column: 1; flex-wrap: wrap; }
}
