/* style.css — Interface responsive mobile (portrait & paysage) */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --a: #2e86ff;      /* équipe A */
  --b: #ff4d4d;      /* équipe B */
  --grass: #2f8f46;
  --bg: #0d1b12;
  --panel: rgba(20, 32, 24, 0.92);
  --accent: #ffd23f;
}
html, body {
  height: 100%; width: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #14331f, var(--bg));
  color: #f2f5f2; overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

/* ---------------- Écrans ---------------- */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; }
.screen.active { display: flex; }

.panel {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px; padding: 26px 22px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); backdrop-filter: blur(8px);
}
.panel.wide { max-width: 560px; }

.logo { font-size: 30px; text-align: center; margin-bottom: 4px; }
.logo span { color: var(--accent); }
.subtitle { text-align: center; opacity: 0.7; margin-bottom: 22px; font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; margin-bottom: 6px; }
input, select {
  width: 100%; padding: 13px 14px; font-size: 16px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.14); background: rgba(0,0,0,0.35);
  color: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }

.btn {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 12px; background: #33463a; color: #fff;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, #38b24a, #1f7a33); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.btn.ghost { background: rgba(255,255,255,0.08); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.or { text-align: center; opacity: 0.5; margin: 14px 0; font-size: 13px; }
.join-row { display: flex; gap: 10px; }
.join-row .code-input { flex: 1; }
.join-row .btn { width: auto; padding: 13px 18px; }
.error { color: #ff8080; text-align: center; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------------- Lobby ---------------- */
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.code-badge { background: var(--accent); color: #1a1a1a; padding: 3px 12px; border-radius: 8px; font-weight: 800; letter-spacing: 3px; }
.teams { display: flex; gap: 14px; margin-bottom: 18px; }
.team-col { flex: 1; background: rgba(0,0,0,0.25); border-radius: 12px; padding: 12px; }
.team-col h3 { font-size: 15px; margin-bottom: 10px; text-align: center; }
.team-a { color: var(--a); } .team-b { color: var(--b); }
.player-list { list-style: none; min-height: 60px; margin-bottom: 10px; }
.player-list li { font-size: 14px; padding: 6px 8px; border-radius: 7px; background: rgba(255,255,255,0.05); margin-bottom: 5px; display: flex; justify-content: space-between; }
.player-list li .tag { font-size: 11px; opacity: 0.7; }
.player-list li.ready { border-left: 3px solid #38b24a; }
.choose-team { padding: 9px; font-size: 13px; }
button.choose-team.team-a { background: rgba(46,134,255,0.25); }
button.choose-team.team-b { background: rgba(255,77,77,0.25); }
.host-controls { display: flex; gap: 12px; margin-bottom: 14px; }
.host-controls .field { flex: 1; margin-bottom: 0; }
.config-readonly { text-align: center; opacity: 0.75; font-size: 14px; margin-bottom: 14px; min-height: 20px; }
.lobby-actions { display: flex; gap: 12px; }
.hint { font-size: 12px; opacity: 0.55; text-align: center; margin-top: 14px; }

/* ---------------- Jeu ---------------- */
#screen-game { padding: 0; display: none; }
#screen-game.active { display: block; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #123; }

.hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 14px; pointer-events: none; }
.scoreboard {
  background: rgba(0,0,0,0.55); border-radius: 10px; padding: 7px 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; font-size: 16px;
}
.sb-team { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.sb-team.team-a { background: var(--a); } .sb-team.team-b { background: var(--b); }
.hud-time { margin-left: 6px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.hud-ctrl { background: rgba(0,0,0,0.55); border-radius: 10px; padding: 7px 12px; font-size: 13px; }

.hud-message {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%) scale(0.9);
  font-size: 32px; font-weight: 800; text-align: center; color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,0.8);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; padding: 0 20px;
}
.hud-message.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

.switch-feedback {
  position: absolute; top: 58%; left: 50%; transform: translateX(-50%);
  color: #ff8080; font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none;
  background: rgba(0,0,0,0.5); padding: 6px 14px; border-radius: 8px;
}
.switch-feedback.show { animation: flash 0.6s; }
@keyframes flash { 0%,100% { opacity: 0; } 25%,75% { opacity: 1; } }

/* Joystick */
.joystick {
  position: absolute; bottom: 26px; left: 26px; width: 130px; height: 130px;
  border-radius: 50%; background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.18);
  touch-action: none;
}
.joystick-knob {
  position: absolute; top: 50%; left: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; background: rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.7);
}

/* Boutons d'action */
.action-buttons {
  position: absolute; bottom: 26px; right: 20px;
  display: grid; grid-template-columns: repeat(2, 68px); gap: 10px; justify-items: end;
}
.act-btn {
  width: 68px; height: 68px; border-radius: 50%; border: none; color: #fff;
  font-weight: 700; font-size: 13px; cursor: pointer; touch-action: none;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3); transition: transform .05s;
}
.act-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.3); }
.act-btn.pass { background: #2f9e57; }
.act-btn.long { background: #c97b1e; }
.act-btn.shoot { background: #d23b3b; width: 78px; height: 78px; font-size: 15px; }
.act-btn.tackle { background: #555; }
.act-btn.gk-dive { background: #d2a11f; }
/* Tireur de corner : seuls Passe / Longue restent utiles (doser + viser à la
   flèche) — Tir/Tacle masqués pour ne pas prêter à confusion. */
.act-btn.corner-hidden { display: none; }

.power-gauge {
  position: absolute; height: 6px; border-radius: 3px; background: rgba(0,0,0,0.5); overflow: hidden;
}
.power-gauge { bottom: 165px; right: 20px; width: 146px; opacity: 0; transition: opacity .1s; }
.power-gauge.show { opacity: 1; }
.power-gauge i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg,#ffd23f,#ff4d4d); }

/* HUD de frappe chronométrée : compte à rebours + astuce.
   (La flèche de visée balaie en 3D, au sol devant le tireur.) */
.shot-target {
  position: absolute; top: 13%; left: 50%; transform: translateX(-50%);
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 6;
}
.shot-target.show { opacity: 1; }
/* Compte à rebours (3.0 -> 0.0) */
.st-count {
  text-align: center; font-size: 30px; font-weight: 800;
  color: #ffd23f; text-shadow: 0 2px 6px #000; font-variant-numeric: tabular-nums;
}
.st-hint { margin-top: 4px; text-align: center; font-size: 12px; color: #fff; text-shadow: 0 1px 3px #000; }

/* Fin de match */
.end-score { font-size: 48px; font-weight: 800; text-align: center; margin: 18px 0; }
.end-result { text-align: center; font-size: 20px; margin-bottom: 22px; color: var(--accent); }

/* Paysage : ajuste tailles */
@media (orientation: landscape) and (max-height: 500px) {
  .joystick { width: 110px; height: 110px; bottom: 16px; left: 18px; }
  .joystick-knob { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
  .action-buttons { bottom: 16px; right: 16px; }
  .act-btn { width: 58px; height: 58px; font-size: 12px; }
  .act-btn.shoot { width: 66px; height: 66px; }
  .hud-message { font-size: 26px; }
}

/* ===================== Chargement du personnage 3D ===================== */
.lobby-loading { text-align: center; font-size: 13px; opacity: 0.8; margin-bottom: 8px; }
.load-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(10, 18, 28, 0.9); z-index: 50;
}
.load-overlay.show { display: flex; }
.load-box { display: flex; flex-direction: column; align-items: center; gap: 14px; color: #fff; font-size: 15px; }
.load-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.25); border-top-color: #ffd23f;
  animation: load-spin 0.9s linear infinite;
}
@keyframes load-spin { to { transform: rotate(360deg); } }
