/* ═══════════════════════════════════════════════════════════
   SONGO — Design System  •  Light mode only
   ═══════════════════════════════════════════════════════════ */

/* ── 1. TOKENS ──────────────────────────────────────────── */
:root {
  /* Surfaces — warm dark brown */
  --bg:        #110D09;
  --surface-1: #1C1510;
  --surface-2: #252019;
  --surface-3: #2E271F;

  /* Text — warm parchment, hierarchy by opacity */
  --text-1: rgba(240, 228, 210, 1.00);
  --text-2: rgba(240, 228, 210, 0.60);
  --text-3: rgba(240, 228, 210, 0.36);

  /* Borders */
  --border:        rgba(240, 228, 210, 0.08);
  --border-strong: rgba(240, 228, 210, 0.15);

  /* Accent — warm amber */
  --accent:       #C4812A;
  --accent-hover: #D49240;
  --accent-dim:   rgba(196, 129, 42, 0.14);

  /* Semantic */
  --success: #4A9264;
  --error:   #9E3A3A;

  /* Board */
  --pit:      #0C0906;
  --pit-ring: rgba(240, 228, 210, 0.06);
  --seed:     #C4912A;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", Arial, sans-serif;

  /* Type scale */
  --t-xs:   12px;
  --t-sm:   14px;
  --t-base: 16px;
  --t-md:   20px;
  --t-lg:   24px;
  --t-xl:   32px;
  --t-2xl:  48px;

  /* Spacing */
  --s1:  4px;
  --s2:  8px;
  --s3:  12px;
  --s4:  16px;
  --s5:  20px;
  --s6:  24px;
  --s8:  32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;

  /* Radius */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-full: 9999px;

  /* Motion */
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:  cubic-bezier(0.0, 0, 0.2, 1);
  --dur-micro: 120ms;
  --dur-state: 150ms;
  --dur-view:  250ms;
  --dur-seed:  160ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}


/* ── 2. RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input {
  font-family: inherit;
  font-size: inherit;
}


/* ── 3. ÉCRANS ──────────────────────────────────────────── */
.ecran {
  position: fixed;
  inset: 0;
  display: none;
  overflow: auto;
}
.ecran.actif { display: flex; }

#ecran-accueil.actif {
  display: grid;
  grid-template-columns: clamp(300px, 36%, 440px) 1fr;
}

/* Theme toggle — hidden, JS still works without crashing */
.btn-theme { display: none !important; }


/* ── 4. SVG ICONS ───────────────────────────────────────── */
/* Dark background: white icons via invert */
.svg-icone {
  display: block;
  width: 1em;
  height: 1em;
  filter: brightness(0) invert(1);
  opacity: 0.55;
  flex-shrink: 0;
}

.btn-retour .svg-icone,
.btn-action .svg-icone,
.btn-fermer-panneau .svg-icone,
.modal-fermer .svg-icone,
.btn-copier .svg-icone {
  opacity: 0.50;
  filter: brightness(0) invert(1);
}

.mode-icone .svg-icone {
  width: 18px;
  height: 18px;
  opacity: 0.45;
  filter: brightness(0) invert(1);
}

.btn-mode.actif .mode-icone .svg-icone { opacity: 0.75; }


/* ══════════════════════════════════════════════════════════
   ÉCRAN D'ACCUEIL — split layout, desktop-first
   ══════════════════════════════════════════════════════════ */

/* ── Pane gauche : identité ── */
.accueil-identite {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s10) var(--s10);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.logo-area {
  display: flex;
  align-items: flex-start;
}

.logo-mark {
  color: var(--accent);
  display: block;
  flex-shrink: 0;
}

/* Title zone — vertically centered in the left pane */
.titre-bloc {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--s12) 0;
}

