/* Style global du conteneur de jeu */
#gameCanvas {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
    background: linear-gradient(135deg, #ffeef8 0%, #ffe5f5 50%, #e5f5ff 100%);
    min-height: 500px; 
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

#gameCanvas * { margin: 0; padding: 0; box-sizing: border-box; }

#gameCanvas:fullscreen {
    background: linear-gradient(135deg, #ffeef8 0%, #ffe5f5 50%, #e5f5ff 100%);
    width: 100vw; height: 100vh;
    padding: 0; margin: 0;
    align-items: center; justify-content: center;
}

#gameCanvas .stars {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1;
}

#gameCanvas .star {
    position: absolute; font-size: 20px; animation: twinkle 2s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

#gameCanvas .container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(255, 105, 180, 0.3);
    max-width: 800px; width: 100%;
    text-align: center;
    position: relative;
    border: 3px solid #ffb3d9;
    z-index: 2;
    max-height: 100vh; overflow-y: auto;
}

#gameCanvas h1 {
    color: #ff69b4; font-size: 2em; margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(255, 105, 180, 0.3); line-height: 1.2;
}

/* BOUTONS ICONES */
#gameCanvas .btn-icon-top {
    position: absolute; top: 15px; right: 15px;
    background: transparent; border: 2px solid #ffb3d9; color: #ff69b4;
    width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; font-size: 1.2rem; display: flex; justify-content: center; align-items: center;
    transition: 0.2s;
}
#gameCanvas .btn-icon-top:hover { background: #ffe5f5; transform: scale(1.1); }

#gameCanvas .game-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#gameCanvas .btn-icon-small {
    background: #fff; border: 2px solid #b8e6ff; color: #7abaff;
    width: 32px; height: 32px; border-radius: 50%;
    cursor: pointer; font-size: 1rem; display: flex; justify-content: center; align-items: center;
}
#gameCanvas .btn-icon-small:hover { background: #e5f5ff; }

/* COMPTE A REBOURS */
#gameCanvas #countdown-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 50; border-radius: 20px;
}
#gameCanvas #countdown-number {
    font-size: 8em; font-weight: 900; color: #ff69b4;
    text-shadow: 0 5px 15px rgba(255, 105, 180, 0.5);
    animation: popNumber 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
}
@keyframes popNumber {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* JEU UI */
#gameCanvas .score-board { display: flex; justify-content: center; margin: 10px 0; gap: 15px; flex-wrap: wrap; }
#gameCanvas .score-item {
    background: linear-gradient(135deg, #ff9ecd, #ffb3e6);
    padding: 8px 15px; border-radius: 15px;
    color: white; font-weight: bold; font-size: 1em;
    box-shadow: 0 3px 10px rgba(255, 105, 180, 0.3);
}

#gameCanvas .game-area {
    background: linear-gradient(135deg, #fff0f8, #ffe8f5);
    border-radius: 20px; padding: 20px; margin: 15px 0;
    min-height: 150px; border: 3px dashed #ffb3d9; position: relative;
}

#gameCanvas .word-display {
    font-size: 2.5em; color: #ff69b4; font-weight: bold;
    margin: 15px 0; letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(255, 182, 193, 0.5);
    animation: bounce 0.5s;
}
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

#gameCanvas .input-area input {
    width: 80%; padding: 12px; font-size: 1.5em;
    border: 3px solid #ffb3d9; border-radius: 15px; text-align: center;
    font-family: Arial, Helvetica, sans-serif; background: white; color: #ff69b4; font-weight: bold;
    -webkit-text-size-adjust: 100%;
}
#gameCanvas .input-area input:focus { outline: none; border-color: #ff69b4; box-shadow: 0 0 20px rgba(255, 105, 180, 0.5); }
#gameCanvas .input-area input:disabled { background: #eee; border-color: #ccc; color: #999; }

#gameCanvas .btn {
    background: linear-gradient(135deg, #ff69b4, #ff9ecd);
    color: white; border: none; padding: 10px 30px;
    font-size: 1.1em; border-radius: 25px; cursor: pointer; margin: 8px;
    font-weight: bold; box-shadow: 0 4px 10px rgba(255, 105, 180, 0.4);
    transition: all 0.3s; display: inline-block;
}
#gameCanvas .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(255, 105, 180, 0.6); }
#gameCanvas .btn:active { transform: translateY(0); }
#gameCanvas .btn-secondary { background: linear-gradient(135deg, #b8e6ff, #d4b3ff); }

