:root {
  --bg: #13141a;
  --surface: #1d1f28;
  --surface-2: #272a36;
  --text: #eef0f5;
  --muted: #9aa0b4;
  --border: #2f3342;
  --accent: #ff6b4a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  padding: 56px 0 40px;
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 55%),
    var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -0.02em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 1.15rem; }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.kofi { flex: 0 0 auto; }

.about { max-width: 70ch; color: var(--muted); margin: 28px 0 8px; white-space: pre-line; }
.about:empty { display: none; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 24px 0; }
.toolbar input, .toolbar select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.toolbar input { flex: 1 1 240px; min-width: 0; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.count { color: var(--muted); font-size: 0.9rem; margin-left: auto; }

/* Grid of game cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 22px;
  padding-bottom: 56px;
}
.card {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--surface-2); }
.card-body { padding: 12px 14px 16px; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; line-height: 1.3; }
.card .meta { font-size: 0.85rem; }

.meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 12px; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text); font-size: 0.8rem;
}
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* Detail popup */
dialog {
  width: min(960px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  overflow: auto;
}
dialog::backdrop { background: rgba(5, 6, 10, .75); backdrop-filter: blur(3px); }
.close {
  position: sticky; top: 10px; float: right; margin: 10px 10px -50px 0; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.6); color: #fff; font-size: 1.6rem; line-height: 1;
}
.close:hover { background: var(--accent); }

.d-media { background: #000; }
#d-main { width: 100%; max-height: 60vh; object-fit: contain; display: block; }
.thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; background: var(--surface-2); }
.thumbs:empty { display: none; }
.thumbs button {
  all: unset; cursor: pointer; flex: 0 0 auto; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; opacity: .65;
}
.thumbs button[aria-current="true"], .thumbs button:hover { opacity: 1; border-color: var(--accent); }
.thumbs img { width: 120px; height: 68px; object-fit: cover; display: block; }

.d-body { padding: 22px 26px 28px; }
.d-body h2 { margin: 0 0 8px; font-size: 1.8rem; line-height: 1.2; }
.desc p { margin: 14px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.links a {
  text-decoration: none; font-weight: 600; color: #fff;
  background: var(--accent); padding: 10px 18px; border-radius: 10px;
}
.links a:hover { filter: brightness(1.12); }

/* Privacy policy pages */
.site-header.small { padding: 28px 0 30px; }
.site-header.small .wrap { max-width: 760px; }
.site-header.small h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.2; margin-top: 14px; }
.back { color: var(--muted); text-decoration: none; font-size: .95rem; }
.back:hover { color: var(--text); }
.policy { max-width: 760px; padding-top: 12px; padding-bottom: 56px; }
.policy h2 { font-size: 1.25rem; margin: 34px 0 6px; }
.policy p { margin: 10px 0 0; color: #d4d7e2; }
.policy ul { margin: 10px 0 0; padding-left: 22px; color: #d4d7e2; }
.policy li { margin: 4px 0; }
.policy a, .site-footer a { color: var(--accent); }
.policy-list { list-style: none; padding: 0 !important; display: grid; gap: 10px; margin-top: 24px !important; }
.policy-list a {
  display: block; padding: 14px 18px; border-radius: 10px; text-decoration: none; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.policy-list a:hover { border-color: var(--accent); }
.privacy-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: .9rem; }
.privacy-link:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); padding: 22px 0; font-size: .9rem; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 10px; }
  .d-body { padding: 18px 16px 22px; }
  .count { margin-left: 0; }
}
