:root {
  --bg1: #0a1847;
  --bg2: #1c4fb5;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #f4f2ff;
  --muted: #b6b0dd;
  --primary: #ffc21a;
  --primary-2: #ff9800;
  --good: #3ee08f;
  --bad: #ff5d73;
  --add: #3ec6ff;
  --sub: #ff7ab6;
  --mul: #a78bfa;
  --radius: 22px;
}
* { box-sizing: border-box; }
html { background: #0a1847; }
html, body { margin: 0; min-height: 100vh; }
body {
  font-family: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg2), var(--bg1) 70%) fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
#stars-bg, #confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#stars-bg { z-index: 0; }
#confetti { z-index: 50; }
main { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }

/* ---------- topbar ---------- */
.topbar { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 12px 16px; max-width: 1100px; margin: 0 auto; }
.logo { background: none; border: 0; font-size: 1.6rem; font-weight: 800; display: flex; gap: 8px; align-items: center; }
.logo { gap: 0 !important; letter-spacing: .5px; }
.logo img { width: 42px; height: 42px; margin-right: 10px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.logo .lw { color: #fff; }
.logo .ly { color: var(--primary); }
.hero { text-align: center; margin-top: 4px; }
.hero-logo { width: min(420px, 82vw); height: auto; filter: drop-shadow(0 10px 24px rgba(0,0,0,.45)); animation: bob 4s ease-in-out infinite; }
.tagline { font-size: clamp(1.3rem, 3.5vw, 1.9rem); font-weight: 800; font-style: italic; color: #fff; margin-top: -4px; }
.tagline::after { content: ""; display: block; width: 220px; max-width: 60%; height: 5px; margin: 2px auto 0; border-radius: 5px; background: var(--primary); transform: rotate(-1.5deg); }
.mascot { width: 110px; height: 110px; border-radius: 50%; box-shadow: 0 0 0 5px var(--primary), 0 10px 26px rgba(0,0,0,.4); animation: bob 2s ease-in-out infinite; }
.mascot-wrap { position: relative; display: inline-block; }
.mascot-wrap .me { position: absolute; right: -14px; bottom: -6px; font-size: 2.4rem; }
.topbar-player { margin-left: auto; display: flex; gap: 10px; align-items: center; font-weight: 700; }
.topbar-player .mini-avatar { font-size: 1.6rem; }
.icon-btn { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; width: 44px; height: 44px; font-size: 1.2rem; }
#sound-toggle { margin-left: 8px; }
.topbar-player.hidden + #sound-toggle { margin-left: auto; }

/* ---------- common ---------- */
.title { text-align: center; font-size: clamp(1.5rem, 3.6vw, 2.3rem); margin: 18px 0 22px; }
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 22px; backdrop-filter: blur(6px); }
.card h2 { margin: 0 0 12px; font-size: 1.5rem; }
.narrow { max-width: 560px; margin: 20px auto; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.field { display: block; font-weight: 700; color: var(--muted); margin: 14px 0 6px; font-size: 1.02rem; }
.field input { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 1.3rem; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--card-border); background: rgba(0,0,0,.25); color: var(--text); }
.field input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--bad); font-weight: 700; min-height: 1.2em; margin: 8px 0 0; }
.link { background: none; border: 0; color: var(--primary); font-weight: 700; padding: 0; text-decoration: underline; }

