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

:root {
  --fond:      #080f1a;
  --surface:   #0f1f35;
  --surface2:  #162840;
  --bordure:   #1e3a5f;
  --texte:     #e2e8f0;
  --texte-dim: #64748b;
  --or:        #f59e0b;
  --or-dark:   #d97706;
  --vert:      #22c55e;
  --vert-dark: #16a34a;
  --rouge:     #ef4444;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--fond);
  color: var(--texte);
  min-height: 100vh;
}

#bg-glow {
  position: fixed; top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 700px; height: 500px;
  background: radial-gradient(ellipse, rgba(245,158,11,0.05) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ===== ÉCRANS ===== */
.ecran { display: none; min-height: 100vh; flex-direction: column; }
.ecran.actif { display: flex; }

/* ===== HEADER MENU ===== */
.enc-header {
  background: rgba(6,13,24,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
  padding: 14px 28px;
  text-align: center;
  position: relative; z-index: 1;
}
.enc-logo {
  font-size: 24px; font-weight: 800;
  display: inline-flex; align-items: center; gap: 10px;
}
.enc-logo span {
  background: linear-gradient(135deg, var(--or), #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.enc-sous-titre { color: var(--texte-dim); font-size: 14px; margin-top: 6px; }

/* ===== MENU CARDS ===== */
.menu-contenu {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  gap: 14px; padding: 24px 24px 80px;
  position: relative; z-index: 1;
}
.menu-card {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 18px;
  padding: 22px 28px;
  width: 100%; max-width: 420px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: all 0.2s;
}
.menu-card:hover {
  border-color: var(--or);
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 20px rgba(245,158,11,0.06);
}
.menu-icon { font-size: 26px; margin-bottom: 4px; }
.menu-label { font-size: 16px; font-weight: 700; }
.menu-desc { color: var(--texte-dim); font-size: 13px; }

/* ===== LOBBY ===== */
#ecran-lobby { align-items: center; justify-content: center; }
.lobby-inner {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 24px;
  padding: 40px 32px;
  width: 380px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
  position: relative; z-index: 1;
  text-align: center;
}
.lobby-icon { font-size: 48px; }
.lobby-inner h2 { font-size: 22px; font-weight: 800; }
.lobby-desc { color: var(--texte-dim); font-size: 14px; }
#zone-code {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px; width: 100%;
}
#qrcode-container {
  display: flex; justify-content: center;
}
#qrcode-container canvas, #qrcode-container img {
  border-radius: 8px; display: block;
}
.code-label { color: var(--texte-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.code-box {
  background: var(--surface2);
  border: 2px solid var(--or);
  border-radius: 12px; padding: 12px 24px;
  font-size: 28px; font-weight: 800;
  letter-spacing: 2px; color: var(--or);
}
#input-code {
  background: var(--surface2);
  border: 2px solid var(--bordure);
  border-radius: 12px; padding: 13px 16px;
  font-size: 18px; font-weight: 700;
  font-family: inherit; color: var(--texte);
  text-transform: uppercase; text-align: center;
  letter-spacing: 1px; width: 100%;
  outline: none; transition: border-color 0.2s;
}
#input-code:focus { border-color: var(--or); }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--bordure);
  border-top-color: var(--or);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-retour-menu {
  background: none; border: none;
  color: var(--texte-dim); font-family: inherit;
  font-size: 13px; cursor: pointer; transition: color 0.2s;
}
.btn-retour-menu:hover { color: var(--texte); }

/* ===== BOUTONS ===== */
.btn-principal {
  background: linear-gradient(135deg, var(--or), var(--or-dark));
  color: #1a0800; border: none;
  padding: 13px 28px; border-radius: 12px;
  font-size: 15px; font-weight: 700;
  font-family: inherit; cursor: pointer; width: 100%;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(245,158,11,0.25);
}
.btn-principal:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.35); }
.btn-principal:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-secondaire {
  background: var(--surface2); border: 1px solid var(--bordure);
  color: var(--texte); text-decoration: none;
  padding: 11px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  width: 100%; text-align: center; display: block;
  transition: all 0.2s;
}
.btn-secondaire:hover { border-color: var(--texte-dim); }
.btn-abandonner {
  background: none; border: 1px solid var(--bordure);
  color: var(--texte-dim); padding: 9px 16px;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; width: 100%;
  transition: all 0.2s;
}
.btn-abandonner:hover { border-color: var(--rouge); color: var(--rouge); }
.cache { display: none !important; }

