/* ==================== */
/*   RESET & VARIABLES  */
/* ==================== */

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

:root {
    --primary-color: #1DB954;
    --primary-dark: #1aa34a;
    --secondary-color: #191414;
    --accent-color: #FF006E;
    --text-light: #ffffff;
    --text-dark: #191414;
    --bg-light: #f8f9fa;
    --bg-card: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== */
/*    GLOBAL STYLES     */
/* ==================== */

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    line-height: 1.6;
    color: var(--text-dark);
}

/* ==================== */
/*      CONTAINER       */
/* ==================== */

.container {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    max-width: 800px;
    width: 100%;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== */
/*         LOGO         */
/* ==================== */

.logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-main {
    max-width: 100%;
    width: 320px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.logo-header {
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto 1rem auto;
}

.logo-header-small {
    max-width: 160px;
    height: auto;
    display: block;
    margin: 0;
}

.logo-header-small.centered {
    margin: 0 auto;
}

.logo-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo-icon {
    height: 120px;
    width: auto;
}

.logo-text {
    height: 85px;
    width: auto;
}

@media (max-width: 768px) {
    .logo-main {
        width: 260px;
    }

    .logo-header {
        max-width: 160px;
    }

    .logo-header-small {
        max-width: 130px;
    }

    .logo-icon {
        height: 90px;
    }

    .logo-text {
        height: 65px;
    }
}

@media (max-width: 480px) {
    .logo-main {
        width: 220px;
    }

    .logo-header {
        max-width: 140px;
    }

    .logo-header-small {
        max-width: 110px;
    }

    .logo-inline {
        gap: 0.5rem;
    }

    .logo-icon {
        height: 70px;
    }

    .logo-text {
        height: 50px;
    }
}

/* ==================== */
/*      TYPOGRAPHY      */
/* ==================== */

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
}

p {
    color: #555;
    margin-bottom: 1rem;
}

/* ==================== */
/*       SECTIONS       */
/* ==================== */

.section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.section:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(5px);
}

#room-info {
    position: relative;
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-light);
}

/* Bouton Quitter la Room */
.leave-room-button {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(118, 75, 162, 0.15);
    border: none;
    color: #764ba2;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(10px);
}

.leave-room-button svg {
    width: 24px;
    height: 24px;
}

.leave-room-button:hover {
    background: rgba(118, 75, 162, 0.25);
    color: #5a4a7a;
    transform: translateX(-3px);
}

.leave-room-button:active {
    transform: translateX(-3px) scale(0.95);
    background: rgba(118, 75, 162, 0.35);
}

/* Bouton Télécharger les Logs */
.download-logs-button {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(13, 202, 240, 0.15);
    border: none;
    border-radius: 0 var(--border-radius) 0 var(--border-radius);
    width: 48px;
    height: 48px;
    cursor: pointer;
    transition: var(--transition);
    color: #0dcaf0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(10px);
}

.download-logs-button svg {
    width: 24px;
    height: 24px;
}

.download-logs-button:hover {
    background: rgba(13, 202, 240, 0.25);
    color: #0aa2c0;
    transform: translateX(3px);
}

.download-logs-button:active {
    transform: translateX(3px) scale(0.95);
    background: rgba(13, 202, 240, 0.35);
}

#room-code-display {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-light);
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 2px;
    box-shadow: var(--shadow-sm);
}

#player-count {
    color: #666;
    font-size: 1rem;
    margin-top: 0.5rem;
}

#host-controls-section {
    border-top: 2px solid var(--bg-light);
    padding-top: 1.5rem;
    margin-top: 2rem;
}

/* ==================== */
/*     PLAYERS LIST     */
/* ==================== */

#players-list {
    list-style: none;
    padding: 0;
}

#players-list li {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#players-list li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#players-list li[style*="font-weight: bold"] {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1aa34a 100%);
    color: var(--text-light);
}

#players-list li[style*="color: #888"] {
    opacity: 0.6;
}

/* ==================== */
/*    INPUT FIELDS      */
/* ==================== */

input[type="text"],
input[type="url"],
input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    margin-top: 0.5rem;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

input[type="number"] {
    width: auto;
    min-width: 80px;
}

