/* ===== CSS RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== AUDIO CONTROLS ===== */
.audio-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 9999;
    transition: all 0.3s ease;
}

/* Minimized state - only show toggle button */
.audio-controls.minimized {
    padding: 8px;
    width: 48px;
    height: 48px;
}

.audio-controls.minimized .audio-controls-content {
    display: none;
}

.audio-toggle-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.audio-toggle-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.audio-toggle-btn:active {
    transform: scale(0.95);
}

.audio-toggle-btn svg {
    width: 24px;
    height: 24px;
}

.audio-controls-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: opacity 0.3s ease;
}

.audio-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 45px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.audio-controls:hover {
    background: rgba(30, 41, 59, 1);
    box-shadow: 0 6px 16px var(--shadow);
}

/* Hide/show icons based on minimized state */
.audio-controls.minimized .icon-collapse {
    display: none;
}

.audio-controls.minimized .icon-expand {
    display: block;
}

.audio-controls:not(.minimized) .icon-collapse {
    display: block;
}

.audio-controls:not(.minimized) .icon-expand {
    display: none;
}

.audio-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.audio-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.audio-btn:active {
    transform: scale(0.95);
}

.audio-btn svg {
    width: 24px;
    height: 24px;
}

.icon-muted.hidden,
.icon-unmuted.hidden {
    display: none;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-tertiary);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider:hover {
    background: var(--border);
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: var(--primary-light);
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    background: var(--primary-light);
    transform: scale(1.2);
}

.volume-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: right;
}

/* Mobile audio controls */
@media (max-width: 480px) {
    .audio-controls {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        gap: 8px;
    }

    .audio-controls.minimized {
        padding: 6px;
        width: 44px;
        height: 44px;
    }

    .audio-toggle-btn {
        width: 32px;
        height: 32px;
    }

    .audio-toggle-btn svg {
        width: 20px;
        height: 20px;
    }

    .volume-slider {
        width: 60px;
    }

    .volume-percent {
        font-size: 12px;
        min-width: 36px;
    }

    .audio-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    display: none;
    min-height: 100vh;
    max-height: 100vh; /* Prevent screen from exceeding viewport height */
    padding: 20px;
    animation: fadeIn 0.3s ease;
    overflow-y: auto; /* Enable vertical scrolling when content overflows */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* ===== TYPOGRAPHY ===== */
.title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: block;
}

.helper-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ===== BUTTONS ===== */
.primary-btn,
.secondary-btn,
.icon-btn,
.vote-btn,
.timer-btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 0.75rem;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.secondary-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.icon-btn {
    padding: 0.5rem;
    width: auto;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
}

.vote-btn {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    font-size: 1.125rem;
    padding: 1rem;
}

.vote-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timer-btn {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    margin: 0.25rem;
}

