body, html {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: Georgia, serif;
}

.hidden {
    display: none !important;
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.start-options {
    display: flex;
    gap: 5vw;
    margin-top: 5vh; /* Pushed down slightly */
}

.start-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #FDF6E3;
    font-family: 'Caveat', cursive; /* Using the other font for a different feel */
    text-align: center;
    transition: transform 0.3s ease, filter 0.3s ease;
}

#start-screen .start-options {
  display: flex;
  gap: 5vw;
  margin-top: 5vh;
  justify-content: center;    /* <-- important */
  align-items: center;        /* <-- optionnel mais propre */
}

/* Style + centrage du titre */
#start-screen .game-title {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: clamp(3rem, 8vw, 7rem);
  color: #FDF6E3;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.6);
  letter-spacing: 0.06em;
  margin: 0 0 2vh 0;
  line-height: 1;
  text-align: center;  /* centre le texte */
  align-self: center;  /* s’aligne au centre de la colonne flex */
}

.start-btn img {
    width: 25vw;
    max-width: 280px;
    min-width: 200px;
    filter: drop-shadow(5px 5px 15px rgba(0,0,0,0.5));
}

.start-btn span {
    display: block;
    margin-top: 15px;
    font-size: clamp(2rem, 3.5vw, 3rem);
    font-weight: 700;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
}

.start-btn:hover {
    transform: scale(1.05) translateY(-10px);
    filter: brightness(1.1);
}

.start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.start-btn:disabled:hover {
    transform: none;
    filter: grayscale(50%);
}

#game-setup-screens {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2001; /* Above start-screen */
}

.game-setup-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(45, 35, 30, 0.75);
    backdrop-filter: blur(10px);
}

.game-setup-screen.hidden {
    display: none;
}

.game-setup-screen .setup-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(3rem, 5vw, 4.5rem);
    color: #FDF6E3;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
    margin-bottom: 30px;
}

.input-container {
    display: flex;
    gap: 15px;
    align-items: center;
}

#game-name-input {
    font-family: Georgia, serif;
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    padding: 15px 20px;
    border-radius: 8px;
    border: 2px solid #D1B79A;
    background: #FDF6E3;
    color: #6B4F3A;
    min-width: 300px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

#game-name-input::placeholder {
    color: #a08c7d;
}

.setup-btn {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 2vw, 1.8rem);
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #4A3A2A;
    color: #FDF6E3;
    border: 1px solid #715B48;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.setup-btn:hover {
    background-color: #6B4F3A;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.6);
}

.back-btn {
    position: absolute;
    top: 3vw;
    right: 3vw;
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(40px, 3.5vw, 55px);
    height: clamp(40px, 3.5vw, 55px);
    padding: 0;
    transition: transform 0.2s ease;
}

.back-btn img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}

.back-btn:hover {
    transform: scale(1.15);
}

#saved-games-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    align-items: center; /* Center items for consistent layout */
}

.saved-game-entry {
    display: flex;
    align-items: center;
    gap: 15px;
}

.delete-game-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(35px, 2.5vw, 45px);
    height: clamp(35px, 2.5vw, 45px);
    padding: 0;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.delete-game-btn img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}

.delete-game-btn:hover {
    transform: scale(1.15);
    filter: brightness(1.2);
}

.saved-game-btn {
    font-family: Georgia, serif;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    padding: 15px 40px;
    border-radius: 8px;
    border: 2px solid #D1B79A;
    background: #FDF6E3;
    color: #6B4F3A;
    cursor: pointer;
    text-align: center;
    min-width: 350px;
    transition: all 0.2s ease;
}

.saved-game-btn:hover {
    background: #e9dec7;
    border-color: #bfa588;
    transform: scale(1.03);
}

body {
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    color: #EAE0D5; /* Warm off-white */
    text-align: center;
    text-shadow: none; /* Remove text shadow for paper look */
    height: 100%;
}

#main-screen {
    position: relative;
    width: 100%;
    height: 100%;
}

/* --- Top Elements --- */
#top-left-corner {
    position: absolute;
    top: 2vw;
    left: 2vw;
    display: flex;
    flex-direction: row; /* Aligne les enfants horizontalement */
    align-items: center;  /* Aligne verticalement au centre */
    gap: 140px;
}

