/* ============================================================
   base.css — variables, reset léger, layout général, boutons.
   Styles partagés par TOUTE l'application.
   Pour le look d'un jeu précis -> son propre fichier .css.
   ============================================================ */

:root {
  --bg:        #0f1226;
  --bg-card:   #1a1f3d;
  --bg-soft:   #232a52;
  --line:      #2f3768;
  --text:      #eef1ff;
  --text-soft: #b7bdee;
  --accent:    #6c7bff;
  --accent-2:  #ffce5c;
  --good:      #4ad991;
  --bad:       #ff6b8a;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --font:      "Segoe UI", system-ui, -apple-system, sans-serif;

  /* ----- Design tokens (système) -----
     Rôles : violet = action principale, jaune = récompense UNIQUEMENT,
     gris = secondaire, vert/rouge = états. */
  --primary:   var(--accent);
  --secondary: var(--bg-soft);
  --reward:    var(--accent-2);
  --success:   var(--good);
  --danger:    var(--bad);
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --text-xs: 12px; --text-sm: 14px; --text-md: 16px;
  --text-lg: 20px; --text-xl: 28px; --text-display: 34px;
}

/* Accessibilité : focus clavier visible partout. */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

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

html, body {
  height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, #1c2350 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;            /* jamais de défilement horizontal de page */
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* marges + respect de l'encoche (iPhone) */
  padding:
    calc(28px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
    calc(60px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
}

/* ---------- Conteneurs ---------- */
.screen {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fade .25s ease;
}

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Entête ---------- */
.brand {
  text-align: center;
  margin-bottom: 8px;
}
.brand h1 { font-size: 30px; letter-spacing: .5px; }
.brand p  { color: var(--text-soft); margin-top: 6px; }

/* ---------- Titres ---------- */
.section-title { font-size: 18px; margin-bottom: 14px; }
.muted { color: var(--text-soft); }
.center { text-align: center; }

/* ---------- Boutons ---------- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  /* Style autonome : fonctionne même sans la classe .btn (évite les boutons
     "fins" sans marge). Les classes contextuelles (.acc-btn, .game-rules-btn),
     chargées après dans lobby.css, peuvent réduire padding/taille. */
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2b3266 0%, #20264c 100%);
  color: var(--text);
  border: 1px solid #3b4282;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: transform .08s ease, filter .15s ease, border-color .15s ease;
}
.btn-ghost:hover { border-color: var(--accent); transform: translateY(-1px); filter: brightness(1.07); }
.btn-ghost:active { transform: translateY(0); }
.btn-accent2 { background: var(--accent-2); color: #2a2200; }
.btn-block   { width: 100%; }
.btn-row     { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; color: var(--text-soft); }
.input {
  font-family: inherit;
  font-size: 18px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input.code { letter-spacing: 8px; text-transform: uppercase; text-align: center; font-weight: 700; }

/* ---------- Divers ---------- */
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: 14px;
}
.error { color: var(--bad); font-size: 14px; min-height: 18px; }

/* ---------- Badge mode synchro (coin haut) ---------- */
.sync-badge {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  font-size: 12px; color: var(--text-soft);
  background: rgba(0,0,0,.25); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px;
  z-index: 50;
}

/* ---------- Adaptations petits écrans (téléphone) ---------- */
@media (max-width: 560px) {
  #app {
    padding:
      calc(16px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
      calc(40px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .card { padding: 16px; }
  .brand h1 { font-size: 24px; }
  .screen { gap: 16px; }
  .sync-badge { font-size: 11px; padding: 3px 8px; }
}

/* Filet de sécurité : si un plateau dépasse, on le fait défiler
   horizontalement DANS sa carte plutôt que de casser la page. */
.game-area { width: 100%; }
.game-area #game-root { max-width: 100%; overflow-x: auto; }