.titre-jeu {
  font-size: clamp(64px, 5.5vw, 96px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.88;
  color: var(--text-1);
  margin: 0;
}

.sous-titre {
  font-size: var(--t-sm);
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin: var(--s5) 0 0 0;
}

/* Bottom of left pane */
.accueil-bas {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: flex-start;
}

/* ── Bouton musique ── */
.btn-musique {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-state) var(--ease),
              border-color var(--dur-state) var(--ease),
              background var(--dur-state) var(--ease);
}
.btn-musique:hover {
  color: var(--text-2);
  border-color: var(--border-strong);
}
.btn-musique.actif {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}
.btn-musique.actif:hover {
  background: rgba(196, 129, 42, 0.22);
}
.icone-musique {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stats-accueil {
  font-size: var(--t-xs);
  color: var(--text-3);
  min-height: 16px;
  line-height: 1.6;
}

/* ── Pane droit : action ── */
.accueil-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s10) var(--s10);
  min-height: 100vh;
  overflow-y: auto;
}

.action-contenu {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

/* Section label */
.section-titre {
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}

/* ── Mode buttons — vertical grouped list ── */
.modes-jeu {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.btn-mode {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4);
  background: var(--surface-1);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  text-align: left;
  min-height: 56px;
  transition:
    background var(--dur-state) var(--ease),
    color var(--dur-state) var(--ease),
    box-shadow var(--dur-state) var(--ease);
}

.btn-mode:last-child { border-bottom: none; }

.btn-mode:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

/* Inset left bar = active indicator (Linear-style) */
.btn-mode.actif {
  background: var(--accent-dim);
  color: var(--text-1);
  box-shadow: inset 3px 0 0 var(--accent);
}

.btn-mode:active { transform: scale(0.998); }

.btn-mode:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.mode-icone {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.mode-texte {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-label {
  font-size: var(--t-sm);
  font-weight: 500;
  line-height: 1;
}

.mode-desc {
  font-size: var(--t-xs);
  color: var(--text-3);
  line-height: 1.3;
}

/* ── Options sections ── */
.options-section {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.options-label {
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Difficulty buttons */
.niveaux {
  display: flex;
  gap: var(--s2);
}

.btn-niveau {
  flex: 1;
  height: 36px;
  padding: 0 var(--s3);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition:
    background var(--dur-state) var(--ease),
    border-color var(--dur-state) var(--ease),
    color var(--dur-state) var(--ease);
}

.btn-niveau:hover { color: var(--text-1); border-color: var(--text-3); }

.btn-niveau.actif {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn-niveau:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Primary CTA ── */
.btn-jouer {
  height: 52px;
  width: 100%;
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border-radius: var(--r-sm);
  transition:
    background var(--dur-state) var(--ease),
    transform var(--dur-micro) var(--ease);
}

.btn-jouer:hover { background: var(--accent-hover); }
.btn-jouer:active { transform: scale(0.99); }
.btn-jouer:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Ghost link ── */
.btn-lien {
  font-size: var(--t-sm);
  color: var(--text-3);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color var(--dur-state) var(--ease);
}
.btn-lien:hover { color: var(--text-2); }
.btn-lien:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* ══════════════════════════════════════════════════════════
   INPUTS + FORMS
   ══════════════════════════════════════════════════════════ */

.pseudo-groupe {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.champ-pseudo,
.champ-code {
  height: 44px;
  padding: 0 var(--s3);
  font-size: var(--t-sm);
  color: var(--text-1);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  width: 100%;
  transition:
    border-color var(--dur-state) var(--ease),
    box-shadow var(--dur-state) var(--ease);
  outline: none;
  -webkit-appearance: none;
}

.champ-pseudo::placeholder,
.champ-code::placeholder { color: var(--text-3); }

.champ-pseudo:focus,
.champ-code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.champ-code {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.online-choix {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.ou-separateur {
  font-size: var(--t-xs);
  color: var(--text-3);
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rejoindre-groupe {
  display: flex;
  gap: var(--s2);
}
.rejoindre-groupe .champ-code { flex: 1; }

.btn-online-action {
  height: 44px;
  padding: 0 var(--s4);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-1);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition:
    background var(--dur-state) var(--ease),
    border-color var(--dur-state) var(--ease);
}

.btn-online-action:hover {
  background: var(--surface-2);
}

.btn-online-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ══════════════════════════════════════════════════════════
   MODAL RÈGLES
   ══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  background: rgba(0, 0, 0, 0.60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
}

.modal-overlay[hidden] { display: none; }

.modal-contenu {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: var(--s8) var(--s6) var(--s6);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.50);
}

.modal-contenu h2 {
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin: 0 0 var(--s5) 0;
}

.regles-texte {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.regles-texte p {
  font-size: var(--t-sm);
  color: var(--text-2);
  line-height: 1.65;
  margin: 0;
}

.regles-texte strong {
  color: var(--text-1);
  font-weight: 600;
}

.modal-fermer {
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: background var(--dur-state) var(--ease);
}
.modal-fermer:hover { background: var(--surface-2); }
.modal-fermer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* ══════════════════════════════════════════════════════════
   ÉCRAN D'ATTENTE
   ══════════════════════════════════════════════════════════ */

#ecran-attente {
  align-items: center;
  justify-content: center;
  padding: var(--s8);
}

.attente-contenu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s5);
  max-width: 380px;
  width: 100%;
  text-align: center;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-bois {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin 0.8s linear infinite;
}

.attente-titre {
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin: 0;
}

.attente-sous {
  font-size: var(--t-sm);
  color: var(--text-2);
  margin: 0;
}

.code-affiche {
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(150, 96, 26, 0.22);
  border-radius: var(--r-sm);
  padding: var(--s4) var(--s8);
  user-select: all;
  cursor: default;
}

.btn-copier {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s4);
  font-size: var(--t-sm);
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition:
    color var(--dur-state) var(--ease),
    background var(--dur-state) var(--ease);
}
.btn-copier:hover { color: var(--text-1); background: var(--surface-2); }
.btn-copier:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.attente-info {
  font-size: var(--t-sm);
  color: var(--text-3);
  line-height: 1.5;
  margin: 0;
}


/* ══════════════════════════════════════════════════════════
   ÉCRAN DE JEU
   ══════════════════════════════════════════════════════════ */

#ecran-jeu {
  flex-direction: column;
  background: var(--surface-2);
  overflow: hidden;
  min-height: 100vh;
}

/* ── Header ── */
.jeu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-retour,
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  transition: background var(--dur-state) var(--ease);
}
.btn-retour:hover, .btn-action:hover { background: var(--surface-1); }
.btn-retour:active, .btn-action:active { transform: scale(0.93); }
.btn-retour:focus-visible, .btn-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-action[disabled] { opacity: 0.28; pointer-events: none; }

.mode-indicateur {
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.actions-header {
  display: flex;
  align-items: center;
  gap: var(--s1);
}

/* ── Main game area ── */
.jeu-principal {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s5);
  padding: var(--s6) var(--s8);
  overflow: hidden;
}

/* ── Player zones ── */
.joueur-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 680px;
}

.joueur-info {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.joueur-nom {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--dur-state) var(--ease);
}

.joueur-zone.actif .joueur-nom { color: var(--text-1); }

.tour-indicateur {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--dur-state) var(--ease);
}
.joueur-zone.actif .tour-indicateur { background: var(--accent); }

.statut-connexion {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  display: none;
}
.statut-connexion.connecte   { display: inline; color: var(--success); }
.statut-connexion.deconnecte { display: inline; color: var(--error); }

/* ── Board wrapper ── */
.plateau-wrapper {
  display: flex;
  align-items: stretch;
  gap: var(--s4);
  width: 100%;
  max-width: 680px;
}

/* ── Board ── */
.plateau {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s5) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  position: relative;
  border-top: 2px solid var(--accent);
}

/* Subtle wood grain */
.plateau::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-sm);
  background: repeating-linear-gradient(
    80deg,
    transparent 0px,
    transparent 30px,
    rgba(255, 255, 255, 0.015) 30px,
    rgba(255, 255, 255, 0.015) 31px
  );
  pointer-events: none;
}