input[type="range"] {
    width: 100%;
    margin: 0.5rem 0;
    accent-color: var(--primary-color);
}

/* Radio buttons */
input[type="radio"] {
    margin-right: 0.5rem;
    accent-color: var(--primary-color);
}

label {
    font-weight: 500;
    color: var(--text-dark);
    display: inline-block;
}

/* ==================== */
/*       BUTTONS        */
/* ==================== */

button {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

/* Primary Button */
#create-room-btn,
#join-room-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-light);
    width: 100%;
    margin-top: 1rem;
}

#create-room-btn:hover,
#join-room-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
}

/* Start Game Button */
#start-game-btn {
    background: var(--primary-color);
    color: var(--text-light);
    width: 100%;
    font-size: 1.1rem;
}

#start-game-btn:hover {
    background: var(--primary-dark);
}

/* Loading Spinner */
.loading-spinner {
    margin: 1rem auto;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(118, 75, 162, 0.2);
    border-top: 4px solid #764ba2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Choice Buttons */
#choices {
    min-height: 300px;
    transition: opacity 0.3s ease;
}

#choices button {
    display: block;
    width: 100%;
    margin: 0.75rem 0;
    padding: 1.25rem;
    font-size: 1.1rem;
    background: var(--bg-light);
    color: var(--text-dark);
    border: 2px solid transparent;
    text-align: left;
    position: relative;
}

#choices button:hover:not(:disabled) {
    background: #e8eaf6;
    border-color: var(--primary-color);
}

#choices button.selected {
    background: #e8eaf6;
    border-color: #007bff;
    border-width: 3px;
}

#choices button.correct {
    background: var(--primary-color);
    color: var(--text-light);
    animation: correctPulse 0.5s ease-out;
}

#choices button.incorrect {
    background: var(--accent-color);
    color: var(--text-light);
    animation: shake 0.5s ease-out;
}

#choices button:disabled {
    opacity: 0.7;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ==================== */
/*     GAME AREA        */
/* ==================== */

#game-area {
    animation: fadeIn 0.5s ease-out;
}

#question-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin: 1.5rem 0;
    text-align: center;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 8px;
}

#game-status {
    text-align: center;
    padding: 2rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

#game-status:empty {
    display: none;
    padding: 0;
    margin: 0;
}

#game-status h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#game-status ul {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

#game-status ul li {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

#volume-control {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

#volume-control label {
    margin-right: 1rem;
}

#player {
    display: none;
}

/* ==================== */
/*   RESULTS SECTION    */
/* ==================== */

#results-section {
    animation: fadeIn 0.5s ease-out;
    text-align: center;
}

#results-section h2 {
    color: var(--secondary-color);
    margin-bottom: 2rem;
    font-size: 2rem;
}

#rankings-list {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

#rankings-list li {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-size: 1.1rem;
}

/* Podium styling - basé sur le score, pas la position */
#rankings-list li.rank-gold {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: var(--text-dark);
    font-weight: 700;
    font-size: 1.25rem;
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

#rankings-list li.rank-silver {
    background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
    color: var(--text-dark);
    font-weight: 600;
    font-size: 1.15rem;
}

#rankings-list li.rank-bronze {
    background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
    color: var(--text-light);
    font-weight: 600;
    font-size: 1.1rem;
}

#rankings-list li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#rankings-list li.rank-gold:hover {
    transform: scale(1.07) translateY(-2px);
}

/* New Game Button in Results */
#new-game-results-btn {
    background: var(--primary-color);
    color: var(--text-light);
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    margin-top: 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#new-game-results-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== */
/*   ANSWER HISTORY     */
/* ==================== */

.answer-history {
    margin-top: 2rem;
    text-align: left;
}

.answer-history h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.answer-history details {
    margin-bottom: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
}

.answer-history summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.answer-history summary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.answer-history summary .history-icon-correct {
    color: var(--primary-color);
    font-weight: 700;
}

.answer-history summary .history-icon-incorrect {
    color: var(--accent-color);
    font-weight: 700;
}

.answer-history summary .history-icon-skipped {
    color: #999;
    font-weight: 700;
}

.history-choices {
    list-style: none;
    padding: 0.5rem 1rem 1rem;
    margin: 0;
}

.history-choices li {
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
}

