/* Mise en page : un cahier de passation d'une colonne, une question par écran, cibles tactiles larges. */
:root {
  --paper: #ECEFEA;      /* fond : papier gris vert */
  --sheet: #FAFBF8;      /* feuille */
  --ink: #17201C;        /* encre */
  --muted: #5B665F;      /* texte secondaire */
  --line: #CBD2CA;       /* filets */
  --accent: #2B44C4;     /* bleu papier carbone */
  --accent-soft: #DDE2F6;
  --ok: #2B7A4B;
  --bad: #B3412C;
  --star: #C9921A;      /* étoiles : laiton */
  --font-display: "Young Serif", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #111513; --sheet: #1A1F1C; --ink: #E7ECE7; --muted: #9AA59E; --line: #2D3430;
  --accent: #8B9DFF; --accent-soft: #232A4A; --ok: #6CC490; --bad: #EB8C74; --star: #E6B54A; color-scheme: dark } }
:root[data-theme="dark"] {
  --paper: #111513; --sheet: #1A1F1C; --ink: #E7ECE7; --muted: #9AA59E; --line: #2D3430;
  --accent: #8B9DFF; --accent-soft: #232A4A; --ok: #6CC490; --bad: #EB8C74; --star: #E6B54A; color-scheme: dark }

html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.app { max-width: 30rem; margin-inline: auto; min-height: 100%; display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 24px; }
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); padding-block: 12px 10px;
  display: flex; align-items: center; gap: 12px; }