.rangee {
  display: flex;
  gap: var(--s3);
  justify-content: center;
}

/* ── Pits ── */
.case {
  width: 64px;
  height: 64px;
  border-radius: var(--r-full);
  background: var(--pit);
  border: 1px solid var(--pit-ring);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: var(--s2);
  position: relative;
  transition:
    box-shadow var(--dur-state) var(--ease),
    transform  var(--dur-state) var(--ease);
  overflow: visible;
}

.case.jouable {
  cursor: pointer;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    0 0 0 2px var(--accent);
}

.case.jouable:hover {
  transform: scale(1.04);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    0 0 0 2px var(--accent-hover);
}

.case.jouable:active { transform: scale(0.97); }

.case.jouable:focus-visible {
  outline: none;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    0 0 0 2px var(--text-1);
}

.case.derniere {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    0 0 0 2px var(--accent);
}

.case-compte {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  z-index: 2;
}

/* ── Seeds ── */
.graine {
  --sz: 13px;
  width: var(--sz);
  height: var(--sz);
  border-radius: var(--r-full);
  background: var(--seed);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.case[data-count="7"]  .graine,
.case[data-count="8"]  .graine { --sz: 10px; }
.case[data-count="9"]  .graine,
.case[data-count="10"] .graine { --sz: 9px; }
.case[data-count="11"] .graine,
.case[data-count="12"] .graine { --sz: 8px; }

.case[data-count]:not([data-count="0"]):not([data-count="1"]):not([data-count="2"]):not([data-count="3"]):not([data-count="4"]):not([data-count="5"]):not([data-count="6"]):not([data-count="7"]):not([data-count="8"]):not([data-count="9"]):not([data-count="10"]):not([data-count="11"]):not([data-count="12"]) .graine {
  --sz: 6px;
}

@keyframes seedIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.graine.nouvelle {
  animation: seedIn var(--dur-seed) cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes seedOut {
  0%   { transform: scale(1);    opacity: 1; }
  60%  { transform: scale(1.25); opacity: 0.6; }
  100% { transform: scale(0);    opacity: 0; }
}
.graine.capture-anim {
  animation: seedOut 320ms var(--ease) forwards;
}

/* ── Stores ── */
.grenier {
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s4) var(--s3);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-state) var(--ease);
  flex-shrink: 0;
}