.history-choice-correct {
    background: rgba(29, 185, 84, 0.15);
    color: var(--primary-color);
    font-weight: 600;
}

.history-choice-incorrect {
    background: rgba(255, 0, 110, 0.15);
    color: var(--accent-color);
    font-weight: 600;
}

.history-choice-no-answer {
    font-style: italic;
    color: #999;
    padding: 0.4rem 0.75rem;
}

/* ==================== */
/*  RESPONSIVE DESIGN   */
/* ==================== */

@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    button {
        padding: 0.75rem 1.5rem;
    }

    #choices button {
        padding: 1rem;
        font-size: 1rem;
    }

    #room-code-display {
        font-size: 1.25rem;
        padding: 0.4rem 1rem;
    }

    #rankings-list li {
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
    }

    #rankings-list li.rank-gold {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }

    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .section {
        padding: 1rem;
    }

    input[type="text"],
    input[type="url"] {
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 1.5rem;
        max-height: 85vh;
        width: 95%;
    }

    .help-section {
        padding: 0.75rem;
        margin: 1rem 0;
    }
}

/* ==================== */
/*    UTILITY CLASSES   */
/* ==================== */

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.m-0 { margin: 0; }
.hidden { display: none !important; }
.text-secondary { color: #666; font-size: 0.9rem; }
.spectator-message { text-align: center; color: #666; padding: 2rem; font-size: 1.1rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }
.modal-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.max-width-600 { max-width: 600px; }
.label-block { display: block; margin-bottom: 1rem; }

/* ==================== */
/*     HELP BUTTON      */
/* ==================== */

.help-button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.help-button:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
    color: #5568d3;
    transform: translateY(-1px);
}

.help-button svg {
    flex-shrink: 0;
}

/* ==================== */
/*    HELP SECTIONS     */
/* ==================== */

.help-section {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.help-section h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.help-section ol,
.help-section ul {
    margin-left: 1.5rem;
    color: #555;
}

.help-section li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.help-section code {
    background: #f0f0f0;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #d63384;
    word-break: break-all;
}

/* ==================== */
/*   CONTROL GROUPS     */
/* ==================== */

.control-group {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label,
.control-group .control-label {
    font-weight: 600;
    color: var(--secondary-color);
}

.control-input-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-number-input {
    width: 70px;
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    font-weight: 600;
    transition: var(--transition);
}

.control-number-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

.control-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, #e0e0e0 0%, #e0e0e0 100%);
    border-radius: 5px;
    outline: none;
    transition: var(--transition);
}

.control-slider:hover {
    background: linear-gradient(90deg, #d0d0d0 0%, #d0d0d0 100%);
}

.control-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.control-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.control-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.control-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 480px) {
    .control-input-group {
        gap: 0.75rem;
    }

    .control-number-input {
        width: 60px;
        padding: 0.4rem;
        font-size: 0.9rem;
    }
}

/* ==================== */
/*  SEGMENTED CONTROL   */
/* ==================== */

.segmented-control {
    display: flex;
    gap: 0.5rem;
}

.segmented-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segment-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.segment-option svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: var(--transition);
}

.segment-option:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.segment-option:hover svg {
    opacity: 1;
    color: #667eea;
}

.segmented-control input[type="radio"]:checked + .segment-option {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: var(--text-light);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.segmented-control input[type="radio"]:checked + .segment-option svg {
    opacity: 1;
}

@media (max-width: 480px) {
    .segment-option {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.35rem;
    }

    .segment-option svg {
        width: 14px;
        height: 14px;
    }

    .segment-option span {
        display: inline;
    }
}

/* ==================== */
/*  HOST ROLE SUB-SELECT */
/* ==================== */

.control-group--sub {
    margin-top: -0.25rem;
    padding-left: 1rem;
    border-left: 3px solid rgba(102, 126, 234, 0.3);
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.control-group--sub.hidden {
    display: none;
}

.choice-btn.display-host-disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

/* ==================== */
/*    LOADING STATE     */
/* ==================== */

button.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ==================== */
/*    MESSAGE CONTAINER */
/* ==================== */

#message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 350px;
}

.message {
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.message.error {
    border-left-color: var(--accent-color);
    background: #fff5f5;
}

.message.success {
    border-left-color: var(--primary-color);
    background: #f0fdf4;
}

.message.info {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== */
/*         MODAL        */
/* ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none; /* Remove default dialog border */
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex; /* Use flex for centering */
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
    /* Override potential user-agent dialog styles */
    max-width: 100vw;
    max-height: 100vh;
    color: inherit;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    max-height: 90vh;
    width: 90%;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-content input[type="text"] {
    width: 100%;
    margin: 1rem 0;
}

.modal-button {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-light);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal-button.modal-button-confirm {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.modal-button:hover {
    opacity: 0.9;
}

/* Scrollbar personnalisée pour les modales */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
}

/* ==================== */
/*     TIMER BAR        */
/* ==================== */

.timer-bar-container {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timer-bar-progress {
    height: 100%;
    transition: width 0.1s linear, background-color 0.3s ease;
    border-radius: 4px;
}

/* ==================== */
/*   PLAYLIST SELECTOR  */
/* ==================== */

.playlist-selector {
    margin-bottom: 1.5rem;
}

.playlist-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.playlist-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    transition: var(--transition);
    user-select: none;
}

.playlist-tab:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.playlist-tab:hover svg {
    opacity: 1;
    color: #667eea;
}

.playlist-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: var(--text-light);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.playlist-tab.active svg {
    opacity: 1;
}

.playlist-tab svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: var(--transition);
}

.playlist-mode {
    margin-bottom: 1rem;
}

.search-container {
    position: relative;
}

.search-container input,
.url-input-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.search-container input:focus,
.url-input-container input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item .playlist-title {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.search-result-item .playlist-meta {
    font-size: 0.85rem;
    color: #666;
}

.search-result-loading,
.search-result-empty {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.url-input-container {
    display: flex;
    gap: 0.5rem;
}

.url-input-container input {
    flex: 1;
}

.add-url-button {
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.add-url-button:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.selected-playlists {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.selected-label {
    font-weight: 500;
    color: #666;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.no-playlist-msg {
    color: #999;
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 0.5rem;
}

#selected-playlists-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selected-playlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.selected-playlist-item .playlist-info {
    flex: 1;
    min-width: 0;
}

.selected-playlist-item .playlist-name {
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-playlist-item .playlist-id {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-playlist-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.remove-playlist-btn:hover {
    background: #fee;
    color: #e53935;
}

/* ==================== */
/*    LINK AS BUTTON    */
/* ==================== */

.btn-link-primary {
    display: inline-block;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-light);
    text-decoration: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    width: 100%;
    margin-top: 1rem;
}

.btn-link-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== */
/* V-08: CSP-COMPLIANT  */
/* UTILITY CLASSES      */
/* (replaces inline     */
/*  styles for CSP)     */
/* ==================== */

/* Timer bar states */
.timer-bar-progress--full { width: 100%; }
.timer-bar-progress--green { background-color: #4caf50; }
.timer-bar-progress--orange { background-color: #ff9800; }
.timer-bar-progress--red { background-color: #f44336; }

/* Timer bar visibility */
.timer-bar-container--visible { display: block; }
.timer-bar-container--hidden { display: none; }

/* Choices container visibility */
.choices--hidden { visibility: hidden; opacity: 0; }
.choices--visible { visibility: visible; opacity: 1; }

/* Download format modal */
.modal-download { display: none; }
.modal-download--open { display: flex; }
.modal-download-content { max-width: 400px; }
.modal-download-title { margin-top: 0; }
.modal-download-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.modal-download-btn { flex: 1; }
.modal-download-btn small { opacity: 0.8; }
.modal-download-cancel { margin-top: 1rem; width: 100%; }

/* Track removal animation */
.track-item--removing {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

/* Track add animation */
.track-item--added {
    animation: fadeIn 0.3s ease-out;
}

/* New game button in results */
.btn-new-game-results { margin-top: 2rem; }

/* Progress bar discrete widths (for wrong answers 0/3, 1/3, 2/3, 3/3) */
.progress-bar--0 { width: 0%; }
.progress-bar--33 { width: 33.33%; }
.progress-bar--66 { width: 66.67%; }
.progress-bar--100 { width: 100%; }
