@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

/* --- CONTENEUR PRINCIPAL --- */
#gameCanvas #aero-game-wrapper {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-gradient: linear-gradient(to bottom, #667eea, #a3b9f0);
    --white: #ffffff;
    --text-dark: #2c3e50;
    --danger: #ff6b6b; 
    --success: #2ecc71;
    --card-bg: rgba(255, 255, 255, 0.95);
    
    position: relative; 
    width: 100%; 
    max-width: 800px; 
    height: 550px; 
    margin: 0 auto;
    background: var(--bg-gradient);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden; 
    font-family: 'Poppins', sans-serif;
    color: var(--text-dark);
}

/* PLEIN ECRAN */
#gameCanvas #aero-game-wrapper:fullscreen {
    max-width: none;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas #aero-game-wrapper * { box-sizing: border-box; }

/* --- NUAGES --- */
#gameCanvas .clouds-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
#gameCanvas .cloud {
    position: absolute;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M18.5,12c0-1.7-1.4-3-3-3c-0.2,0-0.4,0-0.6,0.1c-0.6-2.3-2.7-4.1-5.1-4.1c-3,0-5.5,2.5-5.5,5.5 c0,0.1,0,0.2,0,0.3C2.8,11.2,1.5,12.9,1.5,15c0,2.8,2.2,5,5,5h12c2.8,0,5-2.2,5-5S21.3,12,18.5,12z'/%3E%3C/svg%3E");
    background-size: contain; background-repeat: no-repeat;
    opacity: 0.6; animation: floatCloud linear infinite;
}
@keyframes floatCloud { from { left: -150px; } to { left: 110%; } }

/* --- ECRANS / UI --- */
#gameCanvas .screen {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--card-bg); padding: 25px; border-radius: 20px;
    width: 90%; max-width: 500px; 
    max-height: 95%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    opacity: 0; pointer-events: none; z-index: 5; transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}
#gameCanvas .screen.active { opacity: 1; pointer-events: auto; z-index: 10; }
#gameCanvas .hidden { display: none !important; }

/* Header & Titre */
#gameCanvas .header-row { display: flex; justify-content: space-between; align-items: center; width: 100%; border-bottom: 2px solid #f0f2f5; padding-bottom: 10px; margin-bottom: 5px; }
#gameCanvas .aero-title { 
    margin: 0; background: var(--primary-gradient);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    font-size: 1.6rem; font-weight: 700;
}
#gameCanvas .header-actions { display: flex; gap: 10px; }

/* Inputs Configuration */
#gameCanvas textarea {
    width: 100%; height: 100px; 
    border: 2px solid #e2e8f0; border-radius: 12px;
    padding: 12px; font-size: 1rem; resize: none; outline: none;
    font-family: inherit; transition: 0.2s; background: #f8fafc;
}
#gameCanvas textarea:focus { border-color: #667eea; background: #fff; }
#gameCanvas .switches-container { background: #f1f5f9; padding: 12px; border-radius: 12px; display: flex; flex-direction: column; gap: 10px; }
#gameCanvas .switch-row { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
#gameCanvas .switch-label { font-size: 0.9rem; font-weight: 600; color: #475569; }
#gameCanvas .switch-toggle { position: relative; width: 44px; height: 24px; }
#gameCanvas .switch-toggle input { opacity: 0; width: 0; height: 0; }
#gameCanvas .slider { position: absolute; inset: 0; background-color: #cbd5e1; border-radius: 34px; transition: .3s; }
#gameCanvas .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: .3s; }
#gameCanvas input:checked + .slider { background-color: #764ba2; }
#gameCanvas input:checked + .slider:before { transform: translateX(20px); }

/* --- BOUTONS --- */
#gameCanvas .btn-primary { 
    background: var(--primary-gradient); color: white; border: none; 
    padding: 12px 25px; border-radius: 50px; 
    font-size: 1.1rem; font-weight: 600; cursor: pointer; 
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4); 
    transition: transform 0.1s, box-shadow 0.2s; width: 100%; 
}
#gameCanvas .btn-primary:active { transform: translateY(2px); }

#gameCanvas .btn-secondary { 
    background: #94a3b8; color: white; border: none; 
    padding: 10px 20px; border-radius: 50px; 
    cursor: pointer; font-weight: 600; width: 100%; 
    transition: background 0.2s; 
    display: flex; align-items: center; justify-content: center; gap: 5px;
}

/* Style bouton désactivé (Anti-triche) */
#gameCanvas .btn-secondary:disabled {
    background: #e2e8f0; color: #94a3b8; cursor: not-allowed; opacity: 0.7;
}

#gameCanvas .btn-quit { 
    background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.5); 
    color: #fff; padding: 6px 15px; border-radius: 20px; 
    cursor: pointer; align-self: center; font-size: 0.9rem; margin-top: auto; 
}
#gameCanvas .icon-btn { background: #f1f5f9; border: none; border-radius: 50%; width: 40px; height: 40px; display:flex; justify-content:center; align-items:center; cursor: pointer; transition: 0.2s; font-size: 1.2rem; }
#gameCanvas .icon-btn:hover { background: #e2e8f0; transform: scale(1.1); }
#gameCanvas .close-btn { color: var(--danger); background: #fff1f2; font-size: 1rem; width: 32px; height: 32px; }

#gameCanvas .sound-btn {
    width: 60px; height: 60px; border-radius: 50%;
    background: white; border: 3px solid #e2e8f0;
    color: #667eea; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
#gameCanvas .sound-btn:hover { border-color: #667eea; transform: scale(1.05); box-shadow: 0 6px 15px rgba(102, 126, 234, 0.2); }
#gameCanvas .sound-btn:active { transform: scale(0.95); }

