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

:root {
  --bg: #0f0f11;
  --bg2: #18181c;
  --bg3: #222228;
  --surface: #1c1c22;
  --border: #2a2a35;
  --accent: #4f8ef7;
  --accent-dim: rgba(79,142,247,0.15);
  --accent-hover: #6fa3f9;
  --text: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a72;
  --radius: 10px;
  --card-w: 180px;
  --card-h: 100px; /* header images are 460x215, ratio ~2.14:1 */
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.5; }

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

/* ── Nav ── */
.nav {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.nav-logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.nav-logo:hover { color: var(--accent-hover); }
.nav-logo-svg { width: 36px; height: 25px; color: var(--accent); flex-shrink: 0; transition: color 0.2s; }
.nav-logo:hover .nav-logo-svg { color: var(--accent-hover); }
.nav-search-link { margin-left: auto; font-size: 0.85rem; color: var(--text-secondary); }
.nav-search-link:hover { color: var(--text); }

/* ── Landing ── */
.landing-body { display: flex; flex-direction: column; min-height: 100vh; }
.landing-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.landing-hero { text-align: center; max-width: 560px; }
.landing-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.landing-logo-svg { width: 72px; height: 50px; color: var(--accent); flex-shrink: 0; }
.landing-logo-name { font-size: 2.5rem; font-weight: 800; letter-spacing: -1px; }
.landing-tagline { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
.landing-sub { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 32px; line-height: 1.7; }
.landing-error { background: rgba(220,50,50,0.15); border: 1px solid rgba(220,50,50,0.4); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; color: #f87171; font-size: 0.875rem; text-align: left; }
.landing-form { display: flex; gap: 10px; margin-bottom: 12px; }
.landing-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; color: var(--text); font-size: 0.9rem; outline: none;
  transition: border-color 0.2s;
}
.landing-input:focus { border-color: var(--accent); }
.landing-input::placeholder { color: var(--text-muted); }
.landing-btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 12px 20px; font-size: 0.9rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.2s;
}
.landing-btn:hover { background: var(--accent-hover); }
.landing-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.landing-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ── Profile Header ── */
.profile-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--border); }
.profile-name { font-size: 1.25rem; font-weight: 700; }
.profile-stats { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Main Content ── */
.main-content { padding: 24px; max-width: 1600px; margin: 0 auto; }

/* ── Sections ── */
.section { margin-bottom: 40px; }
.section-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-title { font-size: 1.15rem; font-weight: 700; flex: 1; }
.section-controls { display: flex; align-items: center; gap: 8px; }

.genre-select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 4px 8px; font-size: 0.8rem; cursor: pointer;
}

.shuffle-btn, .carousel-btn {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); padding: 4px 10px; font-size: 0.85rem;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.shuffle-btn:hover, .carousel-btn:hover { color: var(--text); border-color: var(--accent); }
.carousel-btn:disabled { opacity: 0.3; cursor: default; }

.page-indicator { font-size: 0.75rem; color: var(--text-muted); min-width: 36px; text-align: center; }

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 12px;
  overflow: hidden;
}
.card-page { display: contents; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
  will-change: transform;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }

.card-img { width: 100%; aspect-ratio: 460/215; object-fit: cover; display: block; background: var(--bg3); }

