/*
 * Petits Chevaux — pages de jeu (solo, défi du jour, multijoueur).
 *
 * Perf : pas de backdrop-filter sur un conteneur permanent, pas de box-shadow
 * animé en boucle, pas de position: fixed décoratif — ces trois-là écroulent le
 * rendu sur Firefox. Les animations passent par transform et opacity.
 */

:root {
  --pc-bois: #7a3b12;
  --pc-bois-clair: #c98a4b;
  --pc-creme: #f6e7c8;
  --pc-or: #f0b429;
  --pc-fond: #1b1209;
  --pc-carte: #2b1d10;
  --pc-bordure: #4b341d;
  --pc-texte: #f7ecd9;
  --pc-texte-doux: #c3ab8c;
  --pc-rouge: #d94141;
  --pc-jaune: #e5ac1e;
  --pc-vert: #2f9e5e;
  --pc-bleu: #3f72d9;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(160deg, #1b1209 0%, #2a1a0c 45%, #140f09 100%);
  color: var(--pc-texte);
}

#app {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  color: var(--pc-texte);
}

.cache { display: none !important; }

/* ================= ÉCRAN DE RÉGLAGES ================= */

#setup h1,
#vue-lobby h1 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin: 18px 0 6px;
  color: var(--pc-texte);
}

.setup-intro {
  color: var(--pc-texte-doux);
  margin: 0 0 26px;
  line-height: 1.6;
}

.setup-bloc { margin-bottom: 26px; }

.setup-bloc h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pc-or);
  margin: 0 0 12px;
}

.choix-groupe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.choix-compact { grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); }

.choix { display: block; cursor: pointer; position: relative; }
.choix input { position: absolute; opacity: 0; pointer-events: none; }

.choix-corps {
  display: block;
  /* Cible tactile large : les réglages doivent rester confortables au doigt. */
  min-height: 62px;
  padding: 14px 16px;
  border: 2px solid var(--pc-bordure);
  border-radius: 12px;
  background: var(--pc-carte);
  transition: border-color 0.15s, background 0.15s;
}

.choix-corps strong { display: block; color: var(--pc-texte); font-size: 1.05rem; margin-bottom: 3px; }
.choix-corps small { display: block; color: var(--pc-texte-doux); font-size: 0.82rem; line-height: 1.45; }

.choix:hover .choix-corps { border-color: var(--pc-or); }
.choix input:focus-visible + .choix-corps { outline: 2px solid var(--pc-or); outline-offset: 2px; }
.choix input:checked + .choix-corps { border-color: var(--pc-or); background: linear-gradient(160deg, #4a2c14, #2b1d10); }
.choix input:checked + .choix-corps strong { color: var(--pc-or); }

.setup-aide { border-top: 1px solid var(--pc-bordure); padding-top: 22px; }
.setup-aide h2 { font-size: 1rem; color: var(--pc-or); margin: 0 0 12px; }
.setup-aide ul { margin: 0; padding-left: 20px; color: var(--pc-texte-doux); line-height: 1.7; }
.setup-aide li { margin-bottom: 8px; }
.setup-aide strong { color: var(--pc-texte); }

.defi-carte {
  background: var(--pc-carte);
  border: 1px solid var(--pc-bordure);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 22px;
}
.defi-carte h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--pc-or); }
.defi-carte p { margin: 0 0 10px; color: var(--pc-texte-doux); line-height: 1.65; }
.defi-carte p:last-child { margin-bottom: 0; }

/* ================= BOUTONS ================= */

/* Base commune aux <button> comme aux <a class="btn"> : sans elle les liens
   restent violets (a:visited) et les boutons gris. On cible donc aussi :visited,
   sinon a:visited (0,1,1) l'emporterait sur .btn-outline (0,1,0). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--pc-bois);
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

a.btn, a.btn:visited { color: #fff; }
.btn:hover { background: #93491a; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-outline { background: transparent; border-color: var(--pc-bordure); color: var(--pc-texte); }
a.btn-outline, a.btn-outline:visited { color: var(--pc-texte); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--pc-or); }

.btn-lancer {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 8px auto 30px;
  font-size: 1.1rem;
  padding: 15px 24px;
  background: linear-gradient(135deg, var(--pc-bois), var(--pc-or));
  color: #2b1607;
}
.btn-lancer:hover { background: linear-gradient(135deg, #93491a, #f7c95a); }

/* ================= LA SCÈNE DE JEU ================= */

