:root {
  --bg: #f6f7fb; --surface: #fff; --text: #171a24; --muted: #5f6577; --line: #dfe2ec;
  --accent: #2348b8; --accent-ink: #fff; --tile: #f1e4c8; --tile-ink: #4a3514;
  --green: #4d8f4a; --yellow: #c9a227; --gray: #8a857c; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141b; --surface: #1b1e28; --text: #e7e9f0; --muted: #9aa0b2; --line: #2e3242;
    --accent: #7ea2ff; --accent-ink: #0b1230; --tile: #3a3122; --tile-ink: #f1dfb8;
  }
}
:root[data-theme="dark"] {
  --bg: #12141b; --surface: #1b1e28; --text: #e7e9f0; --muted: #9aa0b2; --line: #2e3242;
  --accent: #7ea2ff; --accent-ink: #0b1230; --tile: #3a3122; --tile-ink: #f1dfb8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; margin: 1.2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 2rem 0 .7rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
h3 a, h3 small { font-weight: 400; font-size: .9rem; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 70ch; }
.note { color: var(--muted); }
kbd { background: var(--tile); color: var(--tile-ink); border-radius: 4px; padding: 0 .35em; font-family: inherit; font-weight: 700; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.tile { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--tile); color: var(--tile-ink); border-radius: 6px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
nav a { margin-left: 16px; color: var(--text); text-decoration: none; font-weight: 500; white-space: nowrap; }
nav a:hover { color: var(--accent); }
@media (max-width: 520px) { nav a { margin: 0 14px 0 0; font-size: .95rem; } .top .wrap { padding-bottom: 8px; } }
.crumbs { font-size: .9rem; color: var(--muted); margin-top: 1rem; }
.crumbs a { color: var(--muted); }

.hero { padding: .5rem 0 1rem; }
.search { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0; }
.search input[name="lettres"] { flex: 1 1 260px; font-size: 1.25rem; letter-spacing: .08em; text-transform: uppercase; }
.search.compact input[name="lettres"] { font-size: 1rem; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
button { font: inherit; font-weight: 700; border: 0; border-radius: var(--radius); padding: .7rem 1.2rem; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.filters { flex-basis: 100%; }
.filters summary { cursor: pointer; color: var(--muted); font-size: .95rem; }
.filters .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.filters label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: 4px; }
.hint { font-size: .9rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: .92rem; }
.chip.sq { min-width: 2.2rem; text-align: center; border-radius: 6px; font-weight: 700; }
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.stat { display: flex; flex-direction: column; align-items: center; padding: .45rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; }
.stat b { font-size: 1.1rem; }
.stat span { font-size: .8rem; color: var(--muted); }
a.stat:hover { border-color: var(--accent); }

.words { list-style: none; padding: 0; margin: .3rem 0 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px 10px; }
.words li { padding: .15rem 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.words.best li { font-weight: 700; color: var(--accent); }
.res-title { margin-top: 1rem; }
.group h3 small { color: var(--muted); }

.five .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.five .tag { min-width: 220px; font-weight: 600; font-size: .95rem; padding-left: 10px; border-left: 6px solid; }
.tag.green { border-color: var(--green); } .tag.yellow { border-color: var(--yellow); } .tag.gray { border-color: var(--gray); }
.cells { display: flex; gap: 6px; }
.cell { width: 52px; height: 52px; text-align: center; font-size: 1.2rem; font-weight: 700; text-transform: uppercase; padding: 0; }
input[name^="y"].cell { font-size: .9rem; }
.wide { flex: 1 1 200px; text-transform: uppercase; }
.actions { margin-top: 12px; }
@media (max-width: 420px) { .cell { width: 15vw; height: 15vw; } }

.ad { margin: 1.5rem 0; min-height: 100px; }
.ad-placeholder { display: grid; place-items: center; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }

.prose { max-width: 72ch; }
.foot { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0; color: var(--muted); font-size: .92rem; }

/* ---- Le mot du jour ---- */
.daily { max-width: 520px; margin: 0 auto; text-align: center; position: relative; }
.daily .lead { margin: 0 auto 1rem; }
.daily .num { color: var(--muted); font-weight: 500; font-size: .6em; vertical-align: middle; }
.board { display: grid; gap: 6px; justify-content: center; margin: 0 auto 1rem; }
.brow { display: grid; grid-template-columns: repeat(5, 58px); gap: 6px; }
.btile { width: 58px; height: 58px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 6px;
  font-size: 1.8rem; font-weight: 800; text-transform: uppercase; background: var(--surface); }
.btile.filled { border-color: var(--muted); animation: pop .1s; }
.btile.correct, .key.correct, .sw.correct { background: var(--green); border-color: var(--green); color: #fff; }
.btile.present, .key.present, .sw.present { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.btile.absent, .key.absent, .sw.absent { background: var(--gray); border-color: var(--gray); color: #fff; }
.brow.shake { animation: shake .35s; }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.keyboard { display: grid; gap: 6px; margin: 0 auto 1rem; max-width: 500px; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1 1 0; min-width: 0; height: 54px; padding: 0; border-radius: 6px; background: var(--tile); color: var(--tile-ink);
  font-size: 1.05rem; font-weight: 700; text-transform: uppercase; }
.key.wide { flex: 1.6 1 0; font-size: .75rem; }
.toast { position: absolute; left: 50%; top: 5.5rem; transform: translateX(-50%); z-index: 5; background: var(--text); color: var(--bg);
  padding: .55rem 1rem; border-radius: 8px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
.hints ul { list-style: none; padding: 0; text-align: left; }
.hints li { padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.end { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 1rem; margin: 1rem 0; }
.end h2 { margin-top: .3rem; }
.answer { color: var(--accent); letter-spacing: .08em; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 1rem 0; }
.kpis b { display: block; font-size: 1.6rem; }
.kpis span { font-size: .75rem; color: var(--muted); }
.dist { text-align: left; margin: 0 auto 1rem; max-width: 360px; }
.drow { display: flex; align-items: center; gap: 6px; margin: 3px 0; font-size: .85rem; }
.dbar { background: var(--gray); color: #fff; text-align: right; padding: 0 6px; border-radius: 3px; font-weight: 700; }
.dbar.on { background: var(--green); }
.sw { display: inline-block; width: 1em; height: 1em; border-radius: 3px; vertical-align: -2px; }
@media (max-width: 400px) {
  .brow { grid-template-columns: repeat(5, 52px); }
  .btile { width: 52px; height: 52px; font-size: 1.5rem; }
  .key { height: 50px; font-size: .95rem; }
  .krow { gap: 4px; }
}

/* ---- Meilleurs coups / points ---- */
.pts { display: inline-block; margin-left: .3em; min-width: 1.4em; padding: 0 .3em; border-radius: 4px; background: var(--tile);
  color: var(--tile-ink); font-size: .72rem; font-weight: 700; text-align: center; vertical-align: 1px; }
.muted { color: var(--muted); font-size: .85em; }
.small { font-size: .85rem; }
.best { margin: 1rem 0 1.5rem; }
.best-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; padding: 1rem 1.2rem; border-radius: var(--radius);
  background: var(--tile); color: var(--tile-ink); }
.best-hero .label { width: 100%; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.best-hero strong { font-size: clamp(1.8rem, 6vw, 2.6rem); letter-spacing: .06em; line-height: 1.1; }
.best-hero .score { font-weight: 700; }
.best-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.best .card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .7rem 1rem; }
.best .card h3 { margin: .2rem 0 .4rem; font-size: 1rem; }
.best .card ol { margin: 0; padding-left: 1.3rem; }
.best .card li { padding: .15rem 0; }
.best .bingo { border-color: var(--accent); }
.res-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { background: transparent; color: var(--text); border-radius: 0; padding: .45rem .8rem; font-size: .9rem; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.board-field { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.board-field input { max-width: 260px; text-transform: uppercase; letter-spacing: .08em; }
.stats.tiles { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.five[data-len="6"] .cell { width: min(52px, 13.5vw); height: min(52px, 13.5vw); }
.five[data-len="7"] .cell { width: min(52px, 11.5vw); height: min(52px, 11.5vw); }
.pattern { color: var(--accent); letter-spacing: .08em; }