.grenier.actif { border-color: rgba(150, 96, 26, 0.35); }

.grenier-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.grenier-score {
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-1);
  line-height: 1;
  transition: color var(--dur-state) var(--ease);
}

.grenier.actif .grenier-score { color: var(--accent); }

.grenier-graines {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 100%;
  padding: 0 var(--s1);
}
.grenier-graines .graine { --sz: 6px; }

/* ── Status message ── */
.message-statut {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
  opacity: 0;
  transition: opacity var(--dur-state) var(--ease);
}
.message-statut.visible { opacity: 1; }


/* ══════════════════════════════════════════════════════════
   PANNEAU PARAMÈTRES
   ══════════════════════════════════════════════════════════ */

.panneau-lateral {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transform: translateX(100%);
  transition: transform var(--dur-view) var(--ease);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.30);
}

.panneau-lateral[hidden] {
  display: flex;
  transform: translateX(100%);
  pointer-events: none;
}
.panneau-lateral:not([hidden]) { transform: translateX(0); }

.panneau-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panneau-entete h3 {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
}

.btn-fermer-panneau {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  transition: background var(--dur-state) var(--ease);
}
.btn-fermer-panneau:hover { background: var(--surface-2); }

.panneau-corps {
  flex: 1;
  padding: var(--s5) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  overflow-y: auto;
}

