/* Mots en Cascade — base, thèmes, écrans hors partie. Polices système, aucune ressource distante. */
:root {
  --bg: #fbf7ef; --surface: #fffdf8; --surface2: #f3ede1; --ink: #2c3e57; --muted: #5d6b7e; --line: #d8cfbe; --line2: #b9ae99;
  --sel: #128f8c; --sel-ink: #fff; --sel-soft: #cdeeea; --coral: #e0573f; --coral-soft: #fde3da; --lav: #7b65d6; --lav-soft: #ece7ff;
  --yellow: #fff0b3; --ok: #23784b; --ok-soft: #dcf2e4; --bad: #b8372c; --bad-soft: #fbe1dd; --block: #2c3e57; --clue: #efeafc; --fog: #e9e3d6;
  --shadow: 0 6px 22px #2c3e5722; --r: 14px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="sober"]) {
  --bg: #14202e; --surface: #1c2b3c; --surface2: #233448; --ink: #eef2f7; --muted: #a9b6c6; --line: #33475e; --line2: #4c6380;
  --sel: #2fc0bb; --sel-ink: #06201f; --sel-soft: #1d4b4c; --coral: #ff8a70; --coral-soft: #4a2c27; --lav: #b3a3ff; --lav-soft: #322c55;
  --yellow: #4d4320; --ok: #6fd39b; --ok-soft: #1f4232; --bad: #ff8c80; --bad-soft: #4d2522; --block: #0b131c; --clue: #2a2948; --fog: #182533; --shadow: 0 6px 22px #0008; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #14202e; --surface: #1c2b3c; --surface2: #233448; --ink: #eef2f7; --muted: #a9b6c6; --line: #33475e; --line2: #4c6380;
  --sel: #2fc0bb; --sel-ink: #06201f; --sel-soft: #1d4b4c; --coral: #ff8a70; --coral-soft: #4a2c27; --lav: #b3a3ff; --lav-soft: #322c55;
  --yellow: #4d4320; --ok: #6fd39b; --ok-soft: #1f4232; --bad: #ff8c80; --bad-soft: #4d2522; --block: #0b131c; --clue: #2a2948; --fog: #182533; --shadow: 0 6px 22px #0008; color-scheme: dark; }
:root[data-theme="sober"] { --bg: #f6f6f4; --surface: #fff; --surface2: #ececea; --ink: #1f2328; --muted: #565c64; --line: #cfcfcb; --line2: #9a9a96;
  --sel: #2e5d8f; --sel-ink: #fff; --sel-soft: #dbe6f2; --coral: #8a4b2a; --coral-soft: #f1e4dc; --lav: #4c5a6e; --lav-soft: #e6e9ee; --clue: #eceef1; --block: #1f2328; --fog: #e4e4e1; }
:root.contrast { --line: #6f6655; --line2: #3a342a; --muted: #3b4656; --sel-soft: #9fded8; }
:root.contrast[data-theme="dark"] { --line: #8aa0b8; --muted: #d6dde6; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:root.large { font-size: 18px; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 1rem/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--sel); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
main:focus { outline: none; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.loading { text-align: center; padding: 30vh 16px; color: var(--muted); }
.warn { background: var(--coral-soft); color: var(--ink); border-radius: 10px; padding: 10px 14px; }
.top-warn { margin: 0; border-radius: 0; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; text-align: center; font-size: .9rem; }
.muted { color: var(--muted); }
.screen { max-width: 980px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.bar { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-bottom: 8px; }
.bar h1 { flex: 1; margin: 0; font-size: 1.2rem; text-align: center; line-height: 1.2; }
.bar-sp { width: 44px; flex: none; }
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border: 1.5px solid var(--line2); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 650; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { border-color: var(--sel); }
.btn.primary { background: var(--sel); border-color: var(--sel); color: var(--sel-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.warn { border-color: var(--coral); }
.btn.small { min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.btn.block { width: 100%; justify-content: flex-start; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.big { min-height: 64px; justify-content: flex-start; gap: 12px; padding: 10px 18px; font-size: 1.05rem; }
.btn.big span { display: flex; flex-direction: column; text-align: left; }
.btn.big small { font-weight: 500; opacity: .85; font-size: .85rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--surface2); font-size: .78rem; font-weight: 650; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.sug { background: var(--coral-soft); color: var(--coral); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
h2.sub { font-size: 1.05rem; margin: 22px 0 8px; }

/* Accueil */
.home { max-width: 640px; }
.hero { display: flex; align-items: center; gap: 14px; margin: 18px 0 22px; }
.logo { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 4px 10px #2c3e5733); }
.brand { margin: 0; font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.05; letter-spacing: -.02em; }
.brand span { color: var(--coral); }
.tag { margin: 4px 0 0; color: var(--muted); }
.home-actions { display: grid; gap: 10px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.tile { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 650; cursor: pointer; text-align: left; }
.tile:hover { border-color: var(--sel); }
.tile .ico { color: var(--sel); }
.home-progress h2 { font-size: 1rem; margin: 22px 0 8px; }
.prog-grid { display: grid; gap: 6px; }
.prog { display: grid; grid-template-columns: 1fr 90px 40px; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: .92rem; }
.meter { height: 8px; border-radius: 9px; background: var(--surface2); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--sel), var(--coral)); border-radius: 9px; }
.prog-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.foot { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 26px; }

/* Choix du jeu */
.choose { max-width: 760px; }
.step { font-size: 1rem; margin: 18px 0 10px; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg-b { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; border-radius: var(--r); border: 2px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; min-height: 44px; }
.seg-b.on { border-color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel); background: color-mix(in srgb, var(--sel-soft) 45%, var(--surface)); }
.seg-b small { color: var(--muted); font-size: .85rem; }
.seg.small { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg.small .seg-b { padding: 6px 12px; flex-direction: row; font-weight: 600; border-width: 1.5px; }
.mini { width: 54px; height: 40px; border-radius: 6px; margin-bottom: 4px; background-color: var(--surface); border: 2px solid var(--ink); background-size: 13px 13px; }
.mini-crossword { background-image: linear-gradient(var(--ink) 1px, transparent 1px), linear-gradient(90deg, var(--ink) 1px, transparent 1px), linear-gradient(var(--block), var(--block)); background-size: 13px 13px, 13px 13px, 13px 13px; background-repeat: repeat, repeat, no-repeat; background-position: 0 0, 0 0, 13px 13px; }
.mini-arrowword { background-image: linear-gradient(var(--ink) 1px, transparent 1px), linear-gradient(90deg, var(--ink) 1px, transparent 1px), linear-gradient(var(--lav), var(--lav)), linear-gradient(var(--lav), var(--lav)); background-size: 13px 13px, 13px 13px, 13px 13px, 13px 13px; background-repeat: repeat, repeat, no-repeat, no-repeat; background-position: 0 0, 0 0, 0 0, 26px 13px; }
.modes { display: grid; gap: 10px; }
.mode-card { position: relative; display: grid; grid-template-columns: 46px 1fr 24px; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; }
.mode-card:hover { border-color: var(--sel); }
.mode-card b { grid-column: 2; font-size: 1.08rem; }
.mode-card small { grid-column: 2; color: var(--muted); }
.mode-card .go { grid-column: 3; grid-row: 1 / 3; color: var(--muted); }
.mode-ic { grid-row: 1 / 3; width: 46px; height: 46px; border-radius: 12px; background: var(--sel-soft); position: relative; }
.mode-ic::before, .mode-ic::after { content: ""; position: absolute; border-radius: 4px; }
.mode-classic .mode-ic::before { inset: 9px; background: conic-gradient(var(--sel) 25%, transparent 0 50%, var(--sel) 0 75%, transparent 0); background-size: 14px 14px; }
.mode-cascade .mode-ic { background: var(--coral-soft); }
.mode-cascade .mode-ic::before { left: 7px; top: 7px; width: 14px; height: 14px; background: var(--coral); box-shadow: 9px 9px 0 var(--coral), 18px 18px 0 color-mix(in srgb, var(--coral) 45%, transparent); }
.mode-discovery .mode-ic { background: var(--lav-soft); }
.mode-discovery .mode-ic::before { left: 13px; top: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--lav); }
.mode-discovery .mode-ic::after { left: 18px; top: 30px; width: 10px; height: 7px; background: var(--lav); }

/* Listes de grilles */
.pack-head p { margin: 4px 0; }
.pack-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .92rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.filter { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; }
.filter select { min-height: 44px; min-width: 130px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--surface); font-size: 1rem; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; min-height: 92px; }
.card:hover { border-color: var(--sel); }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-meta { color: var(--muted); font-size: .86rem; }
.card-state { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 650; margin-top: auto; }
.st-ic { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); font-size: .8rem; }
.st-done .st-ic { background: var(--ok-soft); color: var(--ok); }
.st-doing .st-ic { background: var(--coral-soft); color: var(--coral); }
.st-done { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.empty { color: var(--muted); padding: 12px; }
.mine { list-style: none; padding: 0; display: grid; gap: 8px; }
.mine-i { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); }
.mine-i small { display: block; color: var(--muted); }
.mine-a { display: flex; flex-wrap: wrap; gap: 6px; }

/* Paramètres, interrupteurs */
.opts { border: 1.5px solid var(--line); border-radius: var(--r); padding: 6px 14px 12px; margin: 0 0 14px; background: var(--surface); }
.opts legend { font-weight: 750; padding: 0 6px; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; padding: 4px 0; }
.switch span { display: flex; flex-direction: column; }
.switch small { color: var(--muted); font-size: .84rem; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; flex: none; border-radius: 99px; background: var(--line2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px #0004; }
.switch input:checked { background: var(--sel); }
.switch input:checked::after { transform: translateX(18px); }
.choice-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.off-list { list-style: none; padding: 0; margin: 6px 0 10px; display: grid; gap: 4px; font-size: .92rem; }

/* Dialogues et notifications */
.dlg { border: 0; border-radius: 20px; padding: 0; width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dlg.wide { width: min(640px, calc(100vw - 24px)); }
.dlg::backdrop { background: #14202e88; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 4px 20px; }
.dlg-head h2 { flex: 1; margin: 0; font-size: 1.15rem; }
.dlg-body { padding: 4px 20px 12px; overflow: auto; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 8px 20px calc(16px + env(safe-area-inset-bottom)); }
.help p { margin: 0 0 10px; }
.preview { max-height: 220px; overflow: auto; font-size: .92rem; }
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100vw - 24px); padding: 10px 14px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 600; font-size: .95rem; }
.toast .btn { background: var(--bg); color: var(--ink); border: 0; }
.toast[hidden] { display: none; }
body.playing .toast { bottom: auto; top: calc(58px + env(safe-area-inset-top)); }
/* Écran de partie : grille, bandeau de définition, outils, clavier. */
body.playing { overflow: hidden; overscroll-behavior: none; }
.play { position: fixed; inset: 0; display: grid; grid-template-columns: 100%; grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  grid-template-areas: "top" "main" "cluebar" "hint" "tools" "kbd"; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--bg); }
.ptop { grid-area: top; display: flex; align-items: center; gap: 4px; padding: 2px 6px; min-height: 48px; }
.ptitle { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.ptitle h1 { margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg { font-size: .85rem; font-weight: 700; color: var(--muted); padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-btn { display: inline-flex; align-items: center; gap: 3px; min-height: 36px; padding: 0 8px; border-radius: 99px; border: 1.5px solid var(--coral); background: var(--coral-soft); color: var(--ink); font-weight: 700; font-size: .82rem; cursor: pointer; }
.chip-btn .ico { width: 16px; height: 16px; color: var(--coral); }
.pmain { grid-area: main; display: flex; min-height: 0; min-width: 0; }
.board-wrap { flex: 1; min-width: 0; min-height: 0; overflow: auto; display: flex; padding: 4px; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.board { margin: auto; display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell); width: max-content; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--line); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board .row { display: contents; }
.c { position: relative; width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); cursor: pointer; overflow: hidden; }
.c .ch { font-weight: 750; font-size: calc(var(--cell) * .56); line-height: 1; text-transform: uppercase; }
.c .n { position: absolute; top: 1px; left: 2px; font-size: max(8px, calc(var(--cell) * .25)); line-height: 1; color: var(--muted); font-weight: 650; pointer-events: none; }
.c.B { background: var(--block); cursor: default; }
.c.H { background-color: var(--fog); background-image: radial-gradient(circle, color-mix(in srgb, var(--ink) 14%, transparent) 1.2px, transparent 1.6px); background-size: 8px 8px; cursor: default; border-color: color-mix(in srgb, var(--line) 50%, var(--fog)); }
.c.H > * { visibility: hidden; }
.c.L.w { background: var(--sel-soft); }
.c.L.cur { background: var(--sel); color: var(--sel-ink); box-shadow: inset 0 0 0 2px var(--ink); }
.c.L.cur .n { color: var(--sel-ink); }
.c.done:not(.cur) { background: var(--ok-soft); box-shadow: inset 0 -3px 0 var(--ok); }
.c.done.w:not(.cur) { background: color-mix(in srgb, var(--ok-soft) 50%, var(--sel-soft)); }
.c.x .ch { color: var(--bad); }
.c.x::after { content: ""; position: absolute; inset: 12%; pointer-events: none; background: linear-gradient(to top right, transparent calc(50% - 1px), var(--bad) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); opacity: .75; }
.c.x.cur .ch { color: var(--sel-ink); }
.c.x.cur::after { background: linear-gradient(to top right, transparent calc(50% - 1.5px), var(--sel-ink) calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px)); }
.c.r::before { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 max(7px, calc(var(--cell) * .24)) max(7px, calc(var(--cell) * .24)) 0; border-color: transparent var(--lav) transparent transparent; pointer-events: none; }
.c.m .ch::before { content: ""; position: absolute; inset: 14%; border: 1.5px dashed var(--coral); border-radius: 50%; pointer-events: none; }
.c.ok { animation: okp 1.1s ease; }
.c.ok::after { content: "✓"; position: absolute; right: 2px; bottom: 0; font-size: max(9px, calc(var(--cell) * .28)); color: var(--ok); font-weight: 800; }
.c.new { animation: appear .7s ease both; }
.c.ping { animation: ping 1.2s ease; }
@keyframes okp { 40% { background: var(--ok-soft); } }
@keyframes appear { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ping { 30%, 70% { box-shadow: inset 0 0 0 3px var(--coral); } }
/* Cases-indices des mots fléchés */
.c.K { flex-direction: column; background: var(--clue); align-items: stretch; padding: 0; }
.q { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1px 2px; color: var(--ink); }
.q1 { border-bottom: 1px solid color-mix(in srgb, var(--lav) 55%, var(--clue)); }
.qt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: max(8px, calc(var(--cell) * .165)); line-height: 1.08; font-weight: 650; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; word-break: normal; }
.q:has(.a-right), .q:has(.a-rightDown) { padding-right: 18%; }
.q:has(.a-down), .q:has(.a-downRight) { padding-bottom: 14%; }
.q:has(.a-downRight) { padding-left: 4%; }
.q1 .qt, .q2 .qt { -webkit-line-clamp: 2; }
.q.act { background: var(--sel-soft); }
.q.locked { background: color-mix(in srgb, var(--fog) 70%, var(--clue)); }
.q.locked::before { content: ""; width: max(9px, calc(var(--cell) * .26)); height: max(9px, calc(var(--cell) * .26)); background: var(--muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 11h12v10H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3' fill='none' stroke='black' stroke-width='2.4'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 11h12v10H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3' fill='none' stroke='black' stroke-width='2.4'/%3E%3C/svg%3E") center/contain no-repeat; }
.arw { position: absolute; width: max(8px, calc(var(--cell) * .22)); height: max(8px, calc(var(--cell) * .22)); background: var(--coral); pointer-events: none; }
.a-right { right: 0; top: 50%; transform: translateY(-50%); clip-path: polygon(0 10%, 100% 50%, 0 90%); }
.a-down { bottom: 0; left: 50%; transform: translateX(-50%); clip-path: polygon(10% 0, 90% 0, 50% 100%); }
.a-downRight, .a-rightDown { background: none; }
.a-downRight::before, .a-rightDown::before { content: ""; position: absolute; inset: 0; background: var(--coral); -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.a-downRight { left: 2px; bottom: 0; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 1v12h10' fill='none' stroke='black' stroke-width='4'/%3E%3Cpath d='M14 6l9 7-9 7z'/%3E%3C/svg%3E"); width: max(10px, calc(var(--cell) * .3)); }
.a-rightDown { right: 0; top: 2px; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1 5h12v10' fill='none' stroke='black' stroke-width='4'/%3E%3Cpath d='M6 14l7 9 7-9z'/%3E%3C/svg%3E"); height: max(10px, calc(var(--cell) * .3)); }
.q1 .a-right { top: 50%; } .q2 .a-down, .q0 .a-down { bottom: 0; }
.board.mini .qt { display: none; }
.board.mini .q:not(.locked)::after { content: "?"; font-weight: 800; font-size: 10px; color: var(--lav); }
.q.locked .qt { display: none; }
/* Liste des définitions */
.clues { display: none; overflow: auto; background: var(--surface); padding: 6px 14px 20px; -webkit-overflow-scrolling: touch; }
.clues-head { display: flex; align-items: center; position: sticky; top: -6px; background: var(--surface); z-index: 1; padding-top: 4px; }
.clues-head h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.clues h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.cl { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.ci { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: baseline; text-align: left; padding: 8px 8px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.ci:hover { background: var(--surface2); }
.ci.act { background: var(--sel-soft); box-shadow: inset 3px 0 0 var(--sel); }
.ci.full .cx { color: var(--muted); }
.ci.ok .cx { text-decoration: line-through; text-decoration-color: var(--ok); color: var(--muted); }
.cn { font-weight: 800; color: var(--sel); }
.cl-len { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.piv { grid-column: 2 / 4; justify-self: start; font-size: .72rem; font-weight: 750; color: var(--coral); background: var(--coral-soft); padding: 1px 7px; border-radius: 99px; }
.locked-note { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.locked-note .ico { width: 18px; height: 18px; }
.zones { font-weight: 700; color: var(--coral); margin: 8px 0 0; }
.mystery { background: var(--coral-soft); border-radius: 12px; padding: 8px 12px; margin-top: 8px; }
.mystery p { margin: 2px 0; }
.mt { display: flex; align-items: center; gap: 6px; font-weight: 750; }
.mt .ico { color: var(--coral); width: 18px; height: 18px; }
.mh { font-size: .85rem; color: var(--muted); }
.mboxes { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.mb { width: 30px; height: 30px; display: grid; place-items: center; border: 1.5px dashed var(--coral); border-radius: 50%; background: var(--surface); font-weight: 800; }
/* Bandeau de définition et indices */
.cluebar { grid-area: cluebar; display: flex; align-items: stretch; gap: 4px; padding: 4px 6px; }
.clue { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 12px; border-radius: 14px; border: 0; background: var(--sel-soft); text-align: left; cursor: pointer; }
.cw { display: flex; flex-direction: column; min-width: 0; }
.tag { font-size: .74rem; font-weight: 750; letter-spacing: .02em; color: color-mix(in srgb, var(--sel) 75%, var(--ink)); }
.ct { font-size: 1.02rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.pic { font-size: 2rem; line-height: 1; }
.pic:empty { display: none; }
.cluebar .icon-btn { height: auto; min-height: 56px; background: var(--surface); }
.hintbar { grid-area: hint; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 4px; align-items: center; }
.hintbar[hidden] { display: none; }
.hint-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 10px; background: var(--yellow); font-size: .9rem; }
.hint-chip .ico { width: 16px; height: 16px; }
.bank, .choices { display: flex; flex-wrap: wrap; gap: 5px; }
.bank-l { width: 38px; height: 38px; border-radius: 9px; border: 1.5px solid var(--lav); background: var(--lav-soft); font-weight: 800; cursor: pointer; }
.choice { min-height: 38px; padding: 4px 12px; border-radius: 10px; border: 1.5px solid var(--lav); background: var(--surface); font-weight: 700; cursor: pointer; }
.choice.no { text-decoration: line-through; opacity: .5; }
/* Outils et clavier */
.tools { grid-area: tools; display: flex; align-items: center; gap: 4px; padding: 2px 6px; overflow-x: auto; scrollbar-width: none; }
.tool { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 650; font-size: .88rem; cursor: pointer; white-space: nowrap; flex: none; }
.tool.sq { width: 44px; justify-content: center; padding: 0; }
.tool[aria-pressed="true"] { background: var(--sel-soft); }
.pmain { position: relative; }
.zoom { position: absolute; z-index: 5; right: 10px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; opacity: .92; }
.zoom .tool { box-shadow: 0 2px 8px #2c3e5730; border: 1px solid var(--line); width: 40px; min-height: 40px; }
@media (max-width: 899px) { .zoom { display: none; } .pmain:has(.board-wrap.zoomed) .zoom { display: flex; } }
@media (min-width: 900px) { .zoom { right: calc(clamp(300px, 30vw, 380px) + 26px); } }
.tools .tool:last-child { margin-left: auto; }
.list-btn { display: inline-flex; }
.kbd { grid-area: kbd; padding: 4px 3px 6px; background: var(--surface2); border-radius: 16px 16px 0 0; }
.kbd[hidden] { display: none; }
.krow { display: flex; justify-content: center; gap: 5px; margin: 0 0 6px; }
.krow:last-child { margin-bottom: 0; }
.key { flex: 1 1 0; min-width: 0; max-width: 54px; height: 48px; border: 0; border-radius: 9px; background: var(--surface); color: var(--ink); font-weight: 750; font-size: 1.2rem; box-shadow: 0 1.5px 0 var(--line2); touch-action: manipulation; cursor: pointer; display: grid; place-items: center; padding: 0; }
.key:active { background: var(--sel); color: var(--sel-ink); }
.key.wide { flex: 1.45 1 0; max-width: 76px; background: var(--sel-soft); }
/* Panneau d'aide (sous-menu ancré en bas) */
.sheet { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); width: min(460px, calc(100vw - 16px)); background: var(--surface); border-radius: 20px; box-shadow: 0 -4px 30px #14202e44; padding: 8px 10px 10px; border: 1.5px solid var(--line); }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; padding-left: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 1rem; }
.sheet-items { display: grid; gap: 6px; }
.sheet-item { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 56px; padding: 8px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); cursor: pointer; }
.sheet-item .ico { color: var(--sel); }
.sheet-item.warn .ico { color: var(--coral); }
.si-t { display: flex; flex-direction: column; }
.si-t small { color: var(--muted); font-size: .82rem; }
.sheet-item[disabled] { opacity: .55; }
/* Fin de partie */
.end { position: relative; }
.end-big { font-size: 1.1rem; font-weight: 700; }
.end-list { padding-left: 18px; }
.end-myst { list-style: none; margin-left: -18px; display: flex; gap: 6px; align-items: center; font-weight: 700; }
.end-myst .ico { color: var(--coral); }
.confetti { position: absolute; inset: -40px 0 auto; height: 0; pointer-events: none; }
.confetti i { position: absolute; top: 0; left: calc(var(--k) * 5.5%); width: 8px; height: 12px; border-radius: 2px; background: var(--coral); animation: fall 1.6s ease-in forwards; animation-delay: calc(var(--k) * 40ms); opacity: 0; }
.confetti i:nth-child(3n) { background: var(--sel); } .confetti i:nth-child(3n+1) { background: var(--lav); }
@keyframes fall { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(260px) rotate(320deg); } }

/* Téléphone : liste en tiroir */
@media (max-width: 899px) {
  .play.list-open .clues { display: block; position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; max-height: min(72dvh, 620px); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px #14202e55; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
/* Ordinateur et tablette large : définitions en panneau latéral */
@media (min-width: 900px) {
  .play { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); grid-template-areas: "top top" "main main" "cluebar cluebar" "hint hint" "tools tools" "kbd kbd"; }
  .pmain { gap: 8px; padding: 0 8px; }
  .clues { display: block; width: clamp(300px, 30vw, 380px); flex: none; border-radius: 16px; border: 1.5px solid var(--line); margin: 4px 0; }
  .close-list, .list-btn { display: none; }
  .cluebar, .tools, .hintbar { max-width: 980px; width: 100%; justify-self: center; }
  .kbd { max-width: 640px; width: 100%; justify-self: center; border-radius: 16px; margin-bottom: 8px; }
}
/* Téléphone en paysage : grille à gauche, commandes à droite */
@media (max-height: 520px) and (orientation: landscape) {
  .play { grid-template-columns: minmax(0, 1fr) minmax(300px, 46%); grid-template-rows: auto auto auto auto minmax(0, 1fr); grid-template-areas: "top top" "main cluebar" "main hint" "main tools" "main kbd"; }
  .kbd { align-self: end; border-radius: 16px; margin: 0 4px 4px; }
  .key { height: 40px; }
  .clue { min-height: 48px; }
  .cluebar .icon-btn { min-height: 48px; }
  .ptop { min-height: 40px; }
}
/* Petits téléphones */
@media (max-width: 440px) { .kl { display: none; } }
@media (max-width: 360px) { .key { height: 44px; font-size: 1.05rem; } .krow { gap: 4px; } .tool span { display: none; } .tool { padding: 0 10px; } }
@media (max-height: 700px) and (orientation: portrait) { .key { height: 42px; } .clue { min-height: 50px; } .krow { margin-bottom: 5px; } }

/* Préférences */
:root.large .ct { font-size: 1.15rem; }
:root.large .key { font-size: 1.35rem; }
:root.simple .zoom, :root.simple .psub { display: none; }
:root.simple .ct { font-size: 1.15rem; }
:root.contrast .board { border-width: 3px; }
:root.contrast .c { border-color: var(--line2); }
:root.still *, :root.still *::before, :root.still *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
/* Éditeur de grilles */
.screen.wide { max-width: 1180px; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); min-width: 0; }
.fld input, .fld select, .ed-words { font-size: 16px; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--surface); color: var(--ink); width: 100%; }
.fld.narrow { max-width: 110px; }
.fld-row { display: flex; gap: 10px; }
.fld-row.wrap { flex-wrap: wrap; align-items: flex-end; }
.ed-new, .ed-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.ed-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 10px; }
.ed-work { display: grid; gap: 16px; }
@media (min-width: 900px) { .ed-work { grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr); align-items: start; } }
.ed-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); width: min(100%, calc(var(--cols) * 52px)); border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--line); gap: 1px; }
.ec { aspect-ratio: 1; border: 0; background: var(--surface); font-weight: 750; font-size: clamp(14px, 4vw, 22px); padding: 0; cursor: pointer; min-width: 0; }
.ec.blk { background: var(--block); }
.ec.cur { background: var(--sel); color: var(--sel-ink); }
.ec.iso { box-shadow: inset 0 0 0 2px var(--bad); }
.ed-typer { position: absolute; opacity: 0; width: 1px; height: 1px; font-size: 16px; pointer-events: none; }
.small { font-size: .85rem; }
.ed-placebox summary, .ed-entry summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ed-place { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 6px 0; }
.ed-entries h2 { margin-top: 0; }
.ed-entry { border: 1.5px solid var(--line); border-radius: 12px; padding: 4px 12px 10px; margin-bottom: 8px; background: var(--surface); display: grid; gap: 8px; }
.ed-entry.todo { border-color: var(--coral); }
.ed-sum { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.ed-report .bad, .ed-issues .bad { color: var(--bad); }
.ed-report .good { color: var(--ok); font-weight: 700; }
.ed-issues { padding-left: 18px; font-size: .92rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 3; }
.ed-words { min-height: 150px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; resize: vertical; }
.ed-props { display: grid; gap: 12px; }
.ed-prop { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); }
.mini-grid { display: grid; grid-template-columns: repeat(var(--cols), 14px); grid-auto-rows: 14px; gap: 1px; background: var(--line); border: 1px solid var(--ink); }
.mini-grid span { background: var(--surface); font-size: 9px; font-weight: 700; display: grid; place-items: center; }
.mini-grid span.b { background: var(--block); }
.mini-grid span.k { background: var(--lav); }
@media (max-width: 520px) { .ed-prop { grid-template-columns: 1fr; } }
