/* Enjoy Videoke — TV stylesheet.
   Gold / Purple / Dark theme (AGENTS.md §3C). Desktop-first: this page is meant to be
   read from a couch, so type is large, contrast is high, and nothing depends on hover. */

/* ============================================================
   Tokens
   ============================================================ */
:root {
    --bg: #0a0a0a;
    --bg-2: #0e0e1a;
    --surface: #1a1a2e;
    --surface-2: #141426;
    --surface-3: #22223a;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --gold: #ffd700;
    --gold-2: #ffc400;
    --gold-soft: rgba(255, 215, 0, 0.14);
    --gold-line: rgba(255, 215, 0, 0.35);
    --purple: #8e44ad;
    --purple-hi: #9b59b6;
    --purple-deep: #5b2c6f;
    --purple-soft: rgba(142, 68, 173, 0.22);
    --error: #e74c3c;
    --ok: #27ae60;
    --text: #fff;
    --muted: #999;
    --muted-2: #aaa;
    --radius-s: 8px;
    --radius: 12px;
    --radius-l: 18px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", Menlo, Consolas, "Courier New", monospace;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    margin: 0;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "tnum" 1, "cv11" 1;
}

button {
    font-family: inherit;
}

button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    display: block;
}

/* ============================================================
   Shell
   ============================================================ */
.videoke-container {
    /* Grid, not column-flex: the queue is a sidebar beside the stage, and <aside> is a
       sibling of .main-content in the markup rather than nested inside it. */
    display: grid;
    grid-template-columns: 1fr 340px;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
        "warning  warning"
        "header   header"
        "main     queue"
        "controls controls";
    height: 100vh;
    gap: 0 16px;
    padding: 0 16px;
    background:
        radial-gradient(900px 520px at 12% -10%, rgba(142, 68, 173, 0.28), transparent 65%),
        radial-gradient(760px 480px at 100% 110%, rgba(255, 215, 0, 0.10), transparent 60%),
        linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
}

.file-warning { grid-area: warning; }
.header { grid-area: header; }
.main-content { grid-area: main; }
.song-queue { grid-area: queue; }
.control-panel { grid-area: controls; }

/* Protocol Warning */
.file-warning {
    margin: 12px 0 0;
    background: rgba(231, 76, 60, 0.16);
    border: 1px solid rgba(231, 76, 60, 0.6);
    border-radius: var(--radius);
    color: #fff;
    text-align: center;
    padding: 12px 20px;
    font-size: 14px;
    line-height: 1.6;
}

.file-warning.hidden {
    display: none;
}

.file-warning code {
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--mono);
}

/* ============================================================
   Header
   ============================================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 8px 14px;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--gold);
    text-shadow: 0 0 22px rgba(255, 215, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo span {
    color: #fff;
    margin-left: -4px;
}

.logo::before {
    content: "";
    width: 10px;
    height: 28px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--gold), var(--purple-hi));
    box-shadow: 0 0 18px rgba(155, 89, 182, 0.6);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.party-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 14px;
    background: rgba(26, 26, 46, 0.85);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    animation: livePulse 2s ease-out infinite;
}

@keyframes livePulse {
    0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.6); }
    100% { box-shadow: 0 0 0 9px rgba(39, 174, 96, 0); }
}

.party-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--muted-2);
}

.party-pin {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 6px;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    margin-right: -6px;
}

.party-guests {
    font-size: 13px;
    color: var(--muted-2);
    border-left: 1px solid var(--line-strong);
    padding-left: 12px;
}

/* Connection loss is worth showing on a TV nobody is standing next to. */
body.offline .party-badge {
    border-color: var(--error);
}

body.offline .live-dot {
    background: var(--error);
    animation: none;
}

body.offline .party-guests::after {
    content: ' · offline';
    color: var(--error);
}

