:root {
    /* Palette de couleurs "Premium Dark" */
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --surface-color-transparent: rgba(30, 30, 30, 0.85);
    --primary-color: #00e676;
    /* Vert vibrant */
    --primary-hover: #00c853;
    --secondary-color: #651fff;
    /* Violet vibrant */
    --secondary-hover: #6200ea;
    --accent-color: #ff4081;
    /* Rose vibrant */
    --text-primary: #ffffff;
    --text-secondary: #b0bec5;
    --border-color: #333;

    /* Variables Landing Page importées */
    --card-glass: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --glass-border: var(--card-border);

    /* Espacements et Rayons */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    /* Ombres */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.3);
    /* Landing shadow */
    --glow-primary: 0 0 15px rgba(0, 230, 118, 0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Fond dégradé violet (identique à l'accueil) */
    background: radial-gradient(circle at 50% 30%, #2a1b3d 0%, #0f0f13 70%);
}

/* --- UTILITAIRES --- */
.hidden {
    display: none !important;
}

.glass-panel {
    background: var(--card-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    /* Match landing page */
    box-shadow: var(--shadow-card);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- LAYOUT PRINCIPAL --- */
#app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Desktop Grid Layout */
@media (min-width: 992px) {
    #app-container {
        display: grid;
        grid-template-columns: 350px 1fr 300px;
        /* Sidebar Gauche (Host), Centre (Jeu), Sidebar Droite (Playlist/Logs) */
        grid-template-rows: auto 1fr;
        gap: var(--spacing-lg);
        height: 100vh;
        overflow: hidden;
        /* Pour éviter le scroll global si possible */
        padding: var(--spacing-lg);
    }

    /* Header prend toute la largeur */
    header {
        grid-column: 1 / -1;
    }

    /* Zones spécifiques */
    .zone-host {
        grid-column: 1;
        grid-row: 2;
        overflow-y: auto;
    }

    .zone-game {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .zone-controls {
        grid-column: 3;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
    }
}

/* --- HEADER --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-full);
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    /* Tricolor */
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#btn-print {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: black;
    border: none;
    padding: 12px 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transform: scale(1.02);
}

#btn-print:hover {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    box-shadow: 0 6px 20px rgba(255, 64, 129, 0.6);
    transform: scale(1.05) translateY(-2px);
}

/* --- BOUTONS --- */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #000;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    font-size: 1.1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-primary);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-full);
}

.btn-secondary:hover {
    background: #2c2c2c;
    border-color: var(--text-secondary);
}

.btn-danger {
    background: #ff5252;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.btn-warning {
    background: #ff9800;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 8px;
    border-radius: 50%;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* --- ZONE JEU (CENTRE) --- */
#challenge-box {
    background: var(--card-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: var(--spacing-xl);
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-card);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#challenge-text {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    /* Gris demandé */
}

#playlist-info-badge {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Réponse */
#answer-box {
    margin-top: var(--spacing-lg);
    text-align: center;
    animation: slideUp 0.5s ease-out;
}

#album-cover {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-md);
    object-fit: cover;
}

#answer-title {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

#answer-artist {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
}

#answer-date {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-top: var(--spacing-sm);
    letter-spacing: 1px;
}

/* --- HOST PANEL (GAUCHE) --- */
#qrcode img {
    margin: 0 auto;
    border: 5px solid white;
    border-radius: 5px;
    background-color: white;
}

.host-panel.compact .lobby-info {
    display: none !important;
}

.host-panel {
    background: var(--card-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    box-shadow: var(--shadow-card);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.host-header h2 {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: var(--spacing-sm);
}

.player-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.player-card.winner {
    border-color: var(--primary-color);
    background: rgba(0, 230, 118, 0.1);
}

.player-card.player-answered {
    border-color: var(--primary-color);
    background: rgba(0, 230, 118, 0.2);
    box-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
    transform: scale(1.05);
}

.player-card.player-offline {
    opacity: 0.6;
    border: 1px dashed var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    filter: grayscale(100%);
}

.player-countdown {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-color);
}

.player-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-sm);
}

