:root {
  --background: #ffffff;
  --surface: #f0f0ee;
  --foreground: #1a1a1a;
  --border: #dedcd7;
  --muted: #666360;
  --accent: #1a1a1a;
  --cyan: hsl(180, 100%, 50%);
  --magenta: hsl(300, 100%, 50%);
  --yellow: hsl(60, 100%, 50%);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --spacing-4: 1rem;
  --z-content-high: 50;
  font-family: "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
}

.view { min-height: 100vh; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--foreground);
  color: var(--background);
  border: 2px solid var(--foreground);
  padding: 0.6rem 1.2rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 2px;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: transparent; color: var(--foreground); transform: translateY(-1px); }
.btn-lg { padding: 0.9rem 1.8rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-outline { background: transparent; color: var(--foreground); }
.btn-outline:hover { background: var(--foreground); color: var(--background); }

/* ---------- Accueil : Hero ---------- */
.hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 4rem 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
}

.lang-selector {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  border-radius: 2px;
}
.lang-selector:hover { border-color: var(--foreground); }
.lang-selector.small { position: static; }

.hero-content { flex: 1 1 420px; max-width: 560px; z-index: 1; }

.title {
  font-size: clamp(2.5rem, 6vw, 4.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  margin: 0 0 1rem;
  line-height: 1;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 2rem;
}

.mode-label {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.8rem;
}

.button-group { display: flex; gap: 1rem; flex-wrap: wrap; }

.visuals { flex: 1 1 320px; display: flex; justify-content: center; z-index: 1; }

.composition {
  position: relative;
  width: 280px;
  height: 280px;
}
/* mix-blend-mode: multiply (synthèse soustractive), comme sur le plateau de
   jeu — pas "screen" : on veut voir les mêmes couleurs secondaires (vert,
   rouge, bleu) et le noir au centre, cohérent avec la règle du jeu. */
.shape { position: absolute; border-radius: 50%; mix-blend-mode: multiply; }
.c-circle { width: 180px; height: 180px; background: var(--cyan); top: 20px; left: 0; }
.m-circle { width: 180px; height: 180px; background: var(--magenta); top: 20px; right: 0; }
.y-circle { width: 180px; height: 180px; background: var(--yellow); bottom: 0; left: 50px; }

/* ---------- Règles ---------- */
.rules-section { max-width: 1200px; margin: 2rem auto; padding: 2rem; border-top: 1px solid var(--border); }
.section-title { text-align: center; letter-spacing: 0.1em; font-size: 1.3rem; margin-bottom: 2rem; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.5rem; }
.rule-card { background: var(--surface); padding: 1.5rem; border-radius: 6px; }
.rule-card h3 { margin: 0.8rem 0 0.6rem; font-size: 1rem; letter-spacing: 0.03em; }
.rule-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.icon-box { font-size: 1.6rem; }

.about-section { max-width: 800px; margin: 2rem auto; padding: 0 2rem 2rem; }
.about-box { background: var(--surface); padding: 2rem; border-radius: 6px; text-align: center; }
.about-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.about-title { margin: 0 0 0.8rem; font-size: 1.2rem; }
.about-desc { color: var(--muted); line-height: 1.7; margin: 0; }

/* ---------- Notation ---------- */
.rating-section { max-width: 640px; margin: 0 auto 2rem; padding: 0 2rem; }
.rating-box { background: var(--surface); border-radius: 6px; padding: 2rem; text-align: center; }

.rating-summary { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; margin-bottom: 1.5rem; }
.rating-average { font-size: 2.2rem; font-weight: 900; }
.rating-stars-display { font-size: 1.3rem; letter-spacing: 0.15em; color: var(--border); }
.rating-stars-display .filled { color: #e0a90b; }
.rating-count { font-size: 0.8rem; color: var(--muted); }

.rating-form-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 0.5rem; }
.rating-stars-input { display: flex; justify-content: center; gap: 0.3rem; margin-bottom: 1rem; }
.star-btn {
  background: none; border: none; cursor: pointer; font-size: 1.8rem; line-height: 1;
  color: var(--border); padding: 0.1rem; transition: color 0.15s ease, transform 0.15s ease;
}
.star-btn:hover, .star-btn.hovered { transform: scale(1.1); }
.star-btn.filled, .star-btn.hovered { color: #e0a90b; }

.rating-name-input, .rating-comment-input {
  display: block; width: 100%; max-width: 420px; margin: 0 auto 0.6rem;
  padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.9rem; background: var(--background); color: var(--foreground);
  font-family: inherit; box-sizing: border-box; resize: vertical;
}
.rating-form-row { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.rating-feedback { min-height: 1.2rem; font-size: 0.85rem; margin: 0.8rem 0 0; color: var(--muted); }

.rating-list { list-style: none; padding: 0; margin: 1.5rem 0 0; text-align: left; border-top: 1px solid var(--border); }
.rating-list li {
  padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.rating-item-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.rating-list .rating-item-stars { color: var(--border); letter-spacing: 0.1em; white-space: nowrap; }
.rating-list .rating-item-stars .filled { color: #e0a90b; }
.rating-list .rating-item-name { flex: 1; color: var(--foreground); font-weight: 600; }
.rating-list .rating-item-date { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.rating-item-comment { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }

.footer { text-align: center; padding: 2rem; color: var(--muted); font-size: 0.85rem; }

/* ---------- Écran de jeu ---------- */
.game-container { min-height: 100vh; display: flex; flex-direction: column; }

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 0.8rem; }
.home-link {
  background: none; border: none; color: var(--foreground);
  font-weight: 700; letter-spacing: 0.05em; cursor: pointer; font-size: 0.95rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.mode-badge {
  border: 1px solid var(--border); padding: 0.25rem 0.6rem; border-radius: 2px;
  font-size: 0.75rem; letter-spacing: 0.05em; color: var(--muted);
}

.turn-indicator { font-size: 0.9rem; color: var(--muted); display: flex; gap: 0.3rem; align-items: center; }
.p1-text { color: var(--cyan); font-weight: 700; }
.p2-text { color: var(--magenta); font-weight: 700; }
.thinking-text { color: var(--yellow); font-style: italic; }

.actions { display: flex; align-items: center; gap: 0.7rem; }

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1.5rem;
}

.player-zone { width: 100%; max-width: 420px; }
.player-card {
  background: var(--surface); border: 1px solid transparent; border-radius: 6px; padding: 0.8rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  transition: border-color 0.2s ease;
}
.player-card.active-player { border-color: var(--foreground); }
.player-header { display: flex; align-items: center; gap: 0.6rem; }
.player-card h3 { margin: 0; font-size: 0.85rem; letter-spacing: 0.08em; }
.pawn-status { display: flex; gap: 0.3rem; }
.status-dot, .status-dot-square {
  width: 14px; height: 14px; opacity: 1; border: 1px solid rgba(0,0,0,0.2);
}
.status-dot { border-radius: 50%; }
.status-dot-square { border-radius: 3px; }
.status-dot.captured, .status-dot-square.captured { opacity: 0.15; }
.status-dot.cyan, .status-dot-square.cyan { background: var(--cyan); }
.status-dot.magenta, .status-dot-square.magenta { background: var(--magenta); }
.status-dot.yellow, .status-dot-square.yellow { background: var(--yellow); }
.objective { margin: 0; font-size: 0.75rem; color: var(--muted); }

.loader {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--yellow); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Plateau ---------- */
.board-wrapper { display: flex; justify-content: center; }
.board-container {
  padding: var(--spacing-4);
  background-color: var(--surface);
  display: inline-block;
  box-shadow: var(--shadow-lg);
  border-radius: 6px;
}
/* Important : display:flex (pas display:grid). CSS Grid empêche mix-blend-mode
   de traverser correctement vers les pions superposés dans certains moteurs de
   rendu — on reproduit donc la structure en lignes flexbox de l'original. */
.grid {
  position: relative;
  display: flex;
  flex-direction: column;
}
.row { display: flex; }
.cell {
  width: 3.6rem; height: 3.6rem;
  display: flex; align-items: center; justify-content: center;
  position: relative; cursor: default;
}
@media (min-width: 600px) {
  .cell { width: 4.4rem; height: 4.4rem; }
}

.cell.cyan { background-color: var(--cyan); }
.cell.magenta { background-color: var(--magenta); }
.cell.yellow { background-color: var(--yellow); }

.cell.valid-move { cursor: pointer; }
.cell.valid-move::after {
  content: ''; position: absolute; inset: 0;
  background-color: rgba(255,255,255,0.3); pointer-events: none;
  animation: pulse 2s infinite;
}
.cell.capture-move::after {
  background-color: rgba(0,0,0,0.2);
  border: 2px solid var(--foreground);
}
@keyframes pulse { 0% { opacity: 0.3; } 50% { opacity: 0.6; } 100% { opacity: 0.3; } }

/* Pions
   ---------------------------------------------------------------------
   La couleur affichée d'un pion (mélange soustractif pion × case) est
   calculée directement en JavaScript (voir pawnDisplayColor() dans app.js)
   et appliquée en background-color sur .pawn — PAS via CSS mix-blend-mode.

   On a essayé mix-blend-mode au départ ; sur Chromium, il se casse dès
   qu'un ANCÊTRE de l'élément mélangé porte la moindre transition ou
   animation (transform, opacity, box-shadow, voire juste left/top), qui le
   fait passer sur son propre calque de composition et lui coupe l'accès à
   la couleur de la case en dessous — le pion retombe alors sur sa couleur
   primaire. Ça s'est reproduit avec le clignotement IA, le flash de
   capture, ET la simple sélection/déplacement d'un pion : trois causes
   différentes pour le même symptôme. Un background-color calculé en JS ne
   dépend d'aucun calque de composition, donc aucune animation ou
   transition sur .pawn-slot / .pawn-effect ne peut plus jamais l'affecter.

   Structure (gardée telle quelle, toujours utile pour la sélection et les
   animations, juste plus critique pour la couleur) :
   .pawn-slot   (position + glissement entre cases)
     .pawn-effect  (sélection / capturable — ombre)
       .pawn         (couleur, calculée en JS)
     .pawn-fx      (clignotement IA, flash de capture)
   --------------------------------------------------------------------- */
.pawns-layer { position: absolute; inset: 0; pointer-events: none; }
.pawn-slot {
  position: absolute;
  width: 16.6667%; height: 16.6667%;
  pointer-events: auto;
  cursor: pointer;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1), top 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  /* Pas de z-index ici (voir plus haut) — même raison. */
}
.pawn-slot.captured { display: none; }

.pawn-effect, .pawn-fx {
  position: absolute;
  inset: 15%; /* = 70% de large/haut, centré, comme avant */
}
.pawn-effect.p1, .pawn-fx.p1 { border-radius: 50%; }
.pawn-effect.p2, .pawn-fx.p2 { border-radius: 4px; }

.pawn-effect { transition: box-shadow 0.2s ease; }
.pawn-effect.selected { box-shadow: 0 0 0 3px var(--foreground); }
.pawn-effect.capturable { box-shadow: 0 0 0 2px rgba(0,0,0,0.6); }

.pawn {
  width: 100%; height: 100%;
  border: 1px solid hsl(0, 0%, 40%);
  border-radius: inherit;
  /* background-color défini en JS (pawnDisplayColor) — voir commentaire ci-dessus */
}

.pawn-fx { pointer-events: none; }

.pawn-fx.blinking {
  animation: blink 0.5s ease-in-out infinite;
  box-shadow: 0 0 0 3px #fff, 0 0 14px 4px rgba(255,255,255,0.85);
}
@keyframes blink { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }

.pawn-fx.capture-blinking { animation: captureBlink 1.2s ease-in-out; }
@keyframes captureBlink {
  0% { box-shadow: 0 0 0 0 rgba(0,0,0,0.7); }
  20% { box-shadow: 0 0 18px 6px rgba(0,0,0,0.55); }
  40% { box-shadow: 0 0 0 0 rgba(0,0,0,0.7); }
  60% { box-shadow: 0 0 18px 6px rgba(0,0,0,0.55); }
  80% { box-shadow: 0 0 0 0 rgba(0,0,0,0.7); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

/* ---------- Dialogue de victoire ---------- */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.dialog-content {
  background: #fbfbfa; border: 1px solid var(--border); border-radius: 6px;
  padding: 2rem; max-width: 380px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.dialog-content h2 { margin: 0 0 0.8rem; letter-spacing: 0.05em; }
.dialog-content p { color: var(--muted); line-height: 1.6; }
.win-visual { font-size: 2.5rem; margin: 1rem 0; }
.dialog-footer { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.2rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #262624; border: 1px solid #3a3a37; color: #f5f5f2;
  padding: 0.7rem 1.2rem; border-radius: 4px; font-size: 0.85rem; z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
