@font-face {
    font-family: 'BelleAllureCM-Fin';
    src: url('./fonts/ba/BelleAllureCM-Fin.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'BelleAllureCM-Gros';
    src: url('./fonts/ba/BelleAllureCM-Gros.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'BelleAllureScript2i-Fin';
    src: url('./fonts/ba/BelleAllureScript2i-Fin.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'BelleAllureScript2i-Gros';
    src: url('./fonts/ba/BelleAllureScript2i-Gros.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

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

body {
    font-family: 'BelleAllureCM-Fin', 'Georgia', serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.hint {
    font-size: 1rem;
    color: #4b6584;
    margin-top: 10px;
}

.story-selector select {
    padding: 10px 15px;
    font-size: 1.1rem;
    border: 2px solid #3498db;
    border-radius: 25px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.story-selector select:hover {
    border-color: #2980b9;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

main {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.reading-toolbar {
    display: flex;
    justify-content: center;
    padding: 14px 18px;
    margin-bottom: 22px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

#audioPlayer {
    width: 100%;
    max-width: 420px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.text-container {
    margin-bottom: 30px;
    min-height: 300px;
}

.story-text {
    font-size: 1.3rem;
    line-height: 1.8;
    text-align: justify;
    padding: 20px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 15px;
    border-left: 5px solid #3498db;
}

.story-text.font-style-fin {
    font-family: 'BelleAllureCM-Fin', 'Georgia', serif;
}

.story-text.font-style-gros {
    font-family: 'BelleAllureCM-Gros', 'Georgia', serif;
}

.story-text.font-style-script-fin {
    font-family: 'BelleAllureScript2i-Fin', 'Georgia', serif;
}

.story-text.font-style-script-gros {
    font-family: 'BelleAllureScript2i-Gros', 'Georgia', serif;
}

.story-heading {
    text-align: center;
    font-size: 2.1rem;
    margin: 10px 0 26px;
    line-height: 1.5;
    color: #2c3e50;
}

.story-heading .word-segment {
    padding: 2px 6px;
    display: inline;
}

.font-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.font-label {
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    margin: 0 4px 0 8px;
}

.font-label--cursive {
    font-family: 'BelleAllureCM-Gros', 'Georgia', serif;
}

.font-label--script {
    font-family: 'BelleAllureScript2i-Gros', 'Georgia', serif;
}

.font-btn {
    appearance: none;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.6);
    color: #2c3e50;
    font-family: 'BelleAllureCM-Gros', 'Georgia', serif;
    cursor: pointer;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.2rem;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    line-height: 1;
}

.font-btn:hover {
    transform: translateY(-1px);
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.font-btn.active {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.2);
    color: #1d5d92;
}

.font-btn[data-font-style="cm-fin"] {
    font-family: 'BelleAllureCM-Fin', 'Georgia', serif;
    font-size: 1.3rem;
}

.font-btn[data-font-style="cm-gros"] {
    font-family: 'BelleAllureCM-Gros', 'Georgia', serif;
    font-size: 1.6rem;
}

.font-btn[data-font-style="script-fin"] {
    font-family: 'BelleAllureScript2i-Fin', 'Georgia', serif;
    font-size: 1.25rem;
}

.font-btn[data-font-style="script-gros"] {
    font-family: 'BelleAllureScript2i-Gros', 'Georgia', serif;
    font-size: 1.45rem;
}

.primary-menu {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.menu-btn {
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #3498db, #1abc9c);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 16px rgba(26, 188, 156, 0.35);
}

.menu-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(26, 188, 156, 0.4);
}

.game-section {
    margin-bottom: 28px;
    padding: 24px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 30px rgba(44, 62, 80, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.25);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.game-section.is-hidden {
    display: none;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

#gameTitle {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 6px;
}

.game-instructions {
    color: #577590;
    font-size: 1rem;
    max-width: 420px;
}

.game-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.game-controls select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #bdc3c7;
    background: white;
    font-size: 1rem;
    cursor: pointer;
}

.game-label {
    font-size: 0.95rem;
    color: #34495e;
}

.game-start-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: #3498db;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 8px 18px rgba(52, 152, 219, 0.35);
}

.game-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(52, 152, 219, 0.45);
}

.game-status {
    display: flex;
    justify-content: center;
    gap: 28px;
    font-size: 1rem;
    color: #2c3e50;
}

.game-status strong {
    font-size: 1.1rem;
    color: #1abc9c;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    column-gap: clamp(120px, 12vw, 200px);
    justify-items: center;
    align-items: start;
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 24px 0;
    position: relative;
}

.game-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.game-column--left {
    font-family: 'BelleAllureScript2i-Gros', 'Georgia', serif;
    align-items: flex-end;
    text-align: right;
}

.game-column--right {
    font-family: 'BelleAllureCM-Gros', 'Georgia', serif;
    align-items: flex-start;
    text-align: left;
}

.game-word {
    border: none;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 6px 14px;
    font-size: 1.45rem;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.game-column--left .game-word {
    align-self: flex-end;
}

.game-column--right .game-word {
    align-self: flex-start;
}

.game-word:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.25);
    background: rgba(52, 152, 219, 0.1);
}

.game-word.selected {
    background: rgba(52, 152, 219, 0.2);
    box-shadow: 0 8px 18px rgba(52, 152, 219, 0.35);
}

.game-word.matched {
    background: rgba(76, 175, 80, 0.2);
    color: #2c3e50;
    box-shadow: 0 8px 18px rgba(76, 175, 80, 0.35);
    cursor: default;
}

.game-word.mismatch {
    background: rgba(231, 76, 60, 0.18);
    box-shadow: 0 8px 18px rgba(231, 76, 60, 0.3);
}

.game-links {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.game-links line {
    stroke: #2ecc71;
    stroke-width: 4;
    stroke-linecap: round;
    filter: drop-shadow(0 2px 6px rgba(46, 204, 113, 0.35));
}

.game-message {
    text-align: center;
    font-size: 1rem;
    color: #2c3e50;
    min-height: 24px;
}

.story-text p {
    margin-bottom: 15px;
    text-indent: 20px;
}

.word-segment {
    transition: all 0.3s ease;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

.word-segment .syllable {
    display: inline;
    padding: 0;
    margin: 0;
    border-radius: 4px;
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.word-segment.segment-playing .syllable {
    opacity: 0.95;
}

.word-segment.segment-playing .syllable-active {
    background: linear-gradient(120deg, #ffe29f 0%, #fdd55f 100%);
    color: #2c3e50;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 2px 6px rgba(253, 213, 95, 0.35);
}

.word-segment:hover {
    background: rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
}

.word-segment.segment-playing {
    background: rgba(76, 175, 80, 0.15);
    color: inherit;
    font-weight: 600;
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.25);
    animation: segmentPulse 0.6s ease-in-out;
    border-bottom: 2px solid rgba(76, 175, 80, 0.6);
}

@keyframes segmentPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1.05); }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .story-text {
        font-size: 1.1rem;
    }
    
    .primary-menu {
        margin-top: 18px;
    }

    .game-section {
        padding: 18px;
    }

    .game-header {
        flex-direction: column;
        align-items: stretch;
    }

    .game-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .game-board {
        display: flex;
        flex-direction: column;
        gap: 18px;
        width: 100%;
    }

    .game-links {
        display: none;
    }

    .game-column--left,
    .game-column--right {
        align-items: center;
    }

    .game-column--left .game-word,
    .game-column--right .game-word {
        align-self: center;
    }

    .reading-toolbar {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}
