:root {
    --portal-ink: #1d2234;
    --portal-ink-soft: #5b647c;
    --portal-bg: #f4f8ff;
    --portal-surface: #ffffff;
    --portal-primary: #0c6dfd;
    --portal-primary-strong: #0048ad;
    --portal-accent: #ff9f1a;
    --portal-accent-strong: #db7e00;
    --portal-success: #1b9c6b;
    --portal-danger: #cc3d4a;
    --portal-border: #d9e0f2;
    --shadow-soft: 0 14px 40px rgba(20, 47, 120, 0.1);
    --shadow-hard: 0 20px 60px rgba(17, 31, 78, 0.18);
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--portal-ink);
    background:
        radial-gradient(850px 400px at 8% -15%, rgba(12, 109, 253, 0.2), transparent 60%),
        radial-gradient(700px 320px at 92% -18%, rgba(255, 159, 26, 0.2), transparent 58%),
        linear-gradient(180deg, #f7f9ff 0%, #edf3ff 100%);
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", sans-serif;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: "Georgia", "Times New Roman", serif;
    letter-spacing: 0.01em;
}

a {
    color: var(--portal-primary-strong);
    text-decoration: none;
}

a:hover {
    color: var(--portal-primary);
}

code,
pre {
    font-family: "Courier New", Courier, monospace;
}

.portal-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
    background: linear-gradient(135deg, rgba(8, 57, 143, 0.94), rgba(12, 109, 253, 0.9));
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.portal-header .navbar-brand,
.portal-header .nav-link {
    color: #f8fbff;
}

.portal-header .nav-link {
    font-weight: 600;
    opacity: 0.92;
}

.portal-header .nav-link:hover,
.portal-header .nav-link.is-active {
    opacity: 1;
    color: #ffffff;
}

.portal-main {
    position: relative;
}

.portal-main::before,
.portal-main::after {
    content: "";
    position: fixed;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    pointer-events: none;
    z-index: -1;
}

.portal-main::before {
    bottom: 20%;
    left: -80px;
    background: radial-gradient(circle, rgba(12, 109, 253, 0.22), transparent 70%);
}

.portal-main::after {
    top: 30%;
    right: -90px;
    background: radial-gradient(circle, rgba(255, 159, 26, 0.22), transparent 70%);
}

.portal-footer {
    background: #1f2a49;
    color: #e2e8fb;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-panel {
    border-radius: var(--radius-lg);
    background:
        linear-gradient(145deg, rgba(16, 74, 176, 0.95), rgba(10, 118, 212, 0.95));
    color: #f7fbff;
    box-shadow: var(--shadow-hard);
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "";
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 72%);
    top: -120px;
    right: -90px;
}

.hero-kicker {
    letter-spacing: 0.16em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.84);
}

.hero-panel .lead {
    max-width: 65ch;
}

