:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --text: #18202a;
  --muted: #5d6875;
  --line: #d8dde5;
  --accent: #1c6fe8;
  --accent-strong: #155ec7;
  --danger: #d44747;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1b1f24;
  --surface-soft: #22272e;
  --text: #f2f4f7;
  --muted: #a7b0bc;
  --line: #313844;
  --accent: #4b9cff;
  --accent-strong: #3b84dc;
  --danger: #ff7272;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; white-space: nowrap; }
.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
}

.header-actions, .main-nav, .site-footer nav { display: flex; align-items: center; gap: 0.8rem; }
.main-nav a, .site-footer a { color: var(--muted); font-weight: 600; }
.main-nav a:hover, .site-footer a:hover { color: var(--text); }

.search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.search-input {
  width: min(28vw, 20rem);
  min-width: 12rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

main { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 3rem; }
.hero { padding: 1.5rem 0 1rem; }
.hero h1 { margin: 0.15rem 0 0.75rem; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.05; }
.hero-copy { max-width: 640px; margin: 0; color: var(--muted); line-height: 1.6; }

.muted, .empty-state { color: var(--muted); }
.section-block { padding: 1.6rem 0 0; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.section-heading h2 { margin: 0.15rem 0 0; font-size: clamp(1.4rem, 3vw, 1.9rem); }

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-list { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.category-chip, .text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.category-chip.is-active {
  border-color: var(--accent);
  background: rgba(75, 156, 255, 0.12);
  color: var(--accent);
}

.text-button, .theme-toggle { color: var(--muted); }
.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
}

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.85rem; }
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

.game-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.game-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-soft);
}
.game-card-body { display: grid; gap: 0.65rem; padding: 0.8rem; }
.game-title { margin: 0; min-height: 2.5rem; font-size: 1rem; line-height: 1.25; }
.game-category { margin: -0.3rem 0 0; color: var(--muted); font-size: 0.85rem; }
.card-actions { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }

.primary-button, .favorite-button { border: 0; border-radius: 8px; cursor: pointer; font-weight: 700; }
.primary-button { padding: 0.68rem 0.95rem; background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-strong); }
.favorite-button {
  min-width: 2.8rem;
  padding: 0.68rem;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}
.favorite-button.is-favorite { border-color: rgba(255, 114, 114, 0.6); color: var(--danger); }

.empty-state { display: none; margin: 1rem 0 0; padding: 0.9rem; border: 1px dashed var(--line); border-radius: 8px; }
.empty-state.is-visible { display: block; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-footer p { margin: 0; color: var(--muted); }

.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 1rem; }
.modal.is-open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); }
.modal-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(18rem, 1fr) auto;
  width: min(1040px, 100%);
  height: min(740px, 92vh);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.modal-header, .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--surface-soft);
}
.modal-header h2 { margin: 0; font-size: 1rem; }
.icon-button {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
iframe { width: 100%; height: 100%; border: 0; background: #000; }

.content-page { max-width: 900px; padding: 1.25rem 0 4rem; }
.content-page h2 { margin: 1.5rem 0 0.5rem; font-size: 1.35rem; }
.content-page p, .content-page li { color: var(--muted); line-height: 1.7; }
.content-page ul { padding-left: 1.25rem; }

.contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(18rem, 1fr);
  gap: 1.5rem;
  max-width: 1050px;
}
.contact-form {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.contact-form label { display: grid; gap: 0.45rem; color: var(--text); font-weight: 700; }
.contact-form input, .contact-form select, .contact-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.8rem;
  background: var(--surface-soft);
  color: var(--text);
}

@media (max-width: 780px) {
  .site-header { align-items: stretch; gap: 0.8rem; }
  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "search search" "nav theme";
    gap: 0.65rem;
    align-items: center;
  }
  .search-input { grid-area: search; width: 100%; min-width: 0; }
  .main-nav { grid-area: nav; width: 100%; flex-wrap: wrap; }
  .theme-toggle { grid-area: theme; justify-self: end; min-width: 2.4rem; }
  .site-footer { align-items: stretch; flex-direction: column; }
  .site-footer nav { width: 100%; flex-wrap: wrap; }
  .section-heading { align-items: start; flex-direction: column; }
  .contact-layout { grid-template-columns: 1fr; }
}