.time-display {
    font-size: 17px;
    font-weight: 700;
    padding: 10px 16px;
    background: rgba(26, 26, 46, 0.85);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

/* ============================================================
   Stage
   ============================================================ */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.video-display {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-l);
    border: 1px solid var(--line);
    overflow: hidden;
    background:
        radial-gradient(700px 420px at 20% 20%, rgba(142, 68, 173, 0.35), transparent 60%),
        radial-gradient(600px 380px at 85% 85%, rgba(255, 215, 0, 0.12), transparent 60%),
        linear-gradient(160deg, #1b1b36 0%, #0f0f1f 100%);
    box-shadow: var(--shadow);
}

.yt-slot {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: #000;
    /* The embed paints its own title bar, channel avatar, "More videos" strip and
       spinner whenever it is not playing. Hold it transparent until script.js sets
       .is-live, so the stage shows our gradient instead of YouTube's furniture.
       The back slot (not .is-front) is pre-buffering the next song and never shows. */
    opacity: 0;
    transition: opacity 0.4s var(--ease);
}

.yt-slot.is-front {
    z-index: 1;
}

.video-display.is-live .yt-slot.is-front {
    opacity: 1;
}

.yt-slot iframe {
    width: 100%;
    height: 100%;
}

.video-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px;
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.video-overlay > * {
    pointer-events: auto;
}

/* Now playing card */
.now-playing {
    /* Above the loading cover: the host should still be able to read what is loading
       while the stage is dimmed. */
    position: relative;
    z-index: 11;
    background: rgba(8, 8, 18, 0.72);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    padding: 18px 24px 18px 22px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    max-width: 640px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}

.song-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.15;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.artist-name {
    font-size: 17px;
    color: var(--gold);
    opacity: 0.95;
}

/* Status line under the stage */
.lyrics-container {
    /* Bottom-left so it never collides with the join panel in the bottom-right. */
    position: absolute;
    bottom: 28px;
    left: 28px;
    max-width: 46%;
    text-align: left;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}

/* Stage HUD auto-hide. The title card and the status pill are for the first seconds
   of a song and for pauses; during playback they would sit on the lyrics for the whole
   song. script.js adds .hud-hidden a few seconds after PLAYING and drops it on pause,
   song change, a new "Next up", or mouse movement over the stage. */
.main-content.hud-hidden .now-playing,
.main-content.hud-hidden .lyrics-container {
    opacity: 0;
    visibility: hidden;
}

/* While a song plays, the status pill waits: script.js adds .is-near-end to it for the
   last NEXT_UP_LEAD_S seconds of the song, and only then does "Next up" appear — and it
   stays up regardless of the HUD timer so the next singer can get to the mic. Paused or
   idle, the pill behaves as before. */
.main-content.is-playing .lyrics-container:not(.is-near-end) {
    opacity: 0;
    visibility: hidden;
}

.main-content.hud-hidden .lyrics-container.is-near-end {
    opacity: 1;
    visibility: visible;
}

/* Fullscreen stage. From PLAYING until the song ends (or is stopped) the video takes
   the whole screen: header, queue and the control bar step aside. The control bar comes
   back as an overlay whenever the HUD is up — a remote press, a mouse nudge, a pause —
   and fades with it. script.js toggles body.is-fullscreen. */
body.is-fullscreen .header,
body.is-fullscreen .song-queue,
body.is-fullscreen .file-warning {
    display: none;
}

body.is-fullscreen .videoke-container {
    display: block;
    padding: 0;
}

body.is-fullscreen .video-display {
    position: fixed;
    inset: 0;
    z-index: 500;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

body.is-fullscreen .video-overlay {
    padding: 40px;
}

body.is-fullscreen .lyrics-container {
    position: fixed;
    left: 40px;
    bottom: 132px; /* clear of the control bar overlay */
    z-index: 510;
    max-width: 60%;
}

body.is-fullscreen .control-panel {
    position: fixed;
    left: 40px;
    right: 40px;
    bottom: 32px;
    margin: 0;
    z-index: 520;
    transition: opacity 0.5s var(--ease), visibility 0.5s var(--ease);
}

body.is-fullscreen.hud-hidden .control-panel {
    opacity: 0;
    visibility: hidden;
}

body.is-fullscreen.hud-hidden {
    cursor: none;
}

/* The queue on demand: in fullscreen, Up from the control bar brings the queue panel
   over the video (script.js enterQueue), in the top-right corner the summoned QR uses,
   clear of the control bar. It leaves when the D-pad does, or with the HUD. */
body.is-fullscreen.queue-summoned .song-queue {
    display: block;
    position: fixed;
    top: 48px;
    right: 48px;
    bottom: 132px;
    width: min(440px, 36vw);
    z-index: 530;
    background: rgba(20, 20, 38, 0.94);
    border-color: var(--gold-line);
    box-shadow: var(--shadow);
}

body.is-fullscreen.offline.queue-summoned .song-queue {
    top: 136px; /* clear of the offline header, as the summoned QR is */
}

/* Connection loss must still show on the fullscreen stage: the header comes back as an
   overlay, red badge and all, for as long as the sync server is unreachable. */
body.is-fullscreen.offline .header {
    display: flex;
    position: fixed;
    top: 0;
    left: 40px;
    right: 40px;
    z-index: 530;
}

/* While the stage is live the overlay takes the pointer, so mouse movement over the
   video reaches the page (an iframe swallows it) and a stray click on the video does
   not pause YouTube — the control bar is the host's transport, not the embed. */
.video-display.is-live .video-overlay {
    pointer-events: auto;
}

.next-up-text {
    display: inline-block;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--gold);
    padding: 12px 22px;
    /* Not 999px: a stadium radius clips the corners of a second line, and long
       status text read as if it had escaped the pill. */
    border-radius: var(--radius-l);
    background: rgba(8, 8, 18, 0.78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--gold-line);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    /* Two lines is the most a glanceable status line should ever need. */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.next-up-text:empty {
    display: none;
}

/* Error / loading states */
.video-error,
.video-loading {
    /* Sits above centre so it clears the join panel, which returns while a failed
       song is being skipped. */
    position: absolute;
    top: 36%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    background: rgba(8, 8, 18, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 30px 44px;
    border-radius: var(--radius-l);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    max-width: 560px;
}

.video-loading {
    /* Loading is a stage state, not a notice pinned over the video: a bordered box
       floating on a black rectangle read as a second, competing spinner. */
    inset: 0;
    top: 0;
    left: 0;
    transform: none;
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: rgba(8, 8, 18, 0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.video-loading.hidden {
    display: none;
}

.video-error p,
.video-loading p {
    font-size: 19px;
    line-height: 1.45;
    margin-bottom: 16px;
}

.video-loading p {
    color: var(--muted-2);
    margin-bottom: 0;
}

.error-message {
    color: #ff8a7a;
}

.skip-btn {
    padding: 11px 28px;
    background: var(--purple);
    border: 1px solid rgba(255, 215, 0, 0.4);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.skip-btn:hover {
    background: var(--purple-hi);
    border-color: var(--gold);
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 215, 0, 0.18);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.video-error.hidden,
.video-loading.hidden {
    display: none;
}

/* Score card */
.score-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 12;
    background: rgba(8, 8, 18, 0.92);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    padding: 36px 64px 32px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--gold-line);
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.08), var(--shadow);
    min-width: 360px;
}

.score-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.score-value {
    font-size: 104px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -3px;
    color: #fff;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.35);
    font-variant-numeric: tabular-nums;
}

.rating {
    font-size: 24px;
    font-weight: 700;
    color: var(--gold);
    margin-top: 12px;
}

.score-detail {
    margin-top: 10px;
    font-size: 14px;
    color: var(--muted-2);
    letter-spacing: 0.3px;
}

.score-display.hidden {
    display: none;
}

.score-display:not(.hidden) {
    animation: scoreIn 0.5s var(--ease);
}

@keyframes scoreIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Join panel: QR + URL, shown whenever nothing is playing */
.join-panel {
    position: absolute;
    right: 28px;
    bottom: 28px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 20px 26px 20px 20px;
    background: rgba(8, 8, 18, 0.82);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
    max-width: min(620px, calc(100% - 56px));
}

.join-panel::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.55), rgba(155, 89, 182, 0.55));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.join-panel.hidden {
    display: none;
}

/* Called up mid-song (QR button / red key, toggleJoinQr): the top corner, clear of the
   lyrics, which karaoke videos put in the lower half — and clear of the control bar. */
.join-panel.is-summoned {
    top: 28px;
    bottom: auto;
    /* Above the title card (z-index 11): pressing the key also brings the HUD back, and
       on a narrow stage the two corners meet. The code must stay scannable. */
    z-index: 12;
    animation: summonIn 0.35s var(--ease);
}

body.is-fullscreen .join-panel.is-summoned {
    top: 40px;
    right: 40px;
}

/* Offline, the header returns as an overlay across the top (z-index 530, above the
   stage); drop the card below it so the QR is not covered. */
body.is-fullscreen.offline .join-panel.is-summoned {
    top: 120px;
}

@keyframes summonIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: none; }
}

