/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:       #0d0f12;
  --bg-surface:    #13161b;
  --bg-elevated:   #1a1e25;
  --bg-hover:      #1f242d;
  --border:        #252b35;
  --border-subtle: #1e232c;
  --text-primary:  #e8eaf0;
  --text-secondary:#8a94a6;
  --text-muted:    #4e5668;
  --accent:        #5b8def;
  --accent-dim:    rgba(91,141,239,.12);
  --accent-hover:  #7aa3f5;
  --success:       #34c17a;
  --success-dim:   rgba(52,193,122,.1);
  --danger:        #e05252;
  --danger-dim:    rgba(224,82,82,.1);
  --warn:          #e09b30;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,.5);
  --transition:    .18s ease;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── Mobile block ────────────────────────────────────────────────────────── */
.mobile-block {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-base);
  align-items: center; justify-content: center; padding: 2rem;
}
.mobile-inner { text-align: center; max-width: 280px; color: var(--text-secondary); }
.mobile-inner svg { margin-bottom: 1.25rem; opacity: .4; }
.mobile-inner h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: .6rem; }
.mobile-inner p  { font-size: .85rem; line-height: 1.7; }

@media (max-width: 768px) {
  .mobile-block { display: flex; }
  .app { display: none; }
}

/* ── Badge ────────────────────────────────────────────────────────── */

.badge-latest {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.6rem;
  border-radius: 99px;
  margin-left: 0.5rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; position: relative; }

/* ── Page background (detail view) ──────────────────────────────────────── */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.9;
  filter: brightness(0.25) saturate(0.7);
  transform: scale(1.06);
}
.page-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;   /* ← préserve les proportions sans déformation */
  display: block;
}
.header, .storage-bar-wrap, .flash, .main { position: relative; z-index: 1; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 2.5rem; height: 62px;
  background: rgba(19,22,27,.92);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.logo {
  display: flex; align-items: center; gap: .55rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1.05rem;
  color: var(--text-primary); letter-spacing: -.01em;
}
.logo svg { color: var(--accent); flex-shrink: 0; }
.header-center { display: flex; flex-direction: column; align-items: center; gap: .05rem; }
.clock {
  font-family: 'Space Grotesk', monospace; font-weight: 700;
  font-size: 1.1rem; letter-spacing: .06em; color: var(--text-primary); line-height: 1;
}
.date { font-size: .72rem; color: var(--text-secondary); letter-spacing: .03em; text-transform: capitalize; }
.header-right { display: flex; align-items: center; gap: .75rem; }

/* ── Storage bar ─────────────────────────────────────────────────────────── */
.storage-bar-wrap {
  display: flex; align-items: center; gap: 1rem; padding: .65rem 2.5rem;
  background: rgba(19,22,27,.8);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}
.storage-label { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.storage-value { font-size: .72rem; color: var(--text-secondary); white-space: nowrap; }
.storage-info  { display: flex; gap: .5rem; align-items: center; }
.storage-track { flex: 1; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.storage-fill  { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.storage-fill.warn { background: var(--warn); }
.storage-pct { font-size: .72rem; color: var(--text-muted); white-space: nowrap; min-width: 2.8rem; text-align: right; }

/* ── Flash ───────────────────────────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; gap: .6rem;
  margin: 1.25rem 2.5rem 0; padding: .75rem 1rem;
  border-radius: var(--radius-sm); font-size: .82rem; font-weight: 500;
}
.flash-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(52,193,122,.25); }
.flash-error   { background: var(--danger-dim);  color: var(--danger);  border: 1px solid rgba(224,82,82,.25); }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main { flex: 1; padding: 2rem 2.5rem 3rem; max-width: 100%; width: 100%; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 5rem 2rem; text-align: center; color: var(--text-muted);
}
.empty-state svg  { opacity: .3; }
.empty-state h3   { font-size: 1.1rem; color: var(--text-secondary); font-weight: 600; }
.empty-state p    { font-size: .85rem; max-width: 320px; line-height: 1.7; }
.empty-state .btn { margin-top: .5rem; }

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: baseline; gap: .75rem; margin-bottom: 1.5rem; }
.section-title  { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; }
.section-count  { font-size: .75rem; color: var(--text-muted); font-weight: 500; }

/* ── Game grid ───────────────────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); /* 280px mini au lieu de 220px */
  gap: 1.5rem;  /* un peu plus d'espace */
  width: 100%;
  /* pas de max-width ni margin:auto → aligné à gauche */
}
.game-card {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);  /* un peu plus de relief */
  box-shadow: 0 8px 32px rgba(91,141,239,.15);
}
.game-card-img {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-elevated);
  overflow: hidden;
}
.game-card-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .3s ease;
}
.game-card:hover .game-card-img img { transform: scale(1.05); }
.game-card-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: .6rem .8rem;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  font-size: .8rem; color: rgba(255,255,255,.9); font-weight: 500;
}
.game-card-body {
  padding: 1rem 1.2rem;  /* plus de padding interne */
  border-top: 1px solid var(--border-subtle);
}
.game-card-title {
  font-weight: 600; font-size: 1rem;  /* titre plus grand */
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: .2rem;
}
.game-card-sub {
  font-size: .8rem; color: var(--text-muted);
}