/* --- CONTROLS (DROITE) --- */
.controls-panel {
    background: var(--card-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    box-shadow: var(--shadow-card);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Input Playlist */
.input-group {
    display: flex;
    gap: var(--spacing-xs);
}

#playlist-id-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: white;
    padding: 10px;
    border-radius: var(--radius-sm);
    flex-grow: 1;
}

/* --- MODALE --- */
/* --- MODALE --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: flex;
    /* Keep flex for transition */
    opacity: 0;
    pointer-events: none;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(30, 30, 30, 0.85);
    /* Darker glass */
    padding: var(--spacing-lg);
    border-radius: 24px;
    /* More rounded */
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

/* --- SETTINGS CARDS --- */
.setting-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    transition: background 0.2s;
}

.setting-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

.setting-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1;
    /* Allow taking available space */
    padding-right: 10px;
    /* Space before switch */
}

.setting-info span {
    white-space: normal;
    /* Allow text wrapping */
    line-height: 1.4;
}

.setting-icon {
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    min-width: 32px;
    /* Prevent shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* --- MODERN TOGGLE --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background: var(--active-gradient, linear-gradient(135deg, #00e676, #00c853));
}

input:checked+.slider:before {
    transform: translateX(22px);
}

input:disabled+.slider {
    background-color: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    opacity: 0.6;
}

/* --- ANIMATIONS --- */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- MOBILE SPECIFIC --- */
@media (max-width: 991px) {
    #app-container {
        padding: var(--spacing-sm);
        gap: var(--spacing-md);
    }

    /* Ordre d'affichage Mobile : Header -> Jeu -> Controls -> Host */
    header {
        order: 1;
    }

    .zone-game {
        order: 2;
    }

    .zone-controls {
        order: 3;
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .zone-host {
        order: 4;
    }

    #challenge-box {
        min-height: 200px;
    }

    #challenge-text {
        font-size: 1.8rem;
    }

    #playlist-info-badge {
        position: static;
        margin-bottom: var(--spacing-sm);
        order: -1;
        /* Ensure it stays at the top */
    }

    .btn-primary {
        width: 100%;
        padding: 16px;
        font-size: 1.2rem;
    }

    /* Rules Modal Mobile Adjustments */
    #rules-modal .modal-content {
        display: flex;
        flex-direction: column;
        max-height: 80vh;
        /* Limite la hauteur pour voir le fond */
        padding: 0;
        /* On gère le padding en interne */
        overflow: hidden;
        /* Le scroll se fait sur le contenu texte */
    }

    /* Le Header du modal (Titre + Crois) */
    #rules-modal .modal-content>h3,
    #rules-modal .modal-content>.close-modal {
        flex-shrink: 0;
        margin: 20px;
    }

    /* Le Contenu scrollable (Texte) */
    #rules-modal .modal-content>div:not(.close-modal) {
        flex: 1;
        overflow-y: auto;
        padding: 0 20px;
        margin: 0;
        /* Reset margin inline */
    }

    /* Le Bouton fixe en bas */
    #rules-modal .modal-content>button {
        flex-shrink: 0;
        margin: 10px 20px 20px 20px;
        /* Reduce top margin */
        width: auto;
        /* Width auto avec margins car flex column stretch par defaut */
        padding: 10px 30px;
        /* Reduced vertical padding, slight horizontal padding */
        font-size: 1rem;
        /* Reduce font size */
        align-self: center;
        /* Prevent stretching to full width */
    }

    #rules-modal h3 {
        font-size: 1.1rem;
    }

    #rules-modal p {
        font-size: 0.85rem;
    }

    #rules-modal ul li {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    /* Gros boutons tactiles */
}

/* --- ANIMATION CLIGNOTEMENT ROUGE (ALMOST WIN) --- */
@keyframes blink-red {
    0% {
        border-color: transparent;
        box-shadow: none;
    }

    50% {
        border-color: #ff5252;
        box-shadow: 0 0 15px rgba(255, 82, 82, 0.6);
    }

    100% {
        border-color: transparent;
        box-shadow: none;
    }
}

.player-card.almost-win {
    animation: blink-red 1s infinite;
    border-width: 2px;
    /* Force border width */
}

/* Conflict resolution: If answered AND almost win */
.player-card.player-answered.almost-win {
    /* On garde le fond vert mais on ajoute le clignotement rouge par dessus */
    /* L'animation blink-red va gérer la bordure et le shadow */
    /* On peut ajuster si besoin */
}