.pc-scene {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 250px;
  gap: 18px;
  align-items: start;
}

.pc-plateau-zone {
  display: flex;
  justify-content: center;
  min-width: 0;
}

#pc-canvas {
  display: block;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
}

.pc-panneau {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pc-joueurs { display: flex; flex-direction: column; gap: 7px; }

.pc-joueur {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-items: center;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--pc-bordure);
  background: var(--pc-carte);
  transition: border-color 0.2s, background 0.2s;
}

.pc-pastille {
  grid-row: 1 / 3;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
}

.pc-nom { font-weight: 700; font-size: 0.92rem; color: var(--pc-texte); }
.pc-stat { font-size: 0.74rem; color: var(--pc-texte-doux); font-variant-numeric: tabular-nums; }

.pc-joueur.actif { border-color: var(--pc-or); background: linear-gradient(120deg, #45301a, #2b1d10); }
.pc-joueur.fini { opacity: 0.55; }

.pc-rouge .pc-pastille { background: var(--pc-rouge); }
.pc-jaune .pc-pastille { background: var(--pc-jaune); }
.pc-vert .pc-pastille  { background: var(--pc-vert); }
.pc-bleu .pc-pastille  { background: var(--pc-bleu); }

.pc-tour {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--pc-or);
  min-height: 1.3em;
}

/* ================= LE DÉ ================= */

.pc-de-bloc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--pc-bordure);
  background: var(--pc-carte);
}

/*
 * Le dé est dessiné en CSS : chaque point est un dégradé radial posé à sa place.
 * Aucune image à charger, et il reste net à toutes les tailles.
 */
.pc-de {
  width: 66px;
  height: 66px;
  border-radius: 14px;
  background-color: #fdf4e0;
  border: 2px solid #a8722c;
  box-shadow: inset 0 -4px 10px rgba(122, 59, 18, 0.25);
  background-repeat: no-repeat;
  background-size: 24% 24%;
}

.pc-de[data-face=""] { background-image: none; }

.pc-de[data-face="1"] {
  background-image: radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 50% 50%;
}
.pc-de[data-face="2"] {
  background-image:
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 22% 22%, 78% 78%;
}
.pc-de[data-face="3"] {
  background-image:
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 22% 22%, 50% 50%, 78% 78%;
}
.pc-de[data-face="4"] {
  background-image:
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 22% 22%, 78% 22%, 22% 78%, 78% 78%;
}
.pc-de[data-face="5"] {
  background-image:
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 22% 22%, 78% 22%, 50% 50%, 22% 78%, 78% 78%;
}
.pc-de[data-face="6"] {
  background-image:
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%),
    radial-gradient(circle, #3a2410 45%, transparent 46%);
  background-position: 22% 20%, 78% 20%, 22% 50%, 78% 50%, 22% 80%, 78% 80%;
}

.pc-de.roule { animation: pc-de-roule 0.48s ease-in-out; }

@keyframes pc-de-roule {
  0%   { transform: rotate(0deg) scale(1); }
  35%  { transform: rotate(140deg) scale(1.14); }
  70%  { transform: rotate(280deg) scale(0.94); }
  100% { transform: rotate(360deg) scale(1); }
}

.pc-chrono {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--pc-texte-doux);
  font-variant-numeric: tabular-nums;
}
.pc-chrono.urgent { color: #f78b8b; }

#btn-de {
  width: 100%;
  font-size: 1rem;
  background: linear-gradient(135deg, #6d3510, #a8501f);
}
#btn-de.pret { background: linear-gradient(135deg, var(--pc-bois), var(--pc-or)); color: #2b1607; }
#btn-de.pret:hover { background: linear-gradient(135deg, #93491a, #f7c95a); }

/* ================= JOURNAL ================= */

.pc-aide-clavier {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--pc-texte-doux);
  text-align: center;
}

#journal {
  max-height: 148px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--pc-bordure);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--pc-texte-doux);
}
#journal p { margin: 0 0 5px; }