/* Nothing loaded (fresh party, or the queue ran out): the join panel is the whole point
   of the stage, so it takes the centre and grows, and the title card — a HUD for
   songs — stays out of the way. script.js toggles .is-empty in
   updateJoinPanelVisibility. A stopped song is not empty: its title stays up. */
.main-content.is-empty .now-playing {
    display: none;
}

.main-content.is-empty .join-panel {
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    gap: 30px;
    padding: 28px 36px 28px 28px;
    /* Room for the join URL on one line beside the larger QR. */
    max-width: min(780px, calc(100% - 56px));
}

.main-content.is-empty .join-panel-url {
    max-width: none;
}

.main-content.is-empty .join-panel-qr {
    width: 212px;
    height: 212px;
}

.main-content.is-empty .join-panel-title {
    font-size: 26px;
    margin-bottom: 14px;
}

.main-content.is-empty .join-panel-steps li {
    font-size: 15px;
}

.join-panel-qr {
    width: 176px;
    height: 176px;
    background: #fff;
    border-radius: var(--radius);
    padding: 8px;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.join-panel-qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

.join-panel-copy {
    min-width: 0;
}

.join-panel-title {
    font-size: 21px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.2px;
    margin-bottom: 10px;
}

.join-panel-steps {
    list-style: none;
    counter-reset: step;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.join-panel-steps li {
    counter-increment: step;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted-2);
}

.join-panel-steps li::before {
    content: counter(step);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gold-soft);
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.join-panel-url {
    font-size: 13px;
    color: var(--muted-2);
    font-family: var(--mono);
    word-break: break-all;
    max-width: 340px;
    margin-bottom: 10px;
}

.join-panel-pin {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted-2);
    letter-spacing: 2.5px;
}