/* --- COULEURS DYNAMIQUES (DÉFIS) --- */
.bg-jaune {
    background: linear-gradient(135deg, #fbc02d, #f57f17) !important;
    color: #000 !important;
    border-color: #fbc02d !important;
}

.bg-jaune #challenge-text,
.bg-jaune #answer-title {
    color: #000 !important;
}

.bg-jaune #answer-artist {
    color: #000 !important;
}

.bg-vert {
    background: linear-gradient(135deg, #00e676, #00c853) !important;
    color: #000 !important;
    border-color: #00e676 !important;
}

.bg-vert #challenge-text,
.bg-vert #answer-title {
    color: #000 !important;
}

.bg-vert #answer-artist {
    color: #000 !important;
}

.bg-bleu {
    background: linear-gradient(135deg, #2979ff, #2962ff) !important;
    color: white !important;
    border-color: #2979ff !important;
}

.bg-bleu #challenge-text,
.bg-bleu #answer-title {
    color: white !important;
}

.bg-bleu #answer-artist {
    color: white !important;
}

.bg-violet {
    background: linear-gradient(135deg, #651fff, #6200ea) !important;
    color: white !important;
    border-color: #651fff !important;
}

.bg-violet #challenge-text,
.bg-violet #answer-title {
    color: white !important;
}

.bg-violet #answer-artist {
    color: white !important;
}

.bg-rose {
    background: linear-gradient(135deg, #ff4081, #f50057) !important;
    color: white !important;
    border-color: #ff4081 !important;
}

.bg-rose #challenge-text,
.bg-rose #answer-title {
    color: white !important;
}

.bg-rose #answer-artist {
    color: white !important;
}

/* --- THEME SPECIFIC BUTTONS --- */
.bg-jaune .apple-music-button {
    background: rgba(0, 0, 0, 0.85);
    color: white !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.bg-jaune .apple-music-button:hover {
    background: rgba(0, 0, 0, 0.7);
    /* Lighter black on hover */
    transform: scale(1.02);
}

.bg-rose .apple-music-button {
    background: rgba(255, 255, 255, 0.9);
    color: #d81b60 !important;
    /* Deep Pink for text contrast */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.bg-rose .apple-music-button:hover {
    background: rgba(255, 255, 255, 1);
    /* Full opaque white */
    transform: scale(1.02);
}

.bg-rose #answer-title {
    color: white !important;
}

.bg-rose #answer-artist {
    color: white !important;
}

/* --- PLAYLIST MODAL REDESIGN --- */

/* Modal Content Adjustment */
.modal-content {
    background: rgba(30, 30, 30, 0.95);
    /* Slightly more opaque for better readability */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    padding: 0;
    /* Remove default padding to let header/list sit flush if needed, or keep and adjust */
    overflow: hidden;
    /* Hide overflow for rounded corners */
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    /* Slightly taller */
}

/* Header of the modal */
.modal-content h3 {
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-sm);
    margin: 0;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

/* Close button positioning */
.close-modal {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
    z-index: 10;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* List Container */
#library-list {
    padding: var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Playlist Item Card */
.playlist-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

/* Icon placeholder */
.pl-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Text Info */
.pl-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.pl-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.playlist-item:hover .pl-title {
    color: var(--primary-color);
}

.pl-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Custom Input Section */
.custom-playlist-section {
    padding: var(--spacing-lg);
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    /* Push to bottom if flex column */
}

/* --- WAITING MESSAGE --- */
.waiting-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: var(--spacing-md);
    width: 100%;
}

/* --- TOGGLE SWITCH --- */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    /* Reduced from 50px */
    height: 22px;
    /* Reduced from 24px */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(18px);
    /* Adjusted for new width */
    -ms-transform: translateX(18px);
    transform: translateX(18px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- SOUND WAVE ANIMATION --- */
@keyframes soundWave {
    0% {
        height: 10px;
    }

    50% {
        height: 25px;
    }

    100% {
        height: 10px;
    }
}

.sound-wave {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    justify-content: center;
    margin-top: 15px;
}

.sound-wave .bar {
    width: 4px;
    background: currentColor;
    border-radius: 2px;
    animation: soundWave 1.2s ease-in-out infinite;
}

.sound-wave .bar:nth-child(1) {
    animation-delay: 0.0s;
}

.sound-wave .bar:nth-child(2) {
    animation-delay: 0.2s;
}

.sound-wave .bar:nth-child(3) {
    animation-delay: 0.4s;
}

.sound-wave .bar:nth-child(4) {
    animation-delay: 0.6s;
}

.sound-wave .bar:nth-child(5) {
    animation-delay: 0.8s;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Settings Text Fix */
#settings-modal p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-top: 5px;
}

/* Specific fix for Settings Modal to override general modal styles */
#settings-modal .modal-content {
    padding: var(--spacing-lg);
    overflow-y: auto;
    display: block;
    max-width: 600px;
    /* Wider as requested */
    max-height: auto;
}

