:root {
  --bg: #14101f;
  --bg-2: #1e1830;
  --card: #241d3a;
  --line: #352b54;
  --text: #f4f0ff;
  --muted: #a99fc8;
  --accent: #ff3d9a;
  --accent-2: #ffb03b;
  --ok: #3ddc97;
  --error: #ff5f6d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; }
h2 { font-size: 1rem; letter-spacing: .02em; margin-bottom: 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.brand.big { font-size: clamp(3rem, 7vw, 6rem); margin-bottom: 32px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 12px; cursor: pointer;
  min-height: 46px; touch-action: manipulation;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: transparent; border-color: var(--error); color: var(--error); width: 100%; }
.btn.small { padding: 8px 12px; min-height: 40px; font-size: .9rem; white-space: nowrap; }
.btn.huge { font-size: 1.6rem; padding: 20px 40px; border-radius: 18px; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 1.1rem; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--line); color: var(--text); }

input {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: 46px; width: 100%; font-size: 16px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip { background: var(--card); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: .85rem; }

/* Celular */
.mobile .topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: rgba(20, 16, 31, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.mobile main { padding: 16px; max-width: 640px; margin: 0 auto; display: grid; gap: 14px; }
.mobile #app { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.join { margin-top: 10vh; text-align: center; }
.join h2 { font-size: 1.6rem; margin-bottom: 4px; }
.join form { display: grid; gap: 10px; margin-top: 16px; }

.search { display: flex; gap: 8px; }
.search input { flex: 1; }

.results { display: grid; gap: 8px; }
.result, .queue li { display: flex; align-items: center; gap: 12px; }
.result { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.result img { border-radius: 8px; object-fit: cover; flex: none; background: var(--line); }
.result img { width: 96px; height: 54px; }
.info { display: grid; min-width: 0; flex: 1; }
.info strong { font-size: .95rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.info span { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: q; }
.mobile .queue li { padding: 8px 4px 8px 8px; border-radius: 10px; }
.mobile .queue li::before {
  counter-increment: q; content: counter(q); color: var(--muted); font-weight: 700; width: 18px; text-align: center; flex: none;
}
.mobile .queue li.empty::before { content: none; }
.queue li.mine { background: rgba(255, 61, 154, .1); }
.queue li.playing { background: rgba(255, 61, 154, .18); border: 1px solid var(--accent); }
.mobile .queue li.playing::before { content: '▶'; counter-increment: none; color: var(--accent); }
.tag-playing {
  justify-self: start; align-self: center; flex: none; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; margin-bottom: 2px;
}
.tv-queue li.playing .pos { background: var(--accent); color: #fff; }

.host summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.pin { display: flex; gap: 8px; margin-top: 12px; }
#host-controls { display: grid; gap: 8px; }
.btn.wide { width: 100%; }
.host-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.host-actions .btn { padding-inline: 6px; }
.finish-btn { justify-self: stretch; margin-top: 8px; }
.invite-box { display: grid; justify-items: center; gap: 8px; margin-top: 12px; }
.invite-box img { width: min(70vw, 260px); height: auto; border-radius: 12px; background: #fff; padding: 8px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; }
.people .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-title { margin-top: 8px; }
.btn.danger-outline { border-color: var(--error); color: var(--error); background: transparent; }

/* Avisos */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 520px); }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent-2); padding: 12px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .4s; }
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--error); }
.toast.out { opacity: 0; }

/* TV */
.tv { height: 100vh; overflow: hidden; }
.start { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; text-align: center; background: radial-gradient(circle at 30% 20%, #3a1d4f, var(--bg) 60%); padding: 24px; }
.start p { margin-top: 20px; }
.start-box { display: grid; justify-items: center; max-width: 640px; }
.start-box h2 { font-size: 1.6rem; margin-bottom: 4px; }
.start form { display: grid; gap: 16px; justify-items: center; width: 100%; }
.invite { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; text-align: center; letter-spacing: .12em; text-transform: uppercase; max-width: 520px; }
.start .hint { font-size: .9rem; max-width: 520px; }
.stage { display: grid; grid-template-columns: 1fr minmax(300px, 26vw); height: 100vh; }
.screen { position: relative; background: #000; display: grid; }
.player-wrap, .player-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.idle { display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; padding: 24px; background: radial-gradient(circle at 50% 30%, #2b1840, var(--bg) 70%); }
.idle h2 { font-size: clamp(1.4rem, 2.6vw, 2.4rem); }
.idle img { width: min(50vh, 460px); height: auto; border-radius: 16px; background: #fff; padding: 10px; }
.url { font-family: ui-monospace, Menlo, monospace; font-size: clamp(1.1rem, 2vw, 1.8rem); color: var(--accent-2); margin: 0; word-break: break-all; }
.url.small { font-size: .95rem; }
.now-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: linear-gradient(transparent, rgba(0,0,0,.85)); opacity: .25; transition: opacity .3s;
}
.now-bar:hover { opacity: 1; }
.now-bar .label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.now-bar strong { display: block; font-size: 1.2rem; }
.singer { color: var(--accent-2); font-weight: 600; }

.side { background: var(--bg-2); border-left: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.join-box { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.join-box img { width: clamp(170px, 13vw, 260px); height: auto; aspect-ratio: 1; border-radius: 10px; background: #fff; padding: 6px; flex: none; }
.join-box p { margin: 2px 0; }
.tv-queue { overflow-y: auto; flex: 1; align-content: start; }
.tv-queue li { background: var(--card); border-radius: 12px; padding: 10px; }
.tv-queue .pos { width: 30px; height: 30px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-weight: 700; flex: none; }
.tv-queue .icon-btn { opacity: .4; }
.tv-queue li:hover .icon-btn { opacity: 1; }
.skip-btn { width: 100%; font-size: 1.3rem; padding: 16px; border-radius: 14px; }
.pin-line { margin: 0; font-size: .85rem; }
.host-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.people-box summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.people-box .people { margin-top: 8px; max-height: 30vh; overflow-y: auto; }
.pin-line strong { color: var(--text); letter-spacing: .15em; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 60vh 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}