.join-panel-pin strong {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--gold);
    line-height: 1;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
}

/* ============================================================
   Queue sidebar
   ============================================================ */
.song-queue {
    background: rgba(26, 26, 46, 0.6);
    border: 1px solid var(--line);
    border-radius: var(--radius-l);
    padding: 18px 16px;
    overflow-y: auto;
    min-height: 0;
}

.queue-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 2.5px;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 14px;
    background: rgba(255, 255, 255, 0.035);
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
        transform 0.2s var(--ease);
    cursor: pointer;
    position: relative;
}

.queue-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line-strong);
}

.queue-item.active {
    background: linear-gradient(90deg, rgba(142, 68, 173, 0.38), rgba(142, 68, 173, 0.14));
    border-color: rgba(255, 215, 0, 0.55);
    box-shadow: inset 3px 0 0 var(--gold);
}

.queue-item.done {
    opacity: 0.4;
}

.queue-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: var(--gold-soft);
    border-radius: var(--radius-s);
    font-weight: 800;
    color: var(--gold);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* The playing row swaps its number for an equaliser. */
.queue-item.active .queue-number {
    color: transparent;
    background: var(--purple);
    position: relative;
    overflow: hidden;
}

.queue-item.active .queue-number::before,
.queue-item.active .queue-number::after {
    content: "";
    position: absolute;
    bottom: 7px;
    width: 4px;
    border-radius: 2px;
    background: var(--gold);
    animation: eq 0.9s ease-in-out infinite alternate;
}

.queue-item.active .queue-number::before {
    left: 9px;
    height: 10px;
}

.queue-item.active .queue-number::after {
    left: 19px;
    height: 16px;
    animation-delay: 0.25s;
}

@keyframes eq {
    from { transform: scaleY(0.45); }
    to { transform: scaleY(1.15); }
}

.queue-details {
    flex: 1;
    min-width: 0;
}

