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

:root {
  --bg:      #111217;
  --surface: #181b1f;
  --surface2:#1f2227;
  --border:  rgba(255,255,255,0.08);
  --text:    #d8d9da;
  --muted:   rgba(216,217,218,0.5);
  --dim:     rgba(216,217,218,0.25);
  --blue:    #5794f2;
  --green:   #73bf69;
  --orange:  #ff9830;
  --yellow:  #fade2a;
  --red:     #f2495c;
  --cyan:    #5dc0ed;
  --radius:  6px;
}

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header {
  background: #0b0c0f;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.logo span { color: var(--blue); }
.header-gap { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #4a87e8; border-color: #4a87e8; }
.btn-danger  { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover  { background: rgba(242,73,92,0.12); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 5px 8px; }

/* ── Inputs ── */
.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 11px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.input:focus { border-color: var(--blue); }
.input::placeholder { color: var(--dim); }

select.input { cursor: pointer; }

/* ── Filters bar ── */
.filters {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filters .input { max-width: 260px; }
.filter-count { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ── Main layout ── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

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

/* ── Game card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .2s, transform .2s;
  position: relative;
}
.card:hover { border-color: rgba(255,255,255,0.16); transform: translateY(-2px); }

.card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--dim);
}

.card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
}
.card-admin {
  display: none;
  gap: 4px;
  position: absolute;
  top: 6px;
  right: 6px;
}
body.is-admin .card-admin { display: flex; }
body.is-admin .badge-draft { display: inline-flex; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-draft    { background: rgba(255,152,48,0.15); color: var(--orange); display: none; }
.badge-published{ background: rgba(115,191,105,0.15); color: var(--green); }

/* Platform badge colors */
.plat-pc       { background: rgba(87,148,242,0.15); color: var(--blue); }
.plat-switch   { background: rgba(229,27,27,0.15);  color: #e51b1b; }
.plat-xbox     { background: rgba(16,124,16,0.15);  color: #52b043; }
.plat-playstation { background: rgba(0,48,135,0.25); color: #6ab0f5; }
.plat-gameboy  { background: rgba(115,191,105,0.15); color: var(--green); }
.plat-retro    { background: rgba(181,118,217,0.15); color: #b877d9; }
.plat-default  { background: rgba(255,255,255,0.08); color: var(--muted); }

/* ── Rating ── */
.rating {
  font-size: 12px;
  font-weight: 600;
  color: var(--yellow);
}
.rating-na { color: var(--dim); font-weight: 400; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 0;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: background .15s;
}
.page-btn:hover  { background: var(--surface2); color: var(--text); }
.page-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 16px; font-weight: 500; margin-bottom: 6px; color: var(--text); }

/* ── Loading ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 60px auto;
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  z-index: 999;
  animation: slideIn .2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.toast.ok  { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity:0; } to { transform: none; opacity:1; } }

/* ── Detail page ── */
.detail-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.detail-back { font-size: 13px; color: var(--muted); margin-bottom: 20px; display: inline-flex; align-items: center; gap: 5px; }
.detail-back:hover { color: var(--text); text-decoration: none; }

.detail-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 28px;
}
@media (max-width: 700px) { .detail-layout { grid-template-columns: 1fr; } }

.detail-img {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.detail-img-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
}

.detail-fields { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  font-weight: 500;
}
.field-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.field-value.title { font-size: 22px; font-weight: 600; }
.field-value.description { color: var(--muted); font-size: 13px; }
.field-empty { color: var(--dim); font-style: italic; }

/* Inline edit */
.field-edit-wrap { position: relative; }
.field-edit-btn {
  opacity: 0;
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  transition: opacity .15s, color .15s;
}
body.is-admin .field:hover .field-edit-btn { opacity: 1; }
body.is-admin .field:hover .field-edit-btn:hover { color: var(--blue); }

.inline-edit { display: none; gap: 6px; align-items: flex-start; margin-top: 4px; }
.inline-edit.active { display: flex; }
.inline-edit textarea { resize: vertical; min-height: 80px; }
.inline-edit-actions { display: flex; gap: 4px; flex-shrink: 0; margin-top: 1px; }

.detail-actions {
  display: none;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
body.is-admin .detail-actions { display: flex; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
}
.login-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.form-group  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label  { font-size: 12px; color: var(--muted); }
.form-error  { font-size: 12px; color: var(--red); margin-top: 8px; display: none; }
.form-error.show { display: block; }
