/* --- VARIABLES ET STYLES DE BASE --- */
:root {
    --primary-color: #007BFF;
    --dark-color: #2c3e50;
    --light-color: #f4f4f8;
    --white-color: #ffffff;
    --danger-color: #e74c3c;
    --gray-color: #7f8c8d;
    --disabled-color: #bdc3c7;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --tile1: #3498db; --tile2: #2ecc71; --tile3: #f1c40f; --tile4: #e67e22; --tile5: #9b59b6;
    --ai-color: #8e44ad;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--light-color);
    color: var(--dark-color);
    padding-bottom: 80px; /* Espace pour le footer fixe */
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
}

/* --- COMPOSANTS PRINCIPAUX --- */
header {
    text-align: center;
    margin-bottom: 15px;
}

h1 {
    font-weight: 300;
    font-size: 1.8rem;
}

section {
    margin-bottom: 15px;
}

/* Inputs Joueur / Observateur */
.player-info {
    display: flex;
    gap: 10px;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

/* Chronomètre */
.chrono-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background-color: var(--white-color);
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#timer {
    font-size: 1.6rem;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Affichage des statistiques */
.stats-display {
    display: flex;
    justify-content: space-around;
    text-align: center;
    background: var(--dark-color);
    color: var(--white-color);
    padding: 20px 15px;
    border-radius: 8px;
}

.stat-item .value {
    display: block;
    font-size: clamp(3rem, 10vw, 4.5rem);
    font-weight: bold;
}

.stat-item .label {
    font-size: 1rem;
    opacity: 0.8;
}

/* Grille des boutons d'action */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.action-btn {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.3;
    color: var(--white-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.action-btn.wide {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    padding: 20px;
}

/* Couleurs des tuiles */
.tile-1 { background-color: var(--tile1); }
.tile-2 { background-color: var(--tile2); }
.tile-3 { background-color: var(--tile3); }
.tile-4 { background-color: var(--tile4); }
.tile-5 { background-color: var(--tile5); }

/* --- BOUTONS ET FOOTER --- */
button {
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
button:active {
    transform: scale(0.96);
    box-shadow: none;
}
button:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#startStopBtn {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
#startStopBtn svg {
    width: 20px;
    height: 20px;
}
button.primary {
    background-color: var(--primary-color);
    color: var(--white-color);
}
button.primary.danger {
    background-color: var(--danger-color);
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--white-color);
    border-top: 1px solid #ddd;
    z-index: 10;
}
.footer-controls {
    display: flex;
    justify-content: space-around;
    max-width: 600px;
    margin: 0 auto;
    padding: 12px 10px;
}
.footer-controls button {
    background: var(--light-color);
    color: var(--gray-color);
    min-width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
}
.footer-controls button:hover:not(:disabled) {
    background-color: #e0e0e0;
}
.footer-controls button svg {
    width: 24px;
    height: 24px;
}
.footer-controls button:disabled {
    color: var(--disabled-color);
    background: var(--light-color);
}
#analysisBtn {
    color: var(--ai-color);
    font-weight: bold;
    border: 1px solid var(--ai-color);
    background-color: transparent;
}
#analysisBtn:hover:not(:disabled) {
    background-color: var(--ai-color);
    color: var(--white-color);
}


/* --- MODAL POUR L'ANALYSE IA --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
}

.modal-content {
    background-color: var(--white-color);
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-color);
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--ai-color);
}

#modal-body {
    min-height: 100px;
    line-height: 1.6;
    /* Styles pour le défilement */
    max-height: 60vh; /* Hauteur maximale de 60% de la vue */
    overflow-y: auto; /* Ascenseur vertical si nécessaire */
    padding-right: 10px; /* Espace pour la barre de défilement */
}

#modal-body h3 {
    margin-top: 15px;
    margin-bottom: 5px;
}


/* Loader/Spinner */
.loader {
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--ai-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