.hero-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.hero-stat-card {
    padding: 0.9rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hero-stat-value {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
}

.hero-stat-label {
    font-size: 0.78rem;
    opacity: 0.95;
}

.section-head h2 {
    color: #111f42;
}

.grade-card,
.arch-card,
.exercise-card,
.filter-panel,
.counter-panel,
.question-stage,
.exercise-shell-head,
.media-table-wrap,
.prompt-pre,
.accordion-item,
.error-wrap,
.exercise-shell,
.ai-assistant-panel {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

.grade-card,
.arch-card,
.exercise-card,
.counter-panel {
    padding: 1rem;
}

.grade-card {
    position: relative;
    overflow: hidden;
}

.grade-card::after {
    content: "";
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 999px;
    right: -70px;
    top: -70px;
    background: radial-gradient(circle, rgba(12, 109, 253, 0.14), transparent 70%);
}

.arch-card ul,
.grade-card ul {
    padding-left: 1rem;
}

.media-table-wrap {
    padding: 0.3rem;
}

.table-portal {
    margin: 0;
}

.table-portal thead th {
    background: #ebf2ff;
    color: #1f3569;
    border-bottom-color: #ccd8f7;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table-portal td,
.table-portal th {
    vertical-align: top;
}

.prompt-code {
    display: inline-block;
    white-space: normal;
    background: #f3f7ff;
    border: 1px dashed #bfd1f7;
    border-radius: 8px;
    padding: 0.25rem 0.4rem;
    font-size: 0.76rem;
    color: #1f396f;
}

.prompt-pre {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 1rem;
    background: #fbfdff;
    border-left: 5px solid var(--portal-accent);
    margin-bottom: 0;
}

.accordion-item {
    overflow: hidden;
}

.accordion-button {
    font-weight: 700;
    color: #1d2f62;
}

.accordion-button:not(.collapsed) {
    background: #edf3ff;
    color: #173b86;
}

.filter-panel {
    border-left: 5px solid var(--portal-primary);
}

.filter-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.domain-chip {
    font-weight: 700;
    border-width: 1px;
}

.domain-chip.is-active {
    box-shadow: inset 0 0 0 1px rgba(17, 37, 74, 0.14);
}

.domain-chip--calcul {
    border-color: #b8d8ff;
    color: #115ea9;
    background: #eaf4ff;
}

.domain-chip--numeration {
    border-color: #ffd8a3;
    color: #8c5800;
    background: #fff5e7;
}

.domain-chip--geometrie {
    border-color: #bde9cc;
    color: #156f4a;
    background: #ecfaf1;
}

.exercise-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.exercise-card--calcul {
    border-top: 4px solid #2d84f4;
}

.exercise-card--numeration {
    border-top: 4px solid #eea62f;
}

.exercise-card--geometrie {
    border-top: 4px solid #28a069;
}

.exercise-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 50px rgba(18, 40, 95, 0.16);
}

.exercise-icon {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    background: linear-gradient(145deg, var(--portal-primary), #48a3ff);
}

.exercise-card--numeration .exercise-icon {
    background: linear-gradient(145deg, #d9901c, #ffbe4f);
}

.exercise-card--geometrie .exercise-icon {
    background: linear-gradient(145deg, #13885c, #45bf8f);
}

.domain-badge {
    font-weight: 700;
}

.domain-badge--calcul {
    color: #115ea9;
    background: #eaf4ff;
}

.domain-badge--numeration {
    color: #8c5800;
    background: #fff5e7;
}

.domain-badge--geometrie {
    color: #156f4a;
    background: #ecfaf1;
}

.exercise-shell {
    padding: 1rem;
}

.exercise-shell-head {
    background: linear-gradient(145deg, #f6f9ff, #edf4ff);
}

.exercise-shell-meta {
    background: #ffffff;
    border: 1px solid #d6e2fb;
    border-radius: 12px;
    padding: 0.85rem;
}

.exercise-app {
    animation: fadeInUp 0.45s ease;
}

.question-stage {
    border-top: 4px solid var(--portal-primary);
}

.timer-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: #edf3ff;
    color: #234f9f;
    font-weight: 700;
}

.timer-wrap.is-off {
    opacity: 0.6;
}

.question-instruction {
    color: #273f77;
    font-weight: 700;
}

.question-equation {
    font-size: clamp(1.45rem, 2.2vw, 2rem);
    font-weight: 800;
    color: #0f2f74;
}

.question-visual {
    min-height: 120px;
    border-radius: 12px;
    border: 1px dashed #bfd1f7;
    background: #f7faff;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.geometry-canvas-stage {
    width: min(100%, 760px);
    margin: 0 auto;
}

.geometry-canvas {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid #bfd1f7;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(191, 209, 247, 0.45);
}

.geometry-canvas-hint {
    margin: 0.55rem 0 0;
    font-size: 0.86rem;
    color: #39568f;
    font-weight: 600;
}

/* Ruler Measure Canvas */
.ruler-measure-canvas {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
    background: #ffffff;
    border: 1px solid #c9d8fa;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(191, 209, 247, 0.45);
}

.ruler-drag-canvas {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #c9d8fa;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(191, 209, 247, 0.45);
    cursor: pointer;
    touch-action: none;
}

.visual-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.visual-pill {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.55rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #c9d8fa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #214381;
}

.visual-pill.is-selectable {
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.visual-pill.is-selectable:hover {
    transform: translateY(-1px);
    border-color: #8fb3f4;
}

.visual-pill.is-selected {
    background: #dbeafe;
    border-color: #6ea0f6;
    color: #143a86;
}

.visual-pill--choice {
    gap: 0.4rem;
    padding: 0.2rem 0.75rem 0.2rem 0.4rem;
    height: auto;
    min-height: 2.4rem;
}

.visual-pill__icon {
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #214381;
    background: #eef3ff;
    border-radius: 50%;
}

.visual-pill__icon svg {
    width: 1.15rem;
    height: 1.15rem;
}

.visual-pill__label {
    font-weight: 700;
    font-size: 0.92rem;
}

.visual-pill.is-selected .visual-pill__icon {
    background: #cfe0ff;
}

.shape-target-canvas {
    display: block;
    margin: 0 auto 0.75rem;
    background: #f7f9ff;
    border: 1px solid #c9d8fa;
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(191, 209, 247, 0.5);
}

.visual-pill.is-crossed {
    background: #ffe9ec;
    border-color: #f5b8c0;
    color: #a73344;
    text-decoration: line-through;
}

.visual-eq {
    font-size: 1.4rem;
    font-weight: 800;
    color: #143a86;
    margin: 0 0.4rem;
}

.visual-column {
    border-collapse: collapse;
    font-weight: 800;
    font-size: 1.3rem;
}

.visual-column td {
    padding: 0.15rem 0.35rem;
    text-align: right;
}

.visual-column .line {
    border-top: 2px solid #264f9b;
}

.visual-card {
    border: 1px solid #cedaf4;
    border-radius: 12px;
    background: #fff;
    padding: 0.65rem 0.8rem;
    min-width: 150px;
    max-width: 100%;
}

.abacus-stage {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid #cedaf4;
    border-radius: 12px;
    background: #fff;
    max-width: 100%;
    align-items: stretch;
}

.abacus-rod {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.abacus-label {
    width: 2rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: #214381;
    text-align: center;
    flex-shrink: 0;
}

.abacus-track {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 2.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #e8c8a0 0%, #d4a574 35%, #b88350 65%, #a07040 100%);
    border: 1px solid #8a5e32;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.abacus-bead-wrap {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.abacus-bead {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.abacus-bead.is-removable {
    cursor: pointer;
    position: relative;
}

.abacus-bead.is-removable:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 3px rgba(204, 61, 74, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.08), 0 3px 8px rgba(0, 0, 0, 0.18);
}

.abacus-bead.is-removable:hover::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 2px;
    background: rgba(180, 40, 50, 0.75);
    transform: translate(-50%, -50%) rotate(45deg);
    border-radius: 1px;
    pointer-events: none;
}

.abacus-add-btn {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: 2px dashed #8a5e32;
    background: rgba(255, 255, 255, 0.6);
    color: #6b4620;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
    line-height: 1;
    padding: 0;
}

.abacus-add-btn:hover:not(:disabled) {
    background: #fff;
    border-style: solid;
    border-color: #6b4620;
    color: #4a2e15;
    transform: scale(1.1);
}

.abacus-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.abacus-bead--c {
    background: #ff8fa3;
}

.abacus-bead--d {
    background: #6ea0f6;
}

.abacus-bead--u {
    background: #6fdcbd;
}

.visual-frac-bars-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.visual-frac-bar {
    width: min(320px, 100%);
    display: grid;
    grid-template-columns: repeat(var(--parts, 6), 1fr);
    gap: 2px;
}

.visual-frac-cell {
    height: 22px;
    border-radius: 4px;
    background: #e3ebff;
}

.visual-frac-cell.is-filled {
    background: #5b8cff;
}

.visual-frac-cell.is-removed {
    background: #ffcfd5;
}

.visual-frac-cell.is-added {
    background: #c5f4da;
}

.feedback-box {
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.feedback-box.is-info {
    background: #eef4ff;
    border-color: #bfd2fa;
    color: #21498b;
}

.feedback-box.is-success {
    background: #e8fff2;
    border-color: #b7f1ce;
    color: #0c6f47;
}

.feedback-box.is-error {
    background: #ffecef;
    border-color: #f5bdc7;
    color: #9e2d3e;
}

.feedback-box.is-warning {
    background: #fff7e8;
    border-color: #f6d69f;
    color: #9a6200;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
}

.control-btn {
    min-height: 46px;
    font-weight: 700;
}

.numeric-pad-panel {
    border: 1px solid #cdd9f7;
    border-radius: 12px;
    background: #f6f9ff;
    padding: 0.55rem;
}

.numeric-pad-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.numeric-pad-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
}

.numeric-pad-key {
    min-height: 42px;
    border: 1px solid #c9d7f8;
    border-radius: 10px;
    background: #fff;
    color: #173f88;
    font-weight: 800;
}

.numeric-pad-key:hover,
.numeric-pad-key:focus {
    background: #ebf2ff;
    border-color: #9ab7f5;
    color: #0f3578;
}

.numeric-pad-key[data-numpad-key="backspace"] {
    grid-column: span 3;
}

.word-pad-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
}

.word-pad-key {
    min-height: 42px;
    border: 1px solid #c9d7f8;
    border-radius: 10px;
    background: #fff;
    color: #173f88;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.25rem 0.35rem;
    text-transform: none;
}

.word-pad-key:hover,
.word-pad-key:focus {
    background: #ebf2ff;
    border-color: #9ab7f5;
    color: #0f3578;
}

.word-pad-key-wide {
    grid-column: span 2;
}

.counter-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.counter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed #d8e2fa;
}

.counter-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.counter-label {
    font-size: 0.88rem;
    color: #3f4f78;
}

.counter-value {
    font-weight: 800;
    color: #123f90;
}

.media-mini-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 250px;
    overflow: auto;
    padding-right: 0.25rem;
}

.media-mini-item {
    padding: 0.55rem;
    border-radius: 10px;
    background: #f7f9ff;
    border: 1px dashed #ccd8f7;
}

.btn-portal-primary {
    background: linear-gradient(145deg, var(--portal-primary), #2f8cff);
    border: none;
    color: #fff;
    font-weight: 700;
}

.btn-portal-primary:hover,
.btn-portal-primary:focus {
    color: #fff;
    background: linear-gradient(145deg, var(--portal-primary-strong), var(--portal-primary));
}

.btn-portal-secondary {
    background: linear-gradient(145deg, #fff9f0, #ffe7bf);
    border: 1px solid #ffc96a;
    color: #7c4a00;
    font-weight: 700;
}

.btn-portal-secondary:hover,
.btn-portal-secondary:focus {
    color: #693d00;
    border-color: #f2b748;
    background: linear-gradient(145deg, #fff2db, #ffdca1);
}

.ai-assistant-btn {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    color: #fff;
    background: linear-gradient(145deg, #0c6dfd, #0e58c8);
    box-shadow: 0 14px 32px rgba(15, 72, 168, 0.35);
    z-index: 1080;
}

.ai-assistant-btn:hover {
    transform: translateY(-2px);
}

.ai-assistant-panel {
    position: fixed;
    right: 1rem;
    bottom: 5.2rem;
    width: min(420px, calc(100vw - 2rem));
    padding: 0.85rem;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    z-index: 1080;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-assistant-panel.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.error-wrap {
    padding: 2rem;
}

[data-reveal] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

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

@media (max-width: 1199.98px) {
    .control-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .portal-header {
        position: static;
    }

    .hero-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .control-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .question-equation {
        font-size: 1.3rem;
    }

    .ai-assistant-btn {
        width: 52px;
        height: 52px;
        bottom: 0.8rem;
        right: 0.8rem;
    }

    .ai-assistant-panel {
        right: 0.8rem;
        bottom: 4.7rem;
    }
}

/* Answer fields (U D C) */
.answer-fields-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    justify-content: center;
}

.answer-field-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.answer-field-label {
    font-weight: 800;
    font-size: 1rem;
    color: #214381;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.answer-field-input {
    width: 80px;
    height: 64px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f2f74;
    border: 2px solid #c9d8fa;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: inset 0 2px 4px rgba(20, 58, 134, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    caret-color: transparent;
}

.answer-field-input:focus {
    outline: none;
    border-color: #0c6dfd;
    box-shadow: 0 0 0 3px rgba(12, 109, 253, 0.18);
}

.answer-field-input.is-active {
    border-color: #0c6dfd;
    background: #f0f6ff;
}

@media (max-width: 767.98px) {
    .answer-field-input {
        width: 70px;
        height: 56px;
        font-size: 1.5rem;
    }
}

/* Unit Choice - Cases cliquables pour choix d'unité */
.unit-choice-card {
    padding: 1.25rem;
    text-align: center;
}

.unit-family-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.unit-choice-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.unit-choice-btn {
    min-width: 80px;
    min-height: 56px;
    padding: 0.5rem 1rem;
    border: 2px solid #c9d8fa;
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff, #f7f9ff);
    color: #214381;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(20, 58, 134, 0.08);
}

.unit-choice-btn:hover {
    transform: translateY(-2px);
    border-color: #8fb3f4;
    background: linear-gradient(145deg, #ffffff, #eef3ff);
    box-shadow: 0 4px 12px rgba(20, 58, 134, 0.15);
}

.unit-choice-btn:active {
    transform: translateY(0);
}

.unit-choice-btn.is-selected {
    background: linear-gradient(145deg, #0c6dfd, #0e58c8);
    border-color: #0c6dfd;
    color: #fff;
    box-shadow: 0 4px 16px rgba(12, 109, 253, 0.35);
}

@media (max-width: 767.98px) {
    .unit-choice-btn {
        min-width: 70px;
        min-height: 48px;
        font-size: 1rem;
    }
}

/* Unit Conversion Reference - Mini tableau dans unit_choice */
.unit-conversion-reference {
    margin-top: 1rem;
    padding: 0.75rem;
    background: linear-gradient(145deg, #f7f9ff, #eef3ff);
    border: 1px solid #d9e0f2;
    border-radius: 10px;
    text-align: center;
}

.unit-conversion-reference-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--portal-primary-strong);
    margin-bottom: 0.5rem;
}

.unit-conversion-reference-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    table-layout: fixed;
}

.unit-conversion-reference-table th {
    background: #ffffff;
    border: 1px solid #c9d8fa;
    border-radius: 6px;
    padding: 0.5rem 0.25rem;
    font-size: 0.9rem;
    color: var(--portal-ink);
    font-weight: 600;
}

.unit-conversion-reference-hint {
    font-size: 0.75rem;
    color: var(--portal-ink-soft);
    padding-top: 0.25rem;
}

@media (max-width: 767.98px) {
    .unit-conversion-reference-table th {
        font-size: 0.8rem;
        padding: 0.4rem 0.15rem;
    }
}

/* Conversion Table Interactive - Glisser-déposer par clic */
.conversion-table-container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
}

.conversion-source-display {
    text-align: center;
    padding: 1rem;
    margin-bottom: 1rem;
    background: linear-gradient(145deg, #f6f9ff, #edf4ff);
    border-radius: 12px;
    border: 2px solid #c9d8fa;
}

.source-label {
    font-size: 0.95rem;
    color: #5b647c;
    margin-right: 0.5rem;
}

.source-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f2f74;
}

.conversion-digits-pool {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #ffffff;
    border-radius: 12px;
    border: 2px dashed #c9d8fa;
}

.digits-label {
    font-size: 0.9rem;
    color: #5b647c;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.digits-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.conversion-digit-tile {
    min-width: 50px;
    height: 50px;
    border: 2px solid #c9d8fa;
    border-radius: 10px;
    background: linear-gradient(145deg, #ffffff, #f7f9ff);
    color: #214381;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(20, 58, 134, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.conversion-digit-tile:hover:not(.is-placed) {
    transform: translateY(-2px);
    border-color: #8fb3f4;
    background: linear-gradient(145deg, #ffffff, #eef3ff);
    box-shadow: 0 4px 12px rgba(20, 58, 134, 0.15);
}

.conversion-digit-tile.is-selected {
    background: linear-gradient(145deg, #0c6dfd, #0e58c8);
    border-color: #0c6dfd;
    color: #fff;
    box-shadow: 0 4px 16px rgba(12, 109, 253, 0.35);
    transform: translateY(-2px);
}

.conversion-digit-tile.is-placed {
    background: #e8ecf5;
    border-color: #d0d8e8;
    color: #9aa5b8;
    cursor: not-allowed;
    opacity: 0.6;
}

.conversion-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.conversion-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    table-layout: fixed;
}

.conversion-table-header th {
    background: linear-gradient(145deg, #0c6dfd, #0e58c8);
    color: #fff;
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    border-radius: 8px;
    text-transform: lowercase;
}

.conversion-table-units td {
    background: #f0f4ff;
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    color: #214381;
    border-radius: 6px;
}

.conversion-table-values td {
    height: 60px;
    background: #ffffff;
    border: 2px dashed #c9d8fa;
    border-radius: 8px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: #214381;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.conversion-table-values td:hover {
    border-color: #8fb3f4;
    background: #f7faff;
}

.conversion-table-values td.is-filled {
    border-style: solid;
    border-color: #0c6dfd;
    background: #e8f1ff;
    color: #0c6dfd;
}

.conversion-table-values td.is-filled:hover {
    border-color: #cc3d4a;
    background: #fff0f2;
    color: #cc3d4a;
}

.conversion-table-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #5b647c;
    margin-top: 1rem;
    font-style: italic;
}

@media (max-width: 767.98px) {
    .conversion-table-container {
        padding: 0.5rem;
    }

    .conversion-table-header th {
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }

    .conversion-table-units td {
        font-size: 0.75rem;
    }

    .conversion-table-values td {
        height: 50px;
        font-size: 1.3rem;
    }

    .conversion-digit-tile {
        min-width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .source-value {
        font-size: 1.2rem;
    }
}

.grid-selection-stage {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
}

.grid-selection-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.grid-selection-box {
    width: 80px;
    height: 80px;
    border: 2px solid var(--portal-border);
    border-radius: var(--radius-md);
    background: var(--portal-surface);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--portal-ink);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(20, 47, 120, 0.06);
}

.grid-selection-box:hover {
    border-color: #8fb3f4;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(20, 47, 120, 0.1);
}

.grid-selection-box.is-selected {
    background: linear-gradient(145deg, #dbeafe, #c3dafe);
    border-color: #6ea0f6;
    color: var(--portal-primary-strong);
}

.grid-selection-box.is-correct {
    background: linear-gradient(145deg, #d1f7e9, #a8ebc6);
    border-color: #1b9c6b;
    color: #0a5c3e;
}

.grid-selection-box.is-wrong {
    background: linear-gradient(145deg, #ffe0e3, #ffc0c5);
    border-color: #cc3d4a;
    color: #8a1c28;
}

.grid-selection-box:disabled {
    cursor: default;
}

.choice-buttons-stage {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.choice-button {
    min-width: 120px;
    min-height: 64px;
    border: 2px solid var(--portal-border);
    border-radius: 12px;
    background: #fff;
    color: var(--portal-text);
    font-weight: 700;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 6px rgba(20, 47, 120, 0.06);
}

.choice-button:hover {
    border-color: #8fb3f4;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(20, 47, 120, 0.1);
}

.choice-button.is-selected {
    background: linear-gradient(145deg, #dbeafe, #c3dafe);
    border-color: #6ea0f6;
    color: var(--portal-primary-strong);
}

.choice-button.is-correct {
    background: linear-gradient(145deg, #d1f7e9, #a8ebc6);
    border-color: #1b9c6b;
    color: #0a5c3e;
}

.choice-button:disabled {
    cursor: default;
    opacity: 0.9;
}

.xy-selector-stage {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.xy-selector-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.xy-selector-label {
    font-weight: 600;
    color: var(--portal-primary-strong);
    min-width: 6.5rem;
    font-size: 0.95rem;
}

.xy-selector-box {
    min-width: 2.4rem;
    min-height: 2.4rem;
    border: 2px solid var(--portal-border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--portal-text);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(20, 47, 120, 0.06);
}

.xy-selector-box:hover {
    border-color: #8fb3f4;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(20, 47, 120, 0.1);
}

.xy-selector-box.is-selected {
    background: linear-gradient(145deg, #dbeafe, #c3dafe);
    border-color: #6ea0f6;
    color: var(--portal-primary-strong);
}

.xy-selector-box.is-correct {
    background: linear-gradient(145deg, #d1f7e9, #a8ebc6);
    border-color: #1b9c6b;
    color: #0a5c3e;
}

.xy-selector-box.is-wrong {
    background: linear-gradient(145deg, #ffe0e3, #ffc0c5);
    border-color: #cc3d4a;
    color: #8a1c28;
}

.xy-selector-box:disabled {
    cursor: default;
    opacity: 0.9;
}

/* Legal / Mentions legales */
.legal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem;
}

.legal-card ul li {
    padding: 0.2rem 0;
}

.legal-card p {
    color: var(--portal-ink-soft);
}

/* Contact form */
.contact-form-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
}

.contact-form-card .form-control {
    border: 1.5px solid var(--portal-border);
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.contact-form-card .form-control:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(12, 109, 253, 0.15);
}

.contact-antispam {
    background: linear-gradient(145deg, #fff9f0, #ffe7bf);
    border: 1px solid #ffc96a;
    border-radius: 12px;
    padding: 1rem;
}

.contact-antispam .form-control {
    max-width: 120px;
    display: inline-block;
    margin-left: 0.5rem;
}

.contact-info-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem;
}

.contact-info-card li {
    padding: 0.25rem 0;
}

.contact-info-detail p,
.contact-info-response p,
.contact-info-privacy p {
    line-height: 1.5;
}

/* Footer links */
.footer-link {
    color: #c4d4f8;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

.footer-divider {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Ferme mystère - pastilles de légende */
.ferme-peg {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ferme-peg--exact {
    background: #22c55e;
}

.ferme-peg--present {
    background: #f59e0b;
}

.ferme-peg--none {
    background: #cbd5e1;
}

/* Toc Toc - Jeu de morpion */
.toc-toc-game-wrap {
    max-width: 580px;
    margin: 0 auto;
}

.toc-toc-toolbar {
    align-items: center;
}

.toc-toc-level-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-toc-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--portal-ink-soft);
}

.toc-toc-status {
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.toc-toc-status .badge {
    font-size: 0.95rem;
    padding: 0.45em 0.7em;
}

.toc-toc-status-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--portal-ink);
}

.toc-toc-canvas-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
}

.toc-toc-canvas {
    width: 100%;
    max-width: 540px;
    height: auto;
    display: block;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(20, 47, 120, 0.12);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.toc-toc-scoreboard .toc-toc-stat-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.toc-toc-stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--portal-primary-strong);
    line-height: 1;
}

.toc-toc-stat-label {
    font-size: 0.78rem;
    color: var(--portal-ink-soft);
    font-weight: 600;
}

@media (max-width: 575.98px) {
    .toc-toc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toc-toc-level-group {
        justify-content: center;
    }

    .toc-toc-canvas {
        border-radius: 12px;
    }

    .toc-toc-stat-value {
        font-size: 1.2rem;
    }

    .toc-toc-status-text {
        font-size: 1.05rem;
    }
}
