html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    overflow: hidden;
    /* Optimisations tactiles - sans bloquer la sélection dans les inputs */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Désactiver la sélection seulement sur les éléments de jeu */
#game, #introduction, #score, #perfect {
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#score {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 2em;
    font-weight: 900;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    z-index: 10;
}

.audio-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn:hover {
    background: rgba(0,0,0,0.9);
    border-color: rgba(255,255,255,0.8);
    transform: scale(1.1);
}

#titleLogo {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    opacity: 1;
    transition: opacity 1s ease-out;
    pointer-events: none;
    width: 400px;
    max-width: 80vw;
}

#titleLogo img {
    width: 100%;
    height: auto;
}

#titleLogo.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Style mobile pour le logo */
@media (max-width: 768px) {
    #titleLogo {
        top: 60px;
        width: 300px;
        max-width: 70vw;
    }
}

#introduction {
    width: 250px;
    height: 150px;
    position: absolute;
    font-weight: 600;
    font-size: 1em;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    transition: opacity 2s;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#restart {
    width: 120px;
    height: 120px;
    position: absolute;
    border-radius: 50%;
    color: white;
    background-color: #e74c3c;
    border: none;
    font-weight: 700;
    font-size: 0.85em;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    display: none;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    padding: 15px;
    box-sizing: border-box;
    line-height: 1.1;
    text-align: center;
    word-wrap: break-word;
    /* Optimisations tactiles */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

#restart:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

#perfect {
    position: absolute;
    opacity: 0;
    transition: opacity 2s;
    font-size: 1.5em;
    font-weight: bold;
    color: #f39c12;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#game {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    /* Optimisations tactiles pour le canvas */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 768px) {
    #introduction {
        width: 200px;
        font-size: 0.9em;
        padding: 15px;
        transform: translateY(-40px); /* Relever de 40px */
    }
    
    #perfect {
        font-size: 1.2em; /* Plus petit (était 1.5em) */
        padding: 8px 15px; /* Réduire le padding */
        transform: translate(-50%, calc(-50% - 30px)); /* Relever de 30px */
    }
    
    #score {
        font-size: 1.5em;
        top: 20px;
        right: 20px;
    }
    
    #restart {
        width: 100px;
        height: 100px;
        font-size: 0.75em;
        padding: 12px;
    }
}

/* Styles pour le système de scores */
#scoreModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    -webkit-overflow-scrolling: touch;
}

#scoreContent {
    background: rgba(255, 255, 255, 0.98);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    max-width: 450px;
    width: 95%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
    overflow-y: auto;
    max-height: 90vh;
}

#scoreContent h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
}

#scoreContent h3 {
    color: #e74c3c;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.score-list {
    background: rgba(52, 73, 94, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    max-height: 500px;
    overflow-y: auto;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(52, 73, 94, 0.2);
}

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

.score-rank {
    font-weight: bold;
    color: #e74c3c;
}

.score-name {
    color: #2c3e50;
    font-weight: 600;
}

.score-value {
    color: #27ae60;
    font-weight: bold;
}

.score-item.first-place {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    border-radius: 8px;
    padding: 12px 8px;
    margin: 5px 0;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(241, 196, 15, 0.3);
    border: 2px solid #e67e22;
}

.score-item.first-place .score-rank {
    color: #8b4513;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.score-item.first-place .score-name {
    color: #2c3e50;
    font-weight: 700;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.score-item.first-place .score-value {
    color: #8b4513;
    font-weight: 900;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#nameInput {
    padding: 15px;
    border: 3px solid #3498db;
    border-radius: 10px;
    font-size: 1.2em;
    margin: 15px auto;
    text-align: center;
    width: 180px;
    max-width: 90%;
    box-sizing: border-box;
    display: block;
    background-color: #ffffff;
    outline: none;
    /* Propriétés universelles pour tous navigateurs */
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    touch-action: manipulation;
    cursor: text;
}

#nameInput:focus {
    outline: none;
    border-color: #e74c3c;
}

.modal-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 5px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    /* Optimisations tactiles */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* Taille minimum recommandée pour le tactile */
}

.modal-button:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.modal-button.secondary {
    background: #95a5a6;
}

.modal-button.secondary:hover {
    background: #7f8c8d;
}

#newTopScore {
    color: #f39c12;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 1.2em;
}

#currentPlayerName {
    background: rgba(52, 152, 219, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    color: #2c3e50;
}

/* === OPTIMISATIONS MOBILES ET TACTILES === */

/* Amélioration de l'expérience tactile sur toute l'interface */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Optimisations pour les appareils tactiles */
@media (hover: none) and (pointer: coarse) {
    .container {
        padding: 10px;
    }
    
    #introduction {
        font-size: 1.1em;
        width: 280px;
        padding: 25px;
        transform: translateY(-40px); /* Relever de 40px */
    }
    
    #restart {
        width: 140px;
        height: 140px;
        font-size: 0.9em;
    }
    
    .modal-button {
        font-size: 1.1em;
        padding: 15px 25px;
        min-height: 50px; /* Plus grande zone tactile */
        margin: 8px;
        border-radius: 10px;
    }
    
    #nameInput {
        font-size: 1.2em;
        padding: 15px;
        min-height: 50px;
        border-radius: 10px;
        margin: 15px auto;
        display: block;
        max-width: 200px;
    }
    
    #scoreContent {
        width: 95%;
        padding: 25px 20px;
    }
}

/* Styles spécifiques pour iOS */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    #game {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Amélioration de la zone de jeu pour le tactile */
#game:active {
    opacity: 0.9;
}

/* Feedback visuel pour les interactions tactiles */
.modal-button:active {
    transform: scale(0.95);
}

#restart:active {
    transform: scale(0.95);
}
}