/* On redéfinit la taille de l'icône "Rules" qui est plus petite */
#rules-btn img {
    width: 6vw;
    max-width: 70px;
    min-width: 50px;
}

/* On ajuste la taille du titre de "Rules" */
#rules-btn .book-title {
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    margin-top: 5px;
}

#top-center-container {
    position: absolute;
    top: 3vw;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

#top-center-container .book-like img {
    width: 6vw;
    max-width: 70px;
    min-width: 50px;
}

#top-center-container .book-title {
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    margin-top: 5px;
}

#top-right-container {
    position: absolute;
    top: 3vw;
    right: 3vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#album-container {
    /* This element is now inside #top-left-corner for layout purposes */
}

#album-container .book-like img {
    width: 15vw;
    max-width: 200px;
    min-width: 120px;
}

#album-container .book-title {
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    margin-top: 10px;
}

#score-record {
    /* Ajout des nouvelles propriétés pour le décalage */
    position: relative;
    bottom: 13vh; /* Pousse le bloc vers le haut de 4% de la hauteur de l'écran */

    /* Le reste des propriétés est inchangé */
    text-align: left;
    background: #FDF6E3;
    color: #6B4F3A;
    padding: 20px 30px;
    border-radius: 5px;
    border: 1px solid #D1B79A;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2), inset 0 0 20px rgba(0,0,0,0.05);
}
#score-record .total-score-line {
    font-weight: bold;
    font-size: 1.3em;
    text-align: center;
    margin-bottom: 10px;
    color: #855934;
    text-shadow: none;
}
#score-record .score-divider {
    border: 0;
    height: 1px;
    background: #D1B79A;
    margin: 5px auto 15px auto;
    width: 80%;
}
#score-record .score-title {
    font-weight: 700;
    font-size: clamp(1.2rem, 2.1vw, 1.8rem); /* Adjusted for new font */
    color: #9A6A43; /* Earthy brown */
    margin-bottom: 10px; /* Increased spacing */
    text-align: center;
    text-shadow: none; /* Remove text shadow for paper look */
}
#score-record p {
    margin: 8px 0;
    text-shadow: none; /* Remove text shadow for paper look */
    font-size: 1.2em;
}

/* --- Center Album Book --- */
#center-container {
    grid-area: center;
    display: flex;
    flex-direction: column; /* <-- Empile les enfants verticalement */
    justify-content: center;
    align-items: center;
    gap: 30px; /* <-- Ajoute de l'espace entre l'album et le conteneur des boutons */
    margin-top: 15vh;
}

#center-container .book-like img {
    width: 32vw;
    max-width: 420px;
    min-width: 280px;
}

#center-container .book-title {
    font-size: clamp(1.4rem, 2.5vw, 3.2rem);
}

.book-like {
    text-decoration: none;
    color: white;
    text-align: center;
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.book-like img {
    width: 22vw;
    max-width: 280px;
    min-width: 180px;
    height: auto;
    display: block;
}

#exit-btn img {
    width: 8vw;
    max-width: 100px;
    min-width: 60px;
    height: auto;
    display: block;
}

.book-like:hover {
    transform: translateY(-10px) scale(1.05);
    filter: brightness(1.1);
}

.book-title {
    margin-top: 15px;
    font-size: clamp(1.6rem, 2.8vw, 2.3rem); /* Adjusted for new font */
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7); /* Softer shadow */
    letter-spacing: 0.1em;
    color: #FDF6E3; /* Parchment color to match score record */
}

/* --- Bottom Left Controls --- */
#bottom-left-container {
    position: absolute;
    bottom: 2vw;
    left: 2vw;
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

#initial-problems-book-container button {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

#initial-problems-book-container {
    position: relative; /* Active la possibilité de décaler l'élément */
    left: 14vw;          /* Pousse l'élément vers la droite de 5% de la largeur de l'écran */
    bottom: 18vh;        /* Pousse l'élément vers le haut de 5% de la hauteur de l'écran */
}

#initial-problems-book-container img {
    width: 9vw;
    max-width: 100px;
    min-width: 60px;
}

#initial-problems-book-container .book-title {
    font-size: clamp(0.9rem, 1.4vw, 1.2rem);
    margin-top: 8px;
    line-height: 1.2;
    letter-spacing: normal;
}

