:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #121212;
  --panel-2: #191919;
  --line: rgba(255, 255, 255, .1);
  --text: #f8f8f8;
  --muted: #949494;
  --red: #ff0033;
  --red-2: #d9002b;
  --green: #2de38f;
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(900px 600px at 8% -8%, rgba(255, 0, 51, .22), transparent 66%),
    radial-gradient(900px 700px at 102% 22%, rgba(95, 35, 255, .11), transparent 70%),
    linear-gradient(180deg, #0c0c0c, #050505 70%);
}

.topbar {
  position: relative; z-index: 5; height: 86px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(22px, 4vw, 72px); border-bottom: 1px solid var(--line); background: rgba(8, 8, 8, .84);
  backdrop-filter: blur(22px);
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: white; text-decoration: none; }
.brand-mark { width: 54px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--red); box-shadow: 0 0 34px rgba(255, 0, 51, .25); }
.brand-mark span { width: 0; height: 0; margin-left: 3px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 14px solid white; }
.brand strong { display: block; font-size: 22px; letter-spacing: -.04em; }
.brand small { display: block; margin-top: 1px; color: #888; font-size: 8px; font-weight: 800; letter-spacing: .23em; }
.connection-pill { display: inline-flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: #aaa; font-size: 12px; font-weight: 750; }
.connection-pill i { width: 8px; height: 8px; border-radius: 50%; background: #777; }
.connection-pill.online i { background: var(--green); box-shadow: 0 0 15px rgba(45, 227, 143, .7); }
.connection-pill.online { color: #d8fff0; }

.view { position: relative; z-index: 1; }
.tv-view { min-height: calc(100vh - 86px); grid-template-columns: minmax(0, 1fr) clamp(330px, 25vw, 470px); }
.tv-stage { min-width: 0; display: grid; place-items: center; padding: clamp(32px, 5vw, 82px); }
.tv-idle { width: min(1120px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: center; gap: clamp(45px, 7vw, 110px); }
.eyebrow, .label { color: #ff476b; font-size: 12px; font-weight: 850; letter-spacing: .17em; text-transform: uppercase; }
.pair-copy h1 { margin: 16px 0 19px; font-size: clamp(54px, 5.4vw, 104px); line-height: .94; letter-spacing: -.065em; }
.lead { max-width: 700px; color: #aaa; font-size: clamp(17px, 1.25vw, 24px); line-height: 1.55; }
.lead b { color: #eee; }
.room-code { margin: 34px 0 26px; font-size: clamp(54px, 5vw, 88px); font-weight: 900; line-height: 1; letter-spacing: .16em; font-variant-numeric: tabular-nums; }
.tv-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.qr-card { justify-self: end; width: 100%; padding: 20px; border: 1px solid rgba(255,255,255,.14); border-radius: 30px; background: white; box-shadow: 0 35px 100px rgba(0,0,0,.4); }
.qr-card img { display: block; width: 100%; border-radius: 12px; }
.qr-card span { display: block; padding: 10px 0 2px; color: #111; text-align: center; font-size: 12px; font-weight: 900; letter-spacing: .18em; }

.button { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; padding: 0 20px; border: 1px solid transparent; border-radius: 15px; color: white; text-decoration: none; font-weight: 800; cursor: pointer; }
.button.primary { background: var(--red); box-shadow: 0 13px 32px rgba(255,0,51,.2); }
.button.primary:hover { background: var(--red-2); }
.button.secondary { border-color: var(--line); background: rgba(255,255,255,.08); }
.button.ghost { border-color: var(--line); color: #aaa; background: transparent; }
.button:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--red); outline-offset: 4px; }

.tv-sidebar { min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 24px; border-left: 1px solid var(--line); background: rgba(12,12,12,.92); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 5px 19px; border-bottom: 1px solid var(--line); }
.sidebar-head strong { display: block; margin-top: 7px; font-size: 23px; letter-spacing: .15em; }
.remote-count { color: #888; font-size: 12px; }
.now-card, .queue-card { padding: 20px; border: 1px solid var(--line); border-radius: 21px; background: rgba(255,255,255,.035); }
.now-card img { width: 100%; margin: 15px 0 12px; aspect-ratio: 16/9; object-fit: cover; border-radius: 15px; }
.now-card h2 { margin: 13px 0 5px; font-size: 20px; line-height: 1.18; }
.now-card p { margin: 0; color: var(--muted); }
.queue-card { flex: 1; overflow: hidden; }
.queue-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.queue-heading h2 { margin: 4px 0 0; }
.queue-list, .remote-queue { list-style: none; padding: 0; margin: 15px 0 0; }
.queue-list li { display: grid; grid-template-columns: 66px 1fr; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.queue-list img { width: 66px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.queue-list strong { display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 1.25; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.queue-list small { color: #777; }
.fair-badge { margin-right: 8px; padding: 5px 7px; border: 1px solid rgba(45,227,143,.3); border-radius: 999px; color: var(--green); font-size: 9px; letter-spacing: .08em; }
.people-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.person-chip { min-width: 0; display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 999px; color: #c7c7c7; background: rgba(255,255,255,.035); font-size: 11px; font-weight: 750; }
.person-chip.you { border-color: rgba(255,71,107,.34); color: white; }
.person-chip i { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: white; font-size: 10px; font-style: normal; font-weight: 900; text-shadow: 0 1px 3px rgba(0,0,0,.4); }

.player-shell { position: relative; width: 100%; max-width: 1600px; aspect-ratio: 16/9; overflow: hidden; border-radius: 26px; background: #000; box-shadow: 0 35px 110px rgba(0,0,0,.55); }
.player-shell iframe, #youtubePlayer { width: 100%; height: 100%; border: 0; }
.player-notice { position: absolute; inset: 0; display: grid; place-content: center; gap: 18px; text-align: center; background: rgba(0,0,0,.78); }

.remote-view { min-height: calc(100vh - 86px); padding: clamp(22px, 4vw, 60px); }
.phone-card { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(18,18,18,.92); box-shadow: 0 22px 70px rgba(0,0,0,.22); }
.join-card { width: min(620px, 100%); margin: clamp(60px, 12vh, 150px) auto; padding: clamp(26px, 5vw, 48px); }
.join-card h1, .send-card h1 { margin: 10px 0; font-size: clamp(34px, 6vw, 56px); letter-spacing: -.045em; }
.muted { color: var(--muted); line-height: 1.5; }
.join-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; margin-top: 28px; }
.join-field { min-width: 0; display: grid; gap: 8px; color: #999; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.join-field input { min-width: 0; height: 58px; padding: 0 18px; border: 1px solid var(--line); border-radius: 16px; background: #080808; color: white; font-size: 18px; font-weight: 750; text-transform: none; }
#roomInput { font-size: 22px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.form-error { min-height: 20px; margin: 11px 0 0; color: #ff7390; font-size: 13px; }
.remote-shell { width: min(1150px, 100%); margin: 0 auto; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 16px 20px; }
.session-bar .people-row { margin-top: 8px; }
.remote-grid { display: grid; grid-template-columns: 1.3fr .9fr; gap: 18px; }
.send-card, .controls-card, .now-playing-card, .remote-queue-card { padding: clamp(20px, 3vw, 32px); }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.icon-button, .text-button { border: 0; color: #aaa; background: transparent; cursor: pointer; font-weight: 750; }
.video-form input { width: 100%; height: 59px; padding: 0 18px; border: 1px solid var(--line); border-radius: 16px; color: white; background: #080808; }
.send-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.youtube-shortcut { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); color: #888; font-size: 13px; }
.youtube-shortcut a { color: white; font-weight: 800; }
.transport { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin: 23px 0; }
.transport button { min-width: 0; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 17px; color: white; background: rgba(255,255,255,.06); font-size: 21px; cursor: pointer; }
.transport .play { background: var(--red); border-color: var(--red); }
.range-row, .volume-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; color: #aaa; font-size: 12px; }
.volume-row { margin-top: 17px; }
input[type="range"] { width: 100%; accent-color: var(--red); }
.now-playing-card { grid-column: 1 / -1; display: grid; grid-template-columns: 180px 1fr; gap: 19px; align-items: center; }
.now-playing-card img { width: 180px; aspect-ratio: 16/9; object-fit: cover; border-radius: 15px; }
.now-playing-card h2 { margin: 8px 0 5px; }
.now-playing-card p { margin: 0; color: #888; }
.remote-queue-card { grid-column: 1 / -1; }
.queue-options { display: flex; align-items: center; gap: 16px; }
.fair-toggle { display: inline-flex; align-items: center; gap: 9px; color: #ddd; cursor: pointer; font-size: 13px; }
.fair-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.fair-toggle > span { position: relative; width: 42px; height: 24px; border: 1px solid var(--line); border-radius: 999px; background: #090909; transition: .18s ease; }
.fair-toggle > span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #777; transition: .18s ease; }
.fair-toggle input:checked + span { border-color: rgba(45,227,143,.5); background: rgba(45,227,143,.15); }
.fair-toggle input:checked + span::after { left: 21px; background: var(--green); box-shadow: 0 0 12px rgba(45,227,143,.45); }
.fair-toggle input:focus-visible + span { outline: 3px solid var(--red); outline-offset: 3px; }
.fair-help { margin: 10px 0 0; color: #777; font-size: 12px; }
.remote-queue li { display: grid; grid-template-columns: 70px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.remote-queue li.current { margin-inline: -10px; padding-inline: 10px; border-radius: 13px; background: rgba(255,0,51,.09); }
.remote-queue img { width: 70px; aspect-ratio: 16/9; object-fit: cover; border-radius: 9px; }
.remote-queue strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-queue small { color: #777; }
.queue-actions { display: flex; gap: 5px; }
.queue-actions button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; color: white; background: rgba(255,255,255,.04); cursor: pointer; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); padding: 12px 17px; border: 1px solid var(--line); border-radius: 13px; color: white; background: #202020; box-shadow: 0 14px 45px rgba(0,0,0,.45); opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .topbar { height: 72px; padding-inline: 18px; }
  .connection-pill { padding: 8px 10px; }
  .connection-pill span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tv-view { grid-template-columns: 1fr; }
  .tv-idle { grid-template-columns: 1fr; }
  .qr-card { justify-self: center; width: min(320px, 80vw); }
  .tv-sidebar { display: none; }
  .remote-view { min-height: calc(100vh - 72px); padding: 16px; }
  .remote-grid { grid-template-columns: 1fr; }
  .now-playing-card, .remote-queue-card { grid-column: auto; }
}

@media (max-width: 560px) {
  .brand-mark { width: 47px; height: 32px; }
  .brand strong { font-size: 19px; }
  .join-form { grid-template-columns: 1fr; }
  .session-bar { align-items: flex-start; }
  .queue-toolbar { align-items: flex-start; flex-direction: column; }
  .queue-options { width: 100%; justify-content: space-between; }
  .send-card h1 { font-size: 31px; line-height: 1.06; }
  .send-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .send-actions .button { min-width: 0; padding-inline: 9px; }
  #pasteButton { grid-column: 1 / -1; }
  .youtube-shortcut { align-items: start; flex-direction: column; }
  .transport { gap: 6px; }
  .transport button { border-radius: 14px; font-size: 18px; }
  .now-playing-card { grid-template-columns: 100px 1fr; }
  .now-playing-card img { width: 100px; }
  .remote-queue li { grid-template-columns: 58px minmax(0,1fr) auto; }
  .remote-queue img { width: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