.param-groupe {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.param-label {
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.theme-toggle-groupe {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--t-sm);
  color: var(--text-2);
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  transition: background var(--dur-state) var(--ease);
  flex-shrink: 0;
}
.toggle-switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }

.toggle-curseur {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  background: var(--text-2);
  transition: transform var(--dur-state) var(--ease), background var(--dur-state) var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.30);
}
.toggle-switch[aria-checked="true"] .toggle-curseur {
  transform: translateX(18px);
  background: #fff;
}

.separateur {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

.btn-danger {
  height: 40px;
  padding: 0 var(--s4);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--error);
  background: transparent;
  border: 1px solid rgba(158, 58, 58, 0.25);
  border-radius: var(--r-sm);
  transition: background var(--dur-state) var(--ease), border-color var(--dur-state) var(--ease);
}
.btn-danger:hover { background: rgba(158, 58, 58, 0.08); border-color: rgba(158, 58, 58, 0.40); }
.btn-danger:focus-visible { outline: 2px solid var(--error); outline-offset: 2px; }

.btn-danger-sec {
  color: var(--text-3);
  border-color: var(--border);
}
.btn-danger-sec:hover { color: var(--text-2); background: var(--surface-2); }


/* ══════════════════════════════════════════════════════════
   ÉCRAN FIN DE PARTIE — open composition
   ══════════════════════════════════════════════════════════ */

#ecran-fin {
  align-items: center;
  justify-content: center;
  padding: var(--s8);
}

@keyframes finSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fin-contenu {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s10);
  animation: finSlideIn var(--dur-view) var(--ease-out) both;
}

.fin-titre {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-1);
  margin: 0;
  text-align: center;
  line-height: 1;
}

.fin-detail {
  font-size: var(--t-sm);
  color: var(--text-3);
  margin: calc(-1 * var(--s6)) 0 0;
  text-align: center;
  min-height: 20px;
}

/* Score display — winner towers via size contrast */
.fin-scores {
  display: flex;
  align-items: center;
  gap: var(--s10);
  width: 100%;
  justify-content: center;
}

.fin-score-bloc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}

.fin-score-val {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-2);
  line-height: 1;
  transition: font-size var(--dur-view) var(--ease), color var(--dur-view) var(--ease);
}

.fin-score-val.gagnant {
  font-size: 80px;
  font-weight: 800;
  color: var(--accent);
}

.fin-score-label {
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
}

.fin-score-sep {
  font-size: var(--t-md);
  color: var(--text-3);
  font-weight: 300;
  flex-shrink: 0;
}

.fin-boutons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  width: 100%;
}

.fin-boutons .btn-jouer { max-width: 260px; }


/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

/* ── Tablet large (≤ 1024px) ───────────────────────────── */
@media (max-width: 1024px) {
  .accueil-identite { padding: var(--s8) var(--s8); }
  .accueil-action   { padding: var(--s8) var(--s8); }
  .titre-jeu { font-size: clamp(56px, 5.5vw, 80px); }
}

/* ── Tablet portrait / collapse (≤ 740px) ─────────────── */
@media (max-width: 740px) {
  /* Stack the two panes */
  #ecran-accueil.actif {
    display: flex;
    flex-direction: column;
  }

  .accueil-identite {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: var(--s6) var(--s6);
    gap: var(--s6);
  }

  .logo-area { display: none; }

  .titre-bloc {
    flex: none;
    padding: 0;
    justify-content: flex-start;
  }

  .titre-jeu { font-size: 52px; }
  .sous-titre { margin-top: var(--s2); font-size: var(--t-xs); }

  .accueil-bas {
    flex-direction: column;
    align-items: flex-end;
    gap: var(--s1);
    flex-shrink: 0;
  }

  .accueil-action {
    min-height: auto;
    padding: var(--s6) var(--s6);
    align-items: flex-start;
    justify-content: flex-start;
  }

  .action-contenu { max-width: 100%; }

  /* Fin screen */
  .fin-titre { font-size: 32px; }
  .fin-score-val { font-size: 36px; }
  .fin-score-val.gagnant { font-size: 64px; }
  .fin-scores { gap: var(--s8); }
  .fin-contenu { gap: var(--s8); }
}