.timer-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.timer-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== INPUTS ===== */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group input[type="text"],
.input-group input[type="number"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* ===== MENU ===== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-box {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.info-box strong {
    color: var(--primary-light);
}

.info-box ul {
    margin-top: 1rem;
    padding-left: 1.5rem;
}

.info-box li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* ===== LOBBY ===== */
.lobby-info {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

#room-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    color: var(--primary-light);
    font-family: 'Courier New', monospace;
}

.player-list-container {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.player-list-container h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.player-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.player-item.ready {
    border-color: var(--secondary);
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.player-status {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.player-status.ready {
    color: var(--secondary);
}

/* ===== ERROR MESSAGES ===== */
.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

.error-msg.visible {
    display: block;
}

/* ===== SETUP SCREEN ===== */
.setup-form {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.timer-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ===== UPLOAD SCREEN ===== */
.upload-progress {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.upload-progress p {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 0%;
}

.participant-form {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.upload-area {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    margin-bottom: 1.5rem;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.upload-area svg {
    margin-bottom: 1rem;
    color: var(--primary);
}

.upload-area p:first-of-type {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.image-preview-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.image-preview-container.hidden {
    display: none;
}

.image-preview {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 12px;
    background: var(--bg-tertiary);
}

.change-image-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
}

.waiting-message {
    text-align: center;
    padding: 2rem;
}

.waiting-message.hidden {
    display: none;
}

.waiting-message p {
    color: var(--text-secondary);
    margin-top: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== HOST PROGRESS ===== */
.host-progress-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.progress-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.progress-item h3 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.progress-item p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.progress-item .progress-bar {
    margin-top: 0.75rem;
}

/* ===== HOST PREVIEW OF UPLOADS ===== */
.uploaded-preview-container {
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.uploaded-preview-container h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-light);
    font-size: 1.25rem;
}

.uploaded-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.preview-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: all 0.2s ease;
}

.preview-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.preview-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: var(--bg-primary);
}

.preview-card-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.preview-style {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.preview-style.melee {
    color: #ef4444;
}

.preview-style.range {
    color: #10b981;
}

.preview-style.both {
    color: #f59e0b;
}

.preview-player {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== BRACKET DISPLAY ===== */
.bracket-info {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.bracket-info p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin: 0;
}

.bracket-info strong {
    color: var(--primary-light);
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.bracket-container {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    overflow-y: auto; /* Allow vertical scrolling for tall brackets on mobile */
    max-height: 80vh; /* Limit height on mobile to ensure scrollability */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Tree-style bracket layout for larger screens */
@media (min-width: 769px) {
    .bracket-tree {
        display: flex;
        gap: 3rem;
        min-width: fit-content;
        padding: 1rem 0;
        align-items: center;
    }

    .bracket-round {
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-width: 280px;
        position: relative;
    }

    .bracket-round h3 {
        margin-bottom: 1.5rem;
        color: var(--primary-light);
        font-size: 1.25rem;
        text-align: center;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        background: linear-gradient(135deg, var(--primary-light), var(--primary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .bracket-matches {
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;
        gap: 3rem;
    }

    .bracket-match {
        position: relative;
        background: var(--bg-tertiary);
        border: 2px solid var(--border);
        border-radius: 12px;
        padding: 1rem;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    /* Horizontal connector line extending to the right */
    .bracket-match::after {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        width: 1.5rem;
        height: 3px;
        background: linear-gradient(90deg, var(--primary) 0%, var(--border) 100%);
        transform: translateY(-1.5px);
        z-index: -1;
    }

    /* Vertical connector line joining pairs of matches */
    .bracket-match::before {
        content: '';
        position: absolute;
        left: calc(100% + 1.5rem);
        top: 50%;
        width: 3px;
        background: linear-gradient(180deg, var(--border), var(--primary));
        z-index: -1;
    }

    /* For odd-numbered matches (first of pair), line goes DOWN to connect with next match */
    .bracket-match:nth-child(odd)::before {
        height: calc(3rem + 50%);
        transform: translateY(0);
        background: linear-gradient(180deg, var(--border) 0%, var(--primary) 100%);
    }

    /* For even-numbered matches (second of pair), line goes UP to connect with previous match */
    .bracket-match:nth-child(even)::before {
        height: calc(3rem + 50%);
        transform: translateY(-100%);
        background: linear-gradient(180deg, var(--primary) 0%, var(--border) 100%);
    }

    /* Last match in a round (if odd number of matches) has no vertical connector */
    .bracket-matches:has(.bracket-match:nth-child(odd):last-child) .bracket-match:last-child::before {
        display: none;
    }

    /* Last round has no connectors at all */
    .bracket-round:last-child .bracket-match::after,
    .bracket-round:last-child .bracket-match::before {
        display: none;
    }

    /* Single match in round (Finals) - no vertical line needed */
    .bracket-matches:has(.bracket-match:only-child) .bracket-match::before {
        display: none;
    }

    /* Enhanced hover effect */
    .bracket-match:hover {
        transform: translateX(4px);
        border-color: var(--primary-light);
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    }
}

/* Mobile stacked layout */
@media (max-width: 768px) {
    .bracket-round {
        margin-bottom: 2.5rem;
        padding-bottom: 2rem;
        border-bottom: 2px solid var(--border);
    }

    .bracket-round:last-child {
        margin-bottom: 0;
        border-bottom: none;
    }

    .bracket-round h3 {
        margin-bottom: 1.5rem;
        color: var(--primary-light);
        font-size: 1.25rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        background: linear-gradient(135deg, var(--primary-light), var(--primary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .bracket-matches {
        display: grid;
        gap: 1rem;
    }

    .bracket-match {
        background: var(--bg-tertiary);
        border: 2px solid var(--border);
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .bracket-match.active {
        border-color: var(--primary);
        border-width: 3px;
        background: linear-gradient(135deg, var(--bg-tertiary), rgba(99, 102, 241, 0.1));
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    }
}

.bracket-match.active {
    border-color: var(--primary);
    border-width: 3px;
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(99, 102, 241, 0.1));
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.4);
    animation: bracketPulse 2s ease-in-out infinite;
    transform: scale(1.02);
}

.bracket-match.active::after {
    background: linear-gradient(90deg, var(--primary-light) 0%, var(--primary) 100%);
    height: 4px;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

@keyframes bracketPulse {
    0%, 100% {
        box-shadow: 0 0 24px rgba(99, 102, 241, 0.4), 0 0 12px rgba(99, 102, 241, 0.2);
    }
    50% {
        box-shadow: 0 0 32px rgba(99, 102, 241, 0.6), 0 0 16px rgba(99, 102, 241, 0.3);
    }
}

.bracket-participants {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
}

.bracket-participant {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.bracket-participant.winner {
    border-color: var(--secondary);
    background: rgba(16, 185, 129, 0.15);
    transform: translateX(4px);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
    position: relative;
}

.bracket-participant.winner::after {
    content: '✓';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
    font-size: 1.5rem;
    font-weight: 700;
}

.bracket-participant.loser {
    opacity: 0.35;
    transform: scale(0.98);
    filter: grayscale(0.6);
}

.bracket-participant-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.bracket-participant-info {
    flex: 1;
    min-width: 0;
}

.bracket-participant-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bracket-participant-votes {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.bracket-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

/* ===== VOTING SCREEN ===== */
.match-info {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-light);
}

.timer-display.warning {
    color: var(--warning);
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.matchup-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.participant-vote-card {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
}

.participant-vote-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.participant-vote-card.voted {
    border-color: var(--secondary);
    background: rgba(16, 185, 129, 0.1);
}

.participant-vote-card.host-view {
    pointer-events: none;
}

.participant-image-container {
    width: 100%;
    height: 200px;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.participant-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
}

.participant-vote-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.vote-count {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.vote-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-light);
}

.vote-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.vs-divider {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 1rem;
}

.vote-confirmation {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--secondary);
    border-radius: 12px;
    color: var(--secondary);
    font-weight: 600;
}

.vote-confirmation.hidden {
    display: none;
}

.vote-status {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.vote-status-header {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.voter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.voter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.voter-item.voted {
    border-color: var(--secondary);
    background: rgba(16, 185, 129, 0.1);
}

.voter-item.waiting {
    opacity: 0.6;
}

.voter-status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voter-status-icon.voted {
    background: var(--secondary);
    color: white;
}

.voter-status-icon.waiting {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
}

.voter-name {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== MATCH RESULT SCREEN ===== */
.match-result-screen {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.result-winner {
    background: var(--bg-secondary);
    border: 3px solid var(--secondary);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.result-winner-badge {
    display: inline-block;
    background: var(--secondary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.result-participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.result-participant img {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
    background: var(--bg-tertiary);
}

.result-participant-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-loser {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.7;
}

.result-loser-badge {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.result-vote-summary {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.result-vote-summary strong {
    color: var(--text-primary);
}

.next-match-info {
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.next-match-countdown {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-light);
    margin-top: 0.5rem;
}

/* ===== COIN FLIP ===== */
.coin-flip-message {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.125rem;
}

.matchup-summary {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.tied-participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
}

.tied-participant img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
    background: var(--bg-tertiary);
}

.tied-participant p {
    font-weight: 600;
    color: var(--text-primary);
}

.coin-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    margin-bottom: 2rem;
    perspective: 1000px;
}

.coin {
    width: 150px;
    height: 150px;
    position: relative;
    transform-style: preserve-3d;
    /* Transition will be set dynamically by JavaScript */
}

/* Removed .coin.flipping animation - JavaScript now controls rotation directly */

.coin-side {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    backface-visibility: hidden;
    border: 4px solid var(--primary);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.coin-side img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
}

.coin-side.heads {
    background: var(--bg-tertiary);
}

.coin-side.tails {
    background: var(--bg-tertiary);
    transform: rotateY(180deg);
}

.coin-label {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
}

.coin-result {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--secondary);
    border-radius: 12px;
    margin-top: 2rem;
    animation: resultSlideIn 0.5s ease;
}

@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.coin-result.hidden {
    display: none;
}

.coin-result p {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.coin-result strong {
    color: var(--secondary);
}

/* ===== RESULTS SCREEN ===== */
.winner-display {
    text-align: center;
    margin-bottom: 3rem;
}

.trophy-icon {
    margin-bottom: 1rem;
    color: var(--warning);
    animation: trophyBounce 2s ease infinite;
}

@keyframes trophyBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.winner-display h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--warning), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.winner-card {
    display: inline-block;
    background: var(--bg-secondary);
    border: 3px solid var(--warning);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.3);
}

.winner-card img {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    object-fit: contain; /* TASK 2: Changed from cover to prevent cropping */
    margin-bottom: 1rem;
    background: var(--bg-tertiary);
}

.winner-card h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.final-bracket-container {
    margin-top: 3rem;
}

.final-bracket-container h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* ===== HOST WINNER DECLARATION BUTTONS ===== */
.host-winner-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}

.declare-winner-btn {
    flex: 1;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.declare-winner-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Participant A Button (Left) - Blue/Cyan Theme */
.winner-a-btn {
    border: 3px solid rgba(59, 130, 246, 0.6);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.15));
    color: rgb(96, 165, 250);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.winner-a-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.25));
    border-color: rgb(59, 130, 246);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.winner-a-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.3);
}

/* Participant B Button (Right) - Purple/Magenta Theme */
.winner-b-btn {
    border: 3px solid rgba(168, 85, 247, 0.6);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(147, 51, 234, 0.15));
    color: rgb(192, 132, 252);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.25);
}

.winner-b-btn:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(147, 51, 234, 0.25));
    border-color: rgb(168, 85, 247);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(168, 85, 247, 0.4);
}

.winner-b-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(168, 85, 247, 0.3);
}

/* Responsive: Stack buttons vertically on mobile */
@media (max-width: 480px) {
    .host-winner-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .declare-winner-btn {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
}

/* ===== ROOM CODE BADGE (HOST ONLY WITH MINIMIZE) ===== */
.room-code-badge {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 9998;
    transition: all 0.3s ease;
}

.room-code-badge.hidden {
    display: none !important;
}

.room-code-badge.minimized {
    padding: 0.5rem 0.75rem;
    gap: 0;
}

.room-code-badge:hover {
    background: rgba(30, 41, 59, 1);
    box-shadow: 0 6px 16px var(--shadow);
    transform: translateY(-2px);
}

.room-code-badge-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.room-code-badge.minimized .room-code-badge-content {
    gap: 0;
}

.room-code-badge-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.room-code-badge.minimized .room-code-badge-label {
    font-size: 0.75rem;
}

.room-code-badge-code {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-light);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.2rem;
    transition: all 0.3s ease;
    overflow: hidden;
    max-width: 200px;
}

.room-code-badge.minimized .room-code-badge-code {
    max-width: 0;
    opacity: 0;
    letter-spacing: 0;
    margin: 0;
}

.room-code-minimize-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.room-code-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-light);
}

.room-code-minimize-btn:active {
    transform: scale(0.95);
}

.room-code-minimize-btn svg {
    transition: transform 0.3s ease;
}

.room-code-badge.minimized .room-code-minimize-btn svg {
    transform: rotate(180deg);
}

/* Mobile room code badge */
@media (max-width: 480px) {
    .room-code-badge {
        top: 10px;
        left: 10px;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .room-code-badge.minimized {
        padding: 0.4rem 0.6rem;
    }

    .room-code-badge-label {
        font-size: 0.75rem;
    }

    .room-code-badge.minimized .room-code-badge-label {
        font-size: 0.65rem;
    }

    .room-code-badge-code {
        font-size: 1rem;
        letter-spacing: 0.15rem;
        max-width: 150px;
    }

    .room-code-minimize-btn {
        padding: 0.2rem;
    }

    .room-code-minimize-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* ===== UTILITY CLASSES ===== */
.host-only {
    display: none;
}

.host-only.visible {
    display: block;
}

.hidden {
    display: none !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    #room-code {
        font-size: 2rem;
        letter-spacing: 0.3rem;
    }

    .matchup-container {
        flex-direction: column;
    }

    .vs-divider {
        transform: rotate(90deg);
        padding: 0.5rem 0;
    }

    .participant-image-container {
        height: 150px;
    }

    .bracket-participants {
        flex-direction: column;
    }

    .bracket-vs {
        transform: rotate(90deg);
        margin: 0.5rem 0;
    }

    .timer-options {
        justify-content: center;
    }

    .timer-btn {
        flex: 1;
        min-width: 60px;
    }

    .matchup-summary {
        flex-direction: column;
    }

    .vs-divider {
        transform: none;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 15px;
    }

    .title {
        font-size: 1.25rem;
    }

    .participant-vote-card h3 {
        font-size: 1rem;
    }

    .participant-image-container {
        height: 120px;
    }

    .vote-number {
        font-size: 1.5rem;
    }

    .winner-card img {
        width: 150px;
        height: 150px;
    }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Mobile-specific scrollbar - more visible */
@media (max-width: 768px) {
    .screen::-webkit-scrollbar {
        width: 10px; /* Slightly wider for easier touch interaction */
    }

    .screen::-webkit-scrollbar-track {
        background: rgba(71, 85, 105, 0.3); /* Semi-transparent track */
    }

    .screen::-webkit-scrollbar-thumb {
        background: rgba(99, 102, 241, 0.6); /* Semi-transparent but visible */
        border: 2px solid transparent;
        background-clip: padding-box;
    }

    .screen::-webkit-scrollbar-thumb:active {
        background: rgba(99, 102, 241, 0.9); /* More opaque when dragging */
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== TOGGLE SWITCH STYLING ===== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-label {
    position: relative;
    display: inline-block;
    width: 100px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-label::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--text-secondary);
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

input[type="checkbox"]:checked + .toggle-label {
    background: var(--primary);
    border-color: var(--primary-light);
}

input[type="checkbox"]:checked + .toggle-label::after {
    left: 62px;
    background: white;
}

.toggle-on, .toggle-off {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    pointer-events: none;
}

.toggle-off {
    left: 12px;
    color: var(--text-secondary);
}

.toggle-on {
    right: 12px;
    color: white;
    opacity: 0;
}

input[type="checkbox"]:checked + .toggle-label .toggle-off {
    opacity: 0;
}

input[type="checkbox"]:checked + .toggle-label .toggle-on {
    opacity: 1;
}

/* ===== SCENARIO MODE STYLING ===== */
.scenario-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 30px;
    animation: scenarioEntrance 0.5s ease-out;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.scenario-banner h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scenario-banner p {
    margin: 0;
    font-size: 1.5em;
    font-weight: bold;
    color: #fff;
    font-style: italic;
    line-height: 1.4;
}

@keyframes scenarioEntrance {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scenario input on upload screen */
#scenario-input-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

#scenario-input-container label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 600;
}

#scenario-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    font-size: 1em;
    transition: all 0.2s ease;
}

#scenario-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    outline: none;
}

#scenario-input::placeholder {
    color: var(--text-muted);
}

/* Mobile scenario banner */
@media (max-width: 768px) {
    .scenario-banner h3 {
        font-size: 1em;
    }

    .scenario-banner p {
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {
    .scenario-banner {
        padding: 15px;
    }

    .scenario-banner h3 {
        font-size: 0.9em;
    }

    .scenario-banner p {
        font-size: 1em;
    }
}

/* ===== IMAGE QUALITY SLIDER ===== */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.75rem;
}

.image-quality-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-quality-slider:hover {
    background: var(--border);
}

.image-quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.image-quality-slider::-webkit-slider-thumb:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}

.image-quality-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.image-quality-slider::-moz-range-thumb:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}

.slider-value-display {
    display: flex;
    justify-content: center;
    align-items: center;
}

.slider-value-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-light);
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--primary);
    min-width: 180px;
    text-align: center;
    transition: all 0.2s ease;
}

.warning-msg {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 2px solid var(--warning);
    border-radius: 8px;
    color: var(--warning);
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.75rem;
    animation: warningPulse 2s ease-in-out infinite;
}

.warning-msg.hidden {
    display: none;
}

.warning-msg svg {
    flex-shrink: 0;
}

@keyframes warningPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Mobile slider adjustments */
@media (max-width: 480px) {
    .image-quality-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .image-quality-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    .slider-value-text {
        font-size: 1rem;
        min-width: 160px;
    }

    .warning-msg {
        font-size: 0.8rem;
    }
}

/* ===== FOCUS STYLES ===== */
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ====================================
   LEGAL DISCLAIMER MODAL STYLES
   ==================================== */

.disclaimer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
    animation: disclaimerFadeIn 0.3s ease-out;
}

.disclaimer-overlay.hidden {
    display: none;
}

@keyframes disclaimerFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes disclaimerFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.disclaimer-dialog {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: disclaimerSlideIn 0.4s ease-out;
    overflow: hidden;
}

@keyframes disclaimerSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.disclaimer-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px 32px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.disclaimer-header h1 {
    margin: 0;
    color: #ffffff;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.disclaimer-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: #0f1419;
    position: relative;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #667eea #1a1a2e;
}

/* Webkit browsers scrollbar */
.disclaimer-content::-webkit-scrollbar {
    width: 10px;
}

.disclaimer-content::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 5px;
}

.disclaimer-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 5px;
    border: 2px solid #1a1a2e;
}

.disclaimer-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.disclaimer-text {
    color: #e0e0e0;
    line-height: 1.8;
    font-size: 15px;
}

.disclaimer-text p {
    margin: 0 0 16px 0;
}

.disclaimer-text h2 {
    color: #667eea;
    margin: 24px 0 12px 0;
    font-size: 22px;
    font-weight: 600;
}

.disclaimer-text h3 {
    color: #667eea;
    margin: 24px 0 12px 0;
    font-size: 18px;
    font-weight: 600;
}

.disclaimer-text strong {
    color: #ffffff;
    font-weight: 600;
}

.disclaimer-text ul {
    margin: 12px 0;
    padding-left: 20px;
}

.disclaimer-text li {
    margin: 8px 0;
}

.disclaimer-footer {
    padding: 24px 32px;
    background: #16213e;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scroll-indicator {
    text-align: center;
    color: #fbbf24;
    font-size: 14px;
    font-weight: 500;
    animation: pulseGlow 2s ease-in-out infinite;
    transition: opacity 0.3s ease;
}

.scroll-indicator.hidden {
    opacity: 0;
    height: 0;
    overflow: hidden;
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.disclaimer-accept-btn {
    width: 100%;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.disclaimer-accept-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.disclaimer-accept-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.disclaimer-accept-btn:disabled {
    background: linear-gradient(135deg, #4a4a4a 0%, #2a2a2a 100%);
    color: #888888;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .disclaimer-overlay {
        padding: 10px;
    }

    .disclaimer-dialog {
        max-height: 90vh;
        border-radius: 12px;
    }

    .disclaimer-header {
        padding: 20px 24px;
    }

    .disclaimer-header h1 {
        font-size: 20px;
    }

    .disclaimer-content {
        padding: 24px 20px;
    }

    .disclaimer-text {
        font-size: 14px;
    }

    .disclaimer-text h2 {
        font-size: 20px;
    }

    .disclaimer-text h3 {
        font-size: 16px;
    }

    .disclaimer-footer {
        padding: 20px;
    }

    .disclaimer-accept-btn {
        padding: 14px 24px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .disclaimer-header h1 {
        font-size: 18px;
    }

    .disclaimer-content {
        padding: 20px 16px;
    }

    .disclaimer-text {
        font-size: 13px;
    }

    .scroll-indicator {
        font-size: 12px;
    }
}

/* Ensure game content is behind disclaimer */
.game-container {
    position: relative;
    z-index: 1;
}