/* ===== MODALE ABANDON ===== */
#abandon-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8, 15, 26, 0.75);
  backdrop-filter: blur(4px);
  z-index: 900;
  animation: fadeIn 0.15s ease;
}
#abandon-modal {
  display: none;
  position: fixed; inset: 0;
  align-items: center; justify-content: center;
  z-index: 901;
  pointer-events: none;
}
#abandon-inner {
  pointer-events: all;
  background: #0f1f35;
  border: 1px solid #1e3a5f;
  border-radius: 20px;
  padding: 32px 28px;
  width: 320px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: slideUp 0.2s ease;
}
#abandon-icone {
  font-size: 40px;
  margin-bottom: 14px;
}
#abandon-titre {
  font-size: 18px; font-weight: 800;
  color: #e2e8f0; margin-bottom: 10px;
}
#abandon-desc {
  font-size: 13px; color: #64748b;
  line-height: 1.6; margin-bottom: 24px;
}
#abandon-btns {
  display: flex; gap: 10px;
}
#abandon-non {
  flex: 1;
  background: none; border: 1px solid #1e3a5f;
  color: #94a3b8; padding: 11px 16px;
  border-radius: 10px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
#abandon-non:hover { border-color: #3b82f6; color: #e2e8f0; }
#abandon-oui {
  flex: 1;
  background: rgba(239,68,68,0.1); border: 1px solid #ef4444;
  color: #ef4444; padding: 11px 16px;
  border-radius: 10px; font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
#abandon-oui:hover { background: rgba(239,68,68,0.2); }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ===== HUD ===== */
#hud {
  background: rgba(6,13,24,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px; padding: 10px 260px 10px 20px;
  position: sticky; top: 0; z-index: 10;
}
.hud-joueur { display: flex; flex-direction: column; gap: 2px; }
.hud-joueur.droite { align-items: flex-end; }
.hud-pseudo { font-size: 12px; font-weight: 700; color: var(--texte-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.hud-budget { font-size: 22px; font-weight: 800; color: var(--or); }
.hud-centre { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-tour { font-size: 11px; color: var(--texte-dim); font-weight: 600; }

#timer-ring { position: relative; width: 48px; height: 48px; }
#timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 4; }
.ring-fg {
  fill: none; stroke: var(--or); stroke-width: 4;
  stroke-dasharray: 107; stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.ring-fg.urgent { stroke: var(--rouge); }
#timer-texte {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: var(--or);
}
#timer-texte.urgent { color: var(--rouge); }

/* ===== SPLIT LAYOUT ===== */
#jeu-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 70px);
}

#jeu-gauche {
  padding: 20px 20px;
  overflow-y: auto;
  border-right: 1px solid var(--bordure);
  display: flex; flex-direction: column; gap: 14px;
}
#jeu-droite {
  padding: 16px;
  display: flex; flex-direction: column;
  gap: 12px; overflow-y: auto;
  background: rgba(6,13,24,0.4);
}
#terrains-titre {
  font-size: 12px; font-weight: 700;
  color: var(--texte-dim); text-transform: uppercase;
  letter-spacing: 0.8px; text-align: center;
}
#terrains-live {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
}

/* ===== CARTE JOUEUR ===== */
#carte-joueur {
  background: linear-gradient(160deg, var(--surface2), var(--surface));
  border: 1px solid var(--bordure);
  border-radius: 18px;
  padding: 20px 22px;
  position: relative;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  text-align: center;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
