:root {
  --bg: #12131a;
  --panel: #1c1e29;
  --cell: #232636;
  --cell-hover: #2c3145;
  --line: #343850;
  --text: #eef0f7;
  --muted: #9aa0b8;
  --red: #e8452c;
  --yellow: #f5c518;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 90% at 50% 0%, #1b1e2b 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { width: 100%; max-width: 420px; text-align: center; }

h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.players {
  margin: 0 0 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}
.who { display: inline-flex; align-items: center; gap: 7px; }
.vs { opacity: 0.6; }
.chip { width: 20px; height: 20px; }
.red { color: var(--red); }
.yellow { color: var(--yellow); }

.status {
  min-height: 1.6em;
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 550;
  transition: color 0.2s;
}
.status.win  { color: var(--red); }
.status.lose { color: var(--yellow); }
.status.draw { color: var(--muted); }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 9%;
  border: 0;
  border-radius: 12px;
  background: var(--cell);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.cell:disabled { cursor: default; }
.cell:not(:disabled):hover { background: var(--cell-hover); }
.cell:not(:disabled):active { transform: scale(0.97); }
.cell:focus-visible { outline: 2px solid #6f7bff; outline-offset: 2px; }

.cell svg { width: 100%; height: 100%; display: block; animation: pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* La ligne gagnante : les jetons pulsent, les autres s'effacent. */
.board.over .cell:not(.win) svg { opacity: 0.35; transition: opacity 0.3s; }
.cell.win svg { animation: pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), glow 1.1s ease-in-out 0.22s infinite; }

@keyframes pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes glow { 50% { transform: scale(1.08); } }

.reset {
  margin-top: 20px;
  padding: 11px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.reset:hover { background: var(--cell-hover); border-color: #4a5070; }
.reset:focus-visible { outline: 2px solid #6f7bff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .cell svg, .cell.win svg { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
