/*
 * Identité : un salon de jeu feutré. Fond vert très sombre, cartes sur le tapis, accents laiton (Asser)
 * et bleu glacé (Perfweb), titres en serif. Les variables ci-dessous sont partagées par toutes les pages.
 */
:root {
  --fond: #0e1d18;
  --surface: #16302a;
  --surface-survol: #1f423a;
  --texte: #f4ead5;
  --texte-discret: #a7b8a9;
  --accent-perfweb: #6fd3f0;
  --accent-asser: #f2b544;
  --perfweb-rose: #ff4fa0;
  --bordure: #35574b;
  --laiton: #e9b64d;
  --police-titre: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Lumière douce en haut, reflet bleuté en bas, et un semis très discret de symboles de cartes. */
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(233, 182, 77, 0.16), transparent 70%),
    radial-gradient(ellipse 55% 40% at 100% 100%, rgba(111, 211, 240, 0.09), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg fill='%23f4ead5' fill-opacity='0.04' font-size='26' font-family='serif'%3E%3Ctext x='12' y='36'%3E%E2%99%A0%3C/text%3E%3Ctext x='72' y='66'%3E%E2%99%A5%3C/text%3E%3Ctext x='12' y='96'%3E%E2%99%A6%3C/text%3E%3Ctext x='72' y='118'%3E%E2%99%A3%3C/text%3E%3C/g%3E%3C/svg%3E"),
    var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.bandeau {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bordure);
  background: linear-gradient(180deg, rgba(31, 66, 58, 0.9), rgba(14, 29, 24, 0.9));
  box-shadow: 0 1px 0 rgba(233, 182, 77, 0.35), 0 6px 18px rgba(0, 0, 0, 0.35);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.logo { display: inline-flex; align-items: center; gap: 0.5rem; }
.logo img { width: 2rem; height: 2rem; border-radius: 50%; object-fit: contain; }
.logo-perfweb { color: var(--perfweb-rose); }
.logo-asser { color: var(--accent-asser); }

/* Message d'erreur (couleur partagée avec #message.erreur des classements) */
.erreur { color: var(--accent-asser); }
.croix { color: var(--texte-discret); font-weight: 400; }

main {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

h1, h2 {
  font-family: var(--police-titre);
  letter-spacing: 0.01em;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  line-height: 1.1;
  color: var(--texte);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

/* Filet de symboles sous les titres de page. */
h1::after {
  content: "♠ ♥ ♦ ♣";
  display: block;
  margin-top: 0.5rem;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.7em;
  text-indent: 0.7em;
  color: var(--laiton);
  opacity: 0.85;
}

a { color: var(--accent-perfweb); }

/* Un attribut hidden doit toujours cacher : sans cette règle, .bouton { display: inline-block } l'emporte. */
[hidden] { display: none !important; }

.navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.navigation a,
.bouton {
  flex: 1 1 10rem;
  display: inline-block;
  padding: 1rem;
  border: 1px solid var(--bordure);
  border-radius: 0.75rem;
  background: linear-gradient(180deg, var(--surface-survol), var(--surface));
  color: var(--texte);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.bouton {
  flex: none;
  min-height: 44px;
}

.navigation a:hover,
.navigation a:focus-visible,
.bouton:hover,
.bouton:focus-visible {
  background: var(--surface-survol);
  border-color: var(--laiton);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(233, 182, 77, 0.35);
}

.bouton:active,
.navigation a:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--laiton);
  outline-offset: 2px;
}

/* Actions principales : laiton plein, texte sombre (contraste > 9). */
#creer,
#lancer,
#fin-continuer,
#echange-rendre,
form button[type="submit"].bouton {
  border-color: #b9812a;
  background: linear-gradient(180deg, #f6cb70, #dc9b2e);
  color: #2b1c05;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

#creer:hover,
#lancer:hover,
#fin-continuer:hover,
#echange-rendre:hover,
form button[type="submit"].bouton:hover,
#creer:focus-visible,
#lancer:focus-visible,
#fin-continuer:focus-visible,
#echange-rendre:focus-visible,
form button[type="submit"].bouton:focus-visible {
  background: linear-gradient(180deg, #fbd98f, #e8a93d);
  border-color: #fff1c9;
}

.message {
  color: var(--texte-discret);
}

footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--texte-discret);
}

/* Conteneur des tableaux larges : ils défilent dedans, jamais la page. */
.defilement-x {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Accueil : éventail de cartes et tuiles de navigation ---------- */
.eventail {
  position: relative;
  height: 11rem;
  margin: 0 auto 1rem;
}

.eventail .carte-hero {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 5.5rem;
  transform-origin: 50% 130%;
  transform: translateX(-50%) rotate(var(--angle, 0deg));
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55));
  animation: eventail-entree 500ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
  animation-delay: calc(var(--rang, 0) * 70ms);
  transition: transform 0.2s ease-out;
}

.eventail .carte-hero svg {
  display: block;
  width: 100%;
  height: auto;
}

.eventail:hover .carte-hero {
  transform: translateX(-50%) rotate(calc(var(--angle, 0deg) * 1.25));
}

@keyframes eventail-entree {
  from { opacity: 0; transform: translateX(-50%) translateY(2rem) rotate(0deg); }
  to { opacity: 1; transform: translateX(-50%) rotate(var(--angle, 0deg)); }
}

@media (prefers-reduced-motion: reduce) {
  .eventail .carte-hero {
    animation: none;
    transition: none;
  }
}

.accroche {
  margin: -0.5rem auto 2rem;
  max-width: 28rem;
  color: var(--texte-discret);
  font-size: 1.05rem;
}

.accroche strong { color: var(--texte); }

/* Tuiles de l'accueil : un symbole de carte devant chaque entrée. */
.navigation a::before {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--laiton);
}

.navigation a:nth-child(5n + 1)::before { content: "♠"; }
.navigation a:nth-child(5n + 2)::before { content: "♥"; color: #f0766b; }
.navigation a:nth-child(5n + 3)::before { content: "♦"; color: #f0766b; }
.navigation a:nth-child(5n + 4)::before { content: "♣"; }
.navigation a:nth-child(5n + 5)::before { content: "♠"; }

/* ---------- Session en ligne : badge, bandeau, échange, fin de partie ---------- */
.badge-partie {
  display: inline-block;
  margin: 0.5rem 0;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--accent-perfweb);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-perfweb);
  font-weight: 700;
}

.bandeau-fige {
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent-asser);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--accent-asser);
  font-weight: 600;
}

.echange-consigne {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.echange-joueurs {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
  color: var(--texte-discret);
}

.echange-recap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.5rem 0;
}

.echange-titre {
  margin: 0 0 0.25rem;
  color: var(--texte-discret);
}

.echange-cartes {
  display: flex;
  gap: 0.25rem;
}

.carte-mini {
  display: block;
  width: 3rem;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.carte-mini svg,
.carte-echange svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Panneaux de l'échange et de fin de partie : même feutre que la table. */
.echange,
.fin-partie {
  padding: 1.25rem;
  border: 1px solid var(--bordure);
  border-top: 3px solid var(--laiton);
  border-radius: 1rem;
  background: linear-gradient(180deg, var(--surface-survol), var(--surface));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.echange h2,
.fin-partie h2 {
  margin-top: 0;
  color: var(--laiton);
}

.fin-ligne:first-child .fin-rang::before {
  content: "👑 ";
}

.echange-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  padding: 1.25rem 0 0.5rem;
}

.carte-echange {
  flex: 0 0 4rem;
  width: 4rem;
  padding: 0;
  border: 0;
  border-radius: 8%;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.echange-main.verrouillee .carte-echange {
  cursor: default;
}

.carte-echange.recue {
  filter: drop-shadow(0 0 6px var(--accent-asser));
}

.echange-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.echange-actions .bouton:disabled {
  cursor: not-allowed;
  color: var(--texte-discret);
}

.fin-resultats {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.fin-ligne {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--bordure);
}

.fin-rang {
  min-width: 7rem;
  color: var(--texte-discret);
}

.fin-special {
  padding: 0 0.5rem;
  border: 1px solid var(--accent-asser);
  border-radius: 999px;
  color: var(--accent-asser);
  font-size: 0.9rem;
}

.fin-points {
  margin-left: auto;
  font-weight: 700;
}

/* ---------- Mobile portrait (dès 360 px) ---------- */
@media (max-width: 599px) {
  main {
    padding: 1.25rem 0.75rem;
  }

  .navigation a,
  .bouton {
    flex-basis: 100%;
    min-height: 44px;
  }

  img,
  svg,
  video {
    max-width: 100%;
    height: auto;
  }
}

/* ---------- Ordinateur ---------- */
@media (min-width: 900px) {
  main {
    max-width: 56rem;
    padding: 3rem 2rem;
  }
}

/* ---------- Chat vocal (F10) ---------- */
.vocal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.vocal .message { margin: 0; }

.vocal .bouton[aria-pressed="true"] {
  border-color: var(--accent-asser);
  color: var(--accent-asser);
}

/* Joueur qui parle : contour discret sur sa ligne de siège, pulsation sur son bonhomme à la table. */
.siege.parle {
  border-color: var(--accent-perfweb);
  box-shadow: 0 0 0 2px var(--accent-perfweb);
}

.table-jeu .bonhomme.parle {
  outline: 2px solid var(--accent-perfweb);
  outline-offset: 2px;
  border-radius: 0.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  .table-jeu .bonhomme.parle { animation: vocal-pulse 600ms ease-in-out infinite alternate; }
}

@keyframes vocal-pulse {
  from { box-shadow: 0 0 0 0 rgba(233, 182, 77, 0.55); }
  to { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0); }
}

.audio-indisponible {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--accent-asser);
}
