/* ==========================================================================
   GameBrain — CIO Factory dark-luxury design system
   Near-black base, brushed-gold accent, subtle grain overlay.
   Dark mode is default; light mode via [data-theme="light"] override.
   ========================================================================== */

:root {
  --gold: #c9a24b;
  --gold-soft: #e3c887;
  --gold-dim: #8a733a;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: 'Georgia', 'Iowan Old Style', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0a0908;
  --bg-elevated: #131210;
  --bg-card: #16151280;
  --bg-card-solid: #171613;
  --border: #2a2721;
  --border-soft: #201e19;
  --text-primary: #f2ede0;
  --text-secondary: #b8b0a0;
  --text-muted: #7d7568;
  --overlay-scrim: rgba(6, 5, 4, 0.72);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  --grain-opacity: 0.05;
  --input-bg: #151310;
}

[data-theme="light"] {
  --bg: #f4efe4;
  --bg-elevated: #ffffff;
  --bg-card: #ffffffcc;
  --bg-card-solid: #fffdf8;
  --border: #e3d9c2;
  --border-soft: #ece3d1;
  --text-primary: #2a2418;
  --text-secondary: #5b5343;
  --text-muted: #8c8270;
  --overlay-scrim: rgba(20, 16, 8, 0.45);
  --shadow: 0 20px 50px rgba(60, 45, 10, 0.15);
  --grain-opacity: 0.035;
  --input-bg: #ffffff;
}

* { box-sizing: border-box; }

/* Guarantee the native [hidden] attribute always wins over any display:
   rule set elsewhere (flex/grid layouts on the same element would
   otherwise out-specificity the UA stylesheet's [hidden] { display:none }). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

body {
  min-height: 100vh;
  position: relative;
}

/* ---------- Grain texture overlay ---------- */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

/* Ambient radial glow behind hero, luxury touch */
body::before {
  content: "";
  position: fixed;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 500px;
  background: radial-gradient(ellipse at center, var(--gold) 0%, transparent 70%);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border-soft);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: var(--bg);
  background: linear-gradient(135deg, var(--gold-soft), var(--gold-dim));
  box-shadow: 0 4px 14px rgba(201, 162, 75, 0.25);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.3px;
  color: var(--text-primary);
}
.brand-name em { color: var(--gold); font-style: normal; }

.search-wrap {
  position: relative;
  flex: 1 1 auto;
  max-width: 560px;
}

#search-form {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 18px;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
#search-form:focus-within {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201, 162, 75, 0.12);
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  padding: 9px 8px;
  font-family: var(--font-body);
}
#search-input::placeholder { color: var(--text-muted); }

.search-btn {
  border: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: #191510;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.search-btn:hover { background: var(--gold-soft); transform: scale(1.05); }

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 50;
  max-height: 380px;
  overflow-y: auto;
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.suggestion-item:hover, .suggestion-item.active { background: var(--bg-elevated); }
.suggestion-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--border-soft);
  flex-shrink: 0;
}
.suggestion-meta { min-width: 0; }
.suggestion-name {
  font-size: 13.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link[data-active="true"] {
  color: var(--gold);
  background: rgba(201, 162, 75, 0.1);
}

.count-pill {
  background: var(--gold);
  color: #191510;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 16px;
  text-align: center;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold-dim); }
.icon-sun { display: none; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ---------- Main / hero ---------- */
#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 80px;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 64px 0 28px;
  text-align: center;
}
.hero-compact { padding: 44px 0 24px; }

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 400;
  margin: 0 0 12px;
  letter-spacing: 0.2px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
  flex-wrap: wrap;
}

.filter-bar select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.result-count {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-muted);
}

.status-line {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}
.status-line.error { color: #d98a6c; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}

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

.game-card {
  position: relative;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.28s var(--ease), border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
  box-shadow: var(--shadow);
}

.game-card-media {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--bg-elevated);
}
.game-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease);
}
.game-card:hover .game-card-media img { transform: scale(1.06); }

.game-card-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 45%);
}

.bookmark-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(10, 9, 8, 0.55);
  backdrop-filter: blur(4px);
  color: #f2ede0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.bookmark-btn:hover { transform: scale(1.08); }
.bookmark-btn svg { pointer-events: none; }
.bookmark-btn[data-active="true"] {
  background: var(--gold);
  color: #191510;
  border-color: var(--gold);
}

.game-card-rating {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  background: rgba(10, 9, 8, 0.6);
  backdrop-filter: blur(4px);
  color: var(--gold-soft);
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
}

.game-card-body {
  padding: 12px 14px 14px;
}
.game-card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.game-card-meta span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 36px;
}
.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.ghost-btn:hover:not(:disabled) { border-color: var(--gold-dim); color: var(--gold); }
.ghost-btn:disabled { opacity: 0.35; cursor: not-allowed; }
#page-indicator { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Detail overlay ---------- */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.detail-panel {
  position: relative;
  width: 100%;
  max-width: 880px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: rise 0.35s var(--ease);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(10,9,8,0.5);
  color: #f2ede0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-hero {
  position: relative;
  aspect-ratio: 21 / 9;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  background: var(--bg-card-solid);
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg-elevated) 0%, transparent 55%);
}

.detail-body { padding: 8px 36px 36px; }

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: -46px;
  position: relative;
  z-index: 2;
}

.detail-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 6px;
  color: var(--text-primary);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 20px;
}
.tag {
  font-size: 11.5px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}
.tag-gold { color: var(--gold); border-color: var(--gold-dim); }

.detail-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-md);
}
.detail-rating strong { color: var(--gold-soft); font-size: 18px; }

.detail-desc {
  color: var(--text-secondary);
  line-height: 1.65;
  font-size: 14.5px;
  margin-bottom: 24px;
}

.detail-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-primary);
  margin: 30px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.screenshot-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.screenshot-strip img {
  height: 130px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.video-embed iframe { width: 100%; height: 100%; border: 0; }

.offers-list { display: flex; flex-wrap: wrap; gap: 10px; }
.offer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.offer-chip .price { color: var(--gold); font-weight: 700; }

.similar-strip, .news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.mini-card {
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card-solid);
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease);
}
.mini-card:hover { transform: translateY(-3px); border-color: var(--gold-dim); }
.mini-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.mini-card-title {
  font-size: 12px;
  padding: 8px 9px 10px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-item {
  grid-column: 1 / -1;
  display: flex;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  text-decoration: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.news-item:hover { border-color: var(--gold-dim); background: var(--bg-card-solid); }
.news-item img {
  width: 88px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-elevated);
}
.news-item-title { font-size: 13.5px; color: var(--text-primary); margin: 0 0 4px; line-height: 1.35; }
.news-item-meta { font-size: 11.5px; color: var(--text-muted); }

.detail-loading, .detail-error {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-elevated);
  border: 1px solid var(--gold-dim);
  color: var(--text-primary);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 30px 0 50px;
  color: var(--text-muted);
  font-size: 12px;
}
.site-footer a { color: var(--gold-dim); text-decoration: none; }
.site-footer a:hover { color: var(--gold); }

/* ---------- Skeleton loading ---------- */
.skeleton-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.skeleton-media, .skeleton-line {
  background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 37%, var(--border-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-media { aspect-ratio: 3/4; }
.skeleton-line { height: 10px; margin: 12px 14px; border-radius: 4px; }
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; }
  .search-wrap { order: 3; max-width: none; width: 100%; }
  .detail-title-row { flex-direction: column; }
  .detail-body { padding: 8px 20px 28px; }
}
