:root {
    --primary-color: rgb(52, 73, 94);
    --accent-color-1: rgb(255, 87, 50);
    --accent-color-3: rgb(255, 135, 0);
    --accent-color-4: rgb(126, 87, 197);
    --accent-color-5: rgb(0, 172, 193);
    --bg-color: #f9f9f9;
    --text-color: rgb(52, 73, 94);
    --light-gray: #ecf0f1;
    --dark-gray: #7f8c8d;
    --white: #ffffff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
    --footer-height: 38px;
}

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

@font-face {
    font-family: Kalam;
    src: url(../ttf/Kalam-Bold.ttf);
}

@font-face {
    font-family: Kalam-reg;
    src: url(../ttf/kalam.regular.ttf);
}

@font-face {
    font-family: OpenSansReg;
    src: url(../ttf/OpenSans-Regular.ttf);
}

@font-face {
    font-family: OpenSansSemiBold;
    src: url(../ttf/OpenSans-SemiBold.ttf);
}

html {
    height: 100%;
    overflow-y: scroll;
}

body {
    min-height: 100%;
    position: relative;
    padding-bottom: var(--footer-height);
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239e9d24' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-color);
}

header {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: .3rem 1rem .7rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.08' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.5;
    z-index: 0;
}

.flower-link {
    position: absolute;
    left: 1.8%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    cursor: pointer;
}

.flower-decoration {
    height: 3.8rem;
    width: 3.8rem;
    opacity: 0.9;
    transition: transform 0.3s ease, opacity 0.3s ease;
    background-image: url('./img/flower.svg');
    background-size: contain;
    background-repeat: no-repeat;
}

.flower-link:hover .flower-decoration {
    transform: scale(1.05);
    opacity: 1;
    background-image: url('./img/flower-color.svg');
}

.header-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

header h1 {
    font-family: Kalam;
    font-size: 2.4rem;
    color: var(--accent-color-5);
    color: rgb(38, 198, 218);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

header p {
    font-family: Kalam-reg;
    font-size: 1.4rem;
    max-width: 800px;
    margin: 0 auto;
}

main {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Classe commune pour tous les titres de section */
.section-title {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
    background-color: rgba(236, 240, 241, 0.7);
    padding: 8px 12px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    gap: 15px;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

#easy-mode {
    background-color: var(--accent-color-5);
}

#hard-mode {
    background-color: var(--accent-color-3);
}

.difficulty-btn.active {
    box-shadow: none;
    border: 2.5px solid var(--primary-color);
    font-weight: bold;
    padding: 7px 17px;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border-left: 10px solid var(--accent-color-5);
}

.game-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    background-color: rgba(236, 240, 241, 0.7);
    border-radius: 5px;
    padding: 8px 0;
    margin-bottom: 15px;
}

.game-container h2 {
    color: var(--primary-color);
    margin-right: 10px;
    margin-bottom: 0;
    background: none;
    padding: 0;
    box-shadow: none;
}

.info-icon {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    background-color: var(--primary-color);
    position: absolute;
    right: 15px;
}

.info-icon:hover {
    background-color: var(--accent-color-5);
}

.info-icon img {
    width: 12px;
    height: 12px;
    transition: var(--transition);
    filter: brightness(0) invert(1); /* Pour rendre l'icône blanche */
}

.info-content {
    display: none;
    width: 100%;
    background-color: var(--light-gray);
    border-radius: 8px;
    padding: 15px;
    margin: 0 0 15px 0;
    font-size: 14px;
    color: var(--text-color);
}

.info-content.show {
    display: block;
}

.info-content p {
    margin-bottom: 15px;
}

.info-content p:last-child {
    margin-bottom: 0;
}

.sticks-counter {
    font-size: 1rem;
    font-weight: bold;
    color: var(--accent-color-3);
    margin: 15px 0;
    padding: 8px 15px;
    background-color: var(--light-gray);
    border-radius: 50px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.sticks-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    max-width: 800px;
}

.stick {
    width: 20px;
    height: 100px;
    background-color: var(--accent-color-5);
    border-radius: 3px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    margin: 5px;
    transition: var(--transition);
}

.message {
    font-size: 18px;
    font-weight: bold;
    margin: 15px 0;
    min-height: 27px;
    color: var(--primary-color);
    padding: 10px 20px;
    background-color: var(--light-gray);
    border-radius: 5px;
    text-align: center;
}

.inline-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--primary-color);
    vertical-align: middle;
    margin: 0 4px;
}

.inline-button img {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1); /* Pour rendre l'icône blanche */
}

.controls {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.take-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
    width: 100%;
}

.action-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 10px 20px;
    background-color: var(--accent-color-5);
    color: var(--white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    font-weight: bold;
}

button:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background-color: var(--dark-gray);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#take-one {
    background-color: var(--accent-color-5);
}

#take-two {
    background-color: var(--accent-color-3);
}

#take-three {
    background-color: var(--primary-color);
}