#controls-container {
    position: relative;
    display: flex;
    gap: 0px; /* MODIFIÉ : Réduit l'espace ENTRE les boutons */
    background: rgba(45, 35, 30, 0.6);
    padding: 0px; /* MODIFIÉ : Réduit l'espace AUTOUR des boutons */
    border-radius: 12px; /* On peut garder les coins arrondis */
    border: 1px solid rgba(234, 224, 213, 0.1);
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.control-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.control-hover-text {
    position: absolute;
    bottom: 110%; /* Position above the button */
    font-family: Georgia, serif; /* Different font as requested */
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    font-weight: bold;
    color: #FDF6E3;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    background: rgba(45, 35, 30, 0.7);
    padding: 5px 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    transform: translateY(10px);
}

.control-wrapper:hover .control-hover-text {
    opacity: 1;
    transform: translateY(0);
}

.control-btn {
    background: transparent; /* <-- La modification clé */
    border: none;            /* <-- On retire la bordure */
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease; /* Transition plus adaptée */
    /* On retire border-radius, car il n'y a plus de fond */
    width: clamp(80px, 9vw, 110px); 
    height: clamp(80px, 9vw, 110px); 
    display: flex;
    justify-content: center;
    align-items: center;
    /* On retire l'ombre interne */
}

.control-btn img {
    width: 60%; /* Slightly larger icons */
    height: auto;
    filter: none; /* Remove drop shadow from icon itself */
    opacity: 1;
}

.control-btn:hover {
    transform: scale(1.15); /* On agrandit un peu plus */
    filter: drop-shadow(0 0 8px rgba(255, 223, 150, 0.7)); /* Ombre dorée et douce */
}

/* --- Bottom Right Card Deck --- */
#deck-container {
    /* On change la méthode de positionnement */
    position: absolute;
    bottom: 25vh; /* On le positionne par rapport au bas de l'écran */
    right: 17vw;  /* Et par rapport à la droite */

    /* Le reste est principalement pour l'alignement interne */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    
}

#shuffle-animation-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shuffle-card {
    position: absolute;
    /* On copie les dimensions du paquet de cartes (#card-deck) */
    width: 16vw;
    max-width: 200px;
    min-width: 135px;
    height: auto;
    aspect-ratio: 280 / 400; /* Garde les bonnes proportions (ajustez si besoin) */

    /* On donne l'apparence d'une carte */
    background-image: url('card_back.png');
    background-size: contain;
    background-repeat: no-repeat;
    
    /* Le reste est inchangé */
    animation: shuffle-deal 0.8s ease-out forwards;
    animation-delay: calc(var(--i) * 0.1s);
    opacity: 0;
}

@keyframes shuffle-deal {
    0% {
        transform: translateY(0) rotate(0deg) translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-200px) rotate(calc(var(--i) * 30deg - 30deg)) translateX(calc(var(--i) * 50px - 50px));
        opacity: 0;
    }
}

#card-deck {
    width: 16vw;
    max-width: 200px;
    min-width: 135px;
    height: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
    filter: drop-shadow(3px 3px 8px rgba(0,0,0,0.6));
}

#card-deck:hover {
    transform: scale(1.1) rotate(-5deg);
}

/* --- Card Display Screen --- */
#card-display-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 35, 30, 0.75); /* Dark semi-transparent overlay */
    backdrop-filter: blur(10px) brightness(0.8); /* Blur and darken the background */
    display: none; /* Initially hidden */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

#close-card-screen {
    position: absolute;
    top: 3vw;
    right: 3vw;
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(40px, 3.5vw, 55px);
    height: clamp(40px, 3.5vw, 55px);
    padding: 0;
    transition: transform 0.2s ease;
}

#close-card-screen img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}
#close-card-screen:hover {
    transform: scale(1.15);
}

#displayed-cards-container {
    display: flex;
    gap: clamp(30px, 4vw, 50px); /* Responsive gap */
    justify-content: center;
    align-items: center; /* Make cards same height */
    flex-wrap: wrap; /* Allow wrapping on smaller screens if needed */
}

.card {
    width: clamp(150px, 30vw, 300px);
    background: #FDF6E3; /* Parchment paper color */
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3), 0 0 25px rgba(255, 215, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, opacity 0.4s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    color: #6B4F3A; /* Dark, warm brown text */
    border: 1px solid #D1B79A; /* Soft brown border */
    overflow: hidden; /* To ensure border radius is applied to children */
}

.card.selected {
    transform: scale(1.1) translateY(-15px) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 45px rgba(40, 167, 69, 0.5); /* Greenish glow */
    cursor: default;
}

.card:hover {
    transform: scale(1.08) translateY(-10px) rotate(2deg);
    box-shadow: 0 8px 20px rgba(0,0,0,0.35), 0 0 35px rgba(255, 215, 0, 0.3);
}

.card.selected:hover {
    transform: scale(1.1) translateY(-15px) !important; /* Keep selected transform on hover */
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 45px rgba(40, 167, 69, 0.5);
    transform: scale(1.1) translateY(-15px) rotate(0deg) !important;
}

.card-image {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 5 / 6;
    object-fit: cover;
    background-color: #e9dec7; /* A light color for letterboxing */
}

.card-name {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.8rem, 2.2vw, 2rem);
    color: #9A6A43;
    margin: 15px 0 10px 0;
    padding: 0 10px;
    text-shadow: none;
}

.card-text {
    /* On force la zone de texte à avoir une hauteur fixe */
    height: 120px; /* Essayez une valeur comme celle-ci pour commencer */
    
    /* On s'assure que le texte reste centré verticalement dans sa boîte */
    display: flex;
    align-items: center;
    justify-content: center;

    /* On cache tout texte qui dépasse de cette boîte */
    overflow: hidden;
    
    /* --- LIGNES OPTIONNELLES MAIS RECOMMANDÉES --- */
    /* Ces 3 lignes magiques coupent le texte après un certain nombre de lignes */
    /* et ajoutent "..." à la fin. C'est très propre. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4; /* Nombre de lignes max avant de couper */
    
    /* Le reste de vos styles */
    padding: 20px;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    flex-grow: 1; /* Il est important de garder celui-ci */
    text-align: center;
}

.card-text p {
    margin: 0;
    line-height: 1.4;
    text-shadow: none;
}

.confirm-btn {
    background-color: #28a745; /* Green */
    color: white;
    border: 1px solid #1e7e34;
    padding: 12px 25px;
    margin: 0 auto 20px auto;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    width: 80%;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.confirm-btn.hidden {
    display: none;
}

.confirm-btn:hover {
    background-color: #218838;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.4), 0 0 15px rgba(40, 167, 69, 0.7);
}

/* --- Initial Problems Screen --- */
#initial-problems-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 35, 30, 0.75);
    backdrop-filter: blur(10px) brightness(0.8);
    display: none; /* Initially hidden */
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

#initial-problems-screen .book-page img {
  display: block;
  max-width: 100%;
  height: auto;               /* conserve le ratio 1120×888 */
  object-fit: contain;        /* jamais rognée */
  /* Limite en hauteur pour éviter que ça dépasse l’écran + le titre/sous-titre */
  max-height: calc(70vh - 180px); /* ajuste 180px si besoin */
  margin: 0 auto 12px;
}

#initial-problems-screen.hidden {
    display: none !important;
}

#close-initial-problems-screen {
    position: absolute;
    top: 3vw;
    right: 3vw;
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(40px, 3.5vw, 55px);
    height: clamp(40px, 3.5vw, 55px);
    padding: 0;
    transition: transform 0.2s ease;
    z-index: 10;
}

#close-initial-problems-screen img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}
#close-initial-problems-screen:hover {
    transform: scale(1.15);
}

.problems-book-content {
    background-color: #FDF6E3;
    color: #6B4F3A;
    border: 2px solid #D1B79A;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    padding: clamp(20px, 10vw, 50px);
    box-sizing: border-box;
    overflow-y: auto;
    text-align: left;
}

.problems-book-content .screen-title {
    text-align: center;
    margin-bottom: 10px;
}
.screen-subtitle {
    font-family: Georgia, serif;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: #855934;
    text-align: center;
    margin: 0 auto 30px auto;
    max-width: 80%;
    font-style: italic;
    font-weight: normal;
}

#initial-problems-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

