/* ===== MOSAIK — styles ===== */
:root {
    --bg: #11132b;
    --bg2: #1b1e3d;
    --tile1: #3a3f74;
    --tile2: #232a52;
    --card-bg: #ffffff;
    --ink: #1b1b3a;
    --muted: #8a8fb0;
    --primary: #5b6cff;
    --primary-dark: #4453d6;
    --accent: #ff9f1c;
    --ok: #28c76f;
    --bad: #ff5c5c;
    --warn: #ffb020;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0,0,0,.18);
    font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    color: var(--ink);
    background: linear-gradient(160deg, #1b1e3d, #11132b);
    min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Top bar + container (pages avec layout) */
.topbar {
    display: flex; align-items: center; padding: 12px 20px;
    background: rgba(0,0,0,.2);
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: .5px; }
.container { max-width: 920px; margin: 30px auto; padding: 0 16px; }

/* Boutons */
.btn {
    display: inline-block; cursor: pointer; border: none; border-radius: 10px;
    padding: 12px 20px; font-size: 1rem; font-weight: 700; text-decoration: none;
    transition: transform .08s ease, background .2s ease, opacity .2s; color: #fff;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #4a2c00; }
/* Par défaut adapté aux fonds clairs (cartes/panneaux) */
.btn-ghost { background: #eef0f7; color: #1b1b3a; }
.btn-ghost:hover { background: #dfe3f1; }
/* Sur les écrans sombres (plateau, accueil), version claire sur fond translucide */
.screen .btn-ghost, .home .btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.screen .btn-ghost:hover, .home .btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-big { padding: 16px 28px; font-size: 1.15rem; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }

/* Accueil */
.home { text-align: center; color: #fff; padding: 48px 0 0; }
.home-hero { max-width: 760px; margin: 0 auto; }
.home-logo {
    width: 88px; height: 88px; display: block; margin: 0 auto 18px;
    filter: drop-shadow(0 10px 24px rgba(0,0,0,.4));
    animation: home-logo-in .6s ease both;
}
@keyframes home-logo-in { from { opacity: 0; transform: translateY(-10px) scale(.9); } }
.home h1 { font-size: 3.6rem; margin: 0 0 8px; letter-spacing: 3px; }
.tagline { color: #c9cdf0; font-size: 1.3rem; margin-bottom: 34px; }
.home-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.hint { margin-top: 22px; color: #9aa0cf; }

/* Gros bouton « Rejoindre » */
.home-join { margin: 4px 0; }
.btn-join {
    padding: 22px 52px; font-size: 1.6rem; border-radius: 18px;
    box-shadow: 0 12px 30px rgba(91,108,255,.45);
    animation: join-pulse 2.4s ease-in-out infinite;
}
.btn-join:hover { background: var(--primary-dark); transform: translateY(-2px); }
@keyframes join-pulse {
    0%, 100% { box-shadow: 0 12px 30px rgba(91,108,255,.45); }
    50% { box-shadow: 0 12px 40px rgba(91,108,255,.75); }
}
@media (prefers-reduced-motion: reduce) { .btn-join { animation: none; } }

/* Accueil — « comment ça marche » */
.home-steps {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
    max-width: 900px; margin: 60px auto 0; text-align: left;
}
.step {
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius); padding: 22px 20px;
    transition: transform .15s ease, background .2s ease;
}
.step:hover { transform: translateY(-3px); background: rgba(255,255,255,.1); }
.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--primary); color: #fff; font-weight: 800; font-size: 1.1rem;
}
.step h3 { margin: 12px 0 6px; font-size: 1.1rem; color: #fff; }
.step p { margin: 0; color: #c2c7ee; font-size: .95rem; line-height: 1.55; }

/* Accueil — pied de page */
.home-footer { margin-top: 56px; padding: 24px 0 36px; color: #9aa0cf; font-size: .95rem; }
.home-footer a { color: #fff; font-weight: 700; text-decoration: none; }
.home-footer a:hover { text-decoration: underline; }
/* Accès Maître du jeu — discret */
.home-master {
    display: inline-block; margin-bottom: 18px; padding: 6px 14px;
    border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
    color: #9aa0cf !important; font-weight: 600 !important; font-size: .85rem;
    opacity: .7; transition: opacity .2s ease, border-color .2s ease;
}
.home-master:hover { opacity: 1; border-color: rgba(255,255,255,.4); text-decoration: none !important; }

@media (max-width: 680px) {
    .home h1 { font-size: 2.5rem; }
    .home-steps { grid-template-columns: 1fr; gap: 14px; margin-top: 44px; }
}

/* Cartes / formulaires */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.card-narrow { max-width: 420px; margin: 8vh auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-weight: 600; margin-top: 8px; }
.form input, .form select {
    padding: 12px; border: 2px solid #e2e5f3; border-radius: 10px; font-size: 1rem;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--primary); }
.form button { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-full { grid-column: 1 / -1; }
.alert { padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.alert-error { background: #ffe6e6; color: #b30000; }
.card-foot { margin: 18px 0 0; text-align: center; font-size: .9rem; }
.card-foot a { color: var(--primary); text-decoration: none; font-weight: 600; }
.card-foot a:hover { text-decoration: underline; }

/* Sélection des photos */
.puzzle-pick { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.puzzle-chip { cursor: pointer; border: 2px solid #e2e5f3; border-radius: 12px; padding: 8px; text-align: center; width: 150px; display: block; }
.puzzle-chip img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; background:#eee; }
.puzzle-chip span { display: block; margin-top: 6px; font-size: .9rem; font-weight: 600; }
.puzzle-chip input { margin-bottom: 6px; }

/* ===== Écrans plein écran ===== */
.screen { color: #fff; min-height: 100vh; }

/* Lobby */
.screen-lobby { display: flex; align-items: center; }
.lobby-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; width: 100%; max-width: 1200px; margin: auto; padding: 30px; align-items: center; }
.lobby-left h1 { font-size: 2.6rem; margin: 0 0 10px; }
.lobby-instr { color: #c9cdf0; font-size: 1.1rem; }
.code-box { font-size: 4.5rem; font-weight: 900; letter-spacing: 12px; background: #fff; color: var(--ink); border-radius: 16px; padding: 14px 10px; text-align: center; margin: 14px 0; }
.lobby-url { color: #9aa0cf; word-break: break-all; }
.lobby-right { text-align: center; }
.qr-box { background:#fff; display:inline-block; padding:14px; border-radius:16px; }
.qr-box img, .qr-box canvas { display:block; }
.lobby-right h2 { margin: 20px 0 10px; }
.team-list { list-style: none; padding: 0; margin: 0; max-height: 40vh; overflow-y: auto; font-size: 1.2rem; }
.team-list li { background: rgba(255,255,255,.1); border-radius: 8px; padding: 8px 14px; margin-bottom: 8px; }

/* Board (plateau projeté) */
.screen-board { display: flex; flex-direction: column; }
.board-code { font-size: 1.2rem; text-align: center; background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 14px; }
.board-timer { font-size: 2.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.board-timer.urgent { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.gauge-label { font-size: .9rem; color: #c9cdf0; }
.board-progress { font-size: 1.1rem; }
.board-finish { background: rgba(255,92,92,.2); }
.board-finish:hover { background: rgba(255,92,92,.45); }
.board-qr { background: #fff; padding: 8px; border-radius: 10px; align-self: center; }
.board-qr img, .board-qr canvas { display: block; }

/* Mise en page 3 colonnes : jauge de temps verticale (gauche) | photo (centre) | QR + code + équipes (droite) */
.board-main { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); gap: 20px; padding: 20px; min-height: 0; align-items: start; }

/* Colonne jauge de temps verticale (gauche) */
.board-gauge-col { display: flex; flex-direction: column; align-items: center; gap: 12px; height: 100%; }
.gauge-v { flex: 1; width: 28px; min-height: 200px; background: rgba(255,255,255,.18); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column-reverse; }
.gauge-v-fill { width: 100%; height: 100%; background: linear-gradient(0deg, var(--bad), var(--accent), var(--ok)); transition: height .5s linear; }

/* Colonne de droite : QR, code, liste des équipes */
.board-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; height: 100%; align-self: stretch; }

.board-grid-wrap { display: flex; flex-direction: column; align-items: center; }
.puzzle-stage { position: relative; width: 100%; max-width: 800px; aspect-ratio: 7 / 5; background: #000; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.puzzle-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tiles { position: absolute; inset: 0; display: grid; }
.tile { background: linear-gradient(135deg, var(--tile1), var(--tile2)); border: 1px solid rgba(0,0,0,.25); transition: opacity .5s ease, transform .5s ease; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.92); font-weight: 800; font-size: clamp(1rem, 2.2vw, 1.9rem); text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.tile.gone { opacity: 0; transform: scale(.85); pointer-events: none; }
.tile.selecting { background: linear-gradient(135deg, #ff9f1c, #ff7a00); color: #3a2300; box-shadow: inset 0 0 0 3px rgba(255,255,255,.5); animation: tilepulse 1.2s ease-in-out infinite; }
@keyframes tilepulse { 50% { filter: brightness(1.15); } }
.solved-banner { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(40,199,111,.95); color: #fff; font-size: 1.6rem; font-weight: 800; padding: 10px 24px; border-radius: 12px; }
.puzzle-hint { color: #c9cdf0; font-size: 1.1rem; margin-top: 14px; }
.board-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

.board-leaderboard { background: rgba(255,255,255,.06); border-radius: 14px; padding: 16px; flex: 1; min-height: 0; overflow-y: auto; }
.board-leaderboard h2 { margin: 0 0 12px; }
.leaderboard { list-style: none; padding: 0; margin: 0; }
.leaderboard li { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 1.1rem; }
.leaderboard .rank { font-weight: 900; width: 38px; }
.leaderboard .lb-name { flex: 1; font-weight: 700; }
.leaderboard .lb-stats { font-size: .85rem; color: #c9cdf0; margin-right: 8px; white-space: nowrap; }
.leaderboard .lb-score { font-variant-numeric: tabular-nums; }
.leaderboard .rank-1 { background: rgba(255,159,28,.25); }
.leaderboard .rank-2 { background: rgba(180,190,210,.2); }
.leaderboard .rank-3 { background: rgba(205,127,50,.22); }

/* Flash plein écran : mauvaise devinette d'une équipe (2 s) */
.wrong-guess-flash {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    background: rgba(10,12,30,.55); color: #fff;
    z-index: 70; pointer-events: none;
    opacity: 0; transition: opacity .2s ease;
    padding: 20px; text-align: center;
}
.wrong-guess-flash.show { opacity: 1; }
.wrong-guess-flash .wgf-team { font-size: clamp(1.2rem, 3vw, 2rem); color: #ffd98a; font-weight: 700; }
.wrong-guess-flash .wgf-msg { font-size: clamp(2rem, 7vw, 5rem); font-weight: 900; line-height: 1.1; }
.wrong-guess-flash .wgf-msg strong { color: var(--accent); }

/* Overlay victoire (écran projeté) */
.winner-overlay { position: fixed; inset: 0; background: rgba(10,12,30,.92); background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; z-index: 50; animation: fadein .4s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.winner-card { text-align: center; color: #fff; padding: 30px; }
.winner-emoji { font-size: 6rem; animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.winner-label { font-size: 1.6rem; color: #c9cdf0; margin: 6px 0; }
.winner-name { font-size: clamp(2.5rem, 9vw, 7rem); font-weight: 900; line-height: 1.05; background: linear-gradient(90deg, var(--accent), var(--ok)); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 10px 0; }
.winner-photo { font-size: 1.4rem; color: #ffd98a; margin-bottom: 24px; }

/* Résultats */
.screen-results { display: flex; align-items: center; justify-content: center; }
.results-card { background: var(--card-bg); color: var(--ink); border-radius: 18px; padding: 36px; max-width: 560px; width: 92%; box-shadow: var(--shadow); text-align: center; }
.results-card h1 { margin-top: 0; font-size: 2.2rem; }
.results-gauge { font-size: 1.15rem; }
.leaderboard-final li { color: var(--ink); background: #f2f4ff; }
.results-actions { margin-top: 22px; }
.review { margin-top: 26px; text-align: left; }
.review h2 { margin-bottom: 10px; }
.review-list { list-style: none; padding: 0; counter-reset: rev; }
.review-item { background: #f6f7ff; border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.review-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.review-statement { font-weight: 600; margin: 4px 0; color: #1b1b3a; }
.review-image { max-width: 100%; max-height: 200px; border-radius: 8px; display: block; margin: 6px 0; }
.review-answer { color: #1a8a4d; margin: 4px 0; }
.review-explain { color: #555a7a; margin: 4px 0 0; }

/* ===== Interface équipe ===== */
.team-body { background: linear-gradient(160deg, #1b1e3d, #11132b); }
.team-join { color: var(--ink); }
.team-play { color: #fff; display: flex; flex-direction: column; min-height: 100vh; }
.play-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: rgba(0,0,0,.25); }
.play-team { font-weight: 800; font-size: 1.1rem; }
.play-score { margin-left: auto; font-weight: 800; }
.play-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.play-progress { display: flex; justify-content: space-between; padding: 8px 16px; color: #c9cdf0; font-size: .9rem; }
.play-main { flex: 1; padding: 16px; display: flex; }

.panel { background: var(--card-bg); color: var(--ink); border-radius: 16px; padding: 22px; width: 100%; max-width: 560px; margin: auto; box-shadow: var(--shadow); }
.panel.center { text-align: center; }
.big-emoji { font-size: 3.5rem; margin: 6px 0; }

.ex-theme { display: inline-block; background: #eef0ff; color: var(--primary-dark); font-weight: 700; padding: 5px 12px; border-radius: 20px; font-size: .85rem; }
.ex-statement { font-size: 1.35rem; font-weight: 600; line-height: 1.45; margin: 16px 0; }
.ex-choices { display: grid; gap: 10px; }
.choice { text-align: left; background: #f4f6ff; border: 2px solid #e2e5f3; color: var(--ink); border-radius: 12px; padding: 14px 16px; font-size: 1.1rem; cursor: pointer; transition: all .15s; }
.choice:hover { border-color: var(--primary); }
.choice.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.ex-numeric input { width: 100%; padding: 14px; font-size: 1.3rem; border: 2px solid #e2e5f3; border-radius: 12px; }
#submitBtn { width: 100%; margin-top: 16px; }

/* Modale plein écran (feedback réussite/correction) — disparaît au clic */
.modal {
    position: fixed; inset: 0; background: rgba(10,12,30,.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 80; cursor: pointer; padding: 20px;
    animation: fadein .15s ease;
}
.modal-card {
    background: #fff; color: #1b1b3a; border-radius: 16px;
    padding: 26px 22px; max-width: 520px; width: 100%; text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,.4);
    animation: modalpop .25s cubic-bezier(.2,.9,.4,1.2);
}
@keyframes modalpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card .m-title { font-size: 1.6rem; font-weight: 900; margin-bottom: 10px; }
.modal-card p { margin: 6px 0; font-size: 1.05rem; line-height: 1.4; }
.modal-card .modal-hint { color: var(--muted); font-size: .85rem; margin-top: 14px; font-style: italic; }
.modal-card.modal-ok   { border-top: 6px solid #28c76f; }
.modal-card.modal-ok   .m-title { color: #1a8a4d; }
.modal-card.modal-bad  { border-top: 6px solid #ff5c5c; }
.modal-card.modal-bad  .m-title { color: #c0392b; }
.modal-card.modal-warn { border-top: 6px solid var(--accent); }
.modal-card.modal-warn .m-title { color: #9a6a00; }

.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-weight: 700; }
.feedback-ok { background: #e3f9ec; color: #1a8a4d; }
.feedback-bad { background: #ffe9e9; color: #c0392b; }
.feedback-warn { background: #fff3da; color: #9a6a00; }

.guess-panel { text-align: center; }
.guess-panel h2 { margin-top: 0; }
.guess-sub { color: var(--muted); }
.guess-hint { font-weight: 700; color: var(--accent); }
#guessAnswer { width: 100%; padding: 14px; font-size: 1.2rem; border: 2px solid #e2e5f3; border-radius: 12px; margin: 10px 0; }
.guess-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== Grille de cases (élève) ===== */
.board-instr { text-align: center; font-size: 1.15rem; font-weight: 600; margin: 0 0 14px; }
.cell-grid { display: grid; gap: 6px; width: 100%; }
.cell {
    aspect-ratio: 1 / 1; border: none; border-radius: 8px; cursor: pointer;
    background: linear-gradient(135deg, #5b6cff, #4453d6); color: #fff;
    font-weight: 800; font-size: clamp(.55rem, 2.6vw, 1.1rem);
    display: flex; align-items: center; justify-content: center; transition: transform .1s, background .2s, opacity .2s;
    min-width: 0; padding: 0; overflow: hidden; line-height: 1;
}
.cell:hover { transform: translateY(-2px); }
.cell.selected { background: linear-gradient(135deg, #ff9f1c, #ff7a00); color: #3a2300; transform: scale(1.04); box-shadow: 0 0 0 3px rgba(255,159,28,.5); }
.cell.revealed { background: #d7dbe8; color: #9aa0bf; cursor: default; }
.cell.revealed:hover { transform: none; }
.cell.locked { background: #b9bed0; color: #6b7090; cursor: not-allowed; opacity: .8; }
.cell.locked:hover { transform: none; }
.cell.locked::after { content: ' 🔒'; font-size: .7em; }
.cell.mine { background: #28c76f; color: #fff; }
#guessOpenBtn { display: block; width: 100%; margin-top: 14px; }
.guess-info { text-align: center; color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.exercise-area { margin-top: 16px; padding-top: 16px; border-top: 2px dashed #e2e5f3; }

.ex-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ex-cell { background: var(--accent); color: #3a2300; font-weight: 800; border-radius: 8px; padding: 4px 12px; font-size: 1.1rem; }
.ex-image { max-width: 100%; max-height: 320px; display: block; margin: 10px auto; border-radius: 10px; border: 1px solid #e2e5f3; }
.ex-actions { display: flex; gap: 10px; margin-top: 16px; }
.ex-actions .btn { flex: 1; }

/* ===== Admin contenu ===== */
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.admin-cols .card { margin: 0; }
.admin-cols h2 { margin-top: 0; }
.form textarea { padding: 12px; border: 2px solid #e2e5f3; border-radius: 10px; font-size: 1rem; font-family: inherit; resize: vertical; }
.form textarea:focus { outline: none; border-color: var(--primary); }
.content-list { margin-top: 12px; max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.content-item { display: flex; align-items: center; gap: 10px; background: #f6f7ff; border-radius: 10px; padding: 8px 10px; }
.content-item img { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; background: #fff; }
.ci-body { flex: 1; min-width: 0; }
.ci-body div { font-size: .9rem; }
.tag { display: inline-block; border-radius: 12px; padding: 2px 8px; font-size: .75rem; font-weight: 700; color: #fff; }
.tag-algebre { background: #5b6cff; }
.tag-geometrie { background: #28c76f; }
.tag-fonctions { background: #ff9f1c; color: #3a2300; }
.tag-probabilites { background: #b052ff; }
.tag-films_animation { background: #e63946; }
.tag-series_tv { background: #0d6efd; }

/* ===== Accès prof aux contestations (page de création) ===== */
.dispute-access-card { margin-top: 20px; text-align: center; }
.dispute-access-card h2 { margin-top: 0; }
.dispute-access-qr { display: inline-block; background: #fff; padding: 12px; border-radius: 12px; box-shadow: var(--shadow); margin: 10px 0; }
.dispute-access-qr img, .dispute-access-qr canvas { display: block; }

/* ===== Boutons d'action (acceptation / refus / contestation) ===== */
.btn-ok { background: var(--ok); }
.btn-danger { background: var(--bad); }
.btn-warn { background: var(--warn); color: #3a2300; }

/* ===== Contestation côté élève (dans la modale) ===== */
.modal-dispute { display: block; width: 100%; margin-top: 16px; }
.dispute-note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #fff3da; color: #9a6a00; font-weight: 700; }

/* ===== Contestation : écran d'attente + réponse du prof (plein écran) ===== */
.dispute-overlay {
    position: fixed; inset: 0; z-index: 90; padding: 24px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10,12,30,.92); animation: fadein .15s ease;
}
.dispute-overlay-card {
    background: #fff; color: var(--ink); border-radius: 20px; padding: 34px 26px;
    max-width: 540px; width: 100%; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5);
    border-top: 8px solid var(--accent); animation: modalpop .25s cubic-bezier(.2,.9,.4,1.2);
}
.dispute-overlay-card.do-ok  { border-top-color: var(--ok); cursor: pointer; }
.dispute-overlay-card.do-bad { border-top-color: var(--bad); cursor: pointer; }
.do-title { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 900; margin: 10px 0; }
.dispute-overlay-card p { font-size: 1.1rem; line-height: 1.4; margin: 8px 0; }
.do-emoji { font-size: clamp(3.5rem, 16vw, 6rem); line-height: 1; animation: pop .5s ease; }
.do-big { font-size: clamp(2rem, 9vw, 3.4rem); font-weight: 900; color: var(--ok); margin: 6px 0; }
.do-hint { color: var(--muted); font-size: .9rem; font-style: italic; margin-top: 16px; }
.do-spinner {
    width: 56px; height: 56px; margin: 6px auto 14px; border-radius: 50%;
    border: 6px solid #e2e5f3; border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Plateau : alerte contestations ===== */
.dispute-alert {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    background: var(--warn); color: #3a2300; font-weight: 800; font-size: 1.1rem;
    padding: 12px 22px; border-radius: 14px; box-shadow: var(--shadow); z-index: 60;
    animation: pulse 1.6s infinite;
}

/* ===== Interface téléphone du prof : contestations ===== */
.disputes-body { color: var(--ink); min-height: 100vh; }
.disputes-top {
    position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
    background: var(--primary); color: #fff; padding: 14px 16px; box-shadow: var(--shadow);
}
.disputes-title { font-weight: 800; font-size: 1.15rem; }
.disputes-code { margin-left: auto; font-size: .95rem; opacity: .9; }
.disputes-count {
    min-width: 30px; text-align: center; background: var(--warn); color: #3a2300;
    font-weight: 900; border-radius: 999px; padding: 2px 10px;
}
.disputes-wrap { padding: 14px; max-width: 640px; margin: 0 auto; }
.disputes-empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 1.1rem; }
.disputes-list { display: flex; flex-direction: column; gap: 14px; }
.dispute {
    background: var(--card-bg); border-radius: 16px; padding: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12); border: 1px solid #e7e9f5;
    transition: opacity .2s ease;
}
.dispute.resolving { opacity: .5; }
.dispute-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dispute-team { font-weight: 800; font-size: 1.05rem; }
.dispute-points { margin-left: auto; background: #eef0f7; color: var(--primary); font-weight: 800; border-radius: 999px; padding: 2px 10px; font-size: .85rem; }
.dispute-q { font-weight: 600; margin: 4px 0 10px; color: #1b1b3a; }
.dispute-img { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; margin: 6px 0 10px; }
.dispute-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.dispute-given, .dispute-expected { border-radius: 10px; padding: 10px; }
.dispute-given { background: #ffe9e9; }
.dispute-expected { background: #e3f9ec; }
.dispute-answers span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 4px; }
.dispute-answers strong { font-size: 1.05rem; word-break: break-word; }
.dispute-actions { display: flex; gap: 10px; }
.dispute-actions .btn { flex: 1; }
.disputes-toast {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    padding: 12px 22px; border-radius: 14px; font-weight: 800; color: #fff;
    box-shadow: var(--shadow); z-index: 30;
}
.disputes-toast-ok { background: var(--ok); }
.disputes-toast-bad { background: var(--bad); }

@media (max-width: 820px) {
    .form-grid { grid-template-columns: 1fr; }
    .lobby-grid { grid-template-columns: 1fr; text-align: center; }
    .board-main { grid-template-columns: 1fr; }
    .board-side { order: -1; }
    .admin-cols { grid-template-columns: 1fr; }
}

/* Téléphones : la grille de cases doit tenir dans le cadre (jusqu'à 10+ colonnes) */
@media (max-width: 560px) {
    .play-main { padding: 8px; }
    .panel { padding: 12px; border-radius: 12px; }
    .cell-grid { gap: 4px; }
    .cell { border-radius: 6px; font-size: clamp(.5rem, 2.3vw, .9rem); }
    .cell.locked::after { content: ''; } /* pas de 🔒 sur très petites cases (manque de place) */
    .play-top, .play-progress { padding-left: 10px; padding-right: 10px; }
}

/* --- Rendu mathématique (KaTeX) --- */
/* KaTeX hérite de la taille de police du conteneur pour rester cohérent avec le texte. */
.ex-statement .katex,
.choice .katex,
.dispute-q .katex,
.dispute-answers .katex,
.math-preview .katex { font-size: 1.05em; }

/* Aperçu du rendu sous les champs de l'admin. */
.math-preview { display: none; }
.math-preview.on {
    display: block;
    margin: 6px 0 4px;
    padding: 8px 10px;
    background: #f6f7fc;
    border: 1px dashed #c9cde6;
    border-radius: 8px;
    line-height: 1.7;
}
.math-preview.on::before {
    content: 'Aperçu';
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a90b0;
    margin-bottom: 4px;
}
