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

:root {
    --primary: #5c6ee6;
    --primary-dark: #4c5ed3;
    --accent: #764ba2;
    --surface: #ffffff;
    --surface-soft: #f8f9fc;
    --surface-soft-2: #f2f5ff;
    --text: #2b3440;
    --muted: #5f6b7a;
    --line: #e7ebf3;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(1200px 420px at 15% -10%, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 60%),
        linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 30px 18px;
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(21, 31, 61, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.55);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 44px 30px 38px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    top: -240px;
    right: -120px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

header h1 {
    font-size: 2.25em;
    margin-bottom: 10px;
    letter-spacing: 0.2px;
    position: relative;
    z-index: 1;
    text-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.92;
    position: relative;
    z-index: 1;
}

.tabs {
    display: flex;
    background: linear-gradient(to bottom, #f7f9ff 0%, #f3f6ff 100%);
    border-bottom: 1px solid #dde4f4;
    gap: 6px;
    padding: 10px;
}

.tab-button {
    flex: 1;
    padding: 13px 18px;
    font-size: 1.02em;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    border-radius: 10px;
    color: var(--muted);
    border: 1px solid transparent;
}

.tab-button:hover {
    background: #ebf0fb;
    color: var(--text);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 22px rgba(92, 110, 230, 0.28);
}

.tab-button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-next:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.35);
    outline-offset: 2px;
}

.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section {
    margin: 0 auto 34px;
    max-width: 980px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 28px rgba(22, 38, 73, 0.08);
}

.section h2 {
    color: var(--primary-dark);
    font-size: 1.72em;
    margin-bottom: 18px;
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

.definition-box {
    background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface-soft-2) 100%);
    padding: 22px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f8;
    border-left: 5px solid #5d7ae7;
    box-shadow: 0 8px 18px rgba(31, 50, 84, 0.08);
}

.definition-box h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.definition-box p {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 8px;
}

.definition-box strong {
    color: var(--primary-dark);
}

