/* --- Réinitialisation et base --- */
html { font-size: clamp(13px, 1.2vw + 0.1rem, 16px); }
body {
    margin: 0; padding: 0; width: 100%; min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #EAEAEA; display: flex; flex-direction: column;
    background-color: #05080f; background-image: url('img_fond.jpg');
    background-size: cover; background-position: center; background-attachment: fixed;
    overflow-x: hidden; overflow-y: auto; touch-action: manipulation; user-select: none;
}
* { box-sizing: border-box; }

/* --- Bandeau principal --- */
#banner {
    width: 100%; min-height: 80px; background-color: rgba(10, 20, 35, 0.85);
    backdrop-filter: blur(8px); padding: 10px 15px; flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    display: flex; flex-direction: row; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px; position: relative; z-index: 50;
}
.banner-left { display: flex; flex-direction: column; flex: 1 1 auto; }
#main_title { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 600; color: #FFF; text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); margin: 0; }
#sub_title { font-size: clamp(0.85rem, 1.5vw, 0.95rem); margin-top: 2px; color: #FFD700; text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }

/* --- Modes de jeu (Bandeau Centre) --- */
.modes-container { display: flex; gap: 5px; background: rgba(0,0,0,0.4); padding: 4px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); justify-content: center; flex: 0 1 auto; white-space: nowrap; }
.mode-btn {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background: transparent; border: 1px solid transparent; color: #aaa; padding: 6px 12px; border-radius: 5px; font-weight: bold; font-size: clamp(0.8rem, 1.5vw, 0.9rem); cursor: pointer; transition: all 0.3s ease;
}
.mode-btn:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,0.1); }
.mode-btn.active { background: #3498db; color: #fff; border-color: #2980b9; box-shadow: 0 0 10px rgba(52, 152, 219, 0.5); }
.mode-btn:disabled { cursor: not-allowed; opacity: 0.5; }

/* --- Menu Déroulant CHRONO --- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none; position: absolute; top: 110%; left: 50%; transform: translateX(-50%);
    background: rgba(10,20,40,0.95); border: 1px solid rgba(255,215,0,0.5); border-radius: 8px;
    flex-direction: column; z-index: 1000; box-shadow: 0 4px 15px rgba(0,0,0,0.6); min-width: 180px; overflow: hidden;
}
.dropdown-menu.show { display: flex; }
.dropdown-item {
    background: transparent; color: #FFF; padding: 10px 15px; border: none; font-size: 0.9rem; text-align: left; cursor: pointer; transition: background 0.2s; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(52, 152, 219, 0.4); }

/* --- Barre Chrono (Jauge) --- */
#chrono_bar_container { width: 100%; height: 22px; background: rgba(0,0,0,0.8); position: relative; border-bottom: 1px solid rgba(255,215,0,0.2); display: none; overflow: hidden; }
#chrono_bar_fill { height: 100%; width: 100%; transition: width 0.1s linear, background 0.3s; }
.fill-timeattack { background: linear-gradient(90deg, #2980b9, #8e44ad); }
.fill-speedrun { background: linear-gradient(90deg, #27ae60, #f1c40f); }
.fill-survival { background: linear-gradient(90deg, #c0392b, #e74c3c); }
#chrono_bar_text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-weight: bold; font-family: 'Courier New', Courier, monospace; font-size: 1rem; text-shadow: 0 0 5px #000; white-space: nowrap; pointer-events: none; }

/* --- Bandeau Droite (Score et Lien) --- */
.banner-right { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; justify-content: flex-end; }
#score_display { font-size: clamp(1rem, 2vw, 1.3rem); font-weight: bold; color: #64ff96; background: rgba(0, 0, 0, 0.5); padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(100, 255, 150, 0.3); white-space: nowrap; }
.banner-link {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-color: #f39c12; color: white; padding: 6px 12px; border-radius: 6px; font-weight: bold; text-decoration: none; box-shadow: 0 4px 6px rgba(0,0,0,0.3); font-size: clamp(0.8rem, 1.5vw, 0.9rem); transition: all 0.2s ease; white-space: nowrap; border: 1px solid #e67e22; display: inline-block; text-align: center;
}
.banner-link:hover { background-color: #d68910; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.4); }

#footer { width: 100%; height: 50px; background-color: rgba(10, 20, 35, 0.85); backdrop-filter: blur(5px); color: #AAA; display: flex; justify-content: center; align-items: center; font-size: 0.9rem; flex-shrink: 0; border-top: 1px solid rgba(255, 215, 0, 0.2); }

/* ======================================= */
/* VUES & CONTENEURS PRINCIPAUX            */
/* ======================================= */
#conteneur_simulation { flex-grow: 1; padding: 15px; gap: 15px; display: flex; flex-direction: column; width: 100%; max-width: 1600px; margin: 0 auto; }
.fenetre, .fenetre-contenu { background: linear-gradient(145deg, rgba(15, 32, 58, 0.85), rgba(0, 10, 30, 0.9)); border: 1px solid rgba(255, 215, 0, 0.25); border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.4), inset 0 0 15px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding: 15px; min-height: 200px; }

/* ======================================= */
/* STYLES DES ÉLÉMENTS D'INTERFACE         */
/* ======================================= */
.fenetre_titre { font-weight: 600; text-align: center; color: gold; flex-shrink: 0; border-bottom: 1px solid rgba(255, 215, 0, 0.2); padding-bottom: 10px; margin-bottom: 10px; font-size: 1.2rem; }
.fenetre_titre_wrapper { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255, 215, 0, 0.2); margin-bottom: 10px; padding-bottom: 10px; flex-shrink: 0; }
.fenetre_titre_wrapper .fenetre_titre { border: none; margin: 0; padding: 0; flex-grow: 1; text-align: left; }

.canvas_container { position: relative; flex-grow: 1; min-height: 150px; display: flex; justify-content: center; touch-action: none; }
.control_row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input_group { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.input_group label { font-size: .95rem; color: #FFD700; text-align: left; font-weight: 500; }

.control_element { -webkit-appearance: none; appearance: none; background-color: rgba(0,20,40,.8); border: 1px solid rgba(255, 215, 0, 0.5); color: #fff; border-radius: 5px; padding: 0.6em 0.8em; font-family: inherit; font-size: 0.9rem; font-weight: 500; outline: none; transition: all 0.2s ease; text-align: center; cursor: pointer; }
.control_element:hover:not(:disabled) { background-color: rgba(0,40,80,.9); border-color: gold; box-shadow: 0 0 8px rgba(255,215,0,0.4); }
.control_element:disabled { border-color: #444; color: #666; background-color: rgba(10,10,10,.7); cursor: not-allowed; }
select.control_element { appearance: auto; cursor: pointer; }
input[type="number"].control_element { font-family: 'Courier New', Courier, monospace; font-weight: bold; color: gold; }
.step-button { font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }

.controls-main-container { display: flex; flex-wrap: wrap; gap: 15px; flex-grow: 1; align-items: stretch; }
.control-main-group { flex: 1; min-width: 250px; display: flex; flex-direction: column; gap: 10px; background-color: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); }
.main-group-title { font-size: 1.1rem; color: gold; text-align: center; margin: 0 0 10px 0; border-bottom: 1px solid rgba(255,215,0,0.1); padding-bottom: 8px; font-weight: 600; }

.selection-panel { display: flex; justify-content: space-around; gap: 10px; margin-bottom: 10px; }
.atom-box { flex: 1; background: rgba(0,0,0,0.3); border: 2px solid #555; border-radius: 8px; padding: 10px; text-align: center; cursor: pointer; transition: all 0.3s ease; }
.atom-box:hover { border-color: #888; background: rgba(255,255,255,0.05); }
.atom-box.active-A { border-color: #6496ff; background: rgba(100, 150, 255, 0.1); box-shadow: 0 0 10px rgba(100, 150, 255, 0.3); }
.atom-box.active-B { border-color: #ff6464; background: rgba(255, 100, 100, 0.1); box-shadow: 0 0 10px rgba(255, 100, 100, 0.3); }
.atom-title { display: block; font-size: 0.8rem; color: #aaa; margin-bottom: 5px; }
.atom-sym { display: block; font-size: 1.8rem; font-weight: bold; color: #FFF; margin-bottom: 5px; }
.atom-en { display: block; font-size: 0.9rem; color: #FFD700; }

.charge-select { -webkit-appearance: none; appearance: none; position: absolute; width: 60px; padding: 4px; font-size: 1rem; background: rgba(10, 20, 35, 0.9); border: 2px solid gold; color: white; border-radius: 6px; outline: none; text-align: center; cursor: pointer; box-shadow: 0 4px 8px rgba(0,0,0,0.5); transform-origin: top center; z-index: 10; }

/* --- Menu d'Accueil --- */
.menu-container { display: flex; gap: 30px; justify-content: center; align-items: center; height: 100%; flex-wrap: wrap; padding: 20px; }
.menu-card { background: linear-gradient(145deg, rgba(15, 32, 58, 0.85), rgba(0, 10, 30, 0.9)); border: 2px solid rgba(255, 215, 0, 0.4); border-radius: 15px; padding: 40px; width: 300px; text-align: center; text-decoration: none; transition: all 0.3s ease; box-shadow: 0 5px 20px rgba(0,0,0,0.5); display: block; }
.menu-card:hover { transform: translateY(-10px); border-color: gold; box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2); }
.menu-card h2 { color: gold; margin-bottom: 15px; }
.menu-card p { color: #EAEAEA; font-size: 1rem; }

/* --- Wow Overlay --- */
.wow-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(5, 8, 15, 0.95); display: flex; justify-content: center; align-items: center; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; backdrop-filter: blur(5px); }
.wow-overlay.show { opacity: 1; pointer-events: auto; }
#wow_content { text-align: center; transform: scale(0.8); transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); background: linear-gradient(145deg, rgba(20, 40, 70, 0.9), rgba(10, 20, 40, 0.95)); padding: 40px; border-radius: 20px; border: 2px solid rgba(255,215,0,0.3); box-shadow: 0 10px 40px rgba(0,0,0,0.8); max-width: 90%; }
.wow-overlay.show #wow_content { transform: scale(1); }
.wow-title { font-size: 3rem; margin-bottom: 10px; }
.wow-subtitle { font-size: 1.2rem; color: #EAEAEA; margin-bottom: 30px; line-height: 1.5; }
.wow-btn { -webkit-appearance: none; appearance: none; padding: 12px 25px; font-size: 1.2rem; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.wow-btn:hover { transform: scale(1.05); }

/* ======================================================= */
/* DISPOSITIONS GLOBALES RESPONSIVES                      */
/* ======================================================= */
@media screen and (max-width: 1024px), screen and (max-height: 800px) {
    .atom-box { padding: 6px; } .atom-sym { font-size: 1.3rem; margin-bottom: 2px; } .atom-title { font-size: 0.7rem; margin-bottom: 2px; } .atom-en { font-size: 0.8rem; }
    .selection-panel { margin-bottom: 5px; gap: 8px; } .main-group-title { font-size: 1rem; margin-top: 0; margin-bottom: 5px; padding-bottom: 4px; }
    .fenetre, .fenetre-contenu { padding: 10px; }
    #select_multiplicite, #btn_toggle_view { font-size: 0.9rem !important; padding: 4px 10px !important; }
}
@media screen and (min-width: 768px) {    
    #conteneur_simulation { display: grid; grid-template-columns: 1fr 1.2fr; grid-template-rows: minmax(180px, auto) minmax(320px, auto); min-height: calc(100vh - 120px); height: auto; }
    #fenetre2 { grid-column: 1 / 2; grid-row: 1 / 2; } #fenetre1 { grid-column: 2 / 3; grid-row: 1 / 3; } #fenetre-informations { grid-column: 1 / 2; grid-row: 2 / 3; }
}
@media screen and (max-width: 767px) {
    #banner { flex-direction: column; text-align: center; padding: 15px; }
    .banner-right { justify-content: center; width: 100%; margin-top: 5px; } .banner-left { align-items: center; text-align: center; width: 100%; } .modes-container { width: 100%; }
    #conteneur_simulation { display: flex; flex-direction: column; }
}