/* Animation pour les points de validation (Côté Host) */
.validating-dots {
    display: block;
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.5em;
    margin-top: -5px;
    line-height: 0.5;
    animation: pulseDots 1.5s infinite ease-in-out;
}

/* --- AUTO COUNTDOWN OVERLAY --- */

#auto-countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    /* Dim background */
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn 0.3s ease-out;
}

.countdown-content {
    position: relative;
    background: rgba(30, 30, 35, 0.95);
    /* Premium Dark */
    padding: 40px 60px;
    border-radius: 24px;
    text-align: center;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    /* Subtle white border */
    transform: scale(1);
    animation: popupScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.countdown-label {
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #a0a0a0;
    /* Neutral Silver */
    margin-bottom: 15px;
    font-weight: 500;
}

#countdown-number {
    font-size: 6rem;
    font-weight: 800;
    /* Brand Gradient */
    background: linear-gradient(90deg, #00e676, #00c853);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Remove text-shadow for clean gradient */
    line-height: 1;
    font-variant-numeric: tabular-nums;
    position: relative;
    z-index: 2;
    /* Optional: Drop shadow on the container or element itself doesn't work well with transparent text fill, so we rely on the gradient pop */
    filter: drop-shadow(0 0 10px rgba(151, 228, 146, 0.15));
}

/* Optional Decorative Ring */
.countdown-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    z-index: 1;
    animation: ringPulse 1s infinite;
}

@keyframes popupScale {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ringPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.5;
        border-color: rgba(255, 255, 255, 0.3);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
        border-color: rgba(255, 255, 255, 0);
    }
}

@keyframes pulseCount {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.3));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 20px rgba(255, 64, 129, 0.6));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.3));
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulseDots {
    0% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }

    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

/* --- NEW ANSWER BOX STYLES --- */

/* Note: .answer-content is now flex column centered */

#answer-title {
    background: linear-gradient(90deg, #fff, #ccc);
    -webkit-background-clip: text;
    background-clip: text;
    /* -webkit-text-fill-color: transparent; (Optional, keeps it cleaner white) */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.apple-music-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #fa243c;
    /* Apple Music Red / Pinkish */
    color: white !important;
    /* Force white text */
    padding: 10px 24px;
    border-radius: 999px;
    /* Capsule */
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(250, 36, 60, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 10px;
}

.apple-music-button:hover {
    background-color: #d41c30;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(250, 36, 60, 0.6);
}

.apple-music-button svg {
    display: block;
    /* Fix vertical alignment */
}

/* Ensure images have nice styling */
#album-cover {
    transition: transform 0.3s ease;
}

/* --- ANSWER BOX REFACTORED STYLES --- */
.answer-label {
    color: #000 !important;
    /* Requested by user */
    margin-bottom: 20px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.answer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.answer-text-group {
    margin-top: 5px;
    text-align: center;
}

#album-cover {
    width: 250px;
    height: 250px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    object-fit: cover;
}

