/* Styles spécifiques au Tiercé, sans toucher au body ni aux titres du site */
.ti-root,
.ti-root *,
#ti-cotes * {
  font-family: var(--mg-police, "Outfit", system-ui, sans-serif);
  box-sizing: border-box;
}

.ti-root [hidden] {
  display: none !important;
}

/* Barre commune (css/games.css) aux couleurs de l'hippodrome */
.ti-root {
  --mg-jeu-largeur: 1204px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(226, 185, 59, 0.25), transparent 55%),
    linear-gradient(120deg, #133a20, #2f7440);
  --mgb-accent: #e2b93b;
  --mgb-titre: linear-gradient(100deg, #ffffff, #e2b93b);
  --mg-fs-fond: radial-gradient(circle at 50% 40%, #245c36, #0b1a10);
  --mg-bulle-fond: #133a20;
}

.mg-stat b.ti-cagnotte {
  color: #ffd166;
}

/* ---------- Paddock ---------- */
.ti-paddock {
  width: 100%;
  margin: 0 auto 32px auto;
  padding: 20px 24px 24px 24px;
  background:
    repeating-linear-gradient(90deg, #ffffff08 0 60px, transparent 60px 120px),
    linear-gradient(180deg, #2f7440, #1e5230);
  border-radius: 18px;
  box-shadow: 0 8px 28px #0003;
  color: #fff;
}

/* En-tête : nom de la course à gauche, compteurs et outils à droite */
.ti-entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.ti-course {
  display: flex;
  flex-direction: column;
}

.ti-root .ti-prix {
  margin: 0;
  font-family: "Madimi One", var(--mg-police, sans-serif);
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 2px 0 #0003;
}

.ti-distance {
  color: #cfe6d3;
  font-size: 1rem;
}

.ti-label {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b9d6bf;
}

.ti-avis {
  margin: 10px auto 0 auto;
  max-width: 560px;
  padding: 6px 14px;
  border-radius: 10px;
  background: #fff3c4;
  color: #5b4300;
  text-align: center;
  font-weight: 600;
}

.ti-consigne {
  margin: 14px 0 16px 0;
  color: #eaf5ec;
  font-size: 1.05rem;
}

/* ---------- Fiches des chevaux ---------- */
.ti-chevaux {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.ti-root .ti-cheval {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px 14px 14px;
  background: #fbfaf5;
  border: 2px solid transparent;
  border-top: 5px solid var(--c1, #999);
  border-radius: 13px;
  box-shadow: 0 2px 6px #0003;
  color: #1f2a22;
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}

.ti-root .ti-cheval:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px #0004;
}

.ti-root .ti-cheval:focus-visible {
  outline: 3px solid #e2b93b;
  outline-offset: 2px;
}

.ti-root .ti-cheval.ti-choisi {
  border-color: #e2b93b;
  box-shadow:
    0 0 0 3px #e2b93b66,
    0 6px 16px #0005;
  background: #fffbea;
}

.ti-root .ti-cheval.ti-tierce-choix {
  border-color: #7cc48a;
}

.ti-tete {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ti-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 2px #0002;
}

.ti-casaque {
  flex: none;
  width: 44px;
  height: 44px;
}

.ti-ident {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.ti-nom {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.15;
}

.ti-infos {
  margin-top: -4px;
  font-size: 0.8rem;
  color: #66736a;
}

.ti-cote {
  flex: none;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e5230;
  line-height: 1.05;
}

.ti-cote small {
  font-size: 0.64rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a857d;
}

/* Trois jauges côte à côte ; valeur exacte au survol */
.ti-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.ti-barre {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.74rem;
  color: #56625a;
}

.ti-barre i {
  font-style: normal;
}

.ti-barre b {
  height: 7px;
  border-radius: 3px;
  background: #e3e6df;
  overflow: hidden;
}

.ti-barre s {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3d9b56, #9ed36a);
  text-decoration: none;
}

.ti-barre::after {
  content: attr(data-info);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 5px 9px;
  border-radius: 7px;
  background: #16261b;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 10px #0005;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.ti-barre:first-child::after {
  left: -4px;
  transform: none;
}

.ti-barre:last-child::after {
  left: auto;
  right: -4px;
  transform: none;
}

.ti-barre:hover::after {
  opacity: 1;
}

.ti-badge {
  position: absolute;
  top: -11px;
  right: 10px;
  padding: 1px 9px;
  border-radius: 20px;
  background: #e2b93b;
  color: #3b2c05;
  font-size: 0.7rem;
  font-weight: 800;
  box-shadow: 0 2px 4px #0003;
}

.ti-tierce-choix .ti-badge {
  background: #7cc48a;
  color: #10301a;
}

/* ---------- Pari (une seule bande) ---------- */
.ti-pari {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 28px;
  margin-top: 20px;
  padding: 16px 22px;
  background: #0003;
  border-radius: 14px;
}

.ti-pari-bloc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ti-types {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.ti-root .ti-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 108px;
  padding: 8px 12px;
  border-radius: 11px;
  background: #ffffff1a;
  border: 2px solid #ffffff33;
  color: #fff;
  line-height: 1.2;
  cursor: pointer;
}

.ti-root .ti-type b {
  color: inherit;
}

.ti-root .ti-type small {
  font-size: 0.72rem;
  color: #cfe6d3;
}

.ti-root .ti-type:hover {
  background: #ffffff2e;
}

.ti-root .ti-type.ti-actif {
  background: #e2b93b;
  border-color: #e2b93b;
  color: #3b2c05;
}

.ti-root .ti-type.ti-actif small {
  color: #5b4300;
}

.ti-tierce {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ti-tierce b {
  color: #e2b93b;
}

.ti-root .ti-select {
  width: 170px;
  margin: 0;
  padding: 5px 6px;
  font-size: 0.92rem;
  border-radius: 7px;
  border: 0;
  color: #1f2a22;
  background: #fbfaf5;
}

.ti-mise {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ti-root .ti-rond {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff26;
  border: 2px solid #ffffff4d;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.ti-root .ti-rond:disabled {
  opacity: 0.35;
  cursor: default;
}

.ti-mise-valeur {
  min-width: 110px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ti-jetons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.ti-root .ti-jeton {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #b3261e 0 52%, transparent 53%),
    repeating-conic-gradient(#fff 0 20deg, #b3261e 20deg 40deg);
  border: 2px solid #ffffffaa;
  color: #fff;
  font-weight: 800;
  font-size: 0.76rem;
  cursor: pointer;
  box-shadow: 0 2px 4px #0004;
  transition: transform 0.12s;
}

.ti-root .ti-jeton:hover {
  transform: translateY(-2px) rotate(8deg);
}

.ti-root .ti-jeton.ti-tapis {
  width: auto;
  padding: 0 10px;
  border-radius: 20px;
  background: #1f2937;
}

.ti-valider {
  flex: 1 1 260px;
  max-width: 380px;
}

.ti-resume {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #fff3c4;
}

/* Liens-boutons des règles */
.ti-lien {
  padding: 0;
  background: none;
  border: 0;
  color: #1d4ed8;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

/* Tableau d'exemples de la fenêtre des cotes */
.ti-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 12px 0;
  font-size: 0.9rem;
}

.ti-table th,
.ti-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #0001;
  text-align: left;
}

.ti-table th {
  font-size: 0.78rem;
  color: #56625a;
}

.ti-table td:first-child {
  font-weight: 800;
  color: #1e5230;
}

/* ---------- Piste ---------- */
.ti-canvas-container {
  background: linear-gradient(180deg, #245c36, #133a21);
  border-radius: 18px;
  box-shadow:
    0 6px 24px #0007,
    inset 0 0 0 2px #ffffff10;
  padding: 12px;
  margin: 12px auto 32px auto;
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  max-width: calc(100% - 24px);
}

#ti-canvas {
  display: block;
  width: 720px;
  max-width: 100%;
  height: auto;
  background: #4d8a3c;
  border-radius: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Plein écran ---------- */
.ti-root.mg-fs {
  align-items: center;
}

.ti-root.mg-fs .ti-paddock {
  width: 100%;
  margin: auto;
}

/* Plein écran : toujours 4 chevaux par ligne (2 sur un écran étroit) */
.ti-root.mg-fs .ti-chevaux {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .ti-root.mg-fs .ti-chevaux {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ti-root.mg-fs .ti-piste {
  margin: auto 0;
}

.ti-root.mg-fs .ti-canvas-container {
  padding: 0;
  margin: 0;
  background: none;
  box-shadow: none;
  max-width: none;
}

.ti-root.mg-fs #ti-canvas {
  max-width: none;
  box-shadow: 0 0 40px #000c;
}

@media (max-width: 560px) {
  .ti-paddock {
    padding: 10px;
    border-radius: 14px;
  }
  .ti-entete {
    justify-content: center;
    text-align: center;
  }
  .ti-course {
    align-items: center;
    width: 100%;
  }
  
  .ti-chevaux {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .ti-valider {
    max-width: none;
  }
  .ti-canvas-container {
    padding: 6px;
    max-width: 100%;
  }
}

/* Bouton de départ : un peu plus présent que le bouton standard, sans excès */
.ti-root #ti-partir {
  font-size: 1.05rem;
  padding: 8px 26px;
}

/* Fenêtre de confirmation « Nouvelle partie » : plus étroite que les règles */
.mg-regles.ti-confirm {
  max-width: 440px;
}

.ti-confirm .mg-regles-corps {
  display: block;
  columns: auto;
}

.ti-confirm .mg-regles-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