.pc-actions-jeu { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-actions-jeu .btn { flex: 1 1 auto; font-size: 0.85rem; padding: 10px 14px; }

/* ================= OVERLAY DE FIN ================= */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(12, 8, 4, 0.82);
  padding: 20px;
  overflow-y: auto;
}
.overlay.visible { display: flex; align-items: center; justify-content: center; }

.overlay-carte {
  width: min(460px, 100%);
  background: linear-gradient(160deg, #33220f, #201409);
  border: 1px solid var(--pc-bordure);
  border-radius: 18px;
  padding: 26px 24px;
  text-align: center;
}
.overlay-carte h2 { margin: 0 0 10px; font-size: 1.5rem; color: var(--pc-or); }
.overlay-carte > p { margin: 0 0 18px; color: var(--pc-texte-doux); line-height: 1.6; }

.fin-stats { margin: 0 0 18px; }
.stat-ligne {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.9rem;
  color: var(--pc-texte-doux);
}
.stat-ligne strong { color: var(--pc-texte); font-variant-numeric: tabular-nums; }

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

/* ================= LOBBY MULTIJOUEUR ================= */

.lobby-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 24px; }
.lobby-actions .btn { flex: 1 1 200px; }

.lobby-rejoindre { border-top: 1px solid var(--pc-bordure); padding-top: 20px; }
.lobby-rejoindre label { display: block; margin-bottom: 8px; color: var(--pc-texte-doux); font-size: 0.9rem; }
.controle-ligne { display: flex; gap: 10px; }

.controle-ligne input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--pc-bordure);
  background: var(--pc-carte);
  color: var(--pc-texte);
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.lobby-erreur { color: #f9a8a8; min-height: 1.3em; margin: 10px 0 0; font-size: 0.88rem; }
.note-invite { color: var(--pc-texte-doux); font-size: 0.85rem; line-height: 1.6; }

.attente-anim { display: flex; gap: 8px; justify-content: center; margin: 22px 0; }
.attente-anim span {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--pc-or);
  animation: pc-rebond 1s ease-in-out infinite;
}
.attente-anim span:nth-child(2) { animation-delay: 0.15s; }
.attente-anim span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pc-rebond {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-9px); opacity: 1; }
}

.salon-code-bloc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0 20px;
}
.salon-code-bloc strong {
  font-size: 2.1rem;
  letter-spacing: 0.3em;
  color: var(--pc-or);
  font-variant-numeric: tabular-nums;
}

.salon-joueurs { list-style: none; padding: 0; margin: 0 0 20px; }
.salon-joueurs li {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--pc-bordure);
  background: var(--pc-carte);
  margin-bottom: 7px;
  font-size: 0.92rem;
}

.salon-options { margin: 0 0 18px; }
.salon-options label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--pc-texte-doux);
  font-size: 0.9rem;
  cursor: pointer;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 780px) {
  .pc-scene { grid-template-columns: 1fr; }
  .pc-panneau { order: 2; }
  .pc-plateau-zone { order: 1; }
  #app { padding: 22px 14px 34px; }
  .pc-joueurs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
  #journal { max-height: 110px; }
}

@media (max-width: 420px) {
  .pc-de { width: 56px; height: 56px; }
  .salon-code-bloc strong { font-size: 1.7rem; }
}

/*
 * Les deux blocs partagés en gouttière sont visibles sur l'écran de réglages et
 * en fin de partie, masqués pendant la partie : ils tirent l'œil pile quand il
 * faut le garder sur le plateau.
 */
body.petits-chevaux-en-jeu .bandeau-infos-wrap,
body.petits-chevaux-en-jeu .bloc-jeux-une-wrap {
  display: none !important;
}

/*
 * Ces blocs se positionnent avec left: calc((100vw - 800px) / 4), c'est-à-dire
 * pour un contenu de 800 px. Le plateau et son panneau en font 820 : sous
 * 1300 px la gouttière n'est plus assez large et ils mordraient sur le jeu.
 */
@media (max-width: 1300px) {
  .bandeau-infos-wrap, .bloc-jeux-une-wrap { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .pc-de.roule { animation: none; }
  .attente-anim span { animation: none; }
}
