:root {
  --bg: #12100e;
  --bg-alt: #0d0b0a;
  --bg-card: #1d1a17;
  --bg-card-hover: #241f1b;
  --bg-inset: #161310;
  --accent: #d4a017;
  --accent-hover: #e6b52a;
  --accent-dim: #a17f18;
  --accent-red: #a3231f;
  --accent-red-hover: #c2302a;
  --accent-orange: #ff7a45;
  --accent-blue: #5b9bd5;
  --accent-purple: #a78bfa;
  --success: #4ade80;
  --text: #eae6df;
  --text-dim: #9a948a;
  --text-faint: #6f6a62;
  --border: #33302b;
  --border-soft: #262320;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.45);
  --navbar-height: 60px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
}

* { box-sizing: border-box; }

/* Icônes (voir icons.js) : alignées sur la ligne de texte, héritent la
   couleur du texte parent par défaut (stroke="currentColor"). */
.icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}

[data-icon] {
  display: inline-flex;
  align-items: center;
  vertical-align: -3px;
}

button .icon, .card-title .icon, .section-title .icon, h1 .icon, .brand .icon {
  margin-right: 4px;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(circle at top, rgba(212, 160, 23, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

h1, h2, h3 {
  color: var(--text);
  letter-spacing: 0.2px;
  margin: 0;
}

h1 {
  color: var(--accent);
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 4px;
}

h2.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

a { color: var(--accent); }

/* ------------------------------------------------------------------
   NAVBAR — bandeau fixe en haut, présent uniquement une fois connecté
   ------------------------------------------------------------------ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: rgba(18, 16, 14, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.navbar-inner {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
  color: var(--accent);
  background: rgba(212, 160, 23, 0.12);
}

.nav-links a.nav-logout {
  color: var(--accent-red);
  margin-left: 4px;
}

.nav-links a.nav-logout:hover {
  background: rgba(163, 35, 31, 0.15);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ------------------------------------------------------------------
   PAGE LAYOUT
   ------------------------------------------------------------------ */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: calc(var(--navbar-height) + 24px) 20px 40px;
}

.page-auth {
  max-width: 420px;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-header {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

/* --- Grille sticky main + sidebar : page de jeu (prépa/live) --- */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 900px) {
  .layout-with-sidebar {
    grid-template-columns: 1fr 340px;
  }
  .layout-sidebar {
    position: sticky;
    top: calc(var(--navbar-height) + 24px);
    max-height: calc(100vh - var(--navbar-height) - 48px);
    overflow-y: auto;
    padding-right: 2px;
  }
}

.layout-main {
  min-width: 0;
}

/* --- Grille du dashboard admin : plusieurs widgets indépendants --- */
.admin-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 700px) {
  .admin-section-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .admin-section-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 860px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
  }
  .dashboard-grid .player-card {
    position: sticky;
    top: calc(var(--navbar-height) + 24px);
  }
  .leaderboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ------------------------------------------------------------------
   CARDS / SECTIONS
   ------------------------------------------------------------------ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card:last-child { margin-bottom: 0; }

.card-compact {
  padding: 14px 16px;
}

.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-hint {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 0 0 14px;
}

.scroll-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

/* ------------------------------------------------------------------
   FORMS / BUTTONS
   ------------------------------------------------------------------ */
input, textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--bg-alt);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) { background: var(--accent-hover); }
button:active:not(:disabled) { transform: scale(0.99); }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

button.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--text-dim);
}

button.danger {
  background: var(--accent-red);
  color: white;
}

button.danger:hover:not(:disabled) { background: var(--accent-red-hover); }

button.small {
  width: auto;
  padding: 8px 12px;
  font-size: 0.82rem;
  flex-shrink: 0;
}

button + button { margin-top: 8px; }

.button-row {
  display: flex;
  gap: 8px;
}

.button-row button { margin-top: 0 !important; }

.error {
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-bottom: 12px;
  display: none;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat:last-child { border-bottom: none; }

.accent-value {
  color: var(--accent);
  font-weight: 700;
}

.stat-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding-top: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* --- Jeu : posture (boutons de choix) --- */
/* Grid plutôt que flex : avec flex-wrap, un bouton qui passe seul à la ligne
   s'étire sur toute la largeur (flex:1 sur une ligne à 1 item) et casse
   l'alignement avec les autres -- la grid garantit des colonnes égales quelle
   que soit la largeur disponible. */
.choice-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.choice-buttons button {
  min-width: 0;
  margin-top: 0; /* écrase "button + button { margin-top: 8px }" qui s'applique
                    aussi ici (boutons adjacents), décalait les cases dans la
                    grid et les faisait paraître plus petites que la 1ère. */
  padding: 10px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
}

.choice-buttons button.choice-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-alt);
}