/* --- TV / DESKTOP OPTIMIZATIONS --- */
@media (min-width: 992px) {

    /* Compress sidebars to give more room to Game Zone */
    #app-container {
        display: grid;
        /* Use minmax(0, 1fr) to prevent grid blowout from large content */
        grid-template-columns: 350px minmax(0, 1fr) 260px !important;
        grid-template-rows: auto 1fr;
        gap: 20px;
        /* Reduced gap slightly to help fit */
        max-width: none !important;
        width: 100vw !important;
        padding: 20px !important;
        /* Reduced padding to save space */
        height: 100vh;
        overflow: hidden;
    }

    /* Header spans full width */
    header {
        grid-column: 1 / -1;
    }

    /* Challenge Text */
    #challenge-text {
        font-size: 3.5rem !important;
    }

    /* Improved Answer Box Layout (CENTERED COLUMN) */
    .answer-content {
        flex-direction: column !important;
        gap: 15px;
        /* Reduced gap */
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    .answer-text-group {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: 0;
        flex-grow: 1;
        width: 100%;
    }

    /* Make Album Cover Responsive! */
    #album-cover {
        width: 100% !important;
        /* Allow shrinking */
        max-width: 350px !important;
        /* Max size capped */
        height: auto !important;
        /* Maintain aspect ratio */
        aspect-ratio: 1/1;
        /* Enforce square */
        flex-shrink: 1;
        /* Allow shrinking in flex container */
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }

    /* Typography Upgrades - Centered & Single Line force */
    #answer-title {
        font-size: 3rem !important;
        /* Slightly smaller for safety */
        margin-bottom: 5px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        max-width: 100%;
        /* Ensure it fits container */
        display: block;
    }

    #answer-artist {
        font-size: 2.2rem !important;
    }

    #answer-artist {
        font-size: 2.2rem !important;
        opacity: 0.9;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        max-width: 100%;
        display: block;
    }

    /* Badge adjustment */
    #answer-date-badge {
        font-size: 1.6rem;
        padding: 8px 25px;
        border-radius: 40px;
        margin-top: 15px;
    }

    /* Button scale */
    .apple-music-button {
        font-size: 1.1rem;
        padding: 12px 30px;
        margin-top: 20px;
    }

    /* Adjust Answer Box Padding/Width */
    #answer-box {
        padding: 30px !important;
        width: 90% !important;
        /* Slightly wider to accommodate content */
        max-width: none !important;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin-top: 2vh !important;
    }

    /* Hide scrollbars but allow scroll if needed */
    .zone-game {
        overflow-y: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
        align-items: center;
        gap: 0;
    }

    .zone-game::-webkit-scrollbar {
        display: none;
    }
}

#album-cover:hover {
    transform: scale(1.02);
}

/* --- PHONE PREVIEW ANIMATION --- */
/* --- PHONE PREVIEW ANIMATION --- */
/* --- PHONE PREVIEW ANIMATION --- */
/* --- PHONE PREVIEW ANIMATION --- */
.phone-mockup {
    width: 260px;
    height: 550px;
    /* Ratio ajusté pour 485x1024 */
    background: #000;
    border-radius: 40px;
    /* Plus arrondi */
    /* Updated Shadow: Restore Violet Case, NO Black Rim */
    box-shadow:
        0 0 0 6px #651fff,
        /* Main Violet Border (Case) */
        0 0 0 8px #7c4dff,
        /* Lighter Violet Edge */
        0 30px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(101, 31, 255, 0.4);

    position: relative;
    overflow: hidden;
    margin: 60px auto;
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Hide Notch */
.phone-mockup:before {
    display: none;
}


/* Gloss Reflection */
.phone-mockup::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(105deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(255, 255, 255, 0) 50%);
    pointer-events: none;
    z-index: 50;
}

.slideshow-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #000;
    /* Fond noir pour le letterboxing éventuel */
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background-size: contain;
    /* Contain pour ne rien couper */
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1s ease-in-out;
}

/* Animations Keyframes */
.slide:nth-child(1) {
    animation: fadeInfo 12s infinite;
}

.slide:nth-child(2) {
    animation: fadeInfo 12s infinite 3s;
}

.slide:nth-child(3) {
    animation: fadeInfo 12s infinite 6s;
}

.slide:nth-child(4) {
    animation: fadeInfo 12s infinite 9s;
}

@keyframes fadeInfo {
    0% {
        opacity: 0;
    }

    4% {
        opacity: 1;
    }

    25% {
        opacity: 1;
    }

    29% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Contain aussi ici */
}

/* --- HOW IT WORKS SECTION (REDESIGN) --- */
#how-it-works {
    padding: 60px 0;
    /* More breathing room for premium feel */
}

.how-it-works-content {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    /* Cards stretch to match phone height roughly */
    justify-content: center;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.steps-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    max-width: 500px;
}

/* --- STEP CARDS --- */
.step-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

