:root {
    --bleu:       #00c2ee;
    --bleu-fonce: #1d1379;
    --or:         #c1b26c;
    --rouge:      #b71414;
    --vert:       #1a8a4a;
    --gris-clair: #e8eef2;
    --texte:      #2c3e50;
    --blanc:      #ffffff;
    --fond-page:  #f0f4f8;
    --illegal-bg: #ffe8e8;
    --illegal-border: #e74c3c;
    --interdit-bg: #e8eaff;
    --interdit-border: #3b5bdb;
}

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

body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--fond-page);
    color: var(--texte);
    min-height: 100vh;
}

/* ── HEADER ─────────────────────────────────────── */
header {
    background: linear-gradient(135deg, var(--bleu-fonce) 0%, #0a3d7a 60%, #0d5fa0 100%);
    padding: 18px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo img { height: 48px; filter: brightness(0) invert(1); }

.header-title { flex: 1; text-align: center; }
.header-title h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--blanc);
    letter-spacing: 1px;
}
.header-title .subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 2px;
}

.header-nav { display: flex; gap: 8px; align-items: center; }
.nav-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: var(--blanc);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Source Sans 3', sans-serif;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }

/* ── TIMER DANS LE HEADER ───────────────────────── */
.header-chrono {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 4px 16px;
    position: relative;
    cursor: default;
}
/* ── Tooltip sur le timer ──────────────────────── */
.header-chrono::before,
.header-chrono::after {
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}
.header-chrono::before {
    content: '';
    top: calc(100% + 6px);
    border: 6px solid transparent;
    border-bottom-color: rgba(13,15,40,0.92);
}
.header-chrono::after {
    content: attr(data-tip);
    top: calc(100% + 17px);
    background: rgba(13,15,40,0.92);
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.header-chrono:hover::before,
.header-chrono:hover::after { opacity: 1; }
.header-chrono .chrono-label {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 1px;
}
header #chronoDisplay {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blanc);
    letter-spacing: 2px;
    min-width: 72px;
    text-align: center;
    transition: color .3s;
}
header #chronoDisplay.warning { color: #f39c12; animation: none; }
header #chronoDisplay.danger  { color: #ff6b6b; animation: pulse .6s infinite; }

.header-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 4px 16px;
}
.header-score .chrono-label {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 1px;
}
#adjustedScoreDisplay {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blanc);
    min-width: 72px;
    text-align: center;
    transition: color .3s;
}

/* ── CHRONOMÈTRE ─────────────────────────────────── */
.chrono-bar {
    max-width: 1100px;
    margin: 20px auto 0;
    padding: 0 24px;
}
.chrono-card {
    background: var(--blanc);
    border-radius: 12px;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    gap: 16px;
    flex-wrap: wrap;
}
.chrono-left { display: flex; align-items: center; gap: 12px; }
.chrono-icon { font-size: 1.4rem; }
.chrono-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
}
#chronoDisplay {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--bleu-fonce);
    letter-spacing: 2px;
    min-width: 90px;
    text-align: center;
    transition: color .3s;
}
#chronoDisplay.warning { color: #e67e22; }
#chronoDisplay.danger  { color: var(--rouge); animation: pulse .6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.penalty-badge {
    background: #fff3cd;
    border: 1px solid #e67e22;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #c0392b;
    display: none;
}
.penalty-badge.visible { display: inline-block; }

/* ── IDENTITÉ ────────────────────────────────────── */
.identity-bar {
    max-width: 1100px;
    margin: 12px auto 0;
    padding: 0 24px;
}
.identity-card {
    background: var(--blanc);
    border-radius: 12px;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}
.identity-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}
.identity-field label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7f8c8d;
    white-space: nowrap;
}
.identity-field input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--gris-clair);
    border-radius: 8px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9rem;
    color: var(--bleu-fonce);
    background: #fafcfd;
    transition: border-color .2s;
}
.identity-field input:focus { outline: none; border-color: var(--bleu); }

/* ── LAYOUT PRINCIPAL ────────────────────────────── */
.main-content {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 24px;
}

/* ── BADGE SECTION ───────────────────────────────── */
.badge-section { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.badge-section .icon-badge {
    background: var(--bleu);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 1.6rem;
    line-height: 1;
}
.badge-section h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.4rem;
    color: var(--bleu-fonce);
    font-weight: 600;
}

/* ── CONTEXTE ────────────────────────────────────── */
.fond-contexte {
    background: var(--blanc);
    border-left: 5px solid var(--bleu);
    border-radius: 0 12px 12px 0;
    padding: 20px 24px;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #34495e;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 28px;
}
.fond-contexte strong { color: var(--bleu-fonce); }