#carte-poste-badge {
  display: inline-block;
  background: rgba(245,158,11,0.12);
  border: 1px solid var(--or);
  color: var(--or); border-radius: 8px;
  padding: 3px 10px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 14px;
}
#carte-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: white;
  border: 3px solid rgba(255,255,255,0.1);
}
#carte-nom { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
#carte-details { color: var(--texte-dim); font-size: 12px; line-height: 1.8; margin-bottom: 12px; }
.note-label { font-size: 10px; color: var(--texte-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.note-barre { height: 7px; background: var(--surface); border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
#note-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--or), var(--vert)); transition: width 0.6s ease; }
#note-valeur { font-size: 13px; font-weight: 800; color: var(--or); text-align: right; }

/* ===== ZONE ENCHÈRE ===== */
#zone-enchere {
  display: flex; flex-direction: column;
  gap: 10px;
}
#enchere-label { font-size: 13px; font-weight: 700; color: var(--texte-dim); }
#enchere-input-wrapper { position: relative; }
#input-enchere {
  width: 100%; padding: 13px 48px 13px 16px;
  background: var(--surface); border: 2px solid var(--bordure);
  border-radius: 12px; font-size: 22px; font-weight: 800;
  font-family: inherit; color: var(--texte); outline: none;
  text-align: center; transition: border-color 0.2s, box-shadow 0.2s;
}
#input-enchere:focus { border-color: var(--or); box-shadow: 0 0 0 3px rgba(245,158,11,0.1); }
.input-suffix {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px; font-weight: 700; color: var(--texte-dim);
}
#budget-disponible { font-size: 12px; color: var(--texte-dim); text-align: center; }
#msg-attente { color: var(--or); font-size: 13px; font-weight: 600; text-align: center; }

/* ===== TERRAIN DE FOOT ===== */
.terrain-wrapper {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.terrain-titre {
  font-size: 11px; font-weight: 700;
  color: var(--texte-dim); text-transform: uppercase;
  letter-spacing: 0.5px;
}
.terrain {
  width: 100%;
  aspect-ratio: 2/3;
  background: #1a5522;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  position: relative; overflow: hidden;
}
/* Ligne médiane */
.terrain::before {
  content: '';
  position: absolute; left: 8%; right: 8%; top: 50%; height: 1px;
  background: rgba(255,255,255,0.12);
}
/* Cercle central */
.terrain::after {
  content: '';
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 25%; aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
}
.terrain-joueur {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  align-items: center; gap: 2px; z-index: 2;
}
.terrain-dot {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white;
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  width: 26px; height: 26px; font-size: 8px;
  transition: transform 0.3s;
}
.terrain-dot.acquis  { border-color: #86efac; box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.terrain-dot.en-cours {
  border-color: var(--or);
  box-shadow: 0 0 10px rgba(245,158,11,0.6);
  animation: pulse-or 1.2s ease-in-out infinite;
}
.terrain-dot.futur   { opacity: 0.35; border-color: rgba(255,255,255,0.2); }

@keyframes pulse-or {
  0%, 100% { box-shadow: 0 0 6px rgba(245,158,11,0.4); transform: scale(1); }
  50%       { box-shadow: 0 0 14px rgba(245,158,11,0.8); transform: scale(1.15); }
}
.terrain-nom {
  color: white; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  white-space: nowrap;
  line-height: 1; font-size: 7px;
  max-width: 44px; overflow: hidden; text-overflow: ellipsis;
}
.terrain-nom.futur { opacity: 0.35; }

/* ===== TERRAIN ÉCRAN FIN (grand format) ===== */
#fin-equipes { display: flex; gap: 20px; width: 100%; align-items: flex-start; }
#fin-equipes .terrain-wrapper { flex: 1; min-width: 0; }
#fin-equipes .terrain {
  width: 100%;
  height: 58vh;
  min-height: 400px;
  aspect-ratio: unset;
}
#fin-equipes .terrain-dot { width: 40px; height: 40px; font-size: 11px; }
#fin-equipes .terrain-nom { font-size: 10px; max-width: 64px; font-weight: 700; }
#fin-equipes .terrain-titre { font-size: 13px; margin-bottom: 8px; }

/* ===== OVERLAY RÉSULTAT ===== */
#overlay-resultat {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
#resultat-inner {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 22px; padding: 28px 24px;
  width: 440px; max-width: calc(100vw - 32px);
  animation: popIn 0.3s ease; text-align: center;
}
#resultat-titre { font-size: 18px; font-weight: 800; margin-bottom: 20px; }
#resultat-colonnes {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 10px; align-items: center; margin-bottom: 18px;
}
.res-col {
  background: var(--surface2); border: 1px solid var(--bordure);
  border-radius: 14px; padding: 16px 12px;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px; text-align: center;
}
.res-col.gagnant { border-color: var(--vert); background: rgba(5,46,22,0.5); }
.res-col.consolation { border-color: #334155; }
.res-vs { font-size: 13px; font-weight: 800; color: var(--texte-dim); }

.res-type {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.type-win { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid #16a34a; }
.type-consolation { background: rgba(100,116,139,0.12); color: #94a3b8; border: 1px solid #334155; }

.res-avatar-r {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: white;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.res-joueur-nom { font-size: 14px; font-weight: 800; }
.res-joueur-note {
  font-size: 12px; font-weight: 700;
  background: rgba(245,158,11,0.1);
  color: var(--or); border: 1px solid rgba(245,158,11,0.2);
  border-radius: 6px; padding: 2px 8px;
}
.res-pseudo { font-size: 11px; color: var(--texte-dim); font-weight: 600; margin-top: 2px; }
.res-enchere { font-size: 18px; font-weight: 800; color: var(--or); }
#resultat-suivant { color: var(--texte-dim); font-size: 12px; margin-top: 4px; }

/* ===== FIN DE PARTIE ===== */
#ecran-fin { align-items: center; justify-content: center; padding: 24px; }
#fin-inner {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: 24px; padding: 28px 24px;
  width: calc(100% - 32px); max-width: 1200px;
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  position: relative; z-index: 1;
}
#fin-trophee { font-size: 52px; animation: bounce 0.6s ease; }
@keyframes bounce { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
#fin-titre { font-size: 24px; font-weight: 800; text-align: center; }
#fin-points {
  font-size: 18px; font-weight: 800;
  padding: 8px 24px; border-radius: 40px;
  min-width: 140px; text-align: center;
}
#fin-points.win  { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid var(--vert-dark); }
#fin-points.draw { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid #334155; }
#fin-points.loss { background: rgba(239,68,68,0.08); color: #fca5a5; border: 1px solid #991b1b; }
#fin-scores { display: flex; gap: 28px; }
.fin-score-item { text-align: center; }
.fin-score-pseudo { color: var(--texte-dim); font-size: 12px; margin-bottom: 4px; }
.fin-score-val { color: var(--or); font-size: 26px; font-weight: 800; }
#fin-equipes { display: flex; gap: 20px; width: 100%; }
.fin-actions { display: flex; gap: 12px; width: 100%; }
.fin-actions .btn-principal { flex: 1; }
.fin-actions .btn-secondaire { flex: 1; }

/* ===== RESPONSIVE ===== */
/* Cacher la topbar (pseudo + langue) sur cette page */
#topbar-btns { display: none !important; }

@media (max-width: 768px) {
  #jeu-split { grid-template-columns: 1fr; height: auto; overflow: visible; }
  #jeu-gauche { border-right: none; border-bottom: 1px solid var(--bordure); }
  #terrains-live { grid-template-columns: 1fr 1fr; }
  #fin-equipes { flex-direction: column; }
  /* Terrain fin : hauteur réduite en mobile */
  #fin-equipes .terrain { height: 38vh; min-height: 260px; }
  #fin-equipes .terrain-dot { width: 30px; height: 30px; font-size: 9px; }
  #fin-equipes .terrain-nom { font-size: 8px; max-width: 48px; }
}

@media (max-width: 640px) {
  /* Menu */
  .enc-logo { font-size: 18px; }
  .enc-sous-titre { font-size: 13px; }
  .menu-contenu { grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
  .menu-card { padding: 16px 12px; }
  .menu-icon { font-size: 26px; }
  .menu-label { font-size: 13px; }
  .menu-desc { font-size: 11px; }

  /* Lobby */
  .lobby-inner { padding: 24px 16px; }
  #affichage-code { font-size: 22px; letter-spacing: 4px; }

  /* HUD */
  #hud { padding: 10px 12px; }
  .hud-budget { font-size: 17px; }
  .hud-pseudo { font-size: 10px; }
  #timer-ring { width: 36px; height: 36px; }
  #timer-texte { font-size: 11px; }

  /* Carte joueur */
  #carte-joueur { padding: 14px; }
  #carte-nom { font-size: 18px; }
  #carte-avatar { width: 52px; height: 52px; font-size: 20px; }

  /* Zone enchère */
  #input-enchere { font-size: 16px; }
  #btn-confirmer { padding: 13px; font-size: 15px; }

  /* Résultat overlay */
  #resultat-colonnes { gap: 10px; }
  .res-col { padding: 12px; }

  /* Fin */
  #fin-inner { padding: 16px 12px; gap: 14px; }
  #fin-titre { font-size: 20px; }
  #fin-equipes { flex-direction: column !important; gap: 16px; }
  #fin-equipes .terrain-wrapper { width: 100%; }
  #fin-equipes .terrain { height: 48vh; min-height: 300px; aspect-ratio: unset; width: 100%; }
  #fin-equipes .terrain-dot { width: 34px; height: 34px; font-size: 10px; }
  #fin-equipes .terrain-nom { font-size: 9px; max-width: 56px; }
  #fin-equipes .terrain-titre { font-size: 12px; }
}