.card-body { padding: 8px 10px; }
.card-title { font-size: 0.8rem; font-weight: 600; line-height: 1.3; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.badge {
  font-size: 0.65rem; font-weight: 600; padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}
.badge-playtime { background: var(--bg3); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-reason { background: var(--accent-dim); color: var(--accent); }

/* Skeleton */
.skeleton-card { height: 160px; background: var(--bg3); }
.skeleton-card::after {
  content: '';
  display: block; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Card hover overlay */
.card-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  opacity: 0; transition: opacity 0.15s;
  will-change: opacity;
}
.card:hover .card-overlay { opacity: 1; }
.overlay-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 7px 16px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.overlay-btn:hover { background: var(--accent-hover); }
.overlay-steam-btn {
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 14px; font-size: 0.75rem; cursor: pointer;
  transition: color 0.15s, border-color 0.15s; text-decoration: none; display: inline-block;
}
.overlay-steam-btn:hover { color: var(--text); border-color: var(--text); }

/* ── Loading State ── */
.loading-state { text-align: center; padding: 80px 24px; }
.loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-message { font-size: 1rem; color: var(--text); margin-bottom: 12px; }
.loading-bar-wrap { background: var(--bg3); border-radius: 4px; height: 6px; max-width: 360px; margin: 0 auto 16px; overflow: hidden; }
.loading-bar { background: var(--accent); height: 100%; border-radius: 4px; transition: width 0.4s; }
.loading-sub { font-size: 0.8rem; color: var(--text-muted); line-height: 1.8; }

/* ── Error State ── */
.load-error { text-align: center; padding: 80px 24px; }
.load-error p { color: var(--text-secondary); margin-bottom: 20px; }
.btn-primary {
  display: inline-block; background: var(--accent); color: #fff;
  padding: 10px 20px; border-radius: var(--radius); font-weight: 600; font-size: 0.9rem;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 900px; max-height: 90vh;
  overflow-y: auto; position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; font-size: 0.9rem; cursor: pointer;
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.modal-close:hover { color: var(--text); border-color: var(--text); }

.modal-body { display: grid; grid-template-columns: 1fr 1.2fr; gap: 0; }

.modal-left {
  background: #000;
  border-radius: 14px 0 0 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-poster {
  width: 100%;
  aspect-ratio: 460/215;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}
.modal-video {
  width: 100%;
  aspect-ratio: 460/215;
  object-fit: cover;
  display: none;
  flex-shrink: 0;
}
.modal-video.visible { display: block; }
iframe.modal-video { border: none; }

.modal-right { padding: 24px; overflow-y: auto; }
.modal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; line-height: 1.3; }
.modal-meta { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 10px; }
.modal-playtime { margin-bottom: 10px; }
.modal-playtime .badge { font-size: 0.75rem; padding: 3px 8px; }

.modal-ratings { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.rating-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; font-size: 0.78rem;
}
.rating-mc { color: #f0c040; font-weight: 700; }
.rating-steam { color: #7ec8e3; }

.modal-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.tag-chip {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 8px; font-size: 0.7rem; color: var(--text-secondary);
}
.cat-chip {
  background: var(--accent-dim); border: 1px solid rgba(79,142,247,0.3); border-radius: 4px;
  padding: 3px 8px; font-size: 0.7rem; color: var(--accent);
}

.modal-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 14px; }
.modal-reasons { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chip {
  background: var(--accent-dim); border: 1px solid rgba(79,142,247,0.3);
  border-radius: 20px; padding: 4px 10px; font-size: 0.72rem; color: var(--accent);
}

.modal-steam-btn {
  display: inline-block; background: #1b2838; color: #c6d4df;
  border: 1px solid #4c6b7a; border-radius: 6px; padding: 9px 18px;
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
  transition: background 0.15s;
}
.modal-steam-btn:hover { background: #2a3f55; color: #c6d4df; }

/* ── Responsive ── */
@media (max-width: 700px) {
  /* Layout */
  .main-content { padding: 16px 12px; }
  .profile-header { padding: 14px 16px; gap: 12px; }
  .profile-avatar { width: 44px; height: 44px; }
  .profile-name { font-size: 1.05rem; }

  /* Sections */
  .section { margin-bottom: 28px; }
  .section-header { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; }
  .section-title { flex: 1 1 100%; font-size: 1rem; }
  .section-controls { width: 100%; justify-content: flex-end; }
  .genre-select { flex: 1; max-width: 160px; }

  /* Cards */
  :root { --card-w: 140px; }
  .card-body { padding: 6px 8px; }
  .card-title { font-size: 0.75rem; }

  /* Landing */
  .landing-form { flex-direction: column; }
  .landing-tagline { font-size: 1.05rem; }
  .landing-sub { font-size: 0.85rem; }
  .landing-btn { width: 100%; }

  /* Modal */
  .modal-backdrop { padding: 12px; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-left { border-radius: 14px 14px 0 0; }
  .modal-right { padding: 16px; }
  .modal-title { font-size: 1.1rem; }

  /* Nav */
  .nav { padding: 12px 16px; }
}

@media (max-width: 420px) {
  :root { --card-w: 130px; }
  .section-controls { gap: 6px; }
  .shuffle-btn, .carousel-btn { padding: 4px 8px; font-size: 0.8rem; }
  .page-indicator { min-width: 28px; font-size: 0.7rem; }
}
