:root {
  color-scheme: light;
  --ink: #141312;
  --muted: #6a625c;
  --paper: #f8f2e7;
  --panel: #fffaf0;
  --line: #dfd2c2;
  --gold: #c9912d;
  --coral: #c94254;
  --teal: #087d75;
  --blue: #275d8a;
  --violet: #6045a1;
  --shadow: 0 18px 50px rgba(31, 24, 18, 0.14);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f7efe4;
  --muted: #c9bdb0;
  --paper: #15110e;
  --panel: #211b16;
  --line: #3c3129;
  --gold: #e0ac42;
  --coral: #ef6676;
  --teal: #43b8aa;
  --blue: #72a5d4;
  --violet: #a18be4;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(201, 145, 45, 0.09) 1px, transparent 1px),
    linear-gradient(0deg, rgba(8, 125, 117, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px, 48px 48px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 14px 5vw;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  background: color-mix(in srgb, var(--paper), transparent 6%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small,
.eyebrow,
.featured-caption span,
.site-footer {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.topnav a {
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
  background: color-mix(in srgb, var(--line), transparent 54%);
  outline: none;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button.active {
  border-color: var(--ink);
  outline: none;
}

main {
  overflow: hidden;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
  align-items: center;
  gap: 46px;
  min-height: 560px;
  padding: 56px 5vw 40px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--coral), transparent 88%), transparent 34%),
    linear-gradient(315deg, color-mix(in srgb, var(--teal), transparent 88%), transparent 38%);
}

.stage-copy {
  max-width: 650px;
}

.eyebrow {
  margin: 0 0 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: 64px;
  line-height: 0.96;
}

h2 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.08;
}

.lede {
  max-width: 560px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.7;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button.primary {
  background: var(--ink);
  color: var(--paper);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  outline: none;
}

.featured {
  display: grid;
  gap: 18px;
  justify-items: stretch;
}

.featured img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.featured-caption {
  display: grid;
  gap: 6px;
  padding: 0 4px;
}

.featured-caption strong {
  font-size: 28px;
}

.featured-caption p {
  margin-bottom: 0;
  color: var(--muted);
}

.controls-band,
.category-row,
.library-head,
.games-grid,
.site-footer {
  padding-right: 5vw;
  padding-left: 5vw;
}

.controls-band {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px 160px auto;
  gap: 12px;
  align-items: end;
  padding-top: 28px;
  padding-bottom: 16px;
}

.search-field,
.select-field {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.search-field {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 15px;
}

.search-field svg {
  width: 21px;
  color: var(--muted);
}

.search-field input,
.select-field select {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.search-field input::placeholder {
  color: color-mix(in srgb, var(--muted), transparent 22%);
}

.select-field {
  display: grid;
  gap: 2px;
  padding: 7px 12px 6px;
}

.select-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.view-switch {
  display: flex;
  gap: 8px;
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 0;
  padding-bottom: 24px;
}

.category-row button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.category-row button:hover,
.category-row button:focus-visible,
.category-row button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.library-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
}

.library-head #resultsMeta {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 800;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding-bottom: 58px;
}

.game-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-height: 390px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(35, 24, 16, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--ink), transparent 30%);
  box-shadow: var(--shadow);
}

.game-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #111;
}

.game-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.game-card:hover .game-media img {
  transform: scale(1.035);
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 8px;
  border-radius: 5px;
  background: rgba(20, 19, 18, 0.78);
  color: #fff7ea;
  font-size: 12px;
  font-weight: 900;
}

.favorite {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 6px;
  background: rgba(20, 19, 18, 0.62);
  color: #fff7ea;
  cursor: pointer;
}

.favorite svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.favorite.active {
  background: var(--gold);
  color: #16110d;
}

.card-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.card-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.card-body h3 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.difficulty {
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.card-body p {
  min-height: 48px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  margin-top: auto;
}

.card-actions .button {
  min-height: 42px;
}

.card-actions .icon-button {
  width: 42px;
  height: 42px;
}

.games-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.games-grid.compact .game-card {
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: 1fr;
  min-height: 220px;
}

.games-grid.compact .game-media {
  height: 100%;
  aspect-ratio: auto;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: color-mix(in srgb, var(--panel), transparent 22%);
  font-weight: 800;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  padding-top: 24px;
  padding-bottom: 24px;
  border-top: 1px solid var(--line);
  background: var(--ink);
  color: color-mix(in srgb, var(--paper), transparent 22%);
}

.site-footer a {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.legal-page {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 54px 5vw 72px;
}

.legal-hero {
  max-width: 760px;
  margin-bottom: 30px;
}

.legal-hero h1 {
  margin-bottom: 14px;
  font-size: 54px;
  line-height: 1;
}

.legal-hero p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.license-list {
  display: grid;
  gap: 14px;
}

.license-card {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.license-card h2 {
  font-size: 24px;
}

.license-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.license-card a {
  color: var(--ink);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 1180px) {
  .games-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .topnav {
    display: none;
  }

  .stage {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 38px;
  }

  h1 {
    font-size: 46px;
  }

  .controls-band {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .view-switch {
    justify-content: end;
  }

  .games-grid,
  .games-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .games-grid.compact .game-card {
    grid-template-columns: 1fr;
  }

  .games-grid.compact .game-media {
    aspect-ratio: 16 / 10;
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 10px;
    padding: 10px 16px;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    display: none;
  }

  .stage,
  .controls-band,
  .category-row,
  .library-head,
  .games-grid,
  .site-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  h1 {
    font-size: 40px;
    line-height: 1.02;
  }

  .lede {
    font-size: 17px;
  }

  .featured-caption strong {
    font-size: 24px;
  }

  .controls-band,
  .games-grid,
  .games-grid.compact {
    grid-template-columns: 1fr;
  }

  .legal-page {
    padding-right: 16px;
    padding-left: 16px;
  }

  .legal-hero h1 {
    font-size: 40px;
  }

  .select-field,
  .search-field {
    min-height: 50px;
  }

  .library-head {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .game-card {
    min-height: 0;
  }
}