.btn { border: 0; border-radius: 16px; padding: 12px 22px; font-size: 1.1rem; font-weight: 800; transition: transform .1s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #2a1300; box-shadow: 0 6px 0 #b86a00; }
.btn.primary:active { box-shadow: 0 2px 0 #b86a00; transform: translateY(4px); }
.btn.ghost { background: var(--card); border: 1px solid var(--card-border); }
.btn.huge { width: 100%; font-size: 1.6rem; padding: 16px; margin-top: 22px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: rgba(255,255,255,.06); border: 2px solid var(--card-border); border-radius: 14px; padding: 8px 14px; font-size: 1.05rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; line-height: 1.15; transition: all .12s; }
.chip small { font-weight: 500; font-size: .75rem; color: var(--muted); }
.chip.on { background: rgba(255,176,32,.2); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,176,32,.2); }
.chip.op { flex-direction: row; gap: 6px; }
.chip.op b { font-size: 1.4rem; }
.chip.op.add.on { border-color: var(--add); background: rgba(62,198,255,.18); box-shadow: 0 0 0 3px rgba(62,198,255,.2); }
.chip.op.sub.on { border-color: var(--sub); background: rgba(255,122,182,.18); box-shadow: 0 0 0 3px rgba(255,122,182,.2); }
.chip.op.mul.on { border-color: var(--mul); background: rgba(167,139,250,.2); box-shadow: 0 0 0 3px rgba(167,139,250,.2); }
.chip.mode { min-width: 120px; }
#set-tables .chip { width: 48px; }
.avatars .chip { font-size: 2rem; width: 62px; height: 62px; justify-content: center; }
.colors .chip { width: 44px; height: 44px; border-radius: 50%; padding: 0; }
.opt-block { transition: opacity .2s; }

/* ---------- profils ---------- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.profile-tile { position: relative; border-radius: var(--radius); padding: 20px 14px 16px; text-align: center; border: 2px solid var(--card-border); background: var(--card); transition: transform .15s; }
.profile-tile:hover { transform: translateY(-4px) rotate(-1deg); }
.profile-tile .avatar { font-size: 4rem; display: inline-grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; margin-bottom: 6px; }
.profile-tile .pname { font-size: 1.5rem; font-weight: 800; }
.profile-tile .prank { color: var(--muted); font-size: .95rem; }
.profile-tile .pmeta { margin-top: 6px; font-weight: 700; display: flex; gap: 10px; justify-content: center; }
.profile-tile .del { position: absolute; top: 8px; right: 8px; background: none; border: 0; opacity: .35; font-size: 1rem; }
.profile-tile .del:hover { opacity: 1; }
.profile-tile.add-new { border-style: dashed; display: grid; place-items: center; min-height: 210px; font-size: 1.3rem; font-weight: 800; color: var(--muted); }
.profile-tile.add-new span { font-size: 3.5rem; display: block; }

/* ---------- home ---------- */
.home-grid { display: grid; grid-template-columns: 330px 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .home-grid { grid-template-columns: 1fr; } }
.player-card { text-align: center; }
.player-card .avatar { font-size: 4.2rem; width: 110px; height: 110px; border-radius: 50%; display: inline-grid; place-items: center; }
.player-card .pname { font-size: 1.8rem; font-weight: 800; margin-top: 4px; }
.player-card .prank { color: var(--primary); font-weight: 700; }
.xpbar { height: 18px; background: rgba(0,0,0,.35); border-radius: 12px; overflow: hidden; margin: 10px 0 4px; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, #3ee08f, #3ec6ff); border-radius: 12px; transition: width .8s; }
.xp-caption { font-size: .9rem; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.kpi { background: rgba(0,0,0,.2); border-radius: 14px; padding: 8px 4px; }
.kpi b { display: block; font-size: 1.4rem; }
.kpi span { font-size: .8rem; color: var(--muted); }
.player-card .btn { width: 100%; margin-top: 8px; }
.planet-journey { display: flex; justify-content: center; align-items: center; gap: 4px; font-size: 1.4rem; margin: 6px 0; flex-wrap: wrap; }
.planet-journey .p { opacity: .25; }
.planet-journey .p.done { opacity: 1; }
.planet-journey .p.cur { opacity: 1; animation: bob 1.6s ease-in-out infinite; font-size: 1.9rem; }

/* ---------- game ---------- */
.game-hud { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.track { flex: 1; position: relative; height: 54px; }
.track-line { position: absolute; left: 20px; right: 34px; top: 50%; border-top: 3px dashed rgba(255,255,255,.25); }
.rocket { position: absolute; top: 50%; left: 0; transform: translateY(-50%) rotate(45deg); font-size: 2.1rem; transition: left .5s cubic-bezier(.3,1.6,.5,1); }
.planet-goal { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 2.1rem; }
.hud-right { display: flex; gap: 8px; }
.hud-pill { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 1.15rem; min-width: 64px; text-align: center; }
.hud-pill.streak { color: #ffcf5c; }
.hud-pill.streak:empty { display: none; }
.qtimer { height: 10px; border-radius: 6px; background: rgba(0,0,0,.35); margin-top: 8px; overflow: hidden; }
#qtimer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #ff5d73, #ffb020, #3ee08f); transform-origin: left; }
.question-area { text-align: center; margin: 26px 0 10px; min-height: 170px; }
.question { font-size: clamp(3rem, 12vw, 6rem); font-weight: 800; letter-spacing: 2px; line-height: 1.1; display: inline-flex; gap: .3em; align-items: center; }
.question .opsym { color: var(--primary); }
.question .opsym.add { color: var(--add); } .question .opsym.sub { color: var(--sub); } .question .opsym.mul { color: var(--mul); }
.question .blank { display: inline-block; min-width: 1.4em; padding: 0 .15em; border-bottom: 6px solid var(--primary); color: var(--primary); }
.question.pop { animation: pop .35s ease-out; }
.question.shake { animation: shake .4s; }
.feedback { font-size: 1.5rem; font-weight: 800; min-height: 2.2rem; margin-top: 6px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.keypad-wrap { max-width: 360px; margin: 0 auto; }
.answer-box { text-align: center; font-size: 2.6rem; font-weight: 800; background: rgba(0,0,0,.3); border: 3px solid var(--card-border); border-radius: 18px; padding: 4px; margin-bottom: 12px; min-height: 68px; }
.answer-box.good { border-color: var(--good); } .answer-box.bad { border-color: var(--bad); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { font-size: 2rem; font-weight: 800; padding: 12px 0; border-radius: 18px; border: 0; background: rgba(255,255,255,.12); box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.keypad button:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.keypad .k-ok { background: var(--good); color: #043b20; }
.keypad .k-del { background: rgba(255,93,115,.35); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 520px; margin: 0 auto; }
.choices button { font-size: 2.4rem; font-weight: 800; padding: 18px 0; border-radius: 20px; border: 3px solid var(--card-border); background: rgba(255,255,255,.1); box-shadow: 0 6px 0 rgba(0,0,0,.35); }
.choices button:nth-child(1) { background: rgba(62,198,255,.22); }
.choices button:nth-child(2) { background: rgba(255,122,182,.22); }
.choices button:nth-child(3) { background: rgba(167,139,250,.25); }
.choices button:nth-child(4) { background: rgba(62,224,143,.22); }
.choices button.good { border-color: var(--good); background: rgba(62,224,143,.55); }
.choices button.bad { border-color: var(--bad); background: rgba(255,93,115,.5); }

/* ---------- résultats ---------- */
.result-card { text-align: center; }
.result-card .big-emoji { font-size: 5rem; animation: bob 2s ease-in-out infinite; }
.result-card h2 { font-size: 2rem; margin: 4px 0; }
.stars { font-size: 3.2rem; letter-spacing: 6px; margin: 8px 0; }
.stars .s { display: inline-block; opacity: .2; filter: grayscale(1); transform: scale(.6); transition: all .4s cubic-bezier(.3,1.8,.5,1); }
.stars .s.on { opacity: 1; filter: none; transform: scale(1); }
.result-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.new-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 12px 0; }
.badge-new { background: linear-gradient(135deg, rgba(255,176,32,.3), rgba(255,106,213,.3)); border: 2px solid var(--primary); border-radius: 16px; padding: 8px 14px; animation: pop .6s; }
.badge-new .bi { font-size: 2rem; }
.levelup { font-size: 1.4rem; font-weight: 800; color: #ffcf5c; margin: 10px 0; animation: pulse 1s infinite; }
.mistakes { text-align: left; margin-top: 14px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; }
.mistakes div { font-size: 1.1rem; }
.mistakes .right { color: var(--good); font-weight: 800; }
.mistakes .wrong { color: var(--bad); text-decoration: line-through; }

/* ---------- stats ---------- */
.stats-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 10px 0 18px; }
.stats-head .avatar { font-size: 3rem; width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; }
.stats-head h1 { margin: 0; font-size: 2rem; }
.stats-head .btn { margin-left: auto; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.stats-grid .wide { grid-column: 1 / -1; }
@media (max-width: 820px) { .stats-grid { grid-template-columns: 1fr; } }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.kpi-row .kpi { padding: 12px; text-align: center; background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; }
.kpi-row .kpi .ki { font-size: 1.8rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .75; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.op-bars .op-row { display: grid; grid-template-columns: 160px 1fr 56px; gap: 10px; align-items: center; margin: 10px 0; font-weight: 700; }
.op-bars .track2 { height: 22px; background: rgba(0,0,0,.3); border-radius: 12px; overflow: hidden; }
.op-bars .track2 div { height: 100%; border-radius: 12px; }
.op-bars small { color: var(--muted); font-weight: 500; }
.facts { display: grid; grid-template-columns: 30px repeat(10, 1fr); gap: 3px; font-size: .85rem; }
.facts div { aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; font-weight: 700; }
.facts .h { color: var(--muted); }
.facts .c { background: rgba(255,255,255,.06); color: rgba(255,255,255,.35); cursor: default; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.table-medals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.table-medals .tm { border-radius: 12px; padding: 4px 10px; background: rgba(0,0,0,.25); font-weight: 700; }
.table-medals .tm.m { background: rgba(62,224,143,.3); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { text-align: center; background: rgba(0,0,0,.2); border-radius: 16px; padding: 10px 8px; border: 2px solid transparent; }
.badge .bi { font-size: 2.2rem; }
.badge .bn { font-weight: 800; }
.badge .bd { font-size: .78rem; color: var(--muted); line-height: 1.2; }
.badge.locked .bi { filter: grayscale(1); opacity: .3; }
.badge.locked .bn { opacity: .5; }
.badge.got { border-color: var(--primary); background: rgba(255,176,32,.12); }
.tricky { display: flex; flex-wrap: wrap; gap: 10px; }
.tricky .t { background: rgba(255,93,115,.18); border: 1px solid rgba(255,93,115,.5); border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 1.2rem; }
.tricky .t small { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: 4px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

/* ---------- toast ---------- */
#toast-zone { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #2b2170; border: 2px solid var(--primary); border-radius: 16px; padding: 10px 18px; font-weight: 800; animation: pop .4s; }

@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-14px); } 40% { transform: translateX(12px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(6px); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

@media (max-width: 560px) {
  .logo { font-size: 1.25rem; }
  .profile-tile .avatar { font-size: 3rem; width: 74px; height: 74px; }
  .profile-tile.add-new { min-height: 170px; }
  .logo img { width: 34px; height: 34px; margin-right: 6px; }
  .topbar-player span:not(.mini-avatar) { display: none; }
  .topbar-player .mini-avatar { font-size: 1.4rem; }
  .op-bars .op-row { grid-template-columns: 120px 1fr 48px; }
  .result-kpis { gap: 6px; }
}

/* ---------- disposition jeu : exercice à gauche, clavier à droite ---------- */
.play-area { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: center; }
@media (min-width: 760px) {
  .play-area { grid-template-columns: 1fr minmax(300px, 360px); gap: 30px; min-height: calc(100vh - 190px); }
  .play-area .question-area { margin: 0; }
  .play-area .question { font-size: clamp(3rem, 7vw, 5.5rem); }
  .play-area .choices { grid-template-columns: 1fr 1fr; }
}

/* ---------- calcul posé ---------- */
.pose { --cw: clamp(40px, 8.5vw, 70px); display: inline-block; font-weight: 800; line-height: 1; user-select: none; }
.pose-row { display: grid; grid-template-columns: repeat(var(--cols), var(--cw)); justify-content: center; }
.pose-row > div { width: var(--cw); height: calc(var(--cw) * 1.15); display: grid; place-items: center; font-size: calc(var(--cw) * .82); }
.pose-row.carry > div { height: calc(var(--cw) * .7); font-size: calc(var(--cw) * .42); }
.pose-row .opsym { color: var(--add); }
.pose-row .opsym.sub { color: var(--sub); }
.pose-row .c-cell { width: 62%; height: 80%; margin: auto; border: 2px dashed rgba(255,194,26,.55); border-radius: 8px; color: var(--primary); cursor: pointer; display: grid; place-items: center; }
.pose-row .c-cell.filled { border-style: solid; background: rgba(255,194,26,.12); }
.pose-row .c-cell.hint { border-color: var(--primary); color: var(--primary); background: rgba(255,194,26,.25); }
.pose-line { height: 6px; border-radius: 4px; background: #fff; margin: 6px 0 8px; }
.pose-row.ans > div.a-cell { width: 86%; height: 92%; margin: auto; border-radius: 12px; background: rgba(0,0,0,.28); border: 3px solid var(--card-border); cursor: pointer; color: #fff; }
.pose-row.ans > div.a-cell.active, .pose-row .c-cell.active { border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 4px rgba(255,194,26,.35); animation: blink-b 1.2s infinite; }
.pose-row.ans > div.a-cell.good { border-color: var(--good); background: rgba(62,224,143,.25); animation: none; box-shadow: none; }
.pose-row.ans > div.a-cell.bad { border-color: var(--bad); background: rgba(255,93,115,.3); animation: none; box-shadow: none; }
.pose-row.fix > div { color: var(--good); font-size: calc(var(--cw) * .5); height: calc(var(--cw) * .7); }
.pose-row .colhl { background: rgba(255,255,255,.06); border-radius: 10px; }
.pose-help { background: rgba(0,0,0,.25); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; font-size: .95rem; color: var(--muted); text-align: center; }
.pose-help b { color: #fff; }
@keyframes blink-b { 50% { box-shadow: 0 0 0 7px rgba(255,194,26,.12); } }

/* aperçu dans les réglages */
.pose-opts { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; background: rgba(0,0,0,.18); border-radius: 18px; padding: 6px 16px 14px; margin-top: 10px; }
.pose-preview .pose { --cw: 30px; }
.pose-preview .pose-line { height: 3px; margin: 3px 0 4px; }
@media (max-width: 560px) {
  .pose-opts { grid-template-columns: 1fr; justify-items: center; }
  .keypad button { padding: 8px 0; font-size: 1.7rem; }
  .pose { --cw: clamp(36px, 11vw, 56px); }
}

/* ---------- nouvelles opérations ---------- */
.chip.op.div.on { border-color: #3ee08f; background: rgba(62,224,143,.18); box-shadow: 0 0 0 3px rgba(62,224,143,.2); }
.chip.op.cmp.on { border-color: #ffc21a; background: rgba(255,194,26,.18); box-shadow: 0 0 0 3px rgba(255,194,26,.2); }
.sub-block { background: rgba(0,0,0,.18); border-radius: 18px; padding: 8px 16px 14px; margin-top: 12px; }
.sub-title { font-weight: 800; font-size: 1.15rem; margin-top: 4px; }

/* division posée */
.divbox { display: inline-block; }
.potence { display: inline-flex; align-items: flex-start; --cw: clamp(34px, 6.2vw, 58px); font-weight: 800; }
.div-left { padding-right: 10px; border-right: 5px solid #fff; padding-bottom: 6px; min-height: calc(var(--cw) * 2.6); }
.div-right { padding-left: 10px; }
.drow > div { height: calc(var(--cw) * 1.05); }
.dcell { font-size: calc(var(--cw) * .8); width: 100%; height: 100%; display: grid; place-items: center; }
.drow { margin-bottom: 2px; }
.drow .ul { border-bottom: 4px solid rgba(255,255,255,.75); }
.dcell.prod, .dcell.sign { color: var(--sub); }
.dcell.hl { background: rgba(255,194,26,.25); color: var(--primary); }
.drow > div:has(.hl) + div:has(.hl) .hl { border-top-left-radius: 0; }
.dcell.brought { color: var(--add); }
.dcell.input { border: 3px solid var(--primary); border-radius: 10px; background: rgba(0,0,0,.28); color: #fff; animation: blink-b 1.2s infinite; margin: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }
.dcell.bad { border-color: var(--bad) !important; background: rgba(255,93,115,.3) !important; animation: shake .4s; }
.divisor { display: flex; border-bottom: 5px solid #fff; padding-bottom: 2px; }
.divisor .dcell, .quot .dcell { width: var(--cw); height: calc(var(--cw) * 1.05); }
.quot { display: flex; gap: 2px; margin-top: 6px; }
.quot .dcell.qd { border: 3px solid var(--card-border); border-radius: 10px; background: rgba(0,0,0,.25); color: var(--good); }
.quot .dcell.qd.active { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(255,194,26,.35); animation: blink-b 1.2s infinite; }
.div-rest { margin-top: 10px; font-size: calc(var(--cw) * .45); color: var(--muted); }
.div-rest b { color: var(--primary); font-size: 1.4em; }
.div-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); white-space: nowrap; gap: 4px; margin-top: 12px; font-size: .9rem; color: var(--muted); background: rgba(0,0,0,.2); border-radius: 12px; padding: 8px; }
.div-table b { color: #fff; }

/* comparer / ranger */
.cmp-q { display: flex; align-items: center; justify-content: center; gap: .4em; font-size: clamp(2.2rem, 5.5vw, 4.4rem); font-weight: 800; flex-wrap: wrap; }
.cmp-slot { min-width: 1.3em; padding: 0 .1em; border-radius: 18px; border: 4px dashed var(--primary); color: var(--primary); text-align: center; }
.cmp-slot.good { border-style: solid; border-color: var(--good); color: var(--good); }
.cmp-slot.bad { border-style: solid; border-color: var(--bad); color: var(--bad); }
.cmp-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cmp-buttons button { border: 3px solid var(--card-border); border-radius: 20px; background: rgba(255,255,255,.1); box-shadow: 0 6px 0 rgba(0,0,0,.35); padding: 14px 4px; display: flex; flex-direction: column; align-items: center; }
.cmp-buttons button b { font-size: 3.2rem; line-height: 1; }
.cmp-buttons button small { font-size: .8rem; color: var(--muted); font-weight: 700; }
.cmp-buttons button:nth-child(1) { background: rgba(62,198,255,.22); }
.cmp-buttons button:nth-child(2) { background: rgba(167,139,250,.25); }
.cmp-buttons button:nth-child(3) { background: rgba(255,122,182,.22); }
.cmp-buttons button.good { border-color: var(--good); background: rgba(62,224,143,.5); }
.cmp-buttons button.bad { border-color: var(--bad); background: rgba(255,93,115,.5); }
.ord-title { font-size: 1.3rem; margin-bottom: 14px; }
.ord-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 22px; }
.ord-tile { font-size: clamp(1.4rem, 3.4vw, 2.2rem); font-weight: 800; padding: 10px 18px; border-radius: 16px; border: 3px solid var(--card-border); background: rgba(255,255,255,.12); box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.ord-tile.used { opacity: .2; pointer-events: none; }
.ord-slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.ord-slot { min-width: 3.4em; min-height: 2.4em; font-size: clamp(1.1rem, 2.6vw, 1.7rem); font-weight: 800; border-radius: 14px; border: 3px dashed var(--primary); background: rgba(0,0,0,.25); }
.ord-slot.filled { border-style: solid; background: rgba(255,194,26,.18); }
.ord-sep { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.ord-fix { margin-top: 12px; font-size: 1.3rem; font-weight: 800; color: var(--good); }
.ord-buttons { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.ord-buttons .btn { font-size: 1.3rem; padding: 16px; }
.ord-buttons .btn:disabled { opacity: .4; }

.ord-slot.good { border-color: var(--good); background: rgba(62,224,143,.3); }
.ord-slot.bad { border-color: var(--bad); background: rgba(255,93,115,.3); }

/* ---------- diplômes ---------- */
.diploma { container-type: inline-size; width: 100%; max-width: 1050px; margin: 0 auto; aspect-ratio: 1.414; position: relative;
  background: radial-gradient(ellipse at center, #fffdf5 0%, #fff6dc 70%, #f6e7bd 100%); color: #2b2250; border-radius: 1.2cqw;
  box-shadow: 0 20px 50px rgba(0,0,0,.45); -webkit-print-color-adjust: exact; print-color-adjust: exact; overflow: hidden; font-family: "Baloo 2", system-ui, sans-serif; }
.dp-frame { position: absolute; inset: 2.2cqw; border: .6cqw solid var(--c1); border-radius: 1cqw; outline: .25cqw solid var(--c2); outline-offset: -1.3cqw;
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.2cqw 4cqw 1.6cqw; }
.dp-frame::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent 0 2cqw, color-mix(in srgb, var(--c1) 5%, transparent) 2cqw 4cqw); pointer-events: none; border-radius: .6cqw; }
.dp-corner { position: absolute; font-size: 3.4cqw; line-height: 1; }
.dp-corner.tl { top: -1.2cqw; left: -1.2cqw; } .dp-corner.tr { top: -1.2cqw; right: -1.2cqw; }
.dp-corner.bl { bottom: -1.2cqw; left: -1.2cqw; } .dp-corner.br { bottom: -1.2cqw; right: -1.2cqw; }
.dp-top { display: flex; align-items: center; gap: 1cqw; font-weight: 800; font-size: 1.9cqw; letter-spacing: .1cqw; color: #1b2a6b; }
.dp-top img { width: 4.2cqw; height: 4.2cqw; }
.dp-top .ly { color: #f5a300; }
.dp-title { font-family: "Fredoka", "Baloo 2", sans-serif; font-weight: 700; font-size: 7.4cqw; line-height: .95; margin-top: .6cqw;
  background: linear-gradient(180deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 .25cqw 0 rgba(0,0,0,.12)); }
.dp-sub { font-size: 2.6cqw; font-weight: 800; margin-top: -.2cqw; }
.dp-sub .dp-n { display: inline-grid; place-items: center; width: 4.4cqw; height: 4.4cqw; border-radius: 50%; background: var(--c1); color: #fff; font-size: 2.9cqw; vertical-align: middle; margin-left: .4cqw; }
.dp-awarded { font-size: 1.6cqw; color: #6b6290; margin-top: .8cqw; font-style: italic; }
.dp-name { font-family: "Caveat", cursive; font-weight: 700; font-size: 6.2cqw; line-height: 1; color: #1b2a6b; padding: 0 4cqw; border-bottom: .25cqw dashed var(--c2); }
.dp-text { font-size: 1.8cqw; margin-top: 1.4cqw; line-height: 1.35; }
.dp-fact { font-size: 2cqw; font-weight: 800; color: var(--c1); margin-top: .8cqw; }
.dp-table { display: grid; grid-template-columns: repeat(5, 1fr); gap: .7cqw 1.6cqw; margin-top: 1.8cqw; font-size: 1.8cqw; font-weight: 700;
  background: color-mix(in srgb, var(--c1) 10%, white); border: .2cqw solid color-mix(in srgb, var(--c1) 35%, white); border-radius: 1cqw; padding: .7cqw 1.6cqw; }
.dp-table b { color: var(--c1); }
.dp-bottom { margin-top: auto; width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 2cqw; }
.dp-sign .sig { font-family: "Caveat", cursive; font-size: 2.5cqw; color: #1b2a6b; line-height: 1; }
.dp-sign .line { border-top: .18cqw solid #6b6290; margin-top: .3cqw; padding-top: .2cqw; font-size: 1.1cqw; color: #6b6290; }
.dp-seal { position: relative; width: 11cqw; height: 11cqw; display: grid; place-items: center; }
.dp-seal::before, .dp-seal::after { content: ""; position: absolute; bottom: -1.6cqw; width: 2.6cqw; height: 5cqw; background: var(--c2); z-index: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.dp-seal::before { left: 2.6cqw; transform: rotate(18deg); } .dp-seal::after { right: 2.6cqw; transform: rotate(-18deg); }
.seal-out { position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, #f7c531 0 7.5deg, #e9a800 7.5deg 15deg); display: grid; place-items: center; box-shadow: 0 .4cqw .8cqw rgba(0,0,0,.25); }
.seal-in { width: 78%; height: 78%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe27a, #f0b400); border: .3cqw dashed #b67d00;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6a4300; font-weight: 800; line-height: 1; }
.seal-in .big { font-size: 3.6cqw; }
.seal-in .small { font-size: .95cqw; letter-spacing: .1cqw; text-transform: uppercase; }
.seal-in .em { font-size: 2cqw; }
.diploma-actions { display: flex; justify-content: space-between; gap: 10px; margin: 6px auto 16px; max-width: 1050px; }

/* galerie */
.dp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.dp-thumb { cursor: pointer; transition: transform .15s; border: 0; background: none; padding: 0; text-align: center; color: inherit; }
.dp-thumb:hover { transform: translateY(-4px) rotate(-1deg); }
.dp-thumb .diploma { box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.dp-thumb .cap { margin-top: 6px; font-weight: 800; }
.dp-locked { border: 2px dashed var(--card-border); border-radius: 14px; aspect-ratio: 1.414; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; background: rgba(0,0,0,.18); }
.dp-locked .lk { font-size: 2rem; opacity: .6; }
.dp-locked .t { font-weight: 800; font-size: 1.1rem; }
.dp-locked small { color: var(--muted); font-size: .78rem; line-height: 1.2; }
.dp-locked .mini-bar { width: 80%; height: 8px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
.dp-locked .mini-bar div { height: 100%; background: linear-gradient(90deg, #ffc21a, #3ee08f); }
.new-diploma { margin: 14px 0; padding: 14px; border-radius: 18px; background: linear-gradient(135deg, rgba(255,194,26,.25), rgba(62,224,143,.2)); border: 3px solid var(--primary); animation: pop .6s; }
.new-diploma h3 { margin: 0 0 8px; font-size: 1.5rem; }
.new-diploma .diploma { max-width: 340px; margin: 8px auto; }

@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff !important; }
  body * { visibility: hidden; }
  #stars-bg, #confetti, .topbar, .diploma-actions { display: none !important; }
  #diploma-print, #diploma-print * { visibility: visible; }
  #diploma-print { position: fixed; inset: 0; display: grid; place-items: center; }
  #diploma-print .diploma { width: 297mm; max-width: none; height: 210mm; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
}

/* conversions */
.chip.op.conv.on { border-color: #00d4b4; background: rgba(0,212,180,.18); box-shadow: 0 0 0 3px rgba(0,212,180,.2); }
.question.conv { font-size: clamp(2rem, 5vw, 4rem); flex-wrap: wrap; justify-content: center; gap: .25em; }
.question.conv .unit { color: #00d4b4; }
.keypad .k-comma { display: none; grid-column: 1 / -1; font-size: 1.6rem; padding: 6px 0; background: rgba(0,212,180,.3); }
.keypad .k-comma small { font-size: .9rem; opacity: .8; }
.keypad-wrap.with-comma .k-comma { display: block; }
.convtable { margin: 18px auto 0; max-width: 560px; }
.convtable table { border-collapse: collapse; width: 100%; font-weight: 800; }
.convtable th, .convtable td { border: 2px solid rgba(255,255,255,.25); text-align: center; padding: 6px 2px; }
.convtable th { font-size: 1.05rem; background: rgba(0,0,0,.25); }
.convtable td { font-size: 1.8rem; height: 2.4em; position: relative; }
.convtable .from { background: rgba(62,198,255,.22); }
.convtable .to { background: rgba(255,194,26,.25); color: var(--primary); }
.convtable .comma { position: absolute; right: -6px; bottom: 2px; font-style: normal; color: var(--bad); font-size: 1.8rem; }
.convtable .xp-caption { margin-top: 8px; }

/* ---------- espace maître ---------- */
.teacher-link { text-align: center; margin-top: 30px; }
.teacher-link .btn { font-size: .95rem; opacity: .8; }
.class-group { grid-column: 1 / -1; margin-bottom: 10px; }
.profile-grid.grouped { display: block; }
.class-title { font-size: 1.3rem; margin: 10px 0 12px; color: var(--muted); }
.profile-tile .lock { position: absolute; top: 8px; right: 10px; opacity: .6; }
.left-col { display: flex; flex-direction: column; gap: 20px; }
.t-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 12px; }
.t-head h1 { margin: 0; font-size: 1.8rem; }
.t-head h1 small, .t-head h2 small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.t-head h2 { margin: 0; }
.t-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.t-classes { margin-bottom: 14px; }
.t-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.t-grid3 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 820px) { .t-grid, .t-grid3 { grid-template-columns: 1fr; } }
.t-table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.t-table th { text-align: left; color: var(--muted); font-size: .85rem; padding: 6px 8px; border-bottom: 2px solid var(--card-border); }
.t-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.07); vertical-align: middle; }
.t-scroll { overflow-x: auto; }
.t-table td.av { font-size: 1.7rem; cursor: pointer; width: 50px; text-align: center; }
.t-table .act { white-space: nowrap; text-align: right; }
.t-table .act .icon-btn { width: 38px; height: 38px; font-size: 1rem; }
.t-in, .field select, textarea { font: inherit; font-size: 1rem; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--card-border); background: rgba(0,0,0,.25); color: var(--text); width: 100%; }
.field select { display: block; margin-top: 6px; padding: 10px; }
.field select option { background: #1b2a6b; }
.field input[type=date] { font-size: 1rem; color-scheme: dark; }
textarea { resize: vertical; margin-top: 6px; }
.t-in.pin { max-width: 110px; letter-spacing: 3px; }
.t-in.saved { border-color: var(--good); }
.av-s { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--c) 30%, transparent); margin-right: 4px; }
.t-assign { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; margin-bottom: 12px; }
.t-assign.archived { opacity: .55; }
.t-a-ic { font-size: 2.4rem; text-align: center; }
.t-a-title { font-weight: 800; font-size: 1.25rem; }
.t-a-desc { font-size: .92rem; margin: 4px 0; }
.t-a-act { display: flex; flex-direction: column; gap: 6px; }
.t-a-act .btn { padding: 8px 14px; font-size: .95rem; }
@media (max-width: 820px) { .t-assign { grid-template-columns: 44px 1fr; } .t-a-act { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; } }
.t-progress { display: flex; align-items: center; gap: 10px; font-size: .92rem; color: var(--muted); }
.t-progress .mini-bar { width: 140px; height: 10px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
.t-progress .mini-bar div { height: 100%; background: linear-gradient(90deg, #ffc21a, #3ee08f); }
.tag { display: inline-block; font-size: .78rem; font-weight: 800; padding: 2px 8px; border-radius: 8px; background: rgba(255,255,255,.12); vertical-align: middle; }
.tag.epreuve { background: rgba(255,194,26,.25); color: #ffd866; }
.tag.devoir { background: rgba(62,198,255,.2); color: #8fdcff; }
.tag.ok { background: rgba(62,224,143,.25); color: #7ff0b8; }
.tag.late { background: rgba(255,93,115,.25); color: #ff9aa8; }
.score { font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.score.hi { background: rgba(62,224,143,.25); } .score.mid { background: rgba(255,194,26,.25); } .score.lo { background: rgba(255,93,115,.25); }
.c-hi { color: #7ff0b8; font-weight: 800; } .c-mid { color: #ffd866; font-weight: 800; } .c-lo { color: #ff9aa8; font-weight: 800; }
.errs span { display: inline-block; background: rgba(255,93,115,.15); border-radius: 8px; padding: 1px 6px; margin: 2px; font-size: .85rem; white-space: nowrap; }
.errs small { color: #ff9aa8; }
.tf-ex { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; flex-wrap: wrap; }
a.btn { text-decoration: none; display: inline-block; color: inherit; }

/* devoirs côté élève */
.hw-card h2 { margin-bottom: 8px; }
.hw-count { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 15px; background: var(--bad); font-size: 1rem; vertical-align: middle; animation: pulse 1.4s infinite; }
.hw-item { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: center; background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px; margin-bottom: 8px; border-left: 5px solid #3ec6ff; text-align: left; }
.hw-item.epreuve { border-left-color: var(--primary); }
.hw-ic { font-size: 1.8rem; text-align: center; }
.hw-main small { display: block; color: var(--muted); font-size: .8rem; }
.hw-instr { font-size: .85rem; margin-top: 3px; }
.hw-side { grid-column: 1 / -1; }
.hw-side .btn { width: 100%; padding: 8px; font-size: 1rem; margin: 0; }
.hw-sent { margin-top: 8px; font-weight: 700; color: #7ff0b8; }

/* modale code secret */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(5,10,40,.75); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #16307e; border: 2px solid var(--card-border); border-radius: 24px; padding: 20px; text-align: center; width: min(360px, 100%); }
.modal-card h2 { margin: 4px 0; }
.modal-card p { margin: 4px 0 10px; color: var(--muted); }
.pin-dots { font-size: 2rem; letter-spacing: 10px; min-height: 2.6rem; margin-bottom: 10px; color: var(--primary); }
.keypad.small button { font-size: 1.6rem; padding: 8px 0; }

/* ---------- comptes & tableaux de bord ---------- */
.auth-ic { text-align: center; font-size: 3rem; }
.t-login h2 { text-align: center; }
.ok-msg { color: #7ff0b8; font-weight: 700; }
.warn-msg { background: rgba(255,194,26,.15); border: 1px solid rgba(255,194,26,.4); border-radius: 12px; padding: 8px 12px; font-size: .9rem; }
.t-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.t-grid2 .span2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .t-grid2 { grid-template-columns: 1fr; } }
.new-teacher { background: rgba(0,0,0,.18); border-radius: 14px; padding: 4px 14px 10px; margin-top: 10px; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: rgba(0,0,0,.3); padding: 1px 6px; border-radius: 6px; }
.class-code { letter-spacing: 3px; font-weight: 800; color: var(--primary); }
.class-code.big { font-size: 1.6rem; padding: 4px 12px; }
.code-box { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; background: rgba(255,194,26,.1); border: 1px dashed rgba(255,194,26,.5); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; }
.code-box span { display: block; font-size: .8rem; color: var(--muted); font-weight: 700; }
.code-box .btn { grid-column: 1 / -1; }
@media (max-width: 700px) { .code-box { grid-template-columns: 1fr; } }
.t-table tr.archived { opacity: .5; }
.modal-card.wide { width: min(560px, 100%); }
.cred-box { display: grid; gap: 8px; background: rgba(0,0,0,.25); border-radius: 14px; padding: 12px; margin: 10px 0; text-align: left; }
.cred-box span { display: block; font-size: .8rem; color: var(--muted); font-weight: 700; }
.cred-box code { font-size: 1.4rem; color: var(--primary); user-select: all; }
.class-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; padding: 12px 18px; margin-bottom: 16px; }
.cb-name { font-size: 1.5rem; font-weight: 800; }
.cb-name small { font-size: 1rem; color: var(--muted); }
.code-card { max-width: 520px; margin: 0 auto 22px; text-align: center; }
.code-row { display: flex; gap: 10px; justify-content: center; }
.code-row input { font: inherit; font-size: 2rem; font-weight: 800; letter-spacing: 6px; text-transform: uppercase; text-align: center; width: 240px; padding: 6px 10px; border-radius: 14px; border: 3px solid var(--primary); background: rgba(0,0,0,.3); color: var(--text); }
.teacher-link small { opacity: .7; font-weight: 600; }

/* fiches imprimables */
#print-sheet { display: none; }
.sheet { font-family: "Baloo 2", system-ui, sans-serif; color: #1b2250; background: #fff; padding: 14mm; }
.sheet-head { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid #1c4fb5; padding-bottom: 8px; margin-bottom: 14px; }
.sheet-head img { height: 70px; }
.sheet-head h1 { margin: 0; font-size: 26px; color: #1c4fb5; }
.sheet-cred { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 16px; }
.sheet-cred th, .sheet-cred td { border: 1px solid #c9cfe6; padding: 8px 12px; text-align: left; }
.sheet-cred th { background: #eef2ff; width: 35%; }
.sheet code { background: #fff6d6; color: #1b2250; font-size: 18px; letter-spacing: 2px; }
.sheet-students { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 10px; }
.sheet-st { border: 1px dashed #9aa3c7; padding: 10px; text-align: center; font-size: 14px; break-inside: avoid; }
.sheet-st b { display: block; font-size: 18px; }
.big-av { font-size: 30px; }
.sheet-foot { color: #6b7294; font-size: 12px; margin-top: 16px; }
@media print {
  body.print-sheet-mode > *:not(#print-sheet) { display: none !important; }
  body.print-sheet-mode #print-sheet { display: block !important; page: sheet; }
  body.print-sheet-mode #print-sheet, body.print-sheet-mode #print-sheet * { visibility: visible !important; }
  body.print-sheet-mode { background: #fff !important; }
  body.print-sheet-mode .sheet { padding: 0; }
}

@page sheet { size: A4 portrait; margin: 12mm; }

/* grands nombres */
.chip.op.big.on { border-color: #ff6ad5; background: rgba(255,106,213,.18); box-shadow: 0 0 0 3px rgba(255,106,213,.2); }
.question.bigq { display: block; font-size: clamp(1.4rem, 3.4vw, 2.4rem); letter-spacing: 0; max-width: 680px; margin: 0 auto; }
.bq-label { font-size: .7em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.bq-label .bq-inline { color: var(--text); font-size: 1.5em; white-space: nowrap; }
.bq-words { font-size: .95em; color: #ff9ee6; line-height: 1.25; word-break: break-word; background: rgba(0,0,0,.2); border-radius: 16px; padding: 10px 14px; }
.bq-num { font-size: 2em; white-space: nowrap; }
.bq-text { line-height: 1.35; }
.bq-ans { margin-top: 10px; font-size: 1.4em; }
.question.bigq .blank { min-width: 3em; }
.choices.text-choices { grid-template-columns: 1fr; max-width: 680px; }
.choices.text-choices button { font-size: clamp(.95rem, 1.8vw, 1.15rem); text-align: left; padding: 12px 14px; line-height: 1.3; word-break: break-word; }
.choices.text-choices button b { display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 50%; background: rgba(0,0,0,.3); margin-right: 8px; }
.cls-table { border-collapse: collapse; width: 100%; font-weight: 800; }
.cls-table th, .cls-table td { border: 2px solid rgba(255,255,255,.25); text-align: center; padding: 4px 2px; }
.cls-table th { font-size: .8rem; }
.cls-table td.h { font-size: .95rem; color: var(--muted); }
.cls-table td.dg { font-size: 1.8rem; height: 1.8em; }
.cls-table .c-m { background: rgba(255,106,213,.16); }
.cls-table .c-k { background: rgba(62,198,255,.16); }
.cls-table .c-u { background: rgba(62,224,143,.16); }
.bq-text .nw { white-space: nowrap; }
.cls-table { table-layout: fixed; }

/* fractions */
:root { --frac-on: #3ec6ff; --frac-off: rgba(255,255,255,.07); }
.chip.op.frac.on { border-color: #9be15d; background: rgba(155,225,93,.18); box-shadow: 0 0 0 3px rgba(155,225,93,.2); }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin: 0 .1em; }
.frac .fn { border-bottom: .09em solid currentColor; padding: 0 .15em .06em; min-width: 1.1em; text-align: center; }
.frac .fd { padding: .06em .15em 0; min-width: 1.1em; text-align: center; }
.frac.inline { font-size: .85em; color: var(--primary); }
.fr-big { font-size: 2.2em; margin: 6px 0; display: flex; align-items: center; justify-content: center; gap: .25em; }
.fr-big .blank { min-width: 1.4em; font-size: .9em; }
.frac.fin .fn, .frac.fin .fd { min-width: 1.8em; min-height: 1.1em; border-radius: 12px; border: 3px solid var(--card-border); background: rgba(0,0,0,.28); margin: 3px 0; cursor: pointer; color: var(--primary); }
.frac.fin .fn { border-bottom-width: 3px; }
.frac.fin { gap: 8px; position: relative; }
.frac.fin::after { content: ""; position: absolute; left: -6px; right: -6px; top: 50%; height: 6px; margin-top: -3px; background: #fff; border-radius: 3px; }
.frac.fin .empty { color: rgba(255,255,255,.25); }
.frac.fin .act { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(255,194,26,.35); }
.fig { display: flex; justify-content: center; margin: 6px 0 10px; }
.shape { width: 100%; }
.shape.pie { max-width: 210px; }
.shape.bar { max-width: 460px; }
.shape .part { fill: var(--frac-off); stroke: #fff; stroke-width: 2.5; transition: fill .15s; }
.shape .part.clickable { cursor: pointer; }
.shape .part.clickable:not(.on):hover { fill: rgba(62,198,255,.35); }
.shape .part.on { fill: var(--frac-on); }
.fr-visual { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.fr-visual .eqv { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; }
.unit-bar { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 480px; }
.unit-bar .ub-l { font-size: .8rem; color: var(--muted); font-weight: 800; white-space: nowrap; }
.unit-bar .shape.bar { height: 34px; }
.numline { width: 100%; max-width: 640px; margin-top: 8px; overflow: visible; }
.nl-axis { stroke: #fff; stroke-width: 4; }
.nl-tick { stroke: #fff; stroke-width: 2; } .nl-tick.major { stroke-width: 4; }
.nl-lab { fill: #fff; font: 800 20px "Baloo 2", sans-serif; text-anchor: middle; }
.nl-lab.good { fill: var(--good); }
.nl-hit { fill: transparent; cursor: pointer; } .nl-hit:hover { fill: rgba(255,194,26,.12); }
.nl-arrow { fill: var(--primary); }
.nl-good { fill: var(--good); }
.nl-sel { fill: var(--primary); font: 800 22px "Baloo 2", sans-serif; text-anchor: middle; }
.choices.text-choices button b { width: auto; min-width: 1.8em; padding: 0 .45em; border-radius: 1em; white-space: nowrap; }

.dp-table.skill { grid-template-columns: 1fr; text-align: left; gap: .4cqw; padding: 1cqw 2.4cqw; font-size: 1.7cqw; }
.dp-h3 { margin: 14px 0 8px; font-size: 1.1rem; color: var(--muted); }

.dip-cfg select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 2px solid var(--card-border); background: rgba(0,0,0,.25); color: var(--text); }
.dip-cfg select option { background: #1b2a6b; }
.dip-cfg input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); }
.dip-cfg small { color: var(--muted); }
.dip-matrix td.dm { text-align: center; }
.dip-matrix td.dm.got { background: rgba(62,224,143,.18); }
.dip-matrix td.dm small { color: var(--muted); }

/* géométrie */
.chip.op.tri.on { border-color: #ff922b; background: rgba(255,146,43,.18); }
.chip.op.peri.on { border-color: #4dabf7; background: rgba(77,171,247,.18); }
.chip.op.angle.on { border-color: #da77f2; background: rgba(218,119,242,.18); }
.geo { width: 100%; max-width: 380px; overflow: visible; }
.geo.big { max-width: 360px; }
.g-shape { fill: rgba(62,198,255,.12); stroke: #fff; stroke-width: 3; stroke-linejoin: round; }
.g-line { stroke: #fff; stroke-width: 2.5; } .g-line.blue { stroke: #74c0fc; }
.g-tick { stroke: #ffc21a; stroke-width: 3; }
.g-right { fill: none; stroke: #ff6b6b; stroke-width: 2.5; }
.g-lab { fill: #ffe066; font: 800 17px "Baloo 2", sans-serif; text-anchor: middle; }
.g-grid { stroke: rgba(255,255,255,.18); stroke-width: 1; }
.g-cell { fill: rgba(62,198,255,.12); }
.g-edge { stroke: #4dabf7; stroke-width: 4; stroke-linecap: round; }
.g-ray { stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.g-vertex { fill: #ffc21a; }
.equerre path:first-child { fill: rgba(255,194,26,.35); stroke: #ffc21a; stroke-width: 2; }
.equerre.hidden { display: none; }
.fig.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fig.three .fig-l { font-weight: 800; font-size: 1.3rem; color: var(--primary); }
.eq-btn { margin-top: 6px; font-size: 1rem; padding: 6px 14px; }
.ang-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 560px; margin: 0 auto; }
.ang-cell { background: rgba(0,0,0,.2); border: 3px solid var(--card-border); border-radius: 16px; padding: 4px; font-size: 1.2rem; }
.ang-cell .geo { max-width: 170px; }
.ang-cell.sel { border-color: var(--primary); background: rgba(255,194,26,.2); }
.ang-cell.right { border-color: var(--good); } .ang-cell.notright.sel { border-color: var(--bad); background: rgba(255,93,115,.25); }
.choices.text-choices button b:empty { display: none; }
.geo.big { max-width: 420px; }

/* comptes famille */
.sub-banner { border-radius: 14px; padding: 10px 16px; margin: -4px 0 16px; font-weight: 600; }
.sub-banner.ok { background: rgba(62,224,143,.14); border: 1px solid rgba(62,224,143,.45); }
.sub-banner.warn { background: rgba(255,194,26,.14); border: 1px solid rgba(255,194,26,.5); }
.sub-banner.ko { background: rgba(255,93,115,.16); border: 1px solid rgba(255,93,115,.5); }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 10px; }
.fam-act { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.signup-cta { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--card-border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.signup-cta span { color: var(--muted); font-weight: 600; }

/* 👁️ afficher / masquer le mot de passe */
.pw-wrap { position: relative; display: block; margin-top: 6px; }
.pw-wrap > input { margin-top: 0 !important; padding-right: 54px !important; width: 100%; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; border-radius: 12px;
  background: transparent; font-size: 1.3rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.pw-eye:hover, .pw-eye:focus-visible { background: rgba(255,255,255,.12); outline: none; }

/* 📘 tutoriels */
.tuto-link { margin-top: 14px; text-align: center; }
.modal-card.tuto-card { position: relative; width: min(820px, 100%); max-height: 92vh; overflow-y: auto; text-align: left; padding: 22px; }
.tuto-card > h2 { text-align: center; margin-bottom: 12px; }
.tuto-x { position: sticky; top: 0; float: right; margin: -8px -8px 0 0; width: 40px; height: 40px; border-radius: 50%; border: 0; z-index: 2;
  background: rgba(255,255,255,.12); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.tuto-x:hover { background: rgba(255,255,255,.22); }
.tuto-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 8px; }
.tuto-title { margin: 14px 0 4px; font-size: 1.35rem; }
.tuto-intro { color: var(--muted); margin: 0 0 12px; }
.tuto-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.tuto-steps li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; background: rgba(0,0,0,.18); border: 1px solid var(--card-border);
  border-radius: 18px; padding: 14px; }
.tuto-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 900;
  background: var(--primary); color: #fff; }
.tuto-txt h4 { margin: 4px 0 6px; font-size: 1.08rem; }
.tuto-txt p { margin: 0; color: var(--text); opacity: .9; line-height: 1.5; }
.tuto-txt img { display: block; width: 100%; height: auto; margin-top: 10px; border-radius: 12px; border: 1px solid var(--card-border);
  cursor: zoom-in; }
.tuto-txt img.zoom { position: fixed; inset: 2vh 2vw; width: 96vw; height: 96vh; object-fit: contain; margin: 0; z-index: 90;
  background: rgba(5,10,40,.95); cursor: zoom-out; border: 0; }
.tuto-foot { text-align: center; color: var(--muted); margin: 16px 0 8px; }
@media (max-width: 560px) { .tuto-tabs .chip { padding: 6px 10px; font-size: .9rem; } .tuto-steps li { grid-template-columns: 1fr; } .modal-card.tuto-card { padding: 16px; } }

/* code secret obligatoire */
.pin-cell { white-space: nowrap; }
.pin-cell .t-in.pin { width: 6.5em; display: inline-block; letter-spacing: .15em; }
.pin-cell .icon-btn { margin-left: 4px; }
#pin-msg { min-height: 1.3em; margin: 6px 0 0; }

/* 🚀 animation de bienvenue */
.welcome { position: fixed; inset: 0; z-index: 95; display: grid; grid-template-rows: 1fr auto; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #23408f 0%, #0a1847 55%, #050b26 100%); color: var(--text);
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); animation: wl-in .4s ease both; }
.welcome.out { animation: wl-out .45s ease forwards; }
@keyframes wl-in { from { opacity: 0; } }
@keyframes wl-out { to { opacity: 0; transform: scale(1.04); } }
.wl-stars i { position: absolute; height: 2px; width: var(--w); border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.85)); animation: wl-streak var(--d) linear infinite; }
@keyframes wl-streak { from { transform: translateX(40vw); opacity: 0; } 15% { opacity: 1; } to { transform: translateX(-60vw); opacity: 0; } }
.wl-stage { position: relative; display: grid; place-items: center; min-height: 0; }
.wl-scene { width: min(1100px, 100%); height: 100%; max-height: 62vh; overflow: visible; }
.wl-stage, .wl-text { position: relative; z-index: 2; }
.wl-fly { animation: wl-arrive 2.2s cubic-bezier(.2,.8,.25,1) both; }
@keyframes wl-arrive { 0% { transform: translate(-1400px, 60px) rotate(-6deg); } 70% { transform: translate(30px, -6px) rotate(2deg); }
  100% { transform: translate(0, 0) rotate(0); } }
.wl-bob { animation: wl-bob 2.6s ease-in-out 2.2s infinite; }
@keyframes wl-bob { 50% { transform: translateY(-9px) rotate(-1deg); } }
.wl-flame { transform-origin: 8px 133px; animation: wl-flame .12s ease-in-out infinite alternate; }
@keyframes wl-flame { to { transform: scaleX(1.35) scaleY(.9); } }
.wl-flag { transform-origin: -34px 123px; animation: wl-wave 1s ease-in-out infinite; }
@keyframes wl-wave { 0%, 100% { transform: skewY(-3deg); } 50% { transform: skewY(3deg) translateY(2px); } }
.wl-banner { fill: #ffc21a; stroke: #0d1b4c; stroke-width: 4; }
.wl-banner-tail { fill: #ff9800; stroke: #0d1b4c; stroke-width: 4; stroke-linejoin: round; }
.wl-rope { fill: none; stroke: #bfe6ff; stroke-width: 3; stroke-dasharray: 5 4; }
.wl-name { font-family: inherit; font-weight: 900; fill: #1b1450; letter-spacing: .02em; }
.wl-arm { transform-origin: 196px 92px; animation: wl-hello .5s ease-in-out 2.2s 6 alternate; }
@keyframes wl-hello { from { transform: rotate(-10deg); } to { transform: rotate(22deg); } }
.wl-burst { position: absolute; left: 50%; top: 50%; pointer-events: none; }
.wl-burst b { position: absolute; font-size: 1.6rem; opacity: 0; transform: translate(-50%, -50%);
  animation: wl-pop 1.4s ease-out both; }
@keyframes wl-pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(-1 * var(--r))) rotate(calc(-1 * var(--a))) scale(1.1); } }
.wl-text { text-align: center; display: grid; gap: 10px; justify-items: center; padding-bottom: 8px; }
.wl-text h1 { margin: 0; font-size: clamp(1.6rem, 4.6vw, 3rem); line-height: 1.15; text-wrap: balance;
  animation: wl-rise .6s cubic-bezier(.2,.9,.3,1.3) 1.9s both; }
.wl-text h1 span { color: var(--primary); }
.wl-text h1, .wl-text p { text-shadow: 0 2px 12px rgba(5,11,38,.9); }
.wl-text p { margin: 0; font-size: clamp(1.1rem, 2.6vw, 1.5rem); color: var(--muted); max-width: 32ch; text-wrap: balance;
  animation: wl-rise .6s ease 2.6s both; }
.wl-text .btn { width: auto; min-width: 240px; padding-inline: 34px; margin-top: 10px; animation: wl-rise .5s cubic-bezier(.2,.9,.3,1.4) 3.2s both; }
@keyframes wl-rise { from { opacity: 0; transform: translateY(24px) scale(.95); } }
@media (prefers-reduced-motion: reduce) {
  .welcome *, .welcome { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .wl-stars { display: none; }
}

/* 🛸 Mission Tables — jeu spatial des multiplications */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#screen-space { --sp-panel: #121a45; --sp-panel2: #1a2460; --sp-line: #26307a; --sp-muted: #9aa4d8; --sp-flame: #ffb020;
  --sp-laser: #39f0d0; --sp-pink: #ff6fb1; --sp-gold: #ffe66d; }
.sp-wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 20px; }
.sp-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 14px; }
.sp-head .icon-btn { grid-row: span 2; }
.sp-head h1 { margin: 0; font-family: "Fredoka", "Baloo 2", sans-serif; font-size: clamp(24px, 4vw, 36px); line-height: 1.05;
  background: linear-gradient(90deg, var(--sp-flame), var(--sp-pink) 55%, var(--sp-laser)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sp-head p { margin: 0; color: var(--sp-muted); font-size: 16px; }
.sp-stage { position: relative; width: 100%; aspect-ratio: 16 / 8; border-radius: 20px; overflow: hidden; background: #070b24;
  box-shadow: 0 0 0 2px #1d2766, 0 20px 60px -20px #000; }
@media (max-width: 640px) { .sp-stage { aspect-ratio: 1 / 1; } }
.sp-stage canvas { display: block; width: 100%; height: 100%; }
.sp-end { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5,7,32,.55); }
.sp-end[hidden] { display: none; }
.sp-card { background: var(--sp-panel); box-shadow: inset 0 0 0 2px var(--sp-line), 0 30px 80px -20px #000; border-radius: 22px; padding: 22px 24px;
  max-width: 460px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; animation: sp-pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes sp-pop { from { transform: scale(.7); opacity: 0; } }
.sp-card h2 { margin: 0; font-family: "Fredoka", "Baloo 2", sans-serif; font-size: clamp(22px, 3.6vw, 30px); line-height: 1.15; color: var(--sp-gold); text-wrap: balance; }
.sp-stars { font-size: clamp(34px, 6vw, 48px); letter-spacing: .12em; line-height: 1; }
.sp-stars .on { color: var(--sp-gold); text-shadow: 0 0 18px rgba(255,230,109,.6); }
.sp-stars .off { color: #2c366f; }
.sp-card p { margin: 0; color: var(--sp-muted); font-size: 17px; }
.sp-card .sp-save { color: var(--sp-laser); font-weight: 700; min-height: 1.4em; }
.sp-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.sp-console { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr); gap: 14px; align-items: stretch; }
@media (max-width: 760px) { .sp-console { grid-template-columns: 1fr; } }
.sp-question { background: var(--sp-panel); border-radius: 18px; box-shadow: inset 0 0 0 2px var(--sp-line); padding: 14px 18px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 112px; }
.sp-qline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 800; font-size: clamp(34px,5.5vw,52px); line-height: 1; font-variant-numeric: tabular-nums; }
.sp-answer { min-width: 2.6em; padding: 6px 14px; border-radius: 14px; background: #0a0f33; box-shadow: inset 0 0 0 3px var(--sp-laser); color: var(--sp-laser); text-align: center; }
.sp-answer.empty::after { content: ""; display: inline-block; width: 3px; height: .8em; background: var(--sp-laser); vertical-align: -.05em; animation: sp-blink 1s steps(1) infinite; }
@keyframes sp-blink { 50% { opacity: 0; } }
.sp-feedback { min-height: 1.5em; font-size: 18px; font-weight: 700; color: var(--sp-muted); }
.sp-feedback.ok { color: var(--sp-laser); }
.sp-feedback.ko { color: var(--sp-pink); }
#screen-space :where(button:not(.icon-btn):not(.link)) { font: inherit; cursor: pointer; border: 0; border-radius: 14px; color: var(--text); background: var(--sp-panel);
  padding: 6px 12px; font-weight: 700; font-size: 16px; box-shadow: inset 0 0 0 2px var(--sp-line); transition: transform .1s, background .12s; }
#screen-space :where(button:not(.icon-btn):not(.link)):hover { background: var(--sp-panel2); }
#screen-space button:active { transform: scale(.95); }
#screen-space button:focus-visible { outline: 3px solid var(--sp-laser); outline-offset: 2px; }
.sp-pad { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 8px; }
#screen-space .sp-pad button { font-size: clamp(22px,3.4vw,30px); font-weight: 800; padding: 8px 0; min-height: 52px; font-variant-numeric: tabular-nums; }
#screen-space .sp-pad .fire, #screen-space .sp-primary, #screen-space button[aria-pressed="true"] { background: var(--sp-flame); color: #2a1600; box-shadow: none; }
#screen-space .sp-pad .fire { font-family: "Fredoka", "Baloo 2", sans-serif; font-size: clamp(18px,2.4vw,24px); }
#screen-space .sp-pad .fire:hover, #screen-space .sp-primary:hover { background: #ffc450; }
#screen-space .sp-pad .del { color: var(--sp-pink); }
#screen-space .sp-primary { font-size: 18px; padding: 8px 18px; }
.sp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.sp-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sp-label { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--sp-muted); font-weight: 700; margin-right: 4px; }
#screen-space .sp-group button { min-width: 44px; font-variant-numeric: tabular-nums; }