.queue-song {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.queue-artist {
    font-size: 13px;
    color: var(--muted-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.queue-item:hover .queue-actions,
.queue-item:focus-within .queue-actions,
.pending-item .queue-actions {
    opacity: 1;
}

.queue-action {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: #ddd;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    width: 30px;
    height: 30px;
    transition: background 0.15s ease, color 0.15s ease;
}

.queue-action:hover {
    background: var(--purple-hi);
    color: #fff;
}

.queue-action.danger:hover {
    background: var(--error);
}

.queue-action.approve {
    background: rgba(39, 174, 96, 0.2);
    border-color: rgba(39, 174, 96, 0.5);
    color: #7ee2a8;
}

.queue-action.approve:hover {
    background: var(--ok);
    color: #fff;
}

/* Pending approvals panel */
.pending-panel {
    margin-bottom: 20px;
}

.pending-panel.hidden {
    display: none;
}

.pending-header {
    color: var(--gold);
}

.pending-count {
    display: inline-block;
    background: var(--gold);
    color: #000;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.pending-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    margin-bottom: 8px;
    background: rgba(255, 215, 0, 0.06);
    border: 1px dashed rgba(255, 215, 0, 0.5);
    border-radius: var(--radius);
}

.queue-empty,
.library-empty {
    padding: 34px 18px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

/* Empty states — lit icon, headline, one instruction. Mirrors the shape of the
   reference system's "GRAB THE MIC!" screen, in this project's gold/purple. */
.empty-state {
    padding: 34px 18px;
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

.empty-state-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, var(--purple-soft), transparent 70%);
    box-shadow: 0 0 28px rgba(255, 215, 0, 0.10);
}

.empty-state-mark svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.empty-state-title {
    color: var(--gold);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.3px;
    margin-bottom: 5px;
}

.empty-state-hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

@media (prefers-reduced-motion: no-preference) {
    .empty-state-mark {
        animation: emptyPulse 3.2s var(--ease) infinite;
    }
}

@keyframes emptyPulse {
    0%, 100% { box-shadow: 0 0 22px rgba(255, 215, 0, 0.08); }
    50%      { box-shadow: 0 0 34px rgba(255, 215, 0, 0.18); }
}

/* ============================================================
   Control bar
   ============================================================ */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    margin: 16px 0 16px;
    background: rgba(26, 26, 46, 0.85);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
    gap: 24px;
}

.controls-left,
.controls-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-btn {
    width: 46px;
    height: 46px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
        transform 0.15s var(--ease);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--gold-line);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn.play-pause {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, var(--purple-hi), var(--purple-deep));
    border-color: rgba(255, 215, 0, 0.55);
    box-shadow: 0 0 0 4px rgba(142, 68, 173, 0.22), 0 8px 22px rgba(142, 68, 173, 0.45);
}

.control-btn.play-pause:hover {
    background: linear-gradient(145deg, #a86ac4, var(--purple));
}

.control-btn.play-pause svg {
    width: 26px;
    height: 26px;
}

.control-btn.play-pause .icon-play {
    margin-left: 3px;
}

.control-btn.play-pause .icon-pause,
.control-btn.play-pause.is-playing .icon-play {
    display: none;
}

.control-btn.play-pause.is-playing .icon-pause {
    display: block;
}

.control-btn.stop {
    color: #ff9a8c;
}

.control-btn.stop:hover {
    background: rgba(231, 76, 60, 0.25);
    border-color: rgba(231, 76, 60, 0.6);
    color: #fff;
}

.control-btn.add-song {
    width: auto;
    padding: 0 18px 0 14px;
    border-radius: 999px;
    background: var(--gold);
    border-color: var(--gold);
    color: #1a1200;
    font-weight: 800;
    font-size: 14px;
}

.control-btn.add-song:hover {
    background: var(--gold-2);
}

.control-btn.settings {
    border-radius: 50%;
}

.control-btn.mic.active {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}

.control-btn.mic.pending {
    background: var(--purple);
    opacity: 0.7;
}

.controls-center {
    flex: 1;
    max-width: 560px;
}

.progress-container {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    overflow: visible;
    cursor: pointer;
    margin-bottom: 8px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--purple-hi), var(--gold));
    border-radius: 10px;
    transition: width 0.1s linear;
    position: relative;
}

.progress-fill::after {
    content: "";
    position: absolute;
    right: -6px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gold);
    transform: translateY(-50%);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted-2);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.4px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 6px;
}

.volume-icon {
    display: flex;
    color: var(--muted-2);
}

.volume-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.volume-icon .vol-mute { display: none; }
.volume-icon[data-level="mute"] .vol-wave-1,
.volume-icon[data-level="mute"] .vol-wave-2,
.volume-icon[data-level="low"] .vol-wave-1,
.volume-icon[data-level="low"] .vol-wave-2,
.volume-icon[data-level="mid"] .vol-wave-2 { display: none; }
.volume-icon[data-level="mute"] .vol-mute { display: block; }
.volume-icon[data-level="mute"] { color: var(--error); }

.volume-slider {
    width: 104px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--gold);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--gold);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* ============================================================
   Modals
   ============================================================ */
.modal,
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 10, 0.78);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s var(--ease), visibility 0.25s var(--ease);
}

.modal { z-index: 1000; }
.settings-modal { z-index: 1100; }

.modal.hidden,
.settings-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    background: var(--surface);
    width: 92%;
    max-width: 760px;
    max-height: 80vh;
    border-radius: 22px;
    border: 1px solid var(--line-strong);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
    transform: translateY(0);
    transition: transform 0.25s var(--ease);
}

.modal.hidden .modal-content,
.settings-modal.hidden .modal-content {
    transform: translateY(12px);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(142, 68, 173, 0.25), transparent);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.2px;
}

.close-modal,
.close-settings {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    margin-left: auto;
    transition: background 0.2s ease;
}

.close-modal:hover,
.close-settings:hover {
    background: rgba(255, 255, 255, 0.14);
}

.close-settings:hover {
    color: #fff;
}

.key-status {
    font-size: 12px;
    color: var(--gold);
    opacity: 0.8;
    margin-left: auto;
    white-space: nowrap;
}

.key-status:not(:empty) + .close-modal {
    margin-left: 0;
}

.search-box {
    padding: 18px 24px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--line);
}

.search-row {
    display: flex;
    gap: 10px;
}

.number-input {
    width: 132px;
    flex-shrink: 0;
    padding: 14px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    background: var(--gold-soft);
    border: 2px solid var(--gold-line);
    border-radius: var(--radius);
    color: var(--gold);
    outline: none;
    font-family: var(--mono);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.number-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.14);
}

.number-input::placeholder {
    color: rgba(255, 215, 0, 0.45);
    font-weight: 600;
    letter-spacing: 0;
    font-family: var(--font);
}

.search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--line-strong);
    border-radius: var(--radius);
    color: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
    color: var(--muted);
}

.search-input:focus {
    border-color: var(--purple-hi);
    box-shadow: 0 0 0 4px rgba(155, 89, 182, 0.18);
}

.song-library {
    flex: 1;
    overflow-y: auto;
    padding: 18px 24px 24px;
}

.library-heading {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 2px 2px 12px;
}

.library-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.035);
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.library-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--line-strong);
}

.song-code {
    min-width: 62px;
    padding: 7px 10px;
    background: var(--gold-soft);
    border-radius: var(--radius-s);
    font-weight: 800;
    color: var(--gold);
    text-align: center;
    font-size: 13px;
    font-family: var(--mono);
    letter-spacing: 0.5px;
}

.library-details {
    flex: 1;
    min-width: 0;
}

.library-song {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-artist {
    font-size: 13px;
    color: var(--muted-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-to-queue,
.number-match-add,
.api-retry-btn,
.online-search-btn {
    padding: 10px 20px;
    background: var(--purple);
    border: 1px solid transparent;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    border-radius: 999px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
        transform 0.15s var(--ease);
}

.add-to-queue:hover,
.number-match-add:hover,
.api-retry-btn:hover,
.online-search-btn:hover,
.online-search-btn:focus-visible {
    background: var(--purple-hi);
    border-color: var(--gold-line);
}

.add-to-queue:active,
.number-match-add:active {
    transform: scale(0.96);
}

.library-thumb {
    width: 96px;
    height: 54px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.library-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.library-thumb.thumb-fallback {
    background: linear-gradient(135deg, var(--purple-soft), rgba(255, 215, 0, 0.12));
}

/* Number match card */
.number-match {
    text-align: center;
    padding: 30px;
    color: var(--muted);
    font-size: 14px;
}

.number-match-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    margin: 4px 0 14px;
    background: linear-gradient(90deg, rgba(142, 68, 173, 0.28), rgba(142, 68, 173, 0.08));
    border: 1px solid var(--gold-line);
    border-radius: var(--radius);
}

.number-match-code {
    min-width: 74px;
    padding: 9px 12px;
    background: var(--gold-soft);
    border-radius: var(--radius-s);
    font-weight: 800;
    color: var(--gold);
    text-align: center;
    font-size: 20px;
    font-family: var(--mono);
    letter-spacing: 1px;
}

.number-match-details {
    flex: 1;
    min-width: 0;
}

.number-match-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
}

.number-match-artist {
    font-size: 14px;
    color: var(--muted-2);
}

/* Skeleton loading */
.library-item.skeleton {
    pointer-events: none;
}

.skeleton-thumb,
.skeleton-line {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-thumb {
    width: 64px;
    height: 48px;
    border-radius: 6px;
    flex-shrink: 0;
}

.skeleton-details {
    flex: 1;
}

.skeleton-line {
    height: 12px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line--wide { width: 80%; }
.skeleton-line--narrow { width: 50%; }

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* API error */
.api-error {
    text-align: center;
    padding: 40px 20px;
}

.api-error-text {
    color: #ff8a7a;
    font-size: 15px;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Settings */
.settings-content {
    max-width: 580px;
}

.settings-body {
    padding: 8px 24px 24px;
    overflow-y: auto;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.setting-label {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
}

.setting-hint {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted-2);
    line-height: 1.45;
}

/* Checkbox rendered as a switch */
.setting-toggle {
    -webkit-appearance: none;
    appearance: none;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid var(--line-strong);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s var(--ease);
}

.setting-toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s var(--ease);
}

.setting-toggle:checked {
    background: var(--purple-hi);
    border-color: var(--purple-hi);
}

.setting-toggle:checked::after {
    transform: translateX(20px);
    background: var(--gold);
}

.setting-number {
    width: 76px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 9px 10px;
    text-align: center;
    flex-shrink: 0;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
}

.settings-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    padding: 13px;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.settings-btn:hover {
    background: var(--purple-hi);
    border-color: var(--purple-hi);
}

.settings-btn.danger {
    color: #ff9a8c;
}

.settings-btn.danger:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.settings-btn.danger.armed,
.settings-btn.danger.armed:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
    /* The armed label is longer; shrink type rather than let the row wrap and move
       the button out from under the host's second tap. */
    font-size: 14px;
    white-space: nowrap;
}

.settings-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.settings-note:not(:empty) {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--gold-soft);
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    font-size: 14px;
    color: #eee;
    line-height: 1.5;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 120px;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.97);
    border: 1px solid var(--purple-hi);
    border-radius: 999px;
    padding: 14px 26px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    z-index: 1200;
    box-shadow: var(--shadow);
    animation: toastIn 0.25s var(--ease);
}

.toast.hidden {
    display: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Start overlay
   ============================================================ */
/* Browsers refuse to autoplay audio until the page has been clicked, so the party
   opens with a deliberate gesture (mirrors the reference system). */
.start-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    background:
        radial-gradient(800px 600px at 50% 35%, rgba(142, 68, 173, 0.35), transparent 65%),
        radial-gradient(600px 500px at 50% 100%, rgba(255, 215, 0, 0.10), transparent 60%),
        var(--bg);
    cursor: pointer;
    text-align: center;
    padding: 40px;
    overflow: hidden;
}

.start-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* Five equaliser bars, the same motion the active queue row uses. */
.start-mark {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 34px;
}

.start-mark i {
    display: block;
    width: 7px;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--gold), var(--purple-hi));
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.35);
    transform-origin: bottom;
    animation: eq 0.9s ease-in-out infinite alternate;
}

