/* Pas perdus: Paris stone and paper, the Bièvre's water, Nivelle's violet seal for fiction. */
:root {
  --ink: #1F2A2E; --muted: #55625F; --paper: #F6F1E7; --card: #FFFDF8; --line: #E1D8C6; --bg: #EDE6D8;
  --river: #2F6F73; --river-soft: #DCEBE8; --on-river: #FFFFFF; --brick: #B5532F; --gold: #8A6418; --gold-soft: #F4E6C4;
  --fic: #6E4391; --fic-soft: #EFE6F6; --me: #E4F2E0; --ok: #2E7D4F; --bad: #A33A2A;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ink: #ECE6DA; --muted: #B4AC9E; --paper: #1D2224; --card: #252B2D; --line: #3A4244; --bg: #15191A;
  --river: #7FC0BD; --river-soft: #213A3A; --on-river: #0F1E1E; --brick: #E08A68; --gold: #E5C27A; --gold-soft: #3A3220;
  --fic: #C9A6E8; --fic-soft: #2F2638; --me: #23352A; --ok: #7BD49E; --bad: #F08F7E; color-scheme: dark } }
:root[data-theme="dark"] {
  --ink: #ECE6DA; --muted: #B4AC9E; --paper: #1D2224; --card: #252B2D; --line: #3A4244; --bg: #15191A;
  --river: #7FC0BD; --river-soft: #213A3A; --on-river: #0F1E1E; --brick: #E08A68; --gold: #E5C27A; --gold-soft: #3A3220;
  --fic: #C9A6E8; --fic-soft: #2F2638; --me: #23352A; --ok: #7BD49E; --bad: #F08F7E; color-scheme: dark }

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); min-height: 100dvh; display: flex; flex-direction: column }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance }
a { color: var(--river) }
button { font: inherit; cursor: pointer }
.muted { color: var(--muted) }
.eyebrow { font: 600 11px/1.2 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--brick) }

/* Header: brand, score, the sentence being built */
.top { position: sticky; top: 0; z-index: 5; background: var(--river); color: var(--on-river); padding-top: env(safe-area-inset-top, 0px) }
.top-in { max-width: 720px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)) }
.brand { color: inherit; text-decoration: none; font: 600 18px var(--display); display: flex; align-items: center; gap: 8px; white-space: nowrap }
.brand small { font: 500 12px var(--body); opacity: .85 }
@media (max-width: 430px) { .brand small { display: none } }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold-soft) }
.stats { font: 600 13px var(--body); white-space: nowrap; font-variant-numeric: tabular-nums }
.phrase { max-width: 720px; margin: 0 auto; display: flex; gap: 4px; flex-wrap: wrap; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)) }
.phrase span { font: 700 11px/1 var(--body); letter-spacing: .06em; padding: 5px 7px; border-radius: 6px; background: color-mix(in srgb, var(--on-river) 16%, transparent) }
.phrase span.got { background: var(--gold-soft); color: var(--gold) }

