:root {
  --bg: #f4f2ea;
  --card: #ffffff;
  --ink: #141414;
  --muted: #5f5f54;
  --line: #141414;
  --primary: #4f46e5;
  --primary-ink: #fff;
  --primary-soft: #e5e3ff;
  --success: #0e9f6e;
  --success-soft: #d8f3e7;
  --error: #e5484d;
  --error-soft: #fbdedf;
  --accent: #f97316;
  --accent-soft: #ffe6d2;
  --radius: 18px;
  --radius-sm: 13px;
  --font: 'Space Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); cursor: pointer; }
input { font-family: var(--font); }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; overflow-x: hidden; }

.mi {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
}

/* Masque les flèches des champs numériques */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* mascot */
.mascot { position: relative; border-radius: 16px; background: var(--primary); border: 2px solid #141414; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 2px 2px 0 #141414; flex: none; }
.mascot.sm { width: 48px; height: 48px; gap: 5px; }
.mascot.lg { width: 96px; height: 96px; border-radius: 28px; gap: 9px; box-shadow: 3px 3px 0 #141414; }
.mascot .eyes { display: flex; }
.mascot.sm .eyes { gap: 11px; }
.mascot.lg .eyes { gap: 20px; }
.mascot .eye { border-radius: 50%; background: #fff; }
.mascot.sm .eye { width: 7px; height: 7px; }
.mascot.lg .eye { width: 12px; height: 12px; }
.mascot .mouth { background: #fff; border-radius: 4px; }
.mascot.sm .mouth { width: 16px; height: 4px; }
.mascot.lg .mouth { width: 28px; height: 6px; }
.m-happy .mouth { background: none; border-bottom: 3.5px solid #fff; border-radius: 0 0 22px 22px; }
.mascot.sm.m-happy .mouth { width: 20px; height: 9px; }
.mascot.lg.m-happy .mouth { width: 38px; height: 16px; border-bottom-width: 5px; border-radius: 0 0 38px 38px; }
.m-sad { background: var(--error); }
.m-sad .mouth { background: none; border-top: 3.5px solid #fff; border-radius: 22px 22px 0 0; }
.mascot.sm.m-sad .mouth { width: 20px; height: 9px; }
.mascot.lg.m-sad .mouth { width: 38px; height: 16px; border-top-width: 5px; border-radius: 38px 38px 0 0; }
.bob { animation: bob 3.6s ease-in-out infinite; }

/* home */
.home { padding: 22px 18px 40px; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.h1 { margin: 0; font-weight: 700; font-size: 27px; letter-spacing: -.02em; line-height: 1; }
.sub { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.sect { margin-top: 22px; }
.sl { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 2px 10px; }
.ops { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.chip { display: flex; align-items: center; gap: 9px; padding: 12px 13px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; color: var(--ink); text-align: left; line-height: 1.15; transition: transform .08s; }
.chip:active { transform: translate(1px, 1px); }
.chip .op { font-weight: 700; font-size: 17px; width: 22px; text-align: center; flex: none; color: var(--muted); }
.chip .mi { font-size: 20px; width: 22px; text-align: center; flex: none; color: var(--muted); }
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 2px 2px 0 #141414; }
.chip.on .op, .chip.on .mi { color: var(--primary); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.segi { padding: 11px 4px; text-align: center; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; color: var(--ink); }
.segi.on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 2px 2px 0 #141414; }
.help { font-size: 12.5px; color: var(--muted); margin: 10px 2px 0; line-height: 1.45; min-height: 18px; }
.modes { display: flex; flex-direction: column; gap: 9px; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--card); text-align: left; width: 100%; color: var(--ink); }
.mrow .lead { font-size: 23px; color: var(--muted); flex: none; }
.mrow .mm { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mrow .mm b { font-weight: 700; font-size: 14.5px; }
.mrow .mm span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.mrow .chk { font-size: 22px; color: var(--line); flex: none; }
.mrow.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 2px 2px 0 #141414; }
.mrow.on .lead, .mrow.on .chk, .mrow.on .mm b { color: var(--primary); }
.subpills { display: flex; gap: 7px; margin: 0 2px 0 40px; }
.pill { padding: 7px 15px; border-radius: 11px; border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; color: var(--ink); }
.pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 16px; border-radius: var(--radius-sm); font-weight: 700; font-size: 17px; border: 2px solid #141414; transition: transform .08s, box-shadow .08s; }
.btn .mi { font-size: 22px; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #141414 !important; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 3px 3px 0 #141414; }
.btn-secondary { background: var(--card); color: var(--ink); box-shadow: 3px 3px 0 #141414; }
.start { margin-top: 24px; }
.errline { color: var(--error); font-weight: 600; font-size: 13px; text-align: center; margin: 10px 0 0; min-height: 16px; }
.card { background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); box-shadow: 3px 3px 0 #141414; padding: 16px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat { text-align: center; padding: 13px 6px; border-radius: var(--radius-sm); background: var(--primary-soft); border: 2px solid #141414; }
.stat b { display: block; font-weight: 700; font-size: 23px; color: var(--primary); line-height: 1; }
.stat span { font-size: 10.5px; color: var(--muted); margin-top: 5px; display: block; line-height: 1.2; }
.best { display: flex; align-items: center; gap: 9px; margin-top: 13px; padding: 12px 13px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 2px solid #141414; font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.best .mi { font-size: 19px; flex: none; }
.hist { margin-top: 14px; display: flex; flex-direction: column; }
.hrow { display: flex; align-items: center; gap: 11px; padding: 10px 2px; border-top: 1.5px solid var(--line); font-size: 13px; }
.hrow:first-child { border-top: none; }
.hrow .hd { width: 9px; height: 9px; border-radius: 50%; flex: none; border: 1.5px solid #141414; }
.hrow .hm { flex: 1; color: var(--ink); font-weight: 600; }
.hrow .hs { color: var(--muted); font-weight: 700; }
.histempty { font-size: 12.5px; color: var(--muted); padding: 8px 2px; line-height: 1.4; }
.reset { display: block; margin: 16px auto 2px; background: none; border: none; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }

/* game */
.game { padding: 16px 18px 28px; min-height: 100vh; flex-direction: column; }
.gtop { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0 2px; }
.quit { display: flex; align-items: center; gap: 5px; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 4px; }
.quit .mi { font-size: 20px; }
.gctx { font-weight: 600; font-size: 15px; }
.ghearts { display: inline-flex; gap: 4px; }
.ghearts .mi { font-size: 21px; color: var(--error); }
.ghearts .mi.off { opacity: .2; }
.gtime { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 16px; }
.gtime .mi { font-size: 19px; color: var(--muted); }
.streak { display: flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 11px; background: var(--accent-soft); border: 2px solid #141414; font-weight: 700; font-size: 14px; }
.streak .mi { font-size: 17px; color: var(--accent); }
.dots { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin: 20px 6px 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #e6e3d7; border: 1.5px solid #141414; }
.dot.ok { background: var(--success); }
.dot.no { background: var(--error); }
.dot.now { background: var(--bg); box-shadow: inset 0 0 0 3px var(--primary); }
.bar { height: 12px; border-radius: 11px; background: #e6e3d7; margin: 18px 4px 0; overflow: hidden; border: 2px solid #141414; }
.barfill { height: 100%; transition: width .12s linear, background .3s; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px 0; }
.qsub { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 6px; text-align: center; }
.q { font-weight: 700; font-size: clamp(40px, 13vw, 58px); letter-spacing: -.01em; line-height: 1.05; text-align: center; }
#answer-form { display: flex; flex-direction: column; align-items: center; gap: 24px; width: 100%; }
.input { width: 180px; padding: 15px; text-align: center; font-weight: 600; font-size: 36px; color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-sm); outline: none; box-shadow: 2px 2px 0 #141414; }
.input:focus { border-color: var(--primary); box-shadow: 2px 2px 0 var(--primary); }
.input::placeholder { color: #cdccc0; }
.frac { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.frac .input { width: 130px; padding: 11px; font-size: 28px; }
.frac .fbar { width: 140px; height: 3px; background: var(--ink); border-radius: 3px; }
.keypad { display: grid; grid-template-columns: repeat(3, 62px); gap: 9px; justify-content: center; }
.key { display: flex; align-items: center; justify-content: center; width: 62px; height: 50px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: 21px; color: var(--ink); box-shadow: 2px 2px 0 #141414; transition: transform .08s, box-shadow .08s; user-select: none; }
.key:active { transform: translate(2px, 2px); box-shadow: 0 0 0 #141414; }
.key .mi { font-size: 21px; }
.key-empty { visibility: hidden; box-shadow: none; }
.key-clear { color: var(--muted); }
.validbtn { max-width: 230px; }
.fb { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 20; animation: pop .32s cubic-bezier(.2, 1.4, .4, 1); }
.fbpill { display: flex; align-items: center; gap: 9px; padding: 13px 22px; border-radius: 14px; font-weight: 700; font-size: 17px; border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; }
.fbpill.ok { background: var(--success-soft); color: var(--success); }
.fbpill.no { background: var(--error-soft); color: var(--error); }
.fbpill .mi { font-size: 22px; }
.fbans { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); padding: 3px 10px; border-radius: 8px; }
.fbans b { color: var(--ink); }

/* results */
.res { padding: 22px 20px 30px; min-height: 100vh; flex-direction: column; align-items: center; text-align: center; position: relative; overflow: hidden; }
.record { display: inline-flex; align-items: center; gap: 7px; margin: 6px 0 2px; padding: 9px 17px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; animation: pop2 .5s cubic-bezier(.2, 1.4, .4, 1); animation-fill-mode: both; }
.record .mi { font-size: 19px; }
.rtitle { font-weight: 700; font-size: 28px; margin: 16px 0 2px; letter-spacing: -.02em; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; width: 100%; margin: 24px 0 8px; }
.metric { padding: 17px 13px; border-radius: var(--radius-sm); background: var(--card); border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; text-align: left; }
.metric .mi { font-size: 21px; color: var(--primary); }
.metric b { display: block; font-weight: 700; font-size: 26px; color: var(--ink); line-height: 1; margin: 9px 0 4px; }
.metric span { font-size: 11.5px; color: var(--muted); }
.ractions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 18px; }

/* confetti */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.conf { position: absolute; top: -16px; width: 10px; height: 15px; border-radius: 2px; border: 1.5px solid rgba(0, 0, 0, .25); animation: fall linear forwards; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes pop { 0% { transform: translate(-50%, 0) scale(.5); opacity: 0; } 100% { transform: translate(-50%, 0) scale(1); opacity: 1; } }
@keyframes pop2 { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fall { 0% { transform: translateY(-20px) rotate(0); opacity: 1; } 100% { transform: translateY(105vh) rotate(340deg); opacity: .15; } }

/* navigation entre écrans */
.screen { display: none; }
.screen.active { display: block; }
.screen.active.game, .screen.active.res { display: flex; }
[hidden] { display: none !important; }

/* support (support-kit) : version affichée + signalement */
.support-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding: 0 2px; }
.support-version { font-size: 10.5px; color: var(--muted); opacity: .7; }
.support-report-link { background: none; border: none; padding: 2px 0; font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.support-report-link:hover { color: var(--primary); }

/* support (support-kit) : repli des icônes si Material Symbols Rounded
   (Google Fonts) est indisponible — cf. support/icon-fallback.js */
.icons-fallback .mi {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Noto Sans Symbols 2', system-ui, sans-serif;
  font-variation-settings: normal;
  -webkit-font-feature-settings: normal;
  font-feature-settings: normal;
  font-weight: 400;
}
