:root {
    /* Palette de couleurs "Premium Dark" (Identique à style.css) */
    --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: #6626dd;
    /* 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;
    --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);
}

/* --- RESET & BASICS --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    padding: var(--spacing-md);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    /* 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);
}

/* --- TYPOGRAPHIE --- */
h1 {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: var(--spacing-lg);
    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;
}

/* --- BOUTONS --- */
.print-button-container {
    margin-bottom: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

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-style {
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-style:hover {
    transform: translateY(-2px);
}

.btn-new {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #000;
    box-shadow: var(--glow-primary);
}

.btn-retour {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-retour:hover {
    background: #2c2c2c;
    color: white;
}

.btn-print {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

.btn-leave {
    background: #ff5252;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* --- DASHBOARD CONNECTÉ --- */
.connected-dashboard {
    width: 100%;
    max-width: 500px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    text-align: center;
    animation: slideDown 0.5s ease;
}

.dashboard-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    font-size: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 12px;
    border-radius: var(--radius-full);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #ff9800;
    border-radius: 50%;
    box-shadow: 0 0 5px #ff9800;
}

.status-indicator.live .status-dot {
    background-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    animation: blink 2s infinite;
}

.score-display {
    background: rgba(0, 0, 0, 0.37);
    padding: 6px 12px;
    border-radius: var(--radius-full);
}

.score-display strong {
    color: var(--accent-color);
    font-size: 1.2rem;
}

/* --- CARTE BINGO --- */
.bingo-sheet {
    width: 100%;
    display: flex;
    justify-content: center;
}

.bingo-card {
    width: 100%;
    max-width: 600px;
    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);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Zone d'écriture */
.card-writing-area {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.card-writing-area label {
    font-weight: bold;
    margin-bottom: var(--spacing-xs);
    display: block;
    color: var(--text-secondary);
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.input-wrapper {
    position: relative;
    /* Context de positionnement pour btn-clear */
    flex-grow: 1;
    display: flex;
    align-items: center;
    width: 100%;
    /* S'assure qu'il prend la largeur dispo dans le flex */
}

.answer-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--text-secondary);
    color: white;
    font-size: 1.2rem;
    padding: 5px 40px 5px 5px;
    /* Un peu plus de place pour le bouton */
    font-family: inherit;
}

.answer-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.btn-clear {
    position: absolute;
    right: 5px;
    /* Décalé du bord pour ne pas toucher le bouton valider */
    top: 50%;
    transform: translateY(-50%);

    background: transparent;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    /* Au-dessus de l'input */
    cursor: pointer;
}

.btn-clear:hover {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.1);
}

/* Ajustement pour le bouton valider */
#btn-validate-answer {
    z-index: 2;
    flex-shrink: 0;
    /* Ne pas rétrécir */
}

/* Grille */
.card-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 6px;
    table-layout: fixed;
    /* Force equal columns and prevent overflow */
}

.card-grid td {
    height: 80px;
    width: 20%;
    padding: 4px;
    text-align: center;
    vertical-align: middle;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: transform 0.1s;
}

.card-grid td:active {
    transform: scale(0.95);
}

/* Couleurs Cases */
.bg-jaune {
    background-color: #fbc02d;
    color: #333 !important;
}

.bg-vert {
    background-color: #43a047;
}

.bg-bleu {
    background-color: #1e88e5;
}

.bg-violet {
    background-color: #5e35b1;
}

.bg-rose {
    background-color: #d81b60;
}

/* Le X coché */
.card-grid td.checked::after {
    content: "X";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -53%);
    font-size: 4rem;
    font-weight: 900;
    color: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    line-height: 1;
}

.instruction-mobile {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: var(--spacing-md);
    font-style: italic;
}

/* --- MODALS (Login / Win) --- */
.modal-overlay,
.win-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.login-box,
.win-content {
    background: var(--surface-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    position: relative;
}

.login-box h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
}

.login-box input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

/* Win Modal Specifics */
.win-content {
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.trophy {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
    animation: wiggle 1s infinite alternate;
}

.win-content h2 {
    color: #ffd700;
    font-size: 2rem;
    margin: 0;
}

.win-content p {
    font-size: 1.1rem;
    margin: 10px 0;
}

.close-win {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

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

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

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes wiggle {
    from {
        transform: rotate(-10deg);
    }

    to {
        transform: rotate(10deg);
    }
}

/* --- TOAST --- */
.toast-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    font-weight: bold;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

.toast-color-indicator {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-left: 10px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    vertical-align: middle;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}



/* --- RESULT CONTROL MODE --- */
.grid-disabled {
    /* On enlève l'opacité globale sur le conteneur */
    pointer-events: none;
}

.grid-disabled td {
    opacity: 0.2;
    /* Grisé unitairement */
    filter: grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Les cases cochées restent visibles normalement */
.grid-disabled td.checked {
    opacity: 1;
    filter: grayscale(0);
}

/* Cellule activée temporairement */
.grid-disabled td.cell-enabled {
    opacity: 1;
    filter: grayscale(0);
    pointer-events: auto;
    cursor: pointer;
    /* Bordure mise en valeur, pas d'ombre */
    box-shadow: none;
    border: 3px solid white !important;
    /* Force la bordure blanche */
    transform: scale(1.05);
    z-index: 10;
}

/* ==================================================
   MODE IMPRESSION (PRESERVED & CLEANED)
   ================================================== */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Cacher l'interface */
    .print-button-container,
    h1,
    .instruction-mobile,
    .btn-clear,
    .connected-dashboard,
    .modal-overlay,
    .win-modal,
    .toast-message {
        display: none !important;
    }

    .bingo-sheet {
        display: block;
    }

    .bingo-card {
        box-shadow: none !important;
        border: 2px solid #000 !important;
        background: #fff !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 10px !important;
        border-radius: 0 !important;
    }

    .card-writing-area {
        border: 2px dashed #000 !important;
        background: none !important;
        padding: 10px !important;
        border-radius: 0 !important;
    }

    .card-writing-area label {
        color: #000 !important;
    }

    .answer-input {
        border-bottom: 2px dotted #000 !important;
        color: #000 !important;
    }

    .card-grid td {
        border: 1px solid #000 !important;
        color: #fff !important;
        /* Garde le texte blanc sur fond couleur */
        box-shadow: none !important;
        border-radius: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

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

    /* Cacher les X cochés */
    .card-grid td.checked::after {
        display: none !important;
    }
}

/* --- MOBILE TWEAKS --- */
@media screen and (max-width: 600px) {
    body {
        padding: var(--spacing-sm);
    }

    .bingo-card {
        padding: var(--spacing-sm);
        overflow: hidden;
        /* Prevent visual overflow */
    }

    .card-grid {
        border-spacing: 2px;
        /* Reduce spacing on mobile */
    }

    .card-grid td {
        height: 60px;
        font-size: 0.7rem;
    }

    .card-grid td.checked::after {
        font-size: 3rem;
    }

    .card-grid td.checked::after {
        font-size: 3rem;
    }

    /* Fix overflow input group */
    .input-group {
        flex-wrap: wrap;
        gap: 5px;
    }

    .input-wrapper {
        width: 100%;
    }

    .answer-input {
        margin-bottom: 5px;
        /* Padding déjà défini en global */
    }

    /* Le bouton clear doit être positionné par rapport à l'input qui prend 100% */
    .btn-clear {
        /* Positionnement déjà géré par le wrapper relative */
        right: 0;
        top: 40%;
        /* Un peu plus haut car l'input a une marge bottom */
    }

    #btn-validate-answer {
        width: 100%;
        /* Pleine largeur sur mobile */
        margin-top: 5px;
    }

    /* On cache le bouton clear s'il n'y a pas de texte ? (JS requis) ou on le laisse */
}

/* --- PREMIUM VICTORY / DEFEAT MODAL --- */
.win-content {
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    /* Reset default border/shadow from previous */
    border-radius: 24px;
}

/* VICTORY STATE */
.state-victory {
    border: 2px solid #FFD700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}

.state-victory h2 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
    font-size: 2.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.state-victory .trophy {
    font-size: 5rem;
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
    animation: bounce 2s infinite;
}

/* DEFEAT STATE */
.state-defeat {
    border: 2px solid #546e7a;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

.state-defeat h2 {
    background: linear-gradient(135deg, #eceff1, #b0bec5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2rem;
    text-transform: uppercase;
}

.state-defeat .trophy {
    font-size: 4rem;
    filter: grayscale(100%);
    animation: none;
    opacity: 0.8;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}