/* Conversation */
.chat { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 10px }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 0 rgb(0 0 0 / .04); animation: pop .25s ease both; overflow-wrap: anywhere }
.msg.me { align-self: flex-end; background: var(--me); border-color: transparent }
.msg .who { display: block; font: 600 12px var(--body); color: var(--river); margin-bottom: 3px }
.msg.fic { background: var(--fic-soft); border-color: color-mix(in srgb, var(--fic) 30%, transparent) }
.msg.fic .who { color: var(--fic) }
.seal { display: inline-block; font: 700 10px var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--fic); border: 1px solid var(--fic); border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px }
.msg.know { background: var(--gold-soft); border-color: transparent }
.msg.know .who { color: var(--gold) }
.msg.good { border-color: var(--ok) }
.msg.wrong { border-color: var(--bad) }
.msg ul { margin: 6px 0 0; padding-left: 18px }
.msg p { margin: 0 }
.msg p + p { margin-top: 8px }
.frag { display: inline-block; font: 700 14px var(--body); letter-spacing: .08em; background: var(--gold-soft); color: var(--gold); border-radius: 6px; padding: 3px 9px; margin-top: 6px }
.day { align-self: center; font: 600 12px var(--body); color: var(--muted); background: var(--paper); border-radius: 999px; padding: 4px 12px; margin: 8px 0 }
@keyframes pop { from { transform: translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .msg { animation: none } }

/* Answer area (bottom bar) */
.bar { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
.bar-in { max-width: 720px; margin: 0 auto; display: grid; gap: 8px }
.choices { display: grid; gap: 8px }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 14px; text-align: left; min-height: 48px; font-weight: 500 }
.btn:hover { border-color: var(--river) }
.btn.main { background: var(--river); color: var(--on-river); border-color: transparent; text-align: center; font-weight: 600 }
.btn.ghost { background: transparent; text-align: center; color: var(--river); border-color: transparent; min-height: 40px; padding: 8px }
.btn.on { background: var(--river-soft); border-color: var(--river) }
.btn:focus-visible, .field:focus-visible, a:focus-visible { outline: 3px solid var(--brick); outline-offset: 2px }
.row { display: flex; gap: 8px; flex-wrap: wrap }
.row > * { flex: 1 1 auto }
.answer { display: flex; gap: 8px }
.field { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px }
.answer .btn { flex: none }
.order-picked { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; font-size: 13px; color: var(--muted) }
.order-picked span { background: var(--river-soft); color: var(--river); border-radius: 999px; padding: 3px 10px; font-weight: 600 }
.small { font-size: 13px; color: var(--muted) }
.mode-note { font-size: 13px; color: var(--muted); text-align: center }

/* Welcome and notebook */
.hero { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px; display: grid; gap: 12px }
.hero h1 { font-size: clamp(28px, 7vw, 40px) }
.hero .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted) }
.modes { display: grid; gap: 10px; grid-template-columns: 1fr 1fr }
@media (max-width: 460px) { .modes { grid-template-columns: 1fr } }
.mode { border: 1px solid var(--line); background: var(--paper); border-radius: 16px; padding: 14px; text-align: left; display: grid; gap: 4px; color: var(--ink) }
.mode strong { font: 600 18px var(--display) }
.mode span { font-size: 14px; color: var(--muted) }
.mode:hover { border-color: var(--river) }
.notebook { display: grid; gap: 14px }
.nb-head { background: var(--river); color: var(--on-river); border-radius: 20px; padding: 20px; display: grid; gap: 8px }
.nb-head .row span { background: color-mix(in srgb, var(--on-river) 16%, transparent); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; flex: none }
.nb-stop { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 6px }
.nb-stop h3 { font-size: 19px }
.nb-stop ul { margin: 0; padding-left: 18px; display: grid; gap: 4px }
.nb-stop .src { font-size: 13px; color: var(--muted) }
.noscript { padding: 20px; text-align: center }

/* Printable QR sheet (/qr) */
.sheet { background: var(--paper); display: block }
.sheet-wrap { max-width: 1000px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)) }
.sheet h1 { font-size: 34px; margin: 6px 0 8px }
.lead { color: var(--muted); max-width: 62ch; margin: 0 0 20px }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px }
.qr-card { background: #fff; color: #1F2A2E; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 4px; text-decoration: none; break-inside: avoid }
.qr-card .eyebrow { color: #B5532F }
.qr-card .muted { color: #55625F; font-size: 13px }
.qr-card svg { width: 100%; height: auto; margin-top: 6px }
.qr-card code { font-size: 11px; color: #55625F; overflow-wrap: anywhere }
@media print { .lead { display: none } .qr-grid { grid-template-columns: repeat(3, 1fr) } }
/* Anagram finale (lot « plus ludique », 23/11): letter tiles touched in order. */
.tiles-word { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px }
.tiles-word span { width: 38px; height: 44px; border-bottom: 3px solid var(--river); display: grid; place-items: center; font: 700 22px var(--display); color: var(--ink) }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px }
.tile { width: 46px; height: 50px; border-radius: 10px; border: 1.5px solid var(--gold); background: var(--gold-soft); color: var(--ink); font: 700 22px var(--display); cursor: pointer }
.tile:disabled { opacity: .3; cursor: default }
.tile:focus-visible { outline: 3px solid var(--brick); outline-offset: 2px }
.btn:disabled { opacity: .45; cursor: default }
.tile.word { width: auto; min-width: 46px; padding: 0 12px; font-size: 17px }
.tiles-word.phrase-line p { margin: 0; min-height: 44px; border-bottom: 3px solid var(--river); font: 700 18px var(--display); color: var(--ink); text-align: center; padding: 8px 4px; width: 100% }
.brand-logo { width: 30px; height: 30px; flex: none }
/* The notebook is stamped once the trail is done (logo chosen 23/11: the notebook stamp). */
.nb-head { position: relative }
.nb-stamp { position: absolute; right: 14px; top: 10px; width: 92px; height: 92px; opacity: .95 }
.nb-head h1, .nb-head .eyebrow { padding-right: 96px }