/* ── Mobile (≤ 600px) ─────────────────────────────────── */
@media (max-width: 600px) {
  /* Board: scale down pits */
  .case { width: 52px; height: 52px; }
  .rangee { gap: var(--s2); }
  .grenier { width: 60px; }
  .plateau-wrapper { gap: var(--s3); max-width: 100%; }
  .plateau { padding: var(--s4) var(--s3); gap: var(--s3); }

  .jeu-principal { padding: var(--s4) var(--s4); gap: var(--s4); }

  /* Header: shrink mode label */
  .mode-indicateur { max-width: 100px; font-size: 10px; }

  /* Home */
  .accueil-identite { padding: var(--s5) var(--s5); }
  .accueil-action   { padding: var(--s5) var(--s5); }
  .titre-jeu { font-size: 44px; }

  /* Fin */
  .fin-titre { font-size: 28px; }
  .fin-score-val { font-size: 32px; }
  .fin-score-val.gagnant { font-size: 56px; }
  .fin-scores { gap: var(--s6); }
  .fin-contenu { gap: var(--s6); max-width: 100%; }

  /* Modal: full-screen-ish */
  .modal-contenu { padding: var(--s8) var(--s5) var(--s5); }
}

/* ── Mobile small (≤ 480px) ───────────────────────────── */
@media (max-width: 480px) {
  /* Board: further reduction */
  .case { width: 44px; height: 44px; padding: var(--s1); }
  .rangee { gap: var(--s1); }
  .grenier { width: 52px; padding: var(--s3) var(--s2); }
  .plateau-wrapper { gap: var(--s2); }
  .plateau { padding: var(--s3) var(--s2); gap: var(--s3); }

  .jeu-principal { padding: var(--s3) var(--s3); gap: var(--s3); }

  /* Seeds: reduce max display size for crowded pits */
  .case[data-count="5"] .graine,
  .case[data-count="6"] .graine { --sz: 10px; }
  .case[data-count="7"] .graine,
  .case[data-count="8"] .graine { --sz: 8px; }

  .grenier-score { font-size: var(--t-lg); }

  /* Home */
  .accueil-identite { padding: var(--s4) var(--s4); gap: var(--s4); }
  .accueil-action   { padding: var(--s4) var(--s4); }
  .titre-jeu { font-size: 36px; letter-spacing: -0.04em; }
  .sous-titre { display: none; }
  .stats-accueil { display: none; }

  /* Reduce CTA height slightly */
  .btn-jouer { height: 48px; }

  /* Params panel: full width on mobile */
  .panneau-lateral { width: 100%; border-left: none; border-top: 1px solid var(--border); }

  /* Fin */
  .fin-titre { font-size: 24px; }
  .fin-score-val { font-size: 28px; }
  .fin-score-val.gagnant { font-size: 48px; }
  .fin-scores { gap: var(--s5); }
  .fin-boutons .btn-jouer { max-width: 100%; }
}

/* ── Very small (≤ 380px) — board scrolls horizontally ── */
@media (max-width: 380px) {
  /* Keep pits at 44px (tappable) but allow board scroll */
  .jeu-principal { overflow-x: hidden; padding: var(--s2) var(--s2); }

  .plateau-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    /* Prevent flex children from shrinking */
  }

  .grenier   { flex-shrink: 0; }
  .plateau   { flex-shrink: 0; }

  /* Compact header on very small screens */
  .mode-indicateur { display: none; }
  .jeu-header { padding: 0 var(--s2); }
}