#gameCanvas .message { font-size: 1.2em; color: #ff69b4; margin: 10px 0; font-weight: bold; min-height: 30px; }

#gameCanvas .particles { position: absolute; width: 100%; height: 100%; pointer-events: none; top: 0; left: 0; }
#gameCanvas .particle { position: absolute; font-size: 30px; animation: float 2s ease-out forwards; }
@keyframes float { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(-200px) rotate(360deg); opacity: 0; } }

#gameCanvas .level-indicator {
    background: linear-gradient(135deg, #b8e6ff, #d4b3ff); color: white;
    padding: 5px 15px; border-radius: 15px; display: inline-block;
    margin: 5px 0; font-weight: bold; font-size: 1em;
}

#gameCanvas .start-screen, #gameCanvas .end-screen { text-align: center; }
#gameCanvas .emoji { font-size: 3em; margin: 10px 0; animation: spin 3s infinite linear; display: inline-block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#gameCanvas .hidden { display: none !important; }

#gameCanvas .progress-bar {
    width: 100%; height: 15px; background: #ffe5f5; border-radius: 10px;
    overflow: hidden; margin: 10px 0; border: 2px solid #ffb3d9;
}
#gameCanvas .progress-fill { height: 100%; background: linear-gradient(90deg, #ff69b4, #ff9ecd); transition: width 0.3s; border-radius: 10px; }

#gameCanvas .stats-container {
    background: linear-gradient(135deg, #fff0f8, #ffe8f5);
    border-radius: 20px; padding: 15px; margin: 15px 0; border: 2px solid #ffb3d9;
}
#gameCanvas .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
#gameCanvas .stat-box { background: white; padding: 10px; border-radius: 15px; border: 2px solid #ffb3d9; }
#gameCanvas .stat-label { color: #ff9ecd; font-size: 0.8em; margin-bottom: 3px; }
#gameCanvas .stat-value { color: #ff69b4; font-size: 1.2em; font-weight: bold; }

#gameCanvas .leaderboard { background: white; border-radius: 15px; padding: 15px; margin-top: 15px; border: 2px solid #ffb3d9; }
#gameCanvas .leaderboard-title { color: #ff69b4; font-size: 1.2em; margin-bottom: 10px; font-weight: bold; }
#gameCanvas .leaderboard-entry {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 15px; margin: 5px 0; background: linear-gradient(135deg, #fff0f8, #ffe8f5);
    border-radius: 10px; border: 2px solid #ffb3d9;
}
#gameCanvas .leaderboard-rank { font-size: 1.2em; font-weight: bold; color: #ff69b4; min-width: 30px; }
#gameCanvas .leaderboard-info { flex-grow: 1; text-align: left; margin: 0 10px; font-size: 0.9em; }
#gameCanvas .leaderboard-score { font-size: 1.1em; font-weight: bold; color: #ff69b4; }
#gameCanvas .leaderboard-date { font-size: 0.8em; color: #ff9ecd; }
#gameCanvas .medal { font-size: 1.4em; }

#gameCanvas .accuracy-display { color: #ff69b4; font-size: 1em; margin: 5px 0; }
#gameCanvas .new-record {
    background: linear-gradient(135deg, #ffd700, #ffed4e); color: white; padding: 10px 20px;
    border-radius: 20px; font-size: 1.1em; font-weight: bold; margin: 10px 0; animation: celebrate 1s ease-out;
}
@keyframes celebrate {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@media (max-height: 800px) {
    #gameCanvas { min-height: 450px; padding: 5px; }
    #gameCanvas .container { padding: 15px; }
    #gameCanvas .emoji { font-size: 2em; margin: 5px 0; }
    #gameCanvas h1 { font-size: 1.6em; margin-bottom: 5px; }
    #gameCanvas .word-display { font-size: 2em; margin: 10px 0; }
    #gameCanvas .game-area { padding: 15px; margin: 10px 0; min-height: 120px; }
    #gameCanvas .stat-box { padding: 5px; }
    #gameCanvas .stat-value { font-size: 1.1em; }
}

@media (max-width: 600px) {
    #gameCanvas h1 { font-size: 1.5em; }
    #gameCanvas .word-display { font-size: 1.8em; }
    #gameCanvas .input-area input { font-size: 1.2em; padding: 10px; }
}