.choice-buttons.danger-style button.choice-selected {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}

.voie-triangle {
  display: block;
  margin: 4px auto 12px;
  max-width: 220px;
}

.voie-vertex {
  cursor: pointer;
}

.voie-vertex circle {
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.voie-vertex:hover circle {
  stroke: var(--accent);
}

/* --- Jeu : Live Feed --- */
.live-feed {
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.55;
}

.feed-line {
  padding: 5px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.feed-line:last-child { border-bottom: none; }

.feed-tick {
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-right: 6px;
}

/* Code couleur par nature de l'événement : vert = positif (soin, alliance,
   sponsor...), rouge = négatif (dégâts, malédiction...), atténué = neutre
   (flavor text sans effet). */
.feed-positive { color: var(--success); }
.feed-negative { color: var(--accent-red); }
.feed-neutral { color: var(--text-dim); }

/* Une mort doit être imposible à manquer dans le feed. */
.feed-death {
  color: var(--accent-red);
  font-weight: 700;
  background: rgba(163, 35, 31, 0.16);
  padding: 6px 8px;
  margin: 2px 0;
}

/* Un événement qui implique mon propre tribut doit ressortir du reste du
   feed : liseré doré + fond teinté, cumulable avec .feed-death. */
.feed-mine {
  background: rgba(212, 160, 23, 0.12);
  box-shadow: inset 3px 0 0 var(--accent);
  padding: 6px 8px;
  margin: 2px 0;
  font-weight: 600;
}

.feed-mine.feed-death {
  background: linear-gradient(90deg, rgba(212, 160, 23, 0.18), rgba(163, 35, 31, 0.18));
  box-shadow: inset 3px 0 0 var(--accent);
}

/* --- Jeu : liste des tributs --- */
.tribute-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.85rem;
}

.tribute-row:last-child { border-bottom: none; }

.tribute-row span:first-child {
  flex: 1;
  min-width: 90px;
}

.tribute-dead {
  opacity: 0.4;
  text-decoration: line-through;
}

.hp-bar {
  flex: 2;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.hp-fill {
  height: 100%;
  background: var(--accent-red);
  transition: width 0.3s ease;
}

/* --- badges de statut (posture/voie affichées, "toi" en direct) --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(212, 160, 23, 0.12);
  color: var(--accent);
  border: 1px solid rgba(212, 160, 23, 0.3);
}

.badge-alive { background: rgba(74, 222, 128, 0.12); color: var(--success); border-color: rgba(74, 222, 128, 0.3); }
.badge-dead { background: rgba(163, 35, 31, 0.12); color: var(--accent-red); border-color: rgba(163, 35, 31, 0.3); }

/* --- Jeu/Admin : menus déroulants --- */
select {
  width: 100%;
  padding: 10px 32px 10px 10px;
  margin-bottom: 10px;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%239a948a' stroke-width='1.5' fill='none' fill-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  /* Evite le style natif du navigateur (surtout notable sur mobile Safari/Chrome) */
  -webkit-appearance: none;
  appearance: none;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

select option {
  background: var(--bg-card);
  color: var(--text);
}

/* --- Admin : lignes d'édition (boutique, bots) --- */
.edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.edit-row:last-child { border-bottom: none; }

.edit-row .edit-row-title {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: var(--text);
}

.edit-row .edit-row-title .card-hint { margin: 2px 0 0; }

.edit-row label {
  margin-bottom: 0;
}

.edit-row input {
  width: 90px;
  margin-bottom: 0;
}

.edit-row button {
  width: auto;
  padding: 10px 14px;
}

/* ------------------------------------------------------------------
   RESPONSIVE — bascule bandeau desktop / menu mobile
   ------------------------------------------------------------------ */
@media (max-width: 700px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 8px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }

  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links a {
    padding: 12px;
  }

  .stat-sub {
    font-size: 0.72rem;
    gap: 4px 10px;
  }
}