.start-mark i:nth-child(1) { animation-delay: 0s;    height: 60%; }
.start-mark i:nth-child(2) { animation-delay: 0.18s; height: 100%; }
.start-mark i:nth-child(3) { animation-delay: 0.36s; height: 75%; }
.start-mark i:nth-child(4) { animation-delay: 0.12s; height: 90%; }
.start-mark i:nth-child(5) { animation-delay: 0.3s;  height: 55%; }

.start-features {
    position: relative;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 760px;
    margin-top: 6px;
}

.start-features li {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--muted-2);
    background: rgba(26, 26, 46, 0.55);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.start-features li::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* Join card in the corner, where the reference keeps its QR. The room is created on
   load, so guests can start queueing while the host is still finding the remote. */
.start-join {
    position: absolute;
    right: 36px;
    bottom: 36px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px 14px 14px;
    text-align: left;
    background: rgba(8, 8, 18, 0.78);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--gold-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
}

.start-join-qr {
    width: 124px;
    height: 124px;
    padding: 6px;
    background: #fff;
    border-radius: var(--radius-s);
    flex-shrink: 0;
}

.start-join-qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

.start-join-qr:empty {
    /* No room yet (server unreachable): keep the card honest and blank. */
    background: rgba(255, 255, 255, 0.08);
}

.start-join-title {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}

.start-join-pin {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--muted-2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.start-join-pin strong {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 7px;
    color: var(--gold);
    line-height: 1;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
}

/* Short windows: keep the gesture prompt the one thing on screen. */
@media (max-height: 640px) {
    .start-features,
    .start-join { display: none; }
}

/* "Press anywhere" must mean anywhere. The children are decoration; letting them take
   the pointer risks the one gesture that unlocks audio (SPEC.md §1.6b) landing on a
   pulsing headline instead of the overlay. */
.start-overlay > * {
    pointer-events: none;
}

.start-overlay::before {
    content: "";
    position: absolute;
    width: 140vmax;
    height: 140vmax;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg, transparent 0 80%, rgba(255, 215, 0, 0.07) 90%, transparent 100%);
    animation: sweep 14s linear infinite;
    pointer-events: none;
}

@keyframes sweep {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.start-overlay.hidden {
    display: none;
}

.start-logo {
    position: relative;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 12px;
    padding-left: 12px; /* optical: cancels the trailing letter-spacing */
    color: var(--gold);
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.45);
}

.start-logo span {
    display: block;
    font-size: 18px;
    letter-spacing: 15px;
    color: var(--purple-hi);
    margin-top: 6px;
}

.start-prompt {
    position: relative;
    font-size: 68px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -1px;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    animation: startPulse 2.4s ease-in-out infinite;
}

@keyframes startPulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.015); }
}

.start-hint {
    position: relative;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted-2);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 10px 20px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
}

/* ============================================================
   Host gate
   ============================================================ */