/* --- JEU UI --- */
#gameCanvas #game-interface { background: transparent; box-shadow: none; border: none; padding: 10px; width: 100%; height: 100%; max-width: none; justify-content: flex-start; }

#gameCanvas .progress-track-container { position: relative; width: 100%; max-width: 600px; height: 10px; margin: 20px auto 10px; }
#gameCanvas .track-bg { position: absolute; width: 100%; height: 100%; background: rgba(255,255,255,0.3); border-radius: 5px; }
#gameCanvas #progress-fill { position: absolute; left: 0; height: 100%; background: #fff; border-radius: 5px; width: 0%; transition: width 0.6s ease; }
#gameCanvas .plane-marker {
    position: absolute; left: 0%; top: 50%; transform: translate(-50%, -50%);
    font-size: 2.5rem; transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.2)); z-index: 3;
}
#gameCanvas .plane-takeoff { animation: takeoff 1.5s forwards ease-in !important; }
@keyframes takeoff { 0% { left: 95%; top: 50%; } 100% { left: 150%; top: -100%; opacity: 0; } }

#gameCanvas #word-counter-wrapper { width: 100%; text-align: center; margin-bottom: 5px; }
#gameCanvas #word-counter { 
    display: inline-block;
    background: rgba(0, 0, 0, 0.15); 
    color: #fff; 
    font-weight: 600; 
    font-size: 0.85rem;
    padding: 4px 15px;
    border-radius: 20px;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255,255,255,0.2);
}

#gameCanvas .center-play-area {
    background: var(--white); padding: 25px; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; align-items: center; gap: 15px;
    width: 100%; max-width: 600px; margin: 5px auto;
}

#gameCanvas #slots-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 50px; }
#gameCanvas .char-slot {
    width: 45px; height: 55px; border: 2px solid #e2e8f0; border-radius: 10px;
    font-size: 2rem; font-weight: 700; color: #cbd5e1;
    display: flex; justify-content: center; align-items: center; background: #f8fafc;
    transition: 0.2s;
}
#gameCanvas .char-slot.filled { border-color: #667eea; color: var(--text-dark); background: #fff; }
#gameCanvas .char-slot.correct { border-color: var(--success); color: var(--success); background: #dcfce7; }
#gameCanvas .char-slot.wrong { border-color: var(--danger); color: var(--danger); background: #fee2e2; animation: shake 0.4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

#gameCanvas #real-input { position: absolute; top: 50%; left: 50%; opacity: 0; width: 1px; height: 1px; pointer-events: none; z-index: -1; }

#gameCanvas .controls-row { display: flex; gap: 20px; align-items: center; width: 100%; justify-content: center; margin-top: 10px; }

#gameCanvas .hint-info-text { font-size: 0.75rem; color: #94a3b8; font-style: italic; margin-top: -5px; }

#gameCanvas #feedback-area { height: 35px; display:flex; justify-content:center; align-items:center; width: 100%; }
#gameCanvas .msg-success { color: var(--success); font-weight: bold; animation: popIn 0.3s; font-size: 1.2rem; }
#gameCanvas .msg-hint { 
    background: #fef3c7; color: #d97706; padding: 6px 15px; 
    border-radius: 15px; font-weight: 700; font-size: 1.2rem; 
    animation: popIn 0.3s; letter-spacing: 2px;
}
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- HISTORIQUE AMÉLIORÉ --- */
#gameCanvas .history-content-area { flex-grow: 1; overflow-y: auto; background: #f8fafc; border-radius: 10px; padding: 10px; border: 1px solid #e2e8f0; }
#gameCanvas #history-list { list-style: none; padding: 0; margin: 0; }
#gameCanvas .history-item { 
    background: #fff; border-radius: 8px; padding: 12px; margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); border: 1px solid #f1f5f9;
}
#gameCanvas .h-header { display: flex; justify-content: space-between; font-size: 0.85rem; color: #94a3b8; margin-bottom: 5px; }
#gameCanvas .h-score { font-weight: bold; color: var(--text-dark); }

#gameCanvas .h-words { 
    font-style: italic; font-size: 0.9rem; color: #64748b; 
    margin-bottom: 8px; line-height: 1.4; display: block;
    white-space: normal; word-break: break-word; 
}

#gameCanvas .btn-replay { background: #dbeafe; color: #2563eb; border: none; padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
#gameCanvas .btn-replay:hover { background: #bfdbfe; }
#gameCanvas .btn-danger-text { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.9rem; text-decoration: underline; }

/* --- RESULTATS --- */
#gameCanvas .score-circle {
    width: 100px; height: 100px; border-radius: 50%; 
    background: var(--primary-gradient); color: white;
    display: flex; justify-content: center; align-items: center; 
    font-size: 2rem; font-weight: bold;
    margin: 0 auto 15px; box-shadow: 0 10px 20px rgba(118, 75, 162, 0.3); border: 5px solid #fff;
}
#gameCanvas .mistakes-container { width:100%; text-align: left; background: #f8fafc; padding: 15px; border-radius: 12px; border: 1px solid #e2e8f0; }
#gameCanvas .mistakes-container h3 { margin: 0 0 10px 0; color: #64748b; font-size: 0.9rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; }
#gameCanvas #mistake-list { list-style: none; padding: 0; margin: 0; max-height: 100px; overflow-y: auto; }
#gameCanvas #mistake-list li { color: var(--danger); font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
#gameCanvas .btn-group { display: flex; gap: 10px; width: 100%; }

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
    #gameCanvas .char-slot { width: 35px; height: 45px; font-size: 1.5rem; }
    #gameCanvas .btn-group { flex-direction: column; }
    #gameCanvas .screen { width: 95%; padding: 20px; }
}