.demo-container {
    display: flex;
    gap: 24px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
    background: linear-gradient(180deg, #f7f9ff 0%, #f3f6ff 100%);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #dfe6f7;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

#demoTriangle {
    width: 62%;
    max-width: 620px;
    height: auto;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 14px 28px rgba(34, 56, 102, 0.12);
}

.demo-explanation {
    background: white;
    padding: 20px 18px;
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(34, 56, 102, 0.12);
    width: 38%;
    min-width: 280px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.demo-explanation p {
    font-size: 1.05em;
    margin-bottom: 10px;
    font-weight: 600;
}

.color-angle { color: #e74c3c; }
.color-adjacent { color: #3498db; }
.color-oppose { color: #e67e22; }
.color-hypotenuse { color: #2ecc71; }

.tips-box {
    background: #fff3cd;
    padding: 20px;
    border-radius: 12px;
    border-left: 5px solid #ffc107;
}

.tips-box p {
    font-size: 1.1em;
    margin-bottom: 12px;
    line-height: 1.6;
}

.formula-box {
    background: linear-gradient(180deg, #edf6ff 0%, #e7f2ff 100%);
    padding: 24px;
    border-radius: 12px;
    border-left: 5px solid #3498db;
    margin-bottom: 20px;
}

.formula-box p {
    font-size: 1.25em;
    margin-bottom: 12px;
    font-weight: 600;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    text-align: center;
    vertical-align: middle;
    margin: 0 5px;
}

.fraction > span:first-child {
    border-bottom: 2px solid #333;
    padding-bottom: 3px;
}

.fraction > span:last-child {
    padding-top: 3px;
}

.score-board {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 30px;
    box-shadow: 0 14px 28px rgba(46, 56, 128, 0.24);
}

.exercise-container {
    background: linear-gradient(180deg, #f9faff 0%, #f4f7ff 100%);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #dfe6f7;
}

#triangleContainer {
    text-align: center;
    margin-bottom: 30px;
}

#exerciseTriangle {
    background: white;
    border-radius: 12px;
    box-shadow: 0 14px 26px rgba(34, 56, 102, 0.12);
}

.triangle-side {
    cursor: pointer;
    transition: all 0.2s;
}

.triangle-side:hover {
    stroke-width: 8 !important;
    filter: brightness(1.2);
}

.question-box {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 12px 24px rgba(34, 56, 102, 0.12);
}

.question-box h3 {
    font-size: 1.55em;
    color: #2c3e50;
    margin-bottom: 20px;
}

.feedback {
    font-size: 1.3em;
    font-weight: 600;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

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

.btn-primary, .btn-secondary, .btn-next {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 18px rgba(92, 110, 230, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(102, 126, 234, 0.35);
}

.btn-secondary {
    background: linear-gradient(135deg, #6f7b8b 0%, #606b79 100%);
    color: white;
    box-shadow: 0 8px 16px rgba(70, 82, 99, 0.26);
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-next {
    background: linear-gradient(135deg, #2cbf6d 0%, #1f9e59 100%);
    color: white;
    margin-top: 15px;
    box-shadow: 0 8px 16px rgba(32, 158, 89, 0.28);
}

.btn-next:hover {
    background: #218838;
    transform: translateY(-1px);
}

.calc-exercise {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.calc-triangle-container {
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(34, 56, 102, 0.1);
}

#calcTriangle {
    max-width: 100%;
}

.calc-info {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(34, 56, 102, 0.1);
}

.triangle-data {
    font-size: 1.2em;
}

.triangle-data p {
    margin: 8px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #5f73e9;
}

.answer-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.answer-input input {
    padding: 15px;
    font-size: 1.3em;
    border: 2px solid #667eea;
    border-radius: 8px;
    width: 200px;
    text-align: center;
}

.answer-input input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.answer-input .unit {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

.help-box {
    margin-top: 30px;
    background: var(--surface-soft);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #d7ddf0;
    box-shadow: 0 10px 22px rgba(34, 56, 102, 0.08);
}

footer {
    background: linear-gradient(180deg, #f8faff 0%, #f1f5ff 100%);
    border: 1px solid #dce3f4;
    padding: 22px 26px;
    text-align: center;
    color: #4b5563;
    max-width: 1120px;
    margin: 12px auto 0;
    border-radius: 14px;
    box-shadow: 0 12px 24px rgba(31, 50, 84, 0.1);
}

.container > footer {
    margin-top: 10px;
    max-width: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
}

footer p {
    margin-bottom: 8px;
    font-weight: 600;
}

footer a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer a:last-child {
    margin-left: 2px;
}

.section a {
    color: var(--primary-dark);
    font-weight: 600;
}

.help-box h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.5em;
}

/* Ajout de styles pour rendre le site responsive */

/* Styles pour les petits écrans */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.55em;
    }

    header {
        padding: 28px 18px;
    }

    .tabs {
        flex-direction: column;
        gap: 8px;
    }

    .tab-button {
        font-size: 1em;
        padding: 12px;
    }

    .tab-content {
        padding: 18px;
    }

    .section {
        margin-bottom: 26px;
        padding: 16px;
        border-radius: 12px;
    }

    .section h2 {
        font-size: 1.4em;
    }

    .definition-box {
        padding: 15px;
    }

    .demo-container {
        flex-direction: column;
        gap: 14px;
        padding: 14px;
    }

    .demo-explanation {
        width: 100%;
        text-align: center;
        min-width: 0;
    }

    #demoTriangle {
        width: 100%;
        max-width: none;
    }

    .score-board {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .exercise-container {
        padding: 15px;
    }

    .question-box {
        font-size: 1em;
    }

    .btn-primary, .btn-secondary, .btn-next {
        font-size: 1em;
        padding: 10px 20px;
    }

    .answer-input {
        flex-direction: column;
        gap: 10px;
    }

    .answer-input input {
        width: 100%;
    }

    .help-box {
        font-size: 1em;
    }

    footer {
        padding: 18px 14px;
        font-size: 0.95em;
        border-radius: 12px;
    }
}

/* Ajustements pour l'exemple interactif sur mobile */
@media (max-width: 768px) {
    #demoTriangle {
        width: 100%;
        height: auto;
    }

    .demo-explanation {
        width: 100%;
        text-align: center;
    }
}

/* Ajustements pour les triangles des exercices sur mobile */
@media (max-width: 768px) {
    #exerciseTriangle {
        width: 100%;
        height: auto;
    }

    .exercise-container {
        padding: 15px;
    }

    .question-box {
        font-size: 1em;
        padding: 15px;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
    }
}