/* Above the start overlay: the key is asked for before the party exists. Typed on a TV
   with a remote, so the field is large, visible (not a password mask) and the only
   thing on screen. */
.host-gate {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background:
        radial-gradient(800px 600px at 50% 35%, rgba(142, 68, 173, 0.35), transparent 65%),
        var(--bg);
}

.host-gate.hidden {
    display: none;
}

.host-gate-card {
    width: min(520px, 100%);
    padding: 32px 34px 28px;
    background: rgba(8, 8, 18, 0.82);
    border: 1px solid var(--gold-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
    text-align: center;
}

.host-gate-kicker {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 5px;
    color: var(--gold);
    margin-bottom: 14px;
}

.host-gate-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 10px;
}

.host-gate-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--muted-2);
    margin-bottom: 22px;
}

.host-gate-input {
    width: 100%;
    font: inherit;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    color: #fff;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    margin-bottom: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.host-gate-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.host-gate-btn {
    width: 100%;
    font-size: 17px;
    font-weight: 800;
    padding: 14px 18px;
    color: #111;
    background: var(--gold);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s var(--ease);
}

.host-gate-btn:hover {
    background: var(--gold-2);
}

.host-gate-error {
    min-height: 22px;
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--error);
}

/* ============================================================
   Utilities
   ============================================================ */
/* Visible focus for keyboard and TV-remote navigation (SPEC.md §E9). */
button:focus-visible,
input:focus-visible,
.queue-item:focus-visible,
.pending-item:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

@media (prefers-reduced-motion: reduce) {
    .join-panel.is-summoned,
    .start-prompt,
    .start-overlay::before,
    .start-mark i,
    .live-dot,
    .queue-item.active .queue-number::before,
    .queue-item.active .queue-number::after {
        animation: none;
    }
    .start-prompt { opacity: 1; }
}

/* TV screens. Two things differ from a laptop: the picture is read from across a room,
   and most sets crop 2–5% off every edge (overscan), so nothing important may hug the
   border. Wider margins keep the QR card and the clock inside the visible area, and the
   small text — queue rows, join steps, the URL — steps up a size. */
@media (min-width: 1600px) {
    .videoke-container { padding: 0 44px; gap: 0 20px; grid-template-columns: 1fr 380px; }
    .header { padding: 28px 8px 16px; }
    .control-panel { margin-bottom: 30px; }
    .start-overlay { padding: 64px; }
    .start-join { right: 60px; bottom: 60px; }
    .start-features li { font-size: 15px; padding: 10px 18px; }
    .join-panel { right: 36px; bottom: 36px; }
    .join-panel.is-summoned { top: 36px; bottom: auto; }
    body.is-fullscreen .join-panel.is-summoned { top: 48px; right: 48px; }
    body.is-fullscreen.offline .join-panel.is-summoned { top: 136px; }
    .lyrics-container { left: 36px; bottom: 36px; }
    .next-up-text { font-size: 26px; }
    .join-panel-steps li { font-size: 17px; }
    .join-panel-url { font-size: 15px; max-width: 420px; }
    .queue-song { font-size: 18px; }
    .queue-artist { font-size: 15px; }
    .queue-number { font-size: 15px; }
    .queue-empty { font-size: 16px; }
    .empty-state-title { font-size: 18px; }
    .empty-state-hint { font-size: 15px; }
    .party-guests { font-size: 15px; }
    .time-display { font-size: 19px; }
}

/* Narrow screens (a laptop being used as the TV): stack the queue under the stage. */
@media (max-width: 1100px) {
    .videoke-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr 260px auto;
        grid-template-areas:
            "warning"
            "header"
            "main"
            "queue"
            "controls";
        gap: 12px 0;
    }
    .song-queue { margin-top: 0; }
    .join-panel { right: 16px; bottom: 16px; padding: 14px 16px; gap: 14px; }
    .lyrics-container { left: 16px; bottom: 16px; max-width: 40%; }
    .next-up-text { font-size: 16px; padding: 8px 14px; }
    .join-panel-qr { width: 128px; height: 128px; }
    .join-panel-steps { display: none; }
    .main-content.is-empty .join-panel-qr { width: 160px; height: 160px; }
    .main-content.is-empty .join-panel-title { font-size: 21px; }
    .start-join { right: 20px; bottom: 20px; }
    .start-join-qr { width: 96px; height: 96px; }
    /* Lift the centred block so the feature chips clear the join card in the corner. */
    .start-overlay { padding-bottom: 150px; gap: 22px; }
    .control-btn.add-song .btn-label { display: none; }
    .control-btn.add-song { width: 46px; padding: 0; }
}
