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

:root {
    --bg-base: #0e0e10;
    --bg-surface: #18181b;
    --bg-elevated: #1f1f23;
    --bg-input: #26262c;
    --accent: #9147ff;
    --accent-hover: #772ce8;
    --text-primary: #efeff1;
    --text-secondary: #adadb8;
    --text-muted: #53535f;
    --border: #2f2f35;
    --red: #eb0400;
    --green: #00c853;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* === Page Layout === */
.page-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* === Top Bar === */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.search-form {
    display: flex;
    gap: 6px;
    flex: 1;
    max-width: 400px;
}

.search-form input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.search-form input:focus {
    border-color: var(--accent);
}

.search-form button {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.search-form button:hover {
    background: var(--accent-hover);
}

/* === Countdown === */
.countdown {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

.countdown-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.countdown-short {
    display: none;
}

.countdown-timer {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.countdown-timer.live-now {
    color: var(--red);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === Player === */
.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.player-wrapper {
    position: relative;
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.player-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.yt-player-wrapper {
    position: absolute;
    inset: 0;
    z-index: 1;
}

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

.yt-click-blocker {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: default;
}

.waiting-label {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 12px;
}
.volume-icon {
    cursor: pointer;
    font-size: 18px;
    user-select: none;
}
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}
.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.justin-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    height: 60%;
    max-height: 400px;
    z-index: 3;
    pointer-events: none;
    opacity: 0.9;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    z-index: 2;
}

.play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #fff;
    padding-left: 6px;
    transition: transform 0.15s;
}

.play-button:hover {
    transform: scale(1.1);
}

/* === Stream Info === */
.stream-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.stream-info-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.clip-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clip-uploader {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.stream-info-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.votes-badge {
    background: var(--accent);
    color: #fff;
}

.uploaded-badge {
    display: none;
}

.live-badge {
    background: var(--red);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.paused-badge {
    background: #666;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Tap to Join Button (mobile-only iOS autoplay-block failsafe) === */
.tap-to-join-btn {
    display: none;
    padding: 6px 14px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.tap-to-join-btn:hover,
.tap-to-join-btn:active {
    background: var(--accent-hover);
}

/* === Skip Button === */
.skip-btn {
    position: relative;
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.skip-btn:hover:not(.voted) {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.skip-btn.voted {
    border-color: var(--accent);
    color: var(--text-muted);
    cursor: default;
}

.skip-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0;
    background: var(--accent);
    opacity: 0.3;
    transition: width 0.3s ease;
}

.skip-label {
    position: relative;
    z-index: 1;
}

/* === Up Next === */
.up-next-section {
    flex-shrink: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 8px 16px 12px;
}

.up-next-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.up-next-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.up-next-strip::-webkit-scrollbar {
    height: 12px;
}

.up-next-strip::-webkit-scrollbar-track {
    background: var(--bg-base);
}

.up-next-strip::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

.up-next-card {
    flex-shrink: 0;
    width: 220px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    overflow: hidden;
}

.up-next-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}

.up-next-thumb.placeholder {
    background: var(--bg-input);
}

.up-next-body {
    padding: 6px 10px 8px;
}

.up-next-title {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.up-next-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.up-next-by {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.vote-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.vote-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.15s, border-color 0.15s;
}

.vote-btn.upvote:hover {
    color: var(--green);
    border-color: var(--green);
}

.vote-btn.upvote.voted {
    color: var(--accent);
    border-color: var(--accent);
}

.vote-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 20px;
    text-align: center;
}

/* === Admin Bar === */
.admin-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

.admin-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--red);
    background: rgba(235, 4, 0, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.admin-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.admin-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.admin-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: auto;
}

.admin-remove-btn:hover {
    color: var(--red);
}

/* === Add Video Bar === */
.add-video-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.add-video-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.add-video-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

.add-video-input:focus {
    border-color: var(--accent);
}

.add-video-bar .upload-status {
    font-size: 11px;
    white-space: nowrap;
    min-width: 0;
}

/* === Sidebar === */
.sidebar {
    width: 340px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.viewer-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

/* === Chat Messages === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

.chat-welcome {
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 0;
    text-align: center;
}

.chat-msg {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.system {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

.chat-name {
    font-weight: 700;
}

/* === Chat Input === */
.chat-input-wrapper {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
}

.chat-input-wrapper input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

.chat-input-wrapper input:focus {
    border-color: var(--accent);
}

.chat-send-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.chat-send-btn:hover {
    background: var(--accent-hover);
}

/* === Upload Status === */
.upload-status.uploading { color: var(--text-secondary); }
.upload-status.success { color: var(--green); }
.upload-status.error { color: var(--red); }

/* === Add Video Menu === */
.hidden { display: none !important; }

.add-menu {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.add-option {
    flex: 1;
}

.add-option-btn {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.add-option-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.add-option-btn.yt {
    border-color: #ff0000;
    color: #ff4444;
}

.add-option-btn.yt:hover {
    background: rgba(255, 0, 0, 0.1);
}

.yt-input-wrapper {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.yt-input-wrapper input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.yt-input-wrapper input:focus {
    border-color: var(--accent);
}

.yt-submit-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: #ff0000;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.yt-submit-btn:hover {
    background: #cc0000;
}

/* === Login Page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-base);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    max-width: 440px;
    width: 90%;
}

.login-card.hidden {
    display: none;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 24px;
}

.login-question {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.login-btn {
    padding: 12px 36px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}

.login-btn:hover {
    transform: scale(1.03);
}

.login-btn.yes {
    background: var(--accent);
    color: #fff;
}

.login-btn.yes:hover {
    background: var(--accent-hover);
}

.login-btn.no {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.login-btn.no:hover {
    border-color: var(--text-muted);
}

.login-btn.enter {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.login-btn.enter:hover {
    background: var(--accent-hover);
}

.login-btn.verify {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 100%;
    margin-bottom: 12px;
}

.username-display {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 24px;
    word-break: break-all;
}

.camera-wrapper {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.login-note {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.username-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    outline: none;
    margin-bottom: 16px;
}

.username-input:focus {
    border-color: var(--accent);
}

/* === Responsive === */
@media (max-width: 768px) {
    .tap-to-join-btn {
        display: inline-block;
    }

    .tap-to-join-btn.hidden {
        display: none;
    }

    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }

    .page-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .main-column {
        flex: none;
    }

    .player-section {
        flex: none;
    }

    .player-wrapper {
        aspect-ratio: 16/9;
        flex: none;
    }

    .top-bar {
        padding: 8px 12px;
        gap: 8px;
    }

    .logo {
        font-size: 14px;
    }

    .countdown-label {
        font-size: 9px;
    }

    .countdown-label .countdown-full {
        display: none;
    }

    .countdown-label .countdown-short {
        display: inline;
    }

    .countdown-timer {
        font-size: 13px;
    }

    .stream-info {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .stream-info-right {
        gap: 4px;
    }

    .badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .skip-btn {
        font-size: 11px;
        padding: 5px 10px;
    }

    .justin-overlay {
        height: 40%;
        max-height: 200px;
    }

    /* Up next: show only 1 card, scroll for more */
    .up-next-section {
        padding: 8px 12px;
    }

    .up-next-strip {
        flex-direction: column;
        overflow-x: visible;
        overflow-y: auto;
        max-height: 80px;
    }

    .up-next-card {
        width: 100%;
        display: flex;
        flex-direction: row;
    }

    .up-next-card .up-next-thumb {
        width: 120px;
        aspect-ratio: 16/9;
        flex-shrink: 0;
    }

    .up-next-card .up-next-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .add-video-bar {
        gap: 8px;
    }

    .add-video-label {
        font-size: 10px;
    }

    .add-video-input {
        padding: 6px 10px;
    }

    .page-container {
        max-width: 100vw;
        overflow-x: hidden;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    /* Sidebar fills remaining space with sticky input */
    .sidebar {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .chat-messages {
        padding: 8px 12px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .chat-input-wrapper {
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: var(--bg-elevated);
        border-top: 1px solid var(--border);
    }
}