/* Hover Effect */
.step-card:hover {
    transform: translateX(10px) scale(1.02);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Number Styling - No Circle (Clean) */
.step-number-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    width: 60px;
    /* Keep width for spacing */
    height: auto;
    /* Remove fixed height */
    background: transparent;
    /* Remove circle background */
    border: none;
    /* Remove border */
    flex-shrink: 0;
}

.step-number {
    display: block;
    font-size: 2.8rem;
    /* Much larger since no circle */
    font-weight: 900;
    line-height: 1;
    margin: 0;
    padding: 0;
    /* Remove optical padding */
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
    filter: drop-shadow(0 2px 10px rgba(101, 31, 255, 0.3));
    /* Add subtle glow instead */
}

/* Content */
.step-content {
    flex: 1;
    z-index: 2;
}

.step-title {
    margin: 0 0 8px 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.step-desc {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Decoration Icon (Watermark) - More Visible */
.step-icon-bg {
    position: absolute;
    right: 15px;
    bottom: 0px;
    font-size: 4rem;
    opacity: 0.2;
    transform: rotate(0deg);
    pointer-events: none;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.step-card:hover .step-icon-bg {
    opacity: 0.3;
    transform: scale(1.1);
    filter: drop-shadow(0 0 10px var(--primary-color));
    color: var(--primary-color);
}

.phone-wrapper {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* --- RESPONSIVE --- */
@media (max-width: 991px) {
    .how-it-works-content {
        flex-direction: column;
        gap: 60px;
        padding-bottom: 40px;
    }

    .steps-container {
        width: 100%;
        max-width: none;
    }

    .phone-wrapper {
        width: 100%;
        margin-top: 20px;
    }

    .step-card {
        padding: 20px;
    }

    .step-number-container {
        min-width: 50px;
        width: 50px;
        height: 50px;
    }

    .step-number {
        font-size: 1.5rem;
    }
}

/* --- CUSTOM MODAL (Alert/Confirm) --- */
#custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

#custom-modal.hidden {
    display: none;
}

#custom-modal .modal-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

#custom-modal .modal-title {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 15px;
    font-family: 'Outfit', sans-serif;
}

#custom-modal .modal-body {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

#custom-modal .modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

#custom-modal .btn-modal {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, background-color 0.2s;
}

#custom-modal .modal-confirm {
    background: var(--primary-color);
    color: #000;
}

#custom-modal .modal-confirm:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

#custom-modal .modal-cancel {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
}

#custom-modal .modal-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* --- PREMIUM MODAL MOBILE FIX --- */
@media (max-width: 768px) {
    #premium-modal .modal-content {
        padding: 20px !important;
        /* Reduce padding significantly */
        max-height: 85vh;
        /* Ensure it doesn't overflow screen */
        overflow-y: auto;
        /* Enable scrolling */
        width: 95%;
        /* Use more width */
    }

    #premium-modal .plan-selector {
        flex-direction: column;
        /* Stack plans vertically */
        gap: 10px;
        margin-bottom: 20px;
    }

    #premium-modal h2 {
        font-size: 1.5rem !important;
        /* Smaller title */
    }

    #premium-modal ul {
        margin-bottom: 20px;
    }

    #btn-subscribe-modal {
        width: 100% !important;
        /* Full width button */
        padding: 12px !important;
    }
}

/* --- PLAYLIST MODAL IMPROVEMENTS --- */
.custom-playlist-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.section-label {
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-group-large {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.input-group-large input {
    flex-grow: 1;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.input-group-large input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(101, 31, 255, 0.2);
    outline: none;
}

.input-group-large button {
    padding: 0 25px;
    font-size: 1rem;
    border-radius: 12px;
}

.playlist-help {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
}

.help-text {
    font-size: 0.9rem;
    color: #b0bec5;
    margin-bottom: 10px;
    line-height: 1.4;
}

.badge-icon {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
}

.no-premium-badge {
    display: inline-block;
    background: rgba(0, 230, 118, 0.15);
    color: #69f0ae;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(0, 230, 118, 0.3);
}

@media (max-width: 600px) {
    .input-group-large {
        flex-direction: column;
        gap: 10px;
    }

    .input-group-large button {
        width: 100%;
        padding: 12px;
    }
}