/* Une table lumineuse : fond neutre pour laisser la photo dominer, bleu gentiane pour les actions, Latin toujours en italique. */
:root {
  --bg: #eef1ee; --panel: #fbfcfa; --line: #cfd6d0; --fg: #18211d; --muted: #5c6a62;
  --accent: #2346b8; --accent-fg: #ffffff; --accent-soft: #dfe5f8;
  --ok: #1d7a48; --ok-soft: #d9f0e2; --bad: #b5342b; --bad-soft: #f8dfdc; --warn: #94650a; --warn-soft: #f6ead0;
  --photo: #dfe4df;
  --display: "Alegreya", Georgia, serif; --body: "Figtree", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a17; --panel: #1b2420; --line: #33403a; --fg: #e8eee9; --muted: #9caaa2;
    --accent: #8ea8ff; --accent-fg: #0f1730; --accent-soft: #252f52;
    --ok: #63cf95; --ok-soft: #173325; --bad: #f08a80; --bad-soft: #3d1e1b; --warn: #e2b458; --warn-soft: #362b12;
    --photo: #0d1210; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131a17; --panel: #1b2420; --line: #33403a; --fg: #e8eee9; --muted: #9caaa2;
  --accent: #8ea8ff; --accent-fg: #0f1730; --accent-soft: #252f52;
  --ok: #63cf95; --ok-soft: #173325; --bad: #f08a80; --bad-soft: #3d1e1b; --warn: #e2b458; --warn-soft: #362b12;
  --photo: #0d1210; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--body); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
i.lat, .lat { font-family: var(--display); font-style: italic; font-weight: 700; }
small { color: var(--muted); }
a { color: var(--accent); }

.top { display: flex; align-items: center; gap: 20px; padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, 3vw, env(safe-area-inset-right, 0px)) 10px max(16px, 3vw, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { background: none; border: 0; padding: 0; font: 700 24px var(--display); }
.hud { display: flex; align-items: center; gap: 22px; margin-left: auto; font-variant-numeric: tabular-nums; }
.hud span { display: grid; line-height: 1.15; }
.hud small { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.hud b { font: 500 18px var(--mono); }
.streak { font-size: 13px; color: var(--muted); margin-left: auto; }
.install { font-size: 14px; }
.hud:not([hidden]) + .streak { display: none; }
.progress { height: 4px; background: var(--line); }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; }
.ghost:hover { border-color: var(--fg); }
main { padding: 24px max(16px, 3vw, env(safe-area-inset-right, 0px)) calc(48px + env(safe-area-inset-bottom, 0px)) max(16px, 3vw, env(safe-area-inset-left, 0px)); max-width: 1320px; margin: auto; }

/* Accueil */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.home h1 { font: 700 clamp(30px, 4vw, 44px)/1.1 var(--display); margin: 0 0 6px; text-wrap: balance; }
.home > div > p { margin: 0 0 22px; color: var(--muted); max-width: 62ch; }
.filter { width: 100%; max-width: 460px; margin-bottom: 20px; display: block; }
.fam { margin-bottom: 20px; }
.fam h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.group { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 2px; }
.group:hover { border-color: var(--fg); }
.group[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.group strong { font-weight: 600; }
.group small { font-size: 13px; }
.meter { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.meter div { height: 100%; background: var(--accent); }
.custom { display: flex; gap: 8px; max-width: 460px; }
.custom input { flex: 1; min-width: 0; }
input[type=text] { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; }
.setup { position: sticky; top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: grid; gap: 16px; }
.setup h2 { font: 700 26px/1.1 var(--display); margin: 0; }
.field { display: grid; gap: 6px; }
.field > label, .field > span { font-size: 13px; font-weight: 600; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.check { display: flex; gap: 8px; font-size: 14px; align-items: flex-start; }
.check input { margin-top: 4px; }
.primary { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 7px; padding: 12px 16px; font-weight: 700; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.rank { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.confus { font-size: 14px; margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; }

/* Partie */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; align-items: start; }
.stage { background: var(--photo); border-radius: 8px; position: relative; display: flex; justify-content: center; align-items: center; height: min(78vh, 760px); min-height: 280px; overflow: hidden; }
.stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.flag { position: absolute; right: 8px; bottom: 8px; background: rgba(10, 14, 12, .72); color: #fff; border: 0; border-radius: 5px; font-size: 12px; padding: 5px 9px; }
.side { display: grid; gap: 12px; }
.prompt { font-size: 14px; color: var(--muted); margin: 0; }
.opts { display: grid; gap: 7px; }
.opt { display: grid; grid-template-columns: 26px 1fr; align-items: baseline; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; }
.opt:hover:not(:disabled) { border-color: var(--fg); }
.opt kbd, .pic kbd { font: 500 12px var(--mono); color: var(--muted); }
.opt .lat { font-size: 19px; line-height: 1.15; }
.opt small { display: block; font-size: 13px; }
.selected { border-color: var(--accent) !important; box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.right { border-color: var(--ok) !important; background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.wrong { border-color: var(--bad) !important; background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.typed { width: 100%; font: italic 700 22px var(--display); }
.conf { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.conf button { border-radius: 7px; padding: 9px 8px; background: var(--panel); border: 1px solid var(--line); display: grid; }
.conf button:hover:not(:disabled) { border-color: var(--fg); }
.conf button:disabled { opacity: .45; cursor: not-allowed; }
.conf button b { font-weight: 700; }
.conf small { font: 500 12px var(--mono); }
.conf .pass { grid-column: 1 / -1; }
.label { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 13px 15px; display: grid; gap: 6px; }
.verdict { font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.verdict b { font: 500 16px var(--mono); }
.good { color: var(--ok); } .badv { color: var(--bad); } .mid { color: var(--warn); }
.label .lat { font-size: 25px; line-height: 1.1; }
.meta { font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.compare img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: zoom-in; background: var(--photo); display: block; }
.compare-title { font-size: 13px; margin: 0 0 -6px; font-weight: 600; }
.next { width: 100%; }

.imgplay { display: grid; gap: 14px; }
.imgprompt { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.imgprompt .lat { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; }
.pics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pics.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pic { position: relative; background: var(--photo); border: 3px solid transparent; border-radius: 8px; padding: 0; overflow: hidden; height: 34vh; min-height: 170px; }
.pics.six .pic { height: 30vh; }
.pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pic.selected, .pic.right, .pic.wrong { box-shadow: none; }
.pic kbd { position: absolute; left: 6px; top: 6px; background: rgba(10, 14, 12, .72); color: #fff; padding: 1px 6px; border-radius: 4px; }
.zoom { position: absolute; right: 6px; top: 6px; background: rgba(10, 14, 12, .72); color: #fff; border-radius: 4px; padding: 1px 7px; font-size: 13px; }
.caption { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(10, 14, 12, .78); color: #fff; font-size: 14px; padding: 4px 8px; text-align: left; }
.imgbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.imgbar .pass { grid-column: auto; }
.imgbar.conf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reveal-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }

.state { min-height: 50vh; display: grid; place-content: center; text-align: center; gap: 10px; color: var(--muted); }
.state h2 { font: 700 26px var(--display); color: var(--fg); margin: 0; }

/* Frontière */
.opt-none { grid-template-columns: 26px 1fr; font-weight: 600; border-style: dashed; }
.bet-title { margin: 0 0 6px; }
.bets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.bets button { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 8px; display: grid; gap: 1px; text-align: center; }
.bets button:hover:not(:disabled) { border-color: var(--fg); }
.bets button:disabled { opacity: .45; cursor: not-allowed; }
.bets b { font: 500 19px var(--mono); }
.bets small { font-size: 12px; }
.seed-name { font-size: 24px; }
.predict input { width: 110px; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 500 20px var(--mono); }
.predict .custom { justify-content: center; margin: auto; }
.note input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.note label { font-weight: 500; }
.cal { display: grid; gap: 8px; }
.cal-head, .cal-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 96px; gap: 10px; align-items: center; font-size: 14px; }
.cal-head { font-size: 12px; color: var(--muted); }
.cal-label, .cal-value { font: 500 14px var(--mono); }
.cal-value small { font-size: 12px; }
.cal-track { position: relative; height: 16px; border-bottom: 1px solid var(--line); }
.cal-bar { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.cal-target { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--fg); box-shadow: 0 0 0 2px var(--bg); }

/* Clé vivante */
.keyframe { position: relative; overflow: hidden; flex: none; }
.keyframe img { width: 100%; height: 100%; object-fit: cover; filter: blur(clamp(14px, 2.4vw, 30px)); transform: scale(1.04); cursor: default; }
.keyframe img.clear { filter: none; transform: none; }
.keyframe canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.zones { display: flex; flex-wrap: wrap; gap: 6px; }
.zone-btn { flex: 1 1 auto; font-size: 14px; }
.zone-btn kbd { font: 500 12px var(--mono); color: var(--muted); }
.zone-btn:disabled { opacity: .55; cursor: default; }

/* Bilan */
.end { display: grid; gap: 24px; max-width: 900px; margin: auto; }
.end h1 { font: 700 40px/1.1 var(--display); margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat b { display: block; font: 500 30px var(--mono); }
.stat small { font-size: 13px; }
.advice { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; margin: 0; max-width: 70ch; }
.end h2 { font: 700 22px var(--display); margin: 0 0 8px; }
.misses { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.miss { display: grid; grid-template-columns: 60px 1fr; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px; }
.miss img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }
.miss small { display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .ghost { padding: 12px 16px; }

.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(5, 8, 7, .93); display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.err { color: var(--bad); font-size: 14px; margin: 0; }

@media (max-width: 900px) {
  .home, .play, .reveal-row { grid-template-columns: minmax(0, 1fr); }
  .setup { position: static; }
  .stage { height: 52vh; }
  .pics.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pic, .pics.six .pic { height: 25vh; }
  .hud { gap: 14px; margin-left: 0; width: 100%; justify-content: space-between; }
}
/* Écran tactile : pas de raccourcis clavier, et des cibles confortables */
@media (hover: none) {
  .hk, .opt kbd, .zone-btn kbd { display: none; }
  .opt { grid-template-columns: 1fr; padding-block: 12px; }
  .seg button, .ghost { min-height: 44px; }
}
@media (max-width: 900px) {
  main { padding-top: 12px; }
  .top { gap: 10px; }
  .hud small { font-size: 10px; }
  .hud b { font-size: 16px; }
}
/* Téléphone : la photo reste visible pendant qu'on répond, et le pari tient sur une ligne */
@media (max-width: 600px) {
  .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .play { gap: 10px; }
  .play .stage { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2; height: 38vh; min-height: 220px; }
  .opts { gap: 5px; }
  .opt { padding-block: 8px; }
  .opt .lat { font-size: 18px; }
  .bets { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .bets button { padding: 7px 2px; }
  .bets b { font-size: 16px; }
  .bets small { font-size: 11px; line-height: 1.2; }
  .zone-btn { flex: 1 1 18%; padding-inline: 4px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