/* ── GRILLE PRINCIPALE ───────────────────────────── */
.exercise-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* ── PANNEAU AFFICHE ─────────────────────────────── */
.panneau-affiche {
    background: var(--blanc);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    overflow: hidden;
}
.panneau-header {
    background: linear-gradient(90deg, var(--rouge), #c0392b);
    padding: 12px 16px;
    text-align: center;
}
.panneau-header h3 {
    font-family: 'Rajdhani', sans-serif;
    color: var(--blanc);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.panneau-body {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.panneau-body img { max-width: 100%; border-radius: 8px; }

/* ── OBJETS À TRIER ──────────────────────────────── */
.objets-panel {
    background: var(--blanc);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    overflow: hidden;
}
.objets-header {
    background: linear-gradient(90deg, var(--bleu-fonce), #1565c0);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.objets-header h3 {
    font-family: 'Rajdhani', sans-serif;
    color: var(--blanc);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.consigne-badge {
    background: rgba(255,255,255,0.2);
    color: var(--blanc);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
}

.objets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px;
    justify-content: center;
}

.draggable {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 12px;
    cursor: grab;
    border: 3px solid transparent;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.draggable:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.draggable.dragging { opacity: 0.5; cursor: grabbing; transform: scale(1.1); }
.draggable.correct  { border-color: var(--vert); box-shadow: 0 0 0 3px rgba(26,138,74,0.3); }
.draggable.incorrect{ border-color: var(--rouge); box-shadow: 0 0 0 3px rgba(183,20,20,0.3); }

/* ── ZONES DE DÉPÔT ──────────────────────────────── */
.zones-depot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.zone-depot {
    border-radius: 16px;
    min-height: 180px;
    border: 3px dashed;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    transition: all .2s;
    position: relative;
}
.zone-depot.dragover { transform: scale(1.02); }

#illegal-items { background: var(--illegal-bg); border-color: var(--illegal-border); }
#illegal-items.dragover { background: #ffd5d5; border-color: #c0392b; }
#forbidden-items { background: var(--interdit-bg); border-color: var(--interdit-border); }
#forbidden-items.dragover { background: #d0d5ff; border-color: #2d3ab0; }

.zone-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 6px 20px;
    border-radius: 20px;
    margin-bottom: 12px;
}
#illegal-items .zone-title  { background: var(--illegal-border); color: var(--blanc); }
#forbidden-items .zone-title{ background: var(--interdit-border); color: var(--blanc); }

.zone-subtitle {
    font-size: 0.78rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    text-align: center;
}
#illegal-items .zone-subtitle  { color: #922b21; }
#forbidden-items .zone-subtitle{ color: #1a237e; }

.zone-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.zone-depot .draggable { width: 72px; height: 72px; }

.drop-hint {
    font-size: 2rem;
    opacity: 0.25;
    position: absolute;
    bottom: 12px;
}

/* ── RÉSULTAT ────────────────────────────────────── */
.result-bar {
    background: var(--blanc);
    border-radius: 12px;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.result-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    color: var(--bleu-fonce);
    font-weight: 600;
}

#result {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--bleu);
    transition: color .3s;
}

.progress-mini { flex: 1; min-width: 200px; }
.progress-bar-bg {
    height: 8px;
    background: var(--gris-clair);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bleu), #0090b8);
    border-radius: 4px;
    transition: width .4s ease;
    width: 0%;
}

/* ── FOOTER ──────────────────────────────────────── */
.footer-card {
    background: var(--blanc);
    border-radius: 12px;
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    gap: 16px;
    flex-wrap: wrap;
}
.footer-copy { font-size: 0.9rem; color: #7f8c8d; font-style: italic; }
.footer-btns { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.btn-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all .2s;
}
.btn-reset { background: var(--gris-clair); color: var(--texte); }
.btn-reset:hover { background: #d5dde3; }
.btn-print { background: var(--bleu-fonce); color: var(--blanc); }
.btn-print:hover { background: #0f1a8a; }

/* ── BOÎTE DIALOGUE FIN D'EXERCICE ───────────────── */
@keyframes popIn {
    from { opacity: 0; transform: scale(0.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 15, 40, 0.6);
    backdrop-filter: blur(5px);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.dialog-overlay.active { display: flex; }
.dialog-box {
    background: var(--blanc);
    border-radius: 20px;
    max-width: 420px;
    width: 92%;
    text-align: center;
    box-shadow: 0 28px 80px rgba(13,15,40,0.4);
    animation: popIn .32s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}
.dialog-header {
    background: linear-gradient(135deg, var(--bleu-fonce) 0%, #0a3d7a 55%, #0d5fa0 100%);
    padding: 28px 32px 22px;
    position: relative;
}
.dialog-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--bleu), var(--or));
}
.dialog-icon { font-size: 2.6rem; margin-bottom: 8px; display: block; }
.dialog-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--blanc);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.dialog-body { padding: 24px 32px 28px; }
.dialog-score {
    font-family: 'Rajdhani', sans-serif;
    font-size: 3.2rem;
    font-weight: 700;
    line-height: 1;
    margin: 8px 0 6px;
}
.dialog-detail {
    font-size: 0.82rem;
    color: #7f8c8d;
    line-height: 1.65;
    margin-bottom: 22px;
}
.dialog-btns { display: flex; gap: 10px; justify-content: center; }
.btn-close-dialog {
    background: var(--gris-clair);
    color: var(--texte);
    border: none;
    padding: 11px 24px;
    border-radius: 9px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    letter-spacing: 0.5px;
}
.btn-close-dialog:hover { background: #d0d8df; }
.btn-print-dialog {
    background: linear-gradient(135deg, var(--bleu-fonce), #0d5fa0);
    color: var(--blanc);
    border: none;
    padding: 11px 24px;
    border-radius: 9px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .2s;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-print-dialog:hover { filter: brightness(1.15); }

/* ── MODAL SAISIE NOM ────────────────────────────── */
.nom-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 15, 40, 0.6);
    backdrop-filter: blur(5px);
    z-index: 600;
    align-items: center;
    justify-content: center;
}
.nom-overlay.active { display: flex; }
.nom-box {
    background: var(--blanc);
    border-radius: 20px;
    max-width: 380px;
    width: 92%;
    text-align: center;
    box-shadow: 0 28px 80px rgba(13,15,40,0.4);
    animation: popIn .32s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}
.nom-header {
    background: linear-gradient(135deg, var(--bleu-fonce) 0%, #0a3d7a 55%, #0d5fa0 100%);
    padding: 22px 32px 18px;
    position: relative;
}
.nom-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--bleu), var(--or));
}
.nom-icon  { font-size: 2rem; display: block; margin-bottom: 6px; color: white;}
.nom-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--blanc);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.nom-body { padding: 20px 28px 24px; }
.nom-subtitle {
    font-size: 0.84rem;
    color: #7f8c8d;
    margin-bottom: 14px;
    line-height: 1.5;
}
.nom-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gris-clair);
    border-radius: 9px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    color: var(--bleu-fonce);
    background: #fafcfd;
    margin-bottom: 16px;
    transition: border-color .2s, box-shadow .2s;
    text-align: center;
}
.nom-input:focus {
    outline: none;
    border-color: var(--bleu);
    box-shadow: 0 0 0 3px rgba(0,194,238,0.15);
}
.nom-btns { display: flex; gap: 10px; justify-content: center; }
.btn-nom-cancel {
    background: var(--gris-clair);
    color: var(--texte);
    border: none;
    padding: 11px 22px;
    border-radius: 9px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    letter-spacing: 0.5px;
}
.btn-nom-cancel:hover { background: #d0d8df; }
.btn-nom-confirm {
    background: linear-gradient(135deg, var(--bleu-fonce), #0d5fa0);
    color: var(--blanc);
    border: none;
    padding: 11px 22px;
    border-radius: 9px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .2s;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-nom-confirm:hover { filter: brightness(1.15); }

/* ── PRINT ───────────────────────────────────────── */
@media print {
    @page { size: A4; margin: 15mm 15mm 15mm 15mm; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    body { background: white !important; font-size: 11pt; }
    header, .main-content { display: none !important; }
    .chrono-bar, .identity-bar { display: none !important; }
    #print-sheet { display: block !important; }
}

#print-sheet { display: none; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 750px) {
    .exercise-grid { grid-template-columns: 1fr; }
    .zones-depot { grid-template-columns: 1fr; }
    .header-title h1 { font-size: 1.2rem; }
}

/* ── ICÔNES SVG INLINE ───────────────────────────────── */
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
button svg, .chrono-label svg, .penalty-badge svg { vertical-align: -2px; }
.dialog-icon svg, .nom-icon svg { display: block; margin: 0 auto; }
.icon-badge svg { display: block; }
.drop-hint svg  { display: block; }

