:root {
  --bg: #0b0b0d;
  --panel: #151518;
  --panel-2: #1d1d22;
  --line: #2b2b33;
  --text: #f4f1ea;
  --muted: #9b98a3;
  --accent: #ffd400;
  --good: #19b25a;
  --close: #ff8a1f;
  --bad: #c8303d;
  --display: "Anton", "Impact", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); font-family: var(--body); }
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 50% -120px, rgba(255, 212, 0, .16), transparent 70%),
    radial-gradient(600px 400px at 100% 100%, rgba(200, 48, 61, .10), transparent 70%),
    var(--bg);
}
/* grain photocopie */
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
button { font: inherit; cursor: pointer; }

/* ---------- header ---------- */
header { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px; max-width: 960px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { transform: rotate(-6deg); filter: drop-shadow(0 4px 14px rgba(255, 212, 0, .35)); }
h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.6rem; line-height: 1;
  letter-spacing: .04em; text-shadow: 3px 3px 0 #000; }
h1 span { color: var(--accent); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tagline { text-align: center; color: var(--muted); font-size: .85rem; margin: 2px 16px 0; }

main { max-width: 960px; margin: 0 auto; padding: 18px 16px 32px; }

.tag { display: block; font-family: var(--body); font-size: .62rem; font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--muted); margin-top: 3px; }
#suggestions li .tag { display: inline; margin: 0 0 0 8px; font-size: .75rem; }
#suggestions li.sel .tag, #suggestions li:hover .tag { color: #333; }
.qmark { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--muted); font-size: .6rem; font-family: var(--body); margin-left: 2px; vertical-align: 1px; }
th[data-i] { cursor: help; }
.toast { width: min(420px, calc(100% - 32px)); text-align: center; }
.hint-zone { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
.hint-btn { padding: 8px 16px; border-radius: 999px; border: 1px dashed var(--accent); background: transparent;
  color: var(--accent); font-weight: 800; }
.hint-btn:disabled { opacity: .45; cursor: not-allowed; }
.hints { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.hints li { padding: 7px 14px; border-radius: 10px; background: rgba(255, 212, 0, .12); color: var(--accent); font-weight: 700; }

/* ---------- catégories ---------- */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 14px 16px 4px; max-width: 960px; margin: 0 auto;
  scrollbar-width: none; scroll-snap-type: x proximity; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; scroll-snap-align: center; display: flex; align-items: center; gap: 6px; padding: 9px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-weight: 700; font-size: .88rem; white-space: nowrap; transition: .15s; }
.cat:hover { border-color: var(--accent); }
.cat.active { background: var(--accent); color: #111; border-color: var(--accent); box-shadow: 3px 3px 0 #000; }
.cat-emoji { font-size: 1.05rem; }
.cat .done { background: var(--good); color: #fff; border-radius: 999px; font-size: .7rem; width: 18px; height: 18px;
  display: grid; place-items: center; }
.question { text-align: center; margin: 16px 0 0; font-family: var(--display); font-weight: 400; font-size: 1.7rem;
  letter-spacing: .04em; text-transform: uppercase; }

/* ---------- modes ---------- */
.modes { display: flex; gap: 6px; justify-content: center; margin: 0 auto 10px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; width: max-content; }
.mode { padding: 8px 16px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font-weight: 600; }
.mode.active { background: var(--accent); color: #111; font-weight: 800; }
.subtitle { text-align: center; margin: 4px 0 16px; font-family: var(--display); font-size: 1.15rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- saisie ---------- */
form { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.input-wrap { position: relative; flex: 1; }
#guess-input { width: 100%; padding: 15px 16px; font-size: 1rem; font-weight: 600; border-radius: 12px;
  border: 2px solid var(--line); background: var(--panel); color: var(--text); transition: .15s; }
#guess-input::placeholder { color: #6d6a75; font-weight: 400; }
#guess-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 212, 0, .15); }
#guess-btn { padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: #111;
  font-family: var(--display); font-size: 1.15rem; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 4px 0 #b39500; transition: transform .08s, box-shadow .08s; }
#guess-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b39500; }
#guess-btn:disabled, #guess-input:disabled { opacity: .45; cursor: not-allowed; }
#suggestions { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; max-height: 280px; overflow-y: auto; display: none; box-shadow: 0 18px 40px rgba(0,0,0,.5); }
#suggestions.open { display: block; }
#suggestions li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
#suggestions li.sel, #suggestions li:hover { background: var(--accent); color: #111; }

.hint { text-align: center; margin: 16px auto 0; width: max-content; max-width: 100%;
  padding: 8px 14px; border: 1px dashed var(--accent); border-radius: 10px; color: var(--accent); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- carte résultat ---------- */
.result { position: relative; max-width: 560px; margin: 22px auto 0; padding: 26px 20px 20px; text-align: center;
  background: linear-gradient(160deg, #1f1d14, var(--panel) 55%); border: 2px solid var(--accent);
  border-radius: 18px; box-shadow: 6px 6px 0 #000; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.result::before { content: "VALIDÉ"; position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-3deg);
  background: var(--good); color: #fff; font-family: var(--display); letter-spacing: .12em; padding: 4px 14px;
  border-radius: 6px; box-shadow: 3px 3px 0 #000; }
.result h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; letter-spacing: .05em; font-size: 1.4rem; }
.result .big { font-family: var(--display); font-size: 3rem; line-height: 1.05; color: var(--accent);
  text-transform: uppercase; text-shadow: 3px 3px 0 #000; margin: 4px 0 8px; }
.result .row-btns { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.result button { padding: 12px 18px; border-radius: 12px; border: 0; font-weight: 800; transition: transform .08s; }
.result button:active { transform: translateY(2px); }
.share-btn { background: var(--good); color: #fff; box-shadow: 0 4px 0 #0e7a3b; }
.again-btn { background: var(--accent); color: #111; box-shadow: 0 4px 0 #b39500; }
.countdown { color: var(--muted); margin-top: 14px; font-variant-numeric: tabular-nums; font-size: .9rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- plateau ---------- */
.table-wrap { overflow-x: auto; margin-top: 22px; }
table { border-collapse: separate; border-spacing: 5px; margin: 0 auto; min-width: calc(var(--cols, 7) * 96px); }
th { font-family: var(--display); font-weight: 400; font-size: .85rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 0 4px 6px; border-bottom: 2px solid var(--line); }
td { width: 94px; height: 66px; text-align: center; vertical-align: middle; font-size: .8rem;
  font-weight: 800; border-radius: 10px; padding: 4px; line-height: 1.15; color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 2px 0 rgba(0,0,0,.4);
  text-shadow: 0 1px 1px rgba(0,0,0,.35); animation: flip .5s ease both; }
td.name { background: var(--panel-2); border: 1px solid var(--line); width: 124px; font-family: var(--display);
  font-weight: 400; font-size: 1rem; letter-spacing: .03em; text-transform: uppercase; box-shadow: none; }
td.good { background: linear-gradient(180deg, #22c766, var(--good)); }
td.close { background: linear-gradient(180deg, #ff9d3d, var(--close)); }
td.bad { background: linear-gradient(180deg, #d63c49, var(--bad)); }
td .arrow { display: block; font-size: 1.25rem; line-height: 1; margin-top: 2px; }
@keyframes flip { from { transform: perspective(400px) rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* état vide */
#rows:empty::after { content: ""; }
.empty { text-align: center; color: var(--muted); margin-top: 26px; font-size: .9rem; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 20px 0 0;
  color: var(--muted); font-size: .82rem; }
.sq { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.sq.good { background: var(--good); } .sq.close { background: var(--close); } .sq.bad { background: var(--bad); }

/* ---------- dialogues ---------- */
dialog { background: var(--panel); color: var(--text); border: 2px solid var(--line);
  border-radius: 18px; max-width: 440px; width: calc(100% - 32px); padding: 24px; box-shadow: 8px 8px 0 #000; }
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; font-family: var(--display); font-weight: 400; font-size: 1.9rem;
  letter-spacing: .04em; text-transform: uppercase; }
dialog h2::after { content: ""; display: block; width: 48px; height: 4px; background: var(--accent); margin-top: 6px; }
dialog h3 { font-family: var(--display); font-weight: 400; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
dialog p, dialog li { line-height: 1.5; }
.t-good { color: var(--good); } .t-close { color: var(--close); } .t-bad { color: #ff5a67; }
.close-btn { margin-top: 14px; width: 100%; padding: 13px; border: 0; border-radius: 12px; background: var(--accent);
  color: #111; font-family: var(--display); font-size: 1.15rem; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 4px 0 #b39500; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stats-grid div { background: var(--panel-2); border-radius: 12px; padding: 10px 4px; }
.stats-grid b { display: block; font-family: var(--display); font-weight: 400; font-size: 2rem; color: var(--accent); }
.stats-grid small { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.dist-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: .85rem; font-weight: 700; }
.dist-row .bar { background: var(--line); padding: 3px 8px; border-radius: 6px; text-align: right; min-width: 26px; }
.dist-row .bar.today { background: var(--good); }

.toast { position: fixed; left: 50%; top: 20px; transform: translate(-50%, -10px); background: var(--accent);
  color: #111; padding: 11px 18px; border-radius: 12px; font-weight: 800; opacity: 0; box-shadow: 4px 4px 0 #000;
  pointer-events: none; transition: .2s; z-index: 101; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile ---------- */
@media (max-width: 680px) {
  header { padding: 12px 12px 4px; }
  h1 { font-size: 2.1rem; }
  .logo img { width: 32px; height: 32px; }
  .tagline { font-size: .78rem; }
  .cats { padding: 12px 12px 4px; }
  .question { font-size: 1.35rem; }
  main { padding: 14px 12px 28px; }
  #guess-btn { padding: 0 16px; }
  table { min-width: 0; width: 100%; table-layout: fixed; border-spacing: 3px; }
  th { font-size: .6rem; padding: 0 1px 4px; letter-spacing: .02em; }
  td { width: auto; height: 56px; font-size: .58rem; padding: 2px; border-radius: 7px;
    overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
  td.name { width: auto; font-size: .72rem; }
  td .arrow { font-size: 1rem; }
  .result .big { font-size: 2.4rem; }
}