.brand { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .01em; }
.brand span { color: var(--accent); }
.ticks { flex: 1; display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.ticks i { height: 4px; border-radius: 2px; background: var(--line); }
.ticks i.done { background: var(--ink); }
.ticks i.now { background: var(--accent); }
.quit { font: inherit; font-size: .85rem; color: var(--muted); background: none; border: 0; padding: 8px 4px; cursor: pointer; }
#screen { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }

h1, h2 { font-family: var(--font-display); font-weight: 400; margin: 0; text-wrap: balance; line-height: 1.15; }
h1 { font-size: 2.3rem; }
h2 { font-size: 1.6rem; }
p { margin: 0; }
.lead { font-size: 1.05rem; color: var(--ink); max-width: 34rem; }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.code-tag { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; }
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list.sheet { padding: 4px 16px; gap: 0; }
.list li { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .k { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }

.btn { font: inherit; font-weight: 600; font-size: 1.05rem; min-height: 54px; border-radius: var(--r); border: 0; cursor: pointer;
  background: var(--ink); color: var(--paper); padding: 0 20px; width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, .opt:focus-visible, .key:focus-visible, .quit:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input[type=number] { font: inherit; font-size: 1.4rem; font-family: var(--font-mono); padding: 10px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink); width: 8rem; }
label.check { display: flex; gap: 12px; align-items: flex-start; }
label.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }

/* passation */
.itemhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.itemno { font-family: var(--font-mono); font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.stem { font-size: 1.2rem; line-height: 1.4; }
.stem b { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; }
.seq { font-family: var(--font-mono); font-size: 1.55rem; text-align: center; padding: 22px 6px; background: var(--sheet);
  border: 1px solid var(--line); border-radius: var(--r); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.opts { display: grid; gap: 10px; }
.opts.text { grid-template-columns: 1fr; }
.opts.num { grid-template-columns: 1fr 1fr; }
.opts.pics6 { grid-template-columns: repeat(3, 1fr); }
.opts.pics4 { grid-template-columns: 1fr 1fr; }
.opt { font: inherit; font-size: 1.05rem; text-align: left; min-height: 54px; padding: 12px 16px; border-radius: var(--r); cursor: pointer;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--line); }
.opts.num .opt { text-align: center; font-family: var(--font-mono); font-size: 1.35rem; }
.opts.pics6 .opt, .opts.pics4 .opt { padding: 8px; display: flex; align-items: center; justify-content: center; }
.opt .letter { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); margin-right: 10px; }
.opt.right { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
.opt.wrong { border-color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.opt:active { background: var(--accent-soft); }
.feedback { font-weight: 600; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--bad); }

svg.mx { width: 100%; height: auto; display: block; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); }
svg.cell { width: 100%; height: auto; max-width: 110px; display: block; }
svg .ink { stroke: var(--ink); stroke-width: 2.5; fill: none; }
svg .ink.solid { fill: var(--ink); }
svg .ink.hatched { fill: url(#hatch); }
svg .gridline { stroke: var(--line); stroke-width: 1.5; }
svg .qmark { font-family: var(--font-display); font-size: 46px; fill: var(--accent); text-anchor: middle; }
svg .poly { fill: var(--ink); stroke: var(--sheet); stroke-width: 2; }
.target { display: flex; justify-content: center; padding: 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); }
.target svg { width: 150px; height: 150px; }

.bigdigit { font-family: var(--font-display); font-size: 6rem; text-align: center; min-height: 9rem; display: flex; align-items: center; justify-content: center; }
.entry { font-family: var(--font-mono); font-size: 2rem; letter-spacing: .25em; text-align: center; min-height: 3.5rem; padding: 8px;
  border-bottom: 2px solid var(--ink); font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { font: inherit; font-family: var(--font-mono); font-size: 1.6rem; min-height: 60px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--sheet); color: var(--ink); cursor: pointer; }
.key.small { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.key:active { background: var(--accent-soft); }

svg.glyph { width: 100%; height: 100%; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.codekey { display: grid; grid-template-columns: repeat(9, 1fr); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sheet); }
.codekey div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-right: 1px solid var(--line); }
.codekey div:last-child { border-right: 0; }
.codekey .g { width: 26px; height: 26px; }
.codekey .d { font-family: var(--font-mono); font-size: .95rem; border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 2px; }
.stim { width: 92px; height: 92px; margin: 6px auto; color: var(--accent); }
.clock { font-family: var(--font-mono); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.flash-ok { animation: fok .25s; } .flash-no { animation: fno .3s; }
@keyframes fok { from { color: var(--ok); } }
@keyframes fno { 0%, 100% { transform: none; } 30% { transform: translateX(-5px); } 60% { transform: translateX(5px); } }
.symrow { display: flex; align-items: center; gap: 10px; padding: 14px 10px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); }
.symrow .tg { display: flex; gap: 4px; padding-right: 10px; border-right: 2px solid var(--ink); color: var(--accent); }
.symrow .gs { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.symrow svg { width: 100%; max-width: 40px; height: auto; aspect-ratio: 1; display: block; margin: auto; }
.symrow .tg svg { width: 34px; }

/* résultats */
.score { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.score .n { font-family: var(--font-display); font-size: 5rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.score .r { font-family: var(--font-mono); font-size: .95rem; color: var(--muted); }
svg.profile { width: 100%; height: auto; display: block; }
svg.profile text { font-family: var(--font-body); font-size: 12px; fill: var(--muted); }
svg.profile .lab { fill: var(--ink); font-size: 13px; font-weight: 600; }
svg.profile .val { fill: var(--ink); font-family: var(--font-mono); font-size: 12px; }
svg.profile .band { fill: var(--accent-soft); }
svg.profile .tick { stroke: var(--line); }
svg.profile .mid { stroke: var(--muted); stroke-dasharray: 3 3; }
svg.profile .ci { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
svg.profile .dot { fill: var(--accent); }
table.subs { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.subs td, table.subs th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.subs th { font-weight: 500; color: var(--muted); font-size: .8rem; }
table.subs td.num, table.subs th.num { text-align: right; font-family: var(--font-mono); }
.note { font-size: .88rem; color: var(--muted); }
.warn { border-left: 3px solid var(--accent); padding-left: 12px; }
.confirm { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.stars { display: flex; gap: 6px; font-size: 3rem; line-height: 1; }
.stars span { color: var(--line); }
.stars span.on { color: var(--star); }
.pts { font-size: 1.1rem; }
.pts .plus { font-family: var(--font-display); font-size: 2.2rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.big-n { font-family: var(--font-display); font-size: 3rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.form { display: flex; flex-direction: column; gap: 14px; }
select { font: inherit; font-size: 1rem; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sheet); color: var(--ink); min-height: 50px; width: 100%; }
select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-player { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; border-top: 4px solid var(--star); }
.tab { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.starcell { color: var(--star); letter-spacing: 2px; }
@media (prefers-reduced-motion: reduce) { .flash-ok, .flash-no { animation: none; } .timer > i { transition: none !important; } }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }

/* administration */
.textin { font: inherit; font-size: 1.1rem; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sheet); color: var(--ink); min-height: 50px; width: 100%; }
.textin:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.linkbtn { font: inherit; font-size: .85rem; background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px; cursor: pointer; align-self: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpis .big-n { font-size: 1.8rem; }
table.subs td.num { white-space: nowrap; }
