:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --card: #1c2029;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #6c5ce7;
  --accent-2: #00d1b2;
  --gold: #f1c40f;
  --radius: 12px;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Navbar ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex: 0 0 auto;
}
.brand span { color: var(--accent-2); }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; display: block; }
.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  transition: 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--card); }
.nav-links a.active { color: var(--text); background: var(--accent); }
.badge {
  background: var(--accent-2);
  color: #06241f;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
}

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 32px; }
.page-title { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 24px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.toolbar input, .toolbar select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.toolbar input { flex: 1; min-width: 200px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }

.cover {
  height: 150px;
  display: flex;
  align-items: flex-end;
  padding: 12px;
  position: relative;
  background-size: cover;
  background-position: center;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0.05) 55%);
}
.cover .rating, .cover .genre-tag { position: relative; z-index: 1; }
.cover .rating {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 8px;
}
.cover .genre-tag {
  background: rgba(0,0,0,0.45);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
}

.card-link { display: block; color: inherit; }
.card-head { padding: 14px 14px 0; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-meta { color: var(--muted); font-size: 13px; }
.card-meta .dot { margin: 0 6px; }

.card-actions {
  padding: 14px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-actions .btn { margin-top: 0; }

.note-select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.note-select:focus { border-color: var(--accent); }

.comment-input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  width: 100%;
}
.comment-input:focus { border-color: var(--accent); }

/* ---------- Statuts ---------- */
.status-select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  width: 100%;
}
.status-select.st-playing   { border-color: #f1c40f; color: #f1c40f; }
.status-select.st-finished  { border-color: var(--accent-2); color: var(--accent-2); }
.status-select.st-abandoned { border-color: #ff6b6b; color: #ff6b6b; }
.status-select.st-none      { border-color: var(--accent); color: #fff; background: var(--accent); }

.status-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.status-tag.st-playing   { color: #f1c40f; border-color: #f1c40f; }
.status-tag.st-finished  { color: var(--accent-2); border-color: var(--accent-2); }
.status-tag.st-abandoned { color: #ff6b6b; border-color: #ff6b6b; }

.ro-note { font-size: 13px; color: var(--text); }
.ro-comment { font-size: 13px; color: var(--muted); font-style: italic; }

/* ---------- Joueurs / amis ---------- */
.muted { color: var(--muted); font-size: 14px; }
.user-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.user-name { font-weight: 700; color: var(--accent-2); }
.user-name:hover { text-decoration: underline; }
.user-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-actions .btn { width: auto; padding: 8px 14px; margin-top: 0; }

.user-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.user-header-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Fil d'actualité ---------- */
.feed-item {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.feed-cover {
  flex: 0 0 64px;
  height: 64px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
}
.feed-body { flex: 1; min-width: 0; }
.feed-text { font-size: 15px; line-height: 1.4; }
.feed-game { font-weight: 700; color: var(--text); }
.feed-game:hover { color: var(--accent-2); }
.feed-meta { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Responsive (mobile / tablette) ---------- */
@media (max-width: 760px) {
  /* Navbar : marque au-dessus, liens en barre horizontale défilante */
  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }
  .nav-links {
    overflow-x: auto;
    white-space: nowrap;
    gap: 4px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex: 0 0 auto; padding: 8px 12px; font-size: 14px; }
  [data-auth-nav] {
    margin-left: auto;
    padding-left: 10px;
  }
  .auth-email { max-width: 110px; }

  .container { padding: 20px 16px; }
  .page-title { font-size: 24px; }

  /* Cartes : un peu plus étroites pour tenir sur petit écran */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

  /* Page détail : héros plus court */
  .detail-hero { min-height: 200px; padding: 18px; }
  .detail-hero h1 { font-size: 26px; }

  /* Joueurs : empile pseudo et boutons */
  .user-row { flex-direction: column; align-items: flex-start; }
  .user-actions { width: 100%; }
  .user-actions .btn { flex: 1; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .stat .num { font-size: 26px; }
}

.btn {
  margin-top: auto;
  border: none;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  transition: 0.15s;
  font-family: inherit;
}
.btn-add { background: var(--accent); color: #fff; }
.btn-add:hover { background: #5a4bd6; }
.btn-done { background: transparent; color: var(--accent-2); border: 1px solid var(--accent-2); }
.btn-done:hover { background: rgba(0,209,178,0.1); }
.btn-remove { background: transparent; color: #ff6b6b; border: 1px solid #ff6b6b; }
.btn-remove:hover { background: rgba(255,107,107,0.1); }

/* ---------- Profile stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat .num { font-size: 32px; font-weight: 800; color: var(--accent-2); }
.stat .label { color: var(--muted); font-size: 14px; }

.finished-at { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty .icon { font-size: 56px; margin-bottom: 16px; }
.empty a { color: var(--accent-2); font-weight: 700; }

/* ---------- Auth ---------- */
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.auth-card input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.auth-card .btn { margin-top: 8px; }
.form-error { color: #ff6b6b; font-size: 14px; min-height: 18px; margin: -4px 0; }
.form-switch { text-align: center; color: var(--muted); font-size: 14px; }
.form-switch a { color: var(--accent-2); font-weight: 700; }

.auth-email {
  color: var(--accent-2);
  font-weight: 700;
  font-size: 14px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-auth-nav] {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
[data-auth-nav] a {
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}
[data-auth-nav] a:hover { color: var(--text); background: var(--card); }

.banner {
  background: rgba(108,92,231,0.12);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 14px;
}
.banner a { color: var(--accent-2); font-weight: 700; }

/* ---------- Chips (catégories) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Spinner ---------- */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent-2);
  color: #06241f;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Page détail d'un jeu ---------- */
.back-link {
  display: inline-block;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--text); }

.detail-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 280px;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  background-size: cover;
  background-position: center;
  margin-bottom: 24px;
}
.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15,17,21,0.95), rgba(15,17,21,0.2));
}
.detail-hero-content { position: relative; z-index: 1; }
.detail-hero h1 { font-size: 34px; font-weight: 800; margin-bottom: 8px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.detail-tags span {
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 28px; align-items: start; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-section h2 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.synopsis { color: var(--text); line-height: 1.7; white-space: pre-line; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 24px; }
.shots img { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }

.detail-side {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail-side .info-row { font-size: 14px; }
.detail-side .info-row .k { color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-side .note-block label { color: var(--muted); font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }
.detail-side .note-select { width: 100%; }