/* ── Detail view ─────────────────────────────────────────────────────────── */
.detail-view { display: flex; flex-direction: column; gap: 1.75rem; }
.detail-header {
  display: flex; align-items: flex-start; gap: 1.25rem; flex-wrap: wrap;
}
.back-link {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; color: var(--text-secondary);
  padding: .35rem .6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-surface);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap; align-self: center;
}
.back-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.detail-title-wrap { display: flex; align-items: center; gap: 1rem; flex: 1; }
.detail-thumb {
  width: 56px; height: 74px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0;
  display: none;
}
.detail-title {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: 1.4rem; letter-spacing: -.02em; line-height: 1.2;
}
.detail-meta { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; display: block; }
.detail-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; align-self: center; }

/* ── Saves table ─────────────────────────────────────────────────────────── */
.saves-table-wrap {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.saves-table { width: 100%; border-collapse: collapse; }
.saves-table th {
  text-align: left; padding: .7rem 1.2rem;
  font-size: .71rem; font-weight: 600; color: var(--text-muted);
  letter-spacing: .05em; text-transform: uppercase;
  border-bottom: 1px solid var(--border); background: var(--bg-elevated);
}
.saves-table td {
  padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.saves-table tr:last-child td { border-bottom: none; }
.saves-table tbody tr { transition: background var(--transition); }
.saves-table tbody tr:hover { background: var(--bg-hover); }

.save-name { display: flex; align-items: flex-start; gap: .5rem; }
.save-name svg { color: var(--text-muted); flex-shrink: 0; margin-top: 2px; }
.save-label { display: block; font-size: .83rem; font-weight: 600; color: var(--text-primary); }
.save-filename { display: block; font-size: .72rem; color: var(--text-muted); margin-top: .05rem; }
.save-desc-cell { max-width: 260px; }
.save-desc { font-size: .78rem; color: var(--text-secondary); line-height: 1.5; }
.save-desc-empty { color: var(--text-muted); font-size: .78rem; }
.save-size { font-size: .78rem; color: var(--text-secondary); white-space: nowrap; }
.save-date { font-size: .78rem; color: var(--text-secondary); white-space: nowrap; }
.save-actions { text-align: right; white-space: nowrap; }
.save-actions .btn + .btn { margin-left: .4rem; }

.saves-empty {
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  padding: 3.5rem 2rem; text-align: center; color: var(--text-muted);
}
.saves-empty svg { opacity: .25; }
.saves-empty p { font-size: .83rem; line-height: 1.7; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap; line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 0 0 3px var(--accent-dim); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { color: var(--danger) !important; }
.btn-danger:hover { background: var(--danger-dim) !important; border-color: rgba(224,82,82,.3) !important; }
.btn-sm { padding: .35rem .7rem; font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 500;
  align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow); animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: 1rem; letter-spacing: -.01em;
}
.modal-close {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.1rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}

/* ── Form fields ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field-label { font-size: .76rem; font-weight: 600; color: var(--text-secondary); letter-spacing: .02em; }
.required { color: var(--accent); }
.field-input {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem .85rem;
  font-size: .85rem; font-family: inherit; color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; width: 100%; resize: none;
}
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.field-input::placeholder { color: var(--text-muted); }
.field-textarea { resize: vertical; min-height: 72px; }
.field-hint { font-size: .72rem; color: var(--text-muted); }

/* ── Password wrapper & toggle ──────────────────────────────────────────── */
.field-pw-wrap {
  position: relative;
}
.field-pw-wrap .field-input {
  padding-right: 2.6rem;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.pw-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.pw-toggle svg {
  display: block;
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
  padding: 1.5rem 1rem; cursor: pointer;
  background: var(--bg-elevated); border: 1.5px dashed var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--text-secondary); }
.upload-zone.drag-over { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone.has-file  { border-color: var(--success); background: var(--success-dim); color: var(--success); }
.upload-zone input[type="file"] { display: none; }
.upload-zone span { font-size: .82rem; font-weight: 500; }
.upload-zone-hint { font-size: .72rem; color: var(--text-muted); }

/* ── Image preview & ratio check ────────────────────────────────────────── */
.img-preview-wrap {
  margin-top: .25rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.img-preview-box {
  display: flex;
  justify-content: center;
  background: var(--bg-elevated);
}
.img-preview-box img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
}
.img-ratio-badge {
  display: inline-block;
  padding: .3rem .8rem;
  font-size: .78rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: center;
}
.img-ratio-badge.ratio-ok { color: var(--success); }
.img-ratio-badge.ratio-err { color: var(--danger); }

/* ── Auth pages (login, setup) ──────────────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
}
.auth-center {
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 2rem;
}
.auth-logo svg { color: var(--accent); }
.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-card-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-card-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -.02em;
  margin-bottom: .3rem;
}
.auth-card-header p {
  color: var(--text-secondary);
  font-size: .85rem;
}
.auth-note {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .75rem;
  color: var(--text-muted);
}

/* ── Password strength (setup) ──────────────────────────────────────────── */
.pw-strength-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: .25rem 0 .75rem;
}
.pw-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  transition: width .3s ease, background .3s ease;
}
.pw-strength-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 3.5rem;
  text-align: right;
}
.pw-rules {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  font-size: .78rem;
  color: var(--text-muted);
  padding: 0;
  margin: .5rem 0 0;
}
.pw-rules li {
  display: flex;
  align-items: center;
  gap: .3rem;
}
.rule-icon {
  display: inline-block;
  width: 1.1rem;
  text-align: center;
  font-weight: 700;
}
.pw-rules .rule-ok {
  color: var(--success);
}
.pw-rules .rule-ok .rule-icon {
  color: var(--success);
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }