

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

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #e0e0e0;
  padding: 16px;
  --p4-reserve: 300px;
  --p4-gap: 4px;
}

#app {
  position: relative;
  z-index: 1;
  background: rgba(20, 20, 35, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 24px 24px 20px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
}

[hidden] { display: none !important; }


#app .jeu-banner { margin: -24px -24px 16px; }



.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.top-bar .back-link { justify-self: start; }
.top-bar .etiquette { justify-self: end; font-size: 0.8rem; color: #fcd34d; font-weight: 700; }

.back-link {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #fbbf24;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 0;
}
.back-link:hover { color: #fcd34d; }

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(90deg, #fbbf24, #ef4444, #dc2626);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}



.btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 11px 22px;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s, filter 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.1;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35); }
.btn-secondary { background: linear-gradient(135deg, #7c3aed, #6366f1); box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); }
.btn-discret { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); color: #e2e8f0; }
.btn-grand { font-size: 1.05rem; padding: 14px 34px; }



.reglages { max-width: 520px; margin: 0 auto; text-align: left; }
.reglages h2 { font-size: 1.15rem; font-weight: 800; color: #f8fafc; text-align: center; margin-bottom: 14px; }
.reglage { margin-bottom: 16px; }
.reglage-titre { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #94a3b8; margin-bottom: 8px; }

.choix { display: flex; gap: 8px; flex-wrap: wrap; }
.choix button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.choix button[aria-pressed="true"] {
  color: #fff;
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  box-shadow: 0 0 0 1px #ef4444 inset;
}
.choix-niveaux button { flex: 1 0 calc(20% - 8px); font-size: 1rem; font-weight: 800; }
.description-niveau { font-size: 0.85rem; color: #cbd5e1; margin-top: 8px; min-height: 1.3em; }

.bilan {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 16px;
}
.bilan strong { color: #f8fafc; }
.reglages .action { text-align: center; }



.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  gap: 12px;
  min-height: 42px;
}
.info-item { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; font-weight: 700; }
.pastille { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.pastille-1 { background: radial-gradient(circle at 35% 35%, #f87171, #dc2626); }
.pastille-2 { background: radial-gradient(circle at 35% 35%, #fde68a, #f59e0b); }
.tour-1 { color: #f87171; }
.tour-2 { color: #fbbf24; }
.info-chrono { color: #22d3ee; }
.info-bilan { color: #c4b5fd; font-size: 0.8rem; }


.minuteur { height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; margin: 0 auto 6px; overflow: hidden; max-width: 600px; }
.minuteur span { display: block; height: 100%; width: 100%; background: #22d3ee; transform-origin: left; }
.minuteur.urgent span { background: #f87171; }



.p4-plateau {
  width: min(100%, 580px, calc((100vh - var(--p4-reserve)) * 7 / 6.2));
  width: min(100%, 580px, calc((100svh - var(--p4-reserve)) * 7 / 6.2));
  margin: 0 auto;
  position: relative;
}

.p4-fleches {
  display: none;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--p4-gap);
  padding: 0 8px;
  height: 22px;
}
.p4-fleches span { text-align: center; font-size: 1.1rem; line-height: 22px; opacity: 0; color: #ef4444; transition: opacity 0.12s; }
.p4-fleches span.jaune { color: #fbbf24; }
.p4-fleches span.visible { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .p4-fleches { display: grid; }
}

.p4-grille {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--p4-gap);
  background: #1e40af;
  border: 4px solid #1e3a8a;
  border-radius: 12px;
  padding: 8px;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  touch-action: manipulation;
  outline: none;
}
.p4-grille:focus-visible { box-shadow: 0 0 0 3px #fbbf24; }
.p4-grille.actif { cursor: pointer; }

.p4-case {
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0f172a;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
}
.p4-case.apercu-1 { background: rgba(239, 68, 68, 0.28); }
.p4-case.apercu-2 { background: rgba(251, 191, 36, 0.28); }

.p4-jeton {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}
.p4-jeton.c1 { background: radial-gradient(circle at 35% 35%, #f87171, #dc2626, #991b1b); }
.p4-jeton.c2 { background: radial-gradient(circle at 35% 35%, #fde68a, #fbbf24, #d97706); }
.p4-case.dernier .p4-jeton { box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.55); }
.p4-case.gagnante .p4-jeton { animation: p4-gagne 0.7s ease-in-out infinite alternate; }

.p4-jeton.tombe { animation: p4-chute var(--p4-duree, 0.35s) cubic-bezier(0.45, 0, 0.9, 0.6) both; }

@keyframes p4-chute {
  0% { transform: translateY(calc(var(--p4-lignes, 1) * (-100% - var(--p4-gap)) - 12px)); }
  78% { transform: translateY(0); }
  88% { transform: translateY(-9%); }
  100% { transform: translateY(0); }
}
@keyframes p4-gagne {
  from { box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(255, 255, 255, 0.35); transform: scale(1); }
  to { box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(255, 255, 255, 0.95); transform: scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .p4-jeton.tombe, .p4-case.gagnante .p4-jeton { animation: none; }
}

.p4-attente {
  position: absolute;
  inset: 22px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 12px;
  pointer-events: none;
}

.hint { font-size: 0.8rem; color: #94a3b8; margin: 8px 0 4px; min-height: 1.2em; }


.barre-fin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.barre-fin .resume { width: 100%; font-weight: 800; color: #f8fafc; }



.fin-partie {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 100;
  width: min(420px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: rgba(30, 27, 60, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 26px 22px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: p4-apparait 0.25s ease-out;
}
@keyframes p4-apparait { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

.fin-fermer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.fin-fermer:hover { background: rgba(255, 255, 255, 0.16); }

.fin-partie h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 6px; }
.win-text { color: #4ade80; }
.lose-text { color: #f87171; }
.draw-text { color: #fbbf24; }
.fin-message { color: #cbd5e1; font-size: 0.92rem; margin-bottom: 8px; }
.fin-statut { font-size: 0.85rem; color: #94a3b8; margin-bottom: 14px; min-height: 1.2em; }
.fin-statut.ok { color: #86efac; }
.fin-statut.alerte { color: #fca5a5; }
.fin-statut a { color: #fbbf24; }
.fin-boutons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cta-score-msg { color: #fbbf24; font-size: 0.85rem; margin-bottom: 10px; }
.cta-auth-btns { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.partage-score { margin-bottom: 12px; }
.lien-analyse { display: inline-block; margin-top: 12px; font-size: 0.85rem; color: #fbbf24; text-underline-offset: 2px; }
.lien-analyse:hover { color: #fcd34d; }


.confetti { position: fixed; top: -10px; z-index: 200; pointer-events: none; font-size: 1.2rem; animation: p4-confetti 3s ease-in forwards; }
@keyframes p4-confetti { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }



.lobby-msg { color: #94a3b8; margin: 6px 0 12px; font-size: 0.95rem; min-height: 1.3em; }
.lobby-bloc {
  max-width: 380px;
  margin: 0 auto 14px;
  padding: 14px 16px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}
.lobby-titre { font-size: 1rem; font-weight: 800; color: #f8fafc; margin-bottom: 10px; }
.lobby-bloc .lobby-pref, .lobby-bloc .lobby-actions { margin-bottom: 0; }
.lobby-bloc .lobby-pref { margin-bottom: 12px; }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto 12px; }
.lobby-actions .btn { width: 100%; }
.lobby-sep { color: #64748b; font-size: 0.78rem; margin: 6px 0; letter-spacing: 0.1em; }
.lobby-join { display: flex; gap: 8px; max-width: 340px; margin: 0 auto; }
.lobby-join input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  outline: none;
  text-align: center;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.lobby-join input:focus { border-color: rgba(251, 191, 36, 0.6); }
.lobby-join .btn { flex: 0 0 auto; }
.lobby-pref { max-width: 340px; margin: 0 auto 16px; text-align: left; }

.code-display { font-size: 2rem; font-weight: 800; letter-spacing: 0.3em; color: #fcd34d; margin: 10px 0; }
.private-share { color: #94a3b8; font-size: 0.85rem; line-height: 1.5; max-width: 400px; margin: 0 auto 14px; }
.private-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fcd34d;
  border-radius: 50%;
  animation: p4-tourne 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes p4-tourne { to { transform: rotate(360deg); } }

.joueurs { display: flex; gap: 10px; justify-content: center; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.joueur { padding: 6px 14px; border-radius: 10px; font-weight: 700; font-size: 0.88rem; border: 2px solid transparent; opacity: 0.75; }
.joueur-1 { background: rgba(239, 68, 68, 0.8); color: #fff; }
.joueur-2 { background: rgba(251, 191, 36, 0.85); color: #1a1a1a; }
.joueur.actif { opacity: 1; border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, 0.35); }
.score-manches { font-weight: 800; color: #f8fafc; font-size: 0.95rem; }

.bandeau-alerte {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.compte-a-rebours {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.compte-a-rebours span { font-size: 6rem; font-weight: 800; color: #fcd34d; animation: p4-pop 1s ease-out; }
@keyframes p4-pop { 0% { transform: scale(0.4); opacity: 0; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }

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



footer { font-size: 0.78rem; color: #64748b; margin-top: 12px; }
footer a { color: #fbbf24; text-decoration: none; }
footer a:hover { color: #fcd34d; }




@media (max-height: 900px) and (min-aspect-ratio: 3/4) {
  body.p4-en-jeu .jeu-banner { display: none; }
  body.p4-en-jeu { --p4-reserve: 205px; }
  body.p4-en-jeu #app { padding-top: 14px; }
}


@media (min-width: 1180px) and (min-height: 560px) {
  .fin-partie {
    left: calc(50% + 366px);
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(360px, calc(50% - 382px));
    transform: translateY(-50%);
    animation: p4-apparait-cote 0.25s ease-out;
  }
  .fin-boutons .btn { flex: 1 1 auto; }
}
@keyframes p4-apparait-cote { from { opacity: 0; transform: translate(16px, -50%); } to { opacity: 1; transform: translate(0, -50%); } }

.bilan a { color: #fbbf24; }

@media (max-width: 480px) {
  body { padding: 10px; --p4-gap: 3px; }
  #app { padding: 16px 10px 14px; border-radius: 18px; }
  #app .jeu-banner { margin: -16px -10px 12px; }
  h1 { font-size: 1.1rem; }
  .joueur { padding: 5px 10px; font-size: 0.8rem; }
  .p4-grille { padding: 5px; border-width: 3px; }
  .info-bar { padding: 7px 10px; gap: 6px; }
  .info-item { font-size: 0.8rem; }
  .info-bilan { display: none; }
  .compte-a-rebours span { font-size: 4.5rem; }
  .fin-partie { bottom: 10px; padding: 24px 16px 16px; }
}


@media (orientation: landscape) and (max-height: 520px) {
  body { padding: 6px; }
  body.p4-en-jeu .jeu-banner { display: none; }
  body.p4-en-jeu #app { max-width: none; padding: 8px 12px; }
  
  body.p4-en-jeu .zone-jeu {
    display: grid;
    grid-template-columns: auto minmax(170px, 1fr);
    gap: 14px;
    align-items: start;
  }
  body.p4-en-jeu .zone-jeu .colonne-plateau { order: -1; }
  body.p4-en-jeu .zone-jeu .colonne-infos { text-align: left; padding-top: 52px; }
  body.p4-en-jeu .top-bar { grid-template-columns: 1fr; justify-items: start; margin-bottom: 8px; }
  body.p4-en-jeu .top-bar h1 { font-size: 1.05rem; }
  body.p4-en-jeu .info-bar { flex-direction: column; align-items: flex-start; }
  body.p4-en-jeu .info-bilan { display: flex; }
  body.p4-en-jeu .p4-plateau { width: calc((100vh - 24px) * 7 / 6.2); width: calc((100svh - 24px) * 7 / 6.2); }
  body.p4-en-jeu footer { display: none; }
  .fin-partie { bottom: 6px; max-height: calc(100vh - 12px); padding: 18px 16px 14px; }
}