#initial-problems-list li {
    font-size: clamp(1.1rem, 1.6vw, 1.4rem);
    padding: 15px 20px;
    border-bottom: 1px dashed #D1B79A;
    line-height: 1.5;
}

#initial-problems-list li:last-child {
    border-bottom: none;
}

#initial-problems-list li::before {
    content: "•";
    color: #9A6A43;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* --- Album Screen --- */
#album-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 35, 30, 0.75);
    backdrop-filter: blur(10px) brightness(0.8);
    display: none; /* Initially hidden */
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 1000;
    padding: 10vh 5vw;
    box-sizing: border-box;
    overflow-y: auto;
}

#close-album-screen {
    position: absolute;
    top: 3vw;
    right: 3vw;
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(40px, 3.5vw, 55px);
    height: clamp(40px, 3.5vw, 55px);
    padding: 0;
    transition: transform 0.2s ease;
    z-index: 10;
}

#close-album-screen img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}
#close-album-screen:hover {
    transform: scale(1.15);
}

.screen-title {
    font-family: Georgia, serif; /* On utilise la police principale */
    font-weight: bold;           /* On s'assure qu'elle est en gras */
    letter-spacing: 0.05em;      /* On ajoute un peu d'air entre les lettres */
    font-size: clamp(2.5rem, 4vw, 3.5rem); /* Taille légèrement réduite pour compenser */
    color: #FDF6E3;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
    margin: 0 0 20px 0;
    text-align: center;
}

#album-sort-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.sort-btn {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.2rem, 1.5vw, 1.4rem);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #4A3A2A;
    color: #FDF6E3;
    border: 1px solid #715B48;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.sort-btn:hover {
    background-color: #6B4F3A;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.sort-btn.active {
    background-color: #855934; /* A brighter, active color */
    color: white;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.6);
    pointer-events: none;
}

#album-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(20px, 3vw, 40px);
    justify-content: center;
    width: 100%;
}

.album-card {
    width: clamp(160px, 15vw, 220px);
    background: #FDF6E3;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    text-align: center;
    color: #6B4F3A;
    border: 1px solid #D1B79A;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.album-card:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.album-card img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 5 / 6;
    object-fit: cover;
    background-color: #e9dec7; /* A light color for letterboxing */
}

.album-card p {
    margin: 0;
    padding: 12px 10px;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    font-weight: bold;
    text-shadow: none;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.album-empty-message {
    color: #FDF6E3;
    font-size: clamp(1.5rem, 2vw, 2rem);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    text-align: center;
    max-width: 600px;
}

/* --- Mathematician Detail Modal --- */
#mathematician-detail-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1500;
    pointer-events: none;
}

.mathematician-detail-modal {
    pointer-events: all;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(45, 35, 30, 0.75);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.mathematician-detail-modal.visible {
    opacity: 1;
}

.mathematician-detail-modal .modal-content {
    background-color: #FDF6E3;
    color: #6B4F3A;
    border: 2px solid #D1B79A;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    max-height: 700px;
    padding: clamp(20px, 3vw, 40px);
    box-sizing: border-box;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden; /* Prevent content from spilling before layout is ready */
}

.mathematician-detail-modal.visible .modal-content {
    transform: scale(1);
}

.mathematician-detail-modal .close-modal-btn {
    position: absolute;
    top: clamp(10px, 2vw, 20px);
    right: clamp(10px, 2vw, 20px);
    background: transparent;
    border: none;
    cursor: pointer;
    width: clamp(35px, 3vw, 45px);
    height: clamp(35px, 3vw, 45px);
    padding: 0;
    transition: transform 0.2s ease;
    z-index: 10;
}
.mathematician-detail-modal .close-modal-btn img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.3));
}
.mathematician-detail-modal .close-modal-btn:hover {
    transform: scale(1.15);
}

.modal-main-content {
    display: flex;
    gap: clamp(20px, 3vw, 40px);
    height: 100%;
}

.modal-card-image-container {
    flex: 0 0 clamp(250px, 30%, 350px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-card-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    aspect-ratio: 5 / 6;
    object-fit: cover;
    background-color: #e9dec7; /* A light color for letterboxing */
}

.modal-text-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 20px; /* For scrollbar spacing */
    text-align: left;
}

.modal-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(2.5rem, 4vw, 3.5rem);
    color: #9A6A43;
    margin: 0 0 15px 0;
    text-shadow: none;
}

