:root {
  --bg: #e8edf4;
  --ink: #14213d;
  --board: #2347d9;
  --red: #e8352e;
  --red-deep: #b8231d;
  --yellow: #ffc933;
  --green: #1fa35b;
  --paper: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.45;
}
h1, h2 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.6rem; font-weight: 800; }
p { margin: 0 0 14px; }
b { font-weight: 800; }

/* ---------- En-tête ---------- */
.top { display: flex; align-items: center; gap: 20px; max-width: 1120px; margin: 0 auto; padding: 18px 20px 6px; flex-wrap: wrap; }
.count { margin: 0; font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pts { font-weight: 600; }

.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); font-size: 1.1rem; flex: none; }
.avatar.xl { width: 120px; height: 120px; font-size: 3.6rem; border-width: 5px; }

/* ---------- Boutons / champs ---------- */
.btn, .ok-btn {
  display: inline-block; padding: 12px 18px; border: 3px solid var(--ink); border-radius: 12px; background: var(--paper);
  color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:active, .ok-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.small { padding: 5px 12px; font-size: .9rem; }
.text-in {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 3px solid var(--ink); border-radius: 12px; background: var(--paper);
  color: var(--ink); font: inherit; font-size: 1.1rem;
}
.text-in.big { font-size: 1.6rem; text-align: center; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--board); outline-offset: 3px; }

/* ---------- Profil ---------- */
.profile { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 48px; align-items: center; max-width: 900px; margin: 28px auto; padding: 0 20px; }
.lead { font-size: 1.1rem; }
label, .label { display: block; margin: 16px 0 6px; font-weight: 700; }
.swatches, .emojis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.swatches button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 3px transparent; cursor: pointer; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.emojis button { width: 46px; height: 46px; font-size: 1.5rem; border: 3px solid transparent; border-radius: 12px; background: var(--paper); cursor: pointer; }
.emojis button[aria-pressed="true"] { border-color: var(--ink); }
.error { min-height: 1.4em; margin: 10px 0; color: var(--red-deep); font-weight: 700; }
.preview { display: flex; flex-direction: column; align-items: center; gap: 14px; font-size: 1.3rem; text-align: center; }

/* ---------- Arène ---------- */
#arena { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; max-width: 1120px; margin: 14px auto 40px; padding: 0 20px; align-items: start; }
.stage { min-height: 520px; padding: 22px; background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); }
.hint { margin: 12px 0 0; text-align: center; color: #4a5672; }
.side h2 { margin-bottom: 10px; }
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 2px solid rgba(20, 33, 61, .12); }
.lb .rk { width: 1.6em; font-weight: 800; text-align: right; }
.lb .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb .me .nm { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--yellow); }
.lb .ok { color: var(--green); font-weight: 800; }

/* Annonce / résultats */
.center { text-align: center; padding: 30px 10px; }
.g-icon { font-size: 5rem; line-height: 1; margin-bottom: 8px; }
.center h2 { font-size: 2.4rem; margin-bottom: 10px; }
.center .desc { max-width: 520px; margin: 0 auto 22px; font-size: 1.15rem; }
.cd { font-size: 4.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.res { width: 100%; border-collapse: collapse; margin: 14px 0; }
.res td { padding: 8px 6px; border-bottom: 2px solid rgba(20, 33, 61, .12); }
.res .r { width: 2.2em; font-weight: 800; text-align: right; }
.res .s { text-align: right; font-variant-numeric: tabular-nums; }
.res .p { width: 4em; text-align: right; font-weight: 800; color: var(--board); }
.res tr.me td { background: #fff6d6; }
.res .who2 { display: flex; align-items: center; gap: 10px; font-weight: 600; }

/* ---------- Pendant la manche ---------- */
.hud { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 1.3rem; }
.hud-time { font-variant-numeric: tabular-nums; }
.bar { height: 10px; margin: 8px 0 18px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--red); border-radius: 99px; }
.play { min-height: 380px; position: relative; }
.play[inert] { opacity: .45; }
.sent { margin: 14px 0 0; font-weight: 700; text-align: center; }

.big-btn { width: 100%; height: 300px; border: 4px solid var(--ink); border-radius: 18px; background: var(--yellow); color: var(--ink); font: inherit; font-size: 2.2rem; font-weight: 800; cursor: pointer; box-shadow: 0 6px 0 var(--ink); touch-action: manipulation; }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }

.words { display: flex; flex-wrap: wrap; gap: 6px 12px; height: 150px; overflow: hidden; margin-bottom: 14px; font-size: 1.4rem; line-height: 1.7; }
.words .cur { background: var(--yellow); border-radius: 6px; padding: 0 5px; }
.words .ok { color: var(--green); }
.words .bad { color: var(--red); text-decoration: line-through; }

.mem { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 400px; margin: 0 auto; }
.card { aspect-ratio: 1; font-size: 2.2rem; border: 3px solid var(--ink); border-radius: 14px; background: var(--board); color: transparent; cursor: pointer; }
.card.up { background: var(--paper); color: var(--ink); }
.card.ok { background: #d5f5e1; }

.order, .aim, .dots-box { position: relative; height: 360px; background: var(--bg); border-radius: 14px; overflow: hidden; }
.order button { position: absolute; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); font: inherit; font-weight: 800; font-size: 1.25rem; cursor: pointer; touch-action: manipulation; }
.order .done { opacity: .2; pointer-events: none; }
.order .bad { background: var(--red); color: #fff; }

.react { width: 100%; height: 300px; border: 4px solid var(--ink); border-radius: 18px; color: #fff; font: inherit; font-size: 2.2rem; font-weight: 800; cursor: pointer; touch-action: manipulation; }
.react.wait { background: var(--red); }
.react.go { background: var(--green); }
.react.pause { background: var(--board); }

.math-q, .stroop-word, .par-n, .ana-w, .sw-time { text-align: center; font-weight: 800; }
.math-q { font-size: 3.4rem; margin: 40px 0 24px; }
.sw-time { font-size: 5.5rem; margin: 10px 0 24px; font-variant-numeric: tabular-nums; }
.sw-time + .big-btn { height: 160px; background: var(--red); color: #fff; }

.aim .t { position: absolute; width: 58px; height: 58px; border-radius: 50%; border: 4px solid var(--ink); background: var(--red); box-shadow: inset 0 0 0 9px var(--paper); cursor: crosshair; touch-action: manipulation; }

.stroop-word { font-size: 4.4rem; margin: 34px 0; }
.stroop-btns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stroop-btns button, .par-btns button { padding: 18px; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper); color: var(--ink); font: inherit; font-size: 1.3rem; font-weight: 800; cursor: pointer; touch-action: manipulation; }
.par-n { font-size: 7rem; margin: 20px 0; line-height: 1; }
.par-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.odd { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 380px; margin: 0 auto; }
.odd button { aspect-ratio: 1; font-size: 2rem; border: 3px solid var(--ink); border-radius: 12px; background: var(--paper); cursor: pointer; touch-action: manipulation; }
.odd.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 340px; margin: 10px auto; }
.pad { aspect-ratio: 1.3; border: 4px solid var(--ink); border-radius: 20px; opacity: .5; cursor: pointer; touch-action: manipulation; }
.pad.lit { opacity: 1; filter: brightness(1.2); }

.dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.dots-box .q { position: absolute; inset: 0; display: grid; place-items: center; font-size: 5rem; font-weight: 800; }
.dots-in { display: flex; gap: 12px; margin-top: 14px; }
.dots-in .text-in { margin: 0; }

.ana-w { font-size: 3.4rem; letter-spacing: .18em; margin: 36px 0 24px; }
.ana-w + .text-in { margin-bottom: 14px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .profile { grid-template-columns: 1fr; gap: 20px; }
  .preview { flex-direction: row; justify-content: center; }
  .avatar.xl { width: 64px; height: 64px; font-size: 2rem; }
  #arena { grid-template-columns: 1fr; }
  .who { margin-left: 0; }
  .stage { padding: 16px; }
  .center h2 { font-size: 1.9rem; }
  .big-btn, .react { height: 240px; }
}
@media (prefers-reduced-motion: reduce) { .odd.shake { animation: none; } .btn, .ok-btn { transition: none; } }