.action-btn {
    background-color: var(--primary-color);
    width: 50px;
    height: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
}

.action-btn img {
    width: 30px;
    height: 30px;
    transition: var(--transition);
}

.action-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    white-space: nowrap;
}

.action-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Grille de connaissances de l'IA */
.knowledge-container {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-top: 30px;
    border-left: 10px solid var(--accent-color-5);
}

.knowledge-container p {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-color);
}

.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    width: 100%;
}

.position-cell {
    text-align: center;
    padding: 10px;
    background-color: var(--light-gray);
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    width: 90%;
    margin: 0 auto;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.option-button {
    padding: 8px;
    border-radius: 5px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    margin-top: 5px;
}

.option-button.take-1 {
    background-color: var(--accent-color-5);
    color: var(--white);
}

.option-button.take-2 {
    background-color: var(--accent-color-3);
    color: var(--white);
}

.option-button.take-3 {
    background-color: var(--primary-color);
    color: var(--white);
}

.option-button.invalid {
    background-color: var(--dark-gray);
    text-decoration: line-through;
    opacity: 0.5;
}

/* Historique de la partie */
.game-history {
    margin-top: 30px;
    padding: 15px;
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border-left: 10px solid var(--accent-color-3);
}

.history-moves {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.history-move {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-radius: 5px;
    background-color: var(--light-gray);
}

.move-player {
    font-weight: bold;
    color: var(--accent-color-5);
}

.move-ai {
    font-weight: bold;
    color: var(--accent-color-3);
}

.move-removed {
    background-color: var(--light-gray);
    border: 2px solid var(--accent-color-3);
}

.move-removed strong {
    color: var(--accent-color-3); /* Rouge-orange pour indiquer la suppression */
    font-weight: bold;
    margin-left: 5px;
}

.stats {
    background-color: var(--white);
    border-radius: 10px;
    padding: 15px;
    box-shadow: var(--shadow);
    margin-top: 20px;
    border-left: 10px solid var(--accent-color-3);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.stats-controls {
    margin-top: 20px;
    justify-content: center;
}

/* Footer */
footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--footer-height);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    text-align: center;
    padding: 0 .5rem;
    background-color: var(--primary-color);
    color: var(--white);
    z-index: 100;
}

footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.3;
    z-index: 0;
}

/* Styles pour les éléments à l'intérieur du footer */
footer span, footer a {
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

footer a {
    color: var(--white);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
    color: rgba(255, 255, 255, 0.8);
}

.separator {
    margin: 0 0.75rem;
}

.license-part {
    margin: 0 0.5rem;
}

.contact-part a {
    margin-left: 4px; /* Ajoute un espace entre "Contact :" et le lien */
}

.mobile-text {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    html, body {
        overflow-y: auto;
    }
    
    .flower-link {
        display: none;
    }
    header h1 {
        font-size: 1.8rem;
    }
    :root {
        --footer-height: 50px; /* Hauteur pour deux lignes */
    }   
    .take-controls {
        flex-wrap: nowrap;
        width: 100%;
    }
    
    .take-controls button {
        flex: 1;
        padding: 10px 5px;
        font-size: 14px;
    }
    
    .action-controls {
        flex-wrap: nowrap;
    }
    
    .knowledge-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    :root {
        --footer-height: 50px; /* Hauteur pour deux lignes */
    }
    
    footer {
        flex-wrap: wrap; /* Permet le retour à la ligne */
        justify-content: center;
        padding: .4rem 0;
    }
}

@media (max-width: 480px) {
    main {
        margin-top: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .difficulty-selector {
        flex-wrap: nowrap;
    }
    
    .difficulty-btn {
        padding: 8px 12px;
        font-size: 14px;
        flex: 1;
    }

    .sticks-container {
        margin: 0;
    }
    
    .take-controls button span {
        display: none;
    }
    
    /* Modification du style pour que le chiffre ait la même typographie */
    .take-controls button::after {
        content: attr(data-number);
        font-weight: normal;
        font-size: 1em;
    }
}

@media (max-width: 405px) {
    header h1 {
        font-size: 1.8rem;
    }

    #atelierIA {
        display: none;
    }
    
    header p {
        font-size: 1rem;
    }

    footer {
        display: block;
        padding: .4rem 0;
        text-align: center;
    }

    /* Copyright sur une ligne séparée */
    .copyright-part {
    display: block;
    width: 100%;
    }
    
    /* License et Contact sur la même ligne */
    .license-part, .contact-part {
        display: inline-block;
    }
    
    /* Par défaut, cacher tous les séparateurs */
    .separator {
        display: none !important;
        margin: 0;
    }
    
    /* Afficher uniquement le séparateur entre License et Contact */
    .license-part + .separator {
        display: inline-block !important;
    }
    
    /* Gestion du texte Contact */
    .contact-part .contact-text, 
    .contact-part .email-text {
        display: none;
    }
    
    .contact-part .mobile-text {
        display: inline;
    }
}