:root {
  --bg: #0b0d14;
  --bg-elev: #12151f;
  --card: #161a26;
  --card-hover: #1c2131;
  --border: #232838;
  --text: #eef0f6;
  --text-dim: #9099b0;
  --text-faint: #5b637a;
  --accent: #7c5cff;
  --accent-2: #33d6c0;
  --new-badge: #ff5c7a;
  --star: #ffc94d;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html.modal-open, html.modal-open body {
  overflow: hidden;
  overscroll-behavior: contain;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(124,92,255,0.16), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(51,214,192,0.12), transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; }

header {
  padding: 40px 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(124,92,255,0.4);
  flex-shrink: 0;
}

h1 {
  font-size: 26px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-row a.logo-link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }

.subtitle {
  color: var(--text-dim);
  margin: 6px 0 0 56px;
  font-size: 14.5px;
}

.controls {
  max-width: 1200px;
  margin: 28px auto 0;
  padding: 0 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

select, button {
  font-family: inherit;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

select:hover, button:hover { border-color: #3a4160; }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}

.tab {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), #6a4bff);
  color: white;
}

.filter-pills {
  display: flex;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}

.pill {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  white-space: nowrap;
}

.pill.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border) inset;
}

.status-bar {
  max-width: 1200px;
  margin: 18px auto 0;
  padding: 0 32px;
  color: var(--text-faint);
  font-size: 13px;
  min-height: 18px;
}

main {
  max-width: 1200px;
  margin: 20px auto 60px;
  padding: 0 32px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform .15s, border-color .15s, background .15s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #3a4160;
  background: var(--card-hover);
}

.card-top { display: flex; gap: 12px; align-items: flex-start; }

.icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--bg-elev);
  flex-shrink: 0;
}

.card-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.card-dev { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.badge.new {
  background: rgba(255,92,122,0.15);
  color: var(--new-badge);
  border-color: rgba(255,92,122,0.3);
}

.badge.rating { color: var(--star); border-color: rgba(255,201,77,0.25); background: rgba(255,201,77,0.08); }
.badge.installs { color: var(--accent-2); border-color: rgba(51,214,192,0.25); background: rgba(51,214,192,0.08); }

.meta-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

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

.loading .spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error { color: var(--new-badge); }

/* Modal (home page quick view) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,5,10,0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 880px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header, .detail-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 24px 24px 16px;
}

/* Keep the close button reachable even when modal content scrolls */
.modal .modal-header {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
  border-radius: 20px 20px 0 0;
}

.modal-icon, .detail-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--bg-elev);
  flex-shrink: 0;
}

.modal-title, .detail-title { font-size: 19px; font-weight: 700; line-height: 1.3; }
.modal-dev, .detail-dev { font-size: 13.5px; color: var(--text-dim); margin-top: 4px; }

.modal-close {
  margin-left: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--text-dim);
  flex-shrink: 0;
}

.modal-stats, .detail-stats {
  display: flex;
  gap: 10px;
  padding: 0 24px 16px;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.stat-chip b { color: var(--text); font-size: 13.5px; }

.modal-screens, .detail-screens {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 24px 20px;
  scrollbar-width: thin;
}

.modal-screens img, .detail-screens img {
  height: 260px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--bg-elev);
}

.modal-desc, .detail-desc {
  padding: 0 24px 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-line;
}

.modal-footer, .detail-footer {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}

.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent-2), #16a894);
  color: #04231f;
  font-weight: 700;
  font-size: 14.5px;
  padding: 13px;
  border-radius: 12px;
  text-decoration: none;
}

.play-btn:hover { filter: brightness(1.06); }

/* Standalone game detail page */
.detail-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--accent-2); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.related-section {
  max-width: 720px;
  margin: 32px auto 0;
  padding: 0 20px;
}

.related-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

.related-list { display: flex; flex-direction: column; gap: 8px; }

.related-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, background .15s;
}

.related-item:hover { border-color: #3a4160; background: var(--card-hover); }

.related-item img { width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0; background: var(--bg-elev); }
.related-item span { font-size: 13.5px; font-weight: 600; }

/* Theme is intentionally fixed to dark on every device — no light-mode
   variant, so the site looks identical regardless of system settings. */

/* Mobile */
@media (max-width: 640px) {
  header {
    padding: 24px 16px 16px;
  }

  .logo {
    width: 36px;
    height: 36px;
    font-size: 19px;
    border-radius: 10px;
  }

  h1 { font-size: 21px; }

  .subtitle {
    margin-left: 0;
    margin-top: 10px;
    font-size: 13.5px;
  }

  .controls {
    padding: 0 16px;
    gap: 8px;
  }

  .tabs, .filter-pills {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .tab { padding: 7px 12px; font-size: 12.5px; white-space: nowrap; }
  .pill { padding: 7px 11px; font-size: 12.5px; }

  .status-bar { padding: 0 16px; }

  main { padding: 0 12px; margin: 16px auto 40px; }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card {
    padding: 12px 10px;
    gap: 8px;
    align-items: center;
    text-align: center;
    border-radius: 16px;
  }

  .card-top { flex-direction: column; align-items: center; gap: 8px; }

  .card .icon { width: 68px; height: 68px; border-radius: 16px; }

  .card-title {
    font-size: 13px;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .card-dev, .card .meta-row, .card .badge-row .badge:not(.rating):not(.new):not(.installs) {
    display: none;
  }

  .card .badge-row {
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
  }

  .card .badge {
    font-size: 10px;
    padding: 3px 6px;
  }

  .modal-backdrop { padding: 0; align-items: flex-end; }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }

  .modal-header, .detail-header {
    padding: 18px 16px 12px;
    gap: 10px;
  }

  .modal-icon, .detail-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }

  .modal-title, .detail-title { font-size: 16.5px; }

  .modal-stats, .detail-stats { padding: 0 16px 12px; gap: 6px; }
  .stat-chip { padding: 6px 10px; font-size: 11.5px; }

  .modal-screens, .detail-screens { padding: 0 16px 16px; }
  .modal-screens img, .detail-screens img { height: 180px; }

  .modal-desc, .detail-desc { padding: 0 16px 16px; font-size: 13px; }

  .modal-footer, .detail-footer { padding: 12px 16px 20px; }

  .detail-page { padding: 20px 14px 48px; }
  .related-section { padding: 0 14px; }
}
