/* Bankroll — habillage commun (accueil, lobby, chrome du jeu). */

:root {
  --bg: #14161c;
  --bg-soft: #1c1f28;
  --bg-card: #1f232e;
  --line: #2c3140;
  --text: #eef1f7;
  --muted: #98a0b3;
  /* L'or porte la marque : c'est lui qu'on retrouve sur les boutons, les onglets
     actifs et le focus des champs. `--accent-ink` est la couleur du texte qu'on
     pose dessus — jamais du blanc, illisible sur un fond aussi clair. */
  --accent: #f2c11b;
  --accent-ink: #16180f;
  --accent-soft: rgba(242, 193, 27, 0.14);
  --blue: #2f8bff;
  --accent-2: #4ccf6a;
  --danger: #e8493a;
  --gold: #f2c11b;
  --radius: 14px;
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Nos sections utilisent display:grid/flex, qui l'emporterait sur l'attribut hidden. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  /* Aucun écran ne doit jamais défiler latéralement : c'est la règle, et ce
     garde-fou la tient même si un contenu déborde par accident. */
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: radial-gradient(1200px 600px at 50% -200px, #232838 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
  font-size: 1rem;
}

/* -------------------------------- icônes --------------------------- */
/* Toutes les icônes sont des SVG inline en currentColor (public/js/icons.js) :
   elles héritent donc de la couleur du texte qui les porte. */

.ico {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex: 0 0 auto;
}

/* icône accolée à un texte : légèrement en retrait et un cran plus discrète */
.ico-inline {
  width: 1.05em;
  height: 1.05em;
  opacity: 0.75;
  margin-right: 0.4em;
}

/* icône d'un titre de modale */
.ico-title {
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.4em;
  color: var(--accent);
}

/* ------------------------------- chrome ---------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 22, 28, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
}

.brand img {
  display: block;
  width: 30px;
  height: 30px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* sur un écran étroit, c'est le pseudo qui cède, jamais le lien de sortie */
#user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip .link {
  flex: 0 0 auto;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 64px;
  display: grid;
  gap: 16px;
}

/* -------------------------------- cards ---------------------------- */

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

.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
  line-height: 1.2;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  letter-spacing: 0.01em;
}

.lede {
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.5;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 14px 0 0;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.error {
  color: #ff8b7e;
  font-size: 0.88rem;
  margin: 10px 0 0;
}

/* -------------------------------- forms ---------------------------- */

form label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.row {
  display: flex;
  gap: 10px;
}

.row input {
  flex: 1;
  text-transform: uppercase;
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.2);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  width: 100%;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: var(--danger);
  border-color: transparent;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.85rem;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 0.88rem;
}

/* -------------------------------- tabs ----------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
}

.tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ------------------------------ options ---------------------------- */

.options {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.option-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 7px;
}

.choices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.choice {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: 600;
}

.choice.is-active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

/* ------------------------------- lobby ----------------------------- */

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

/* Une carte, pas une ligne : chaque information a son étage, et le bouton
   occupe toute la largeur en bas. Rien ne se comprime, rien ne déborde. */
.game-row {
  display: grid;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.game-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.game-title > span:not(.badge) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.badge {
  flex: 0 0 auto;
}

/* les réglages de la partie, en pastilles qui passent à la ligne */
.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-meta span {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 7px;
  padding: 3px 8px;
}

.game-players {
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.game-row .btn {
  width: 100%;
  height: 44px;
  border-radius: 11px;
  margin-top: 2px;
}

.badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--line);
  color: var(--muted);
}

.badge.live {
  background: rgba(76, 207, 106, 0.15);
  color: var(--accent-2);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 18px 0;
}

/* ------------------------------------------------------------------ */
/* Écran d'entrée                                                      */
/* ------------------------------------------------------------------ */

.home {
  min-height: 100dvh;
}

/* Un halo doré derrière la carte, pour que la page ne soit pas un mur noir. */
.home::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(620px 420px at 50% -6%, rgba(242, 193, 27, 0.16), transparent 70%),
    radial-gradient(520px 380px at 90% 8%, rgba(232, 73, 58, 0.09), transparent 72%);
}

.auth {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0;
  max-width: 380px;
  margin: 0 auto;
  padding: clamp(18px, 6vh, 54px) 0 40px;
}

.auth-logo {
  width: clamp(88px, 26vw, 120px);
  height: auto;
  margin-bottom: 18px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

.auth h1 {
  font-size: clamp(1.35rem, 5.6vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 22px;
}

.auth .tabs {
  width: 100%;
  margin-bottom: 20px;
}

.auth form {
  width: 100%;
  display: grid;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 7px;
}

.auth input {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-size: 1rem;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* champ avec le bouton d'affichage du mot de passe */
.field {
  position: relative;
}

.field input {
  padding-right: 48px;
}

.reveal {
  position: absolute;
  top: 25px;
  right: 6px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 9px;
}

.reveal:hover {
  color: var(--text);
}

.reveal .ico {
  width: 19px;
  height: 19px;
}

/* jauge de robustesse */
.gauge {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin: -4px 0 7px;
}

.gauge i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--danger);
  transition: width 0.25s ease, background-color 0.25s ease;
}

.gauge i.weak { background: var(--danger); }
.gauge i.fair { background: #f0932b; }
.gauge i.good { background: var(--gold); }
.gauge i.strong { background: var(--accent-2); }

.gauge-label {
  margin: 0 0 12px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  min-height: 1.1em;
}

/* les trois exigences, cochées à mesure qu'on tape */
.rules {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 5px;
}

.rules li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.rules li::before {
  content: '';
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rules li.ok {
  color: var(--accent-2);
}

.rules li.ok::before {
  border-color: var(--accent-2);
  background: var(--accent-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314161c' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 13 4 4L19 7'/%3E%3C/svg%3E")
    center / 11px no-repeat;
}

.auth .btn-primary {
  height: 52px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  margin-top: 4px;
}

.auth .error {
  margin: 0 0 12px;
}

/* ------------------------------------------------------------------ */
/* Lobby : la liste occupe l'écran, les actions restent sous le pouce  */
/* ------------------------------------------------------------------ */

#lobby {
  padding-bottom: 12px;
}

#lobby .card-head {
  margin-bottom: 14px;
}

#lobby h2 {
  margin: 0;
}

.lobby-actions {
  position: sticky;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
  flex-wrap: wrap;
  padding: 14px 16px calc(30px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(20, 22, 28, 0));
}

.lobby-actions .btn {
  flex: 1 1 148px;
  height: 50px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  width: auto;
  padding: 0 12px;
}

/* trop étroit pour deux boutons côte à côte : ils s'empilent */
@media (max-width: 359px) {
  .lobby-actions .btn {
    flex: 1 1 100%;
  }
}

/* la barre d'actions ne doit jamais recouvrir la fin de la liste */
body.home .wrap {
  padding-bottom: 116px;
}

/* --------------------------------- modales -------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(3px);
}

.modal-inner {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.modal-close .ico {
  width: 18px;
  height: 18px;
}

.modal .btn-primary {
  height: 50px;
  border-radius: 12px;
  font-weight: 800;
}

.modal .options {
  margin-bottom: 20px;
}

.modal input {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  padding: 0 14px;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

/* -------------------------------- toast ---------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #2b3040;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