.modal-power, .modal-bio {
    margin-bottom: 25px;
}

.modal-text-content h3 {
    font-family: Georgia, serif;
    font-size: clamp(1.3rem, 1.8vw, 1.6rem);
    color: #855934;
    border-bottom: 1px solid #D1B79A;
    padding-bottom: 5px;
    margin: 0 0 10px 0;
}

.modal-text-content p {
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.6;
    margin: 0;
    text-shadow: none;
}

.modal-power p {
    font-style: italic;
    color: #5a402e;
}

/* Scrollbar styling for the modal */
.modal-text-content::-webkit-scrollbar {
    width: 10px;
}
.modal-text-content::-webkit-scrollbar-track {
    background: #e9dec7;
    border-radius: 5px;
}
.modal-text-content::-webkit-scrollbar-thumb {
    background: #a08c7d;
    border-radius: 5px;
}
.modal-text-content::-webkit-scrollbar-thumb:hover {
    background: #856f5e;
}

#displayed-cards-container.selection-active .card:not(.selected) {
    transform: scale(0.9) !important;
    opacity: 0.6;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#displayed-cards-container.selection-active .card:not(.selected):hover {
    transform: scale(0.95) !important;
    opacity: 0.8;
}

/* --- Generic Modal Styles --- */

/* Style pour les modales qui doivent être centrées (défaut) */
.modal-content.align-center {
    text-align: center;
}

/* Style pour les modales qui doivent être à gauche (règles) */
.modal-content.align-left {
    text-align: left;
}

/* Règle commune pour le titre : il est TOUJOURS centré */
.modal-content h2 {
    text-align: center !important;
}
/*
/* Règle commune pour la taille et le scroll de TOUTES les modales */
#modal-container .modal-content {
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Barre de défilement (optionnel) */
#modal-container .modal-content::-webkit-scrollbar {
    width: 10px;
}
#modal-container .modal-content::-webkit-scrollbar-track {
    background: #e9dec7;
}
#modal-container .modal-content::-webkit-scrollbar-thumb {
    background: #a08c7d;
    border-radius: 5px;
}

/* --- Initial Problems Book: single-page layout and styles --- */
#initial-problems-screen .screen-title {
    color: #2A6DF0; /* blue title inside the book only */
}

#book-pages-container {
    width: 92%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 24px;
}

.book-page {
    flex: 1;
    background: #FFF8E7;
    border: 2px solid #D1B79A;
    border-radius: 12px;
    padding: 16px 20px;
    box-sizing: border-box;
    max-height: 58vh;
    overflow-y: auto;
}

#right-page { display: none; } /* single-page view */

.problem-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.6rem, 2.2vw, 2rem);
    color: #6B4F3A;
    margin: 0 0 8px 0;
}

.problem-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    border: 1px solid #D1B79A;
    border-radius: 8px;
    margin: 6px 0 12px 0;
    background: #FDF6E3;
}

.problem-body p {
    margin: 0 0 10px 0;
    line-height: 1.45;
    color: #6B4F3A;
}

#book-navigation {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#book-navigation .nav-btn {
    font-family: Georgia, serif;
    font-size: clamp(1rem, 1.6vw, 1.1rem);
    padding: 10px 16px;
    border-radius: 8px;
    border: 2px solid #D1B79A;
    background: #6B4F3A;
    color: #FDF6E3;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.2s ease, opacity 0.2s ease;
}
#book-navigation .nav-btn:hover:not([disabled]) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}
#book-navigation .nav-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

#page-indicator {
    font-family: Georgia, serif;
    font-size: clamp(1rem, 1.6vw, 1.1rem);
    color: #FDF6E3;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(45,35,30,0.35);
    border: 1px solid rgba(209,183,154,0.6);
}

/* Retirer la "boîte" autour des images du livre */
#initial-problems-screen .book-page img,
#initial-problems-screen .book-page .image-frame,
#initial-problems-screen .book-page figure,
#initial-problems-screen .book-page .media {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
}

/* Couleur de la "boîte" qui contient le problème */
#initial-problems-screen .book-page,
#initial-problems-screen .problems-book-content {
  background: #ffefd5 !important; /* PapayaWhip */
}

