:root {
    --cobalt: #0047ab;
    --wii-bg: #f0f0f0;
    --wii-gray: #d0d0d0;
    --wii-blue: #00a0e9;
    --wii-dark: #222;
    --vhs-line-color: rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: #000;
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
}

.wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 2rem;
    padding: 1rem;
    position: relative;
}

/* ===== ÉCRAN WII ===== */
.screen {
    width: min(99vw, 800px);
    aspect-ratio: 16 / 9;
    background: var(--wii-bg);
    border: 8px solid var(--cobalt); /* ← BLEU COBALT */
    border-radius: 20px;
    box-shadow: 0 0 25px rgba(0, 71, 171, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 5;
    overflow: hidden;
}

.screen::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
            0deg,
            var(--vhs-line-color) 0px,
            var(--vhs-line-color) 1px,
            transparent 1px,
            transparent 3px
    );
    pointer-events: none;
    z-index: 1;
}

/* GRILLE D’ICÔNES */
.wii-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 2rem 1.5rem;
    width: 100%;
}

.wii-icon {
    min-width: 140px;       /* ← largeur minimale fixe */
    min-height: 120px;      /* ← hauteur minimale fixe */
    background: var(--wii-gray);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.wii-icon:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.lang-icon.active {
    background: var(--wii-blue);
    color: white;
}

.home-icon {
    background: linear-gradient(135deg, #ff9a00, #ff5500);
    color: white;
    box-shadow: 0 0 20px rgba(255, 154, 0, 0.6);
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    from { box-shadow: 0 0 15px rgba(255, 154, 0, 0.5); }
    to { box-shadow: 0 0 30px rgba(255, 85, 0, 0.8); }
}

.fun:hover {
    background: #a0d8ff;
}

.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wii-icon img, .wii-icon i {
    font-size: 1.6rem;
    margin-bottom: 0.4rem;
}

.wii-icon img {
    max-width: 36px;
    max-height: 28px;
    object-fit: contain;
    margin-bottom: 0.5rem;
}

/* FOOTER */
.wii-footer {
    width: 100%;
    background: #e8e8e8;
    border-top: 2px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.2rem;
    font-size: 0.85rem;
    font-family: Arial, sans-serif;
    position: absolute; /* ← Collé en bas */
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.footer-btn {
    color: #333;
    text-decoration: none;
    font-size: 1.2rem;
    transition: 0.2s;
}

.footer-btn:hover {
    color: var(--cobalt);
    transform: scale(1.15);
}

/* CHARGEMENT */
#loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(240, 240, 240, 0.95);
    z-index: 10;
}

.wii-loading-bar {
    width: 70%;
    height: 8px;
    background: #ccc;
    border-radius: 4px;
    margin: 1.5rem auto;
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    width: 0;
    background: var(--cobalt);
    border-radius: 4px;
    transition: width 0.1s ease;
}

.wii-clock {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--cobalt);
}

/* ===== MANETTE ===== */
.controller {
    width: min(85vw, 420px);
    height: 180px;
    background: var(--wii-dark);
    border-radius: 20px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.8s;
    z-index: 4;
}

.controller.hide {
    transform: translateY(200px);
    opacity: 0;
}

/* GAUCHE */
.left-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.right-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.top-btn {
    width: 32px;
    height: 32px;
    background: #444;
    color: white;
    border: none;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
}

.dpad {
    display: grid;
    grid-template-rows: repeat(3, 24px);
    gap: 4px;
}

.dpad button {
    width: 24px;
    height: 24px;
    background: #555;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* DROITE - BOUTONS Y X A B */
.face-buttons {
    display: grid;
    grid-template-columns: repeat(2, 30px);
    grid-template-rows: repeat(2, 30px);
    gap: 6px;
}

.face-buttons button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
}

.y-btn { background: #ff0; color: #000; } /* Jaune */
.x-btn { background: #0f0; }               /* Vert */
.a-btn { background: #f00; }               /* Rouge */
.b-btn { background: #00f; color: white; } /* Bleu */

/* BOUTON HOME CENTRAL */
.home-btn {
    background: #ff5500;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 85, 0, 0.7);
    transition: all 0.2s;
}

.home-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 0 25px rgba(255, 85, 0, 0.9);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 650px) {
    .wii-menu-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
        padding: 1.5rem 1rem;
    }

    .controller {
        width: 90vw;
        height: 160px;
        padding: 0 15px;
    }

    .face-buttons button,
    .dpad button,
    .top-btn {
        font-size: 0.7rem;
    }

    .home-btn {
        width: 44px;
        height: 44px;
    }
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--wii-bg);
    border: 2px solid var(--cobalt);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    text-align: center;
    max-width: 80vw;
    animation: fadeIn 0.3s ease;
}

.popup p {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1rem;
}

.popup .close-btn {
    background: var(--cobalt);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.popup .close-btn:hover {
    background: #003380;
}

/* ===== MODE NUIT ===== */
body.dark-mode .screen {
    background: #1a1a1a;
    border-color: #0077cc;
    box-shadow: 0 0 30px rgba(0, 119, 204, 0.6);
}

body.dark-mode .wii-footer {
    background: #2a2a2a;
    border-top-color: #444;
    color: #e0e0e0;
}

body.dark-mode .wii-icon {
    background: #333;
    color: #e0e0e0;
}

body.dark-mode .lang-icon.active {
    background: #0088cc;
    color: white;
}

body.dark-mode .fun:hover {
    background: #005588;
}

body.dark-mode .popup {
    background: #222;
    color: #e0e0e0;
    border-color: #0077cc;
}

body.dark-mode .popup p {
    color: #e0e0e0;
}

body.dark-mode .wii-clock {
    color: #4fc3f7;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 480px) {
    .wii-menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wii-footer {
        font-size: 0.75rem;
        padding: 0.6rem 1rem;
    }
}

/* ===== TÉLÉPHONE - GRILLE 2 LIGNES × 4 COLONNES ===== */
@media (max-width: 500px) {
    .wii-menu-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr); /* 4 colonnes */
        grid-template-rows: auto auto;         /* 2 lignées */
        gap: 0.6rem;
        padding: 0.3rem 0.5rem;
    }

    .wii-icon {
        min-width: auto;
        min-height: auto;
        width: 60px;              /* Largeur fixe petite */
        height: 57px;             /* Hauteur fixe petite */
        padding: 0.5rem;
        font-size: 0.65rem;       /* Texte très petit */
        border-radius: 8px;
    }

    .wii-icon img,
    .wii-icon i {
        font-size: 1.1rem;        /* Icônes réduites */
        margin-bottom: 0.2rem;
    }

    .wii-icon span {
        line-height: 1.2;
        font-size: 0.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Réduire la manette aussi */
    .controller {
        width: 95vw;
        height: 120px;
        padding: 0 8px;
    }

    .top-btn {
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }

    .dpad button {
        width: 18px;
        height: 18px;
        font-size: 0.5rem;
    }

    .face-buttons button {
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }

    .home-btn {
        width: 34px;
        height: 34px;
        font-size: 0.65rem;
    }

    .wii-footer {
        font-size: 0.65rem;
        padding: 0.4rem;
    }

    .footer-btn {
        font-size: 0.9rem;
    }
}

/* ===== BOUTONS DU MINI-JEU ===== */
#mini-game-screen .close-btn {
    background: transparent;
    color: var(--neon-blue);
    border: 2px solid var(--neon-blue);
    padding: 0.6rem 1.4rem;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
    margin: 0.5rem;
}

#mini-game-screen .close-btn:hover {
    background: rgba(0, 243, 255, 0.15);
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.7);
    transform: translateY(-2px);
}

#score {
    font-size: 1.3rem;
    color: var(--neon-blue);
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
}

#game-over {
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px #ff0055;
}