:root {
  color-scheme: dark;
  --background: #0d1119;
  --surface: #131a25;
  --border: #293545;
  --text: #f0f4f3;
  --muted: #aebbc9;
  --accent: #a9f4c6;
  font-family: system-ui, "Microsoft YaHei UI", sans-serif;
  line-height: 1.6;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 0;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.shell {
  width: min(calc(100% - 3rem), 75rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid #202a38;
}

.header-inner {
  display: grid;
  min-height: 4.5rem;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 1.5rem;
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand img {
  display: block;
  width: 2.65rem;
  height: auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.2rem);
}

.site-nav a,
.repo-link {
  display: inline-grid;
  min-height: 2.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.site-nav a[aria-current="page"],
.site-nav a:hover,
.repo-link:hover {
  color: var(--accent);
}

.repo-link {
  justify-self: end;
}

.hero {
  position: relative;
  display: flex;
  min-height: clamp(22rem, 34vw, 28rem);
  align-items: center;
  overflow: hidden;
  margin-top: clamp(1.25rem, 3vw, 2.25rem);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: #060d20;
}

.hero-art {
  position: absolute;
  inset: 0;
}

.hero-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.hero-art::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #060d20 1%, #060d20dc 24%, #060d2033 55%, transparent 70%);
  content: "";
}

.hero-copy {
  position: relative;
  padding: clamp(2rem, 5.2vw, 4.5rem);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.65rem, 5vw, 4.5rem);
  font-weight: 850;
  line-height: 1.15;
}

.hero h1 span {
  color: var(--accent);
}

.hero-description {
  max-width: 23em;
  margin: 1.25rem 0 1.65rem;
  color: #c8d4e2;
  font-size: clamp(1rem, 1.4vw, 1.125rem);
}

.primary-link,
.secondary-link {
  display: inline-flex;
  width: fit-content;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.primary-link {
  min-height: 3rem;
  padding-inline: 1.2rem;
  background: var(--accent);
  color: #13271e;
  font-size: 1rem;
}

.primary-link:hover {
  background: #ceffdf;
}

.secondary-link {
  border-color: #405064;
  background: #182230;
}

.secondary-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.text-link {
  color: var(--collection-accent, var(--accent));
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 50%, transparent);
  text-underline-offset: 0.23em;
}

.text-link:hover {
  text-decoration-color: currentColor;
}

.library {
  margin-top: clamp(2rem, 3.5vw, 2.75rem);
  scroll-margin-block-start: 1.5rem;
}

.section-title {
  margin: 0 0 1rem;
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.3;
}

.library-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

.library-heading .section-title {
  margin-bottom: 0;
}

.game-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.game-count strong {
  color: var(--collection-accent, var(--accent));
}

[data-game-category="open-source"],
.open-source-intro,
.weekly-list {
  --collection-accent: #f6ca8c;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.catalog-panel,
.page-intro,
.weekly-entry {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
}

.catalog-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  border-top-color: color-mix(in srgb, var(--collection-accent, var(--accent)) 50%, var(--border));
}

.catalog-panel h3 {
  margin: 0;
  color: var(--collection-accent, var(--accent));
  font-size: 1.45rem;
  line-height: 1.3;
}

.catalog-panel > p,
.page-intro > p {
  margin: 0.55rem 0 1.25rem;
  color: var(--muted);
}

.catalog-actions,
.game-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.catalog-actions {
  margin-top: auto;
  padding-top: 1.25rem;
}

.page-intro {
  margin-top: clamp(1.25rem, 3vw, 2.25rem);
  padding: clamp(1.5rem, 5vw, 3.5rem);
  background: radial-gradient(ellipse at top right, color-mix(in srgb, var(--collection-accent, var(--accent)) 16%, var(--surface)), var(--surface) 65%);
}

.page-intro h1 {
  margin: 0;
  color: var(--collection-accent, var(--accent));
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  line-height: 1.2;
}

.page-intro > p {
  max-width: 42rem;
  margin-top: 0.9rem;
}

.weekly-list {
  display: grid;
  max-width: 53rem;
  gap: 1rem;
}

.weekly-entry {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.weekly-entry h2 {
  margin: 0;
  font-size: 1.5rem;
}

.weekly-entry .weekly-date {
  margin-top: 0.3rem;
  color: var(--muted);
}

.weekly-entry p:last-child {
  margin-bottom: 0;
}

.weekly-entry .text-link {
  font-size: inherit;
}

.cartridge {
  position: relative;
  width: 1.55rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-radius: 0.23rem 0.23rem 0.12rem 0.12rem;
}

.cartridge::before,
.cartridge::after {
  position: absolute;
  inset-inline: 0.2rem;
  background: currentColor;
  content: "";
}

.cartridge::before {
  top: 0.2rem;
  height: 0.32rem;
  border-radius: 0.06rem;
}

.cartridge::after {
  right: 0.55rem;
  bottom: 0.18rem;
  height: 1px;
}

.game-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.game-description,
.game-status {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--surface);
}

.game-thumbnail {
  position: relative;
  display: grid;
  aspect-ratio: 16 / 9;
  place-items: center;
  background: radial-gradient(circle, color-mix(in srgb, currentColor 16%, #0d1420), #0d1420 76%);
  color: var(--collection-accent, var(--accent));
}

.game-thumbnail .cartridge {
  scale: 1.5;
}

.game-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-details {
  padding: 1.1rem;
  overflow-wrap: anywhere;
}

.game-actions:has(a:not([hidden])) {
  margin-top: 0.8rem;
}

.catalog-panel .game-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
}

.catalog-panel .game-card {
  display: grid;
  min-height: 4.5rem;
  grid-template-columns: min(4.5rem, 24%) minmax(0, 1fr);
  border-radius: 0.65rem;
  background: #101722;
}

.catalog-panel .game-thumbnail {
  aspect-ratio: auto;
}

.catalog-panel .game-thumbnail .cartridge {
  scale: 1;
}

.catalog-panel .game-details {
  padding: 0.65rem 0.8rem;
}

.play-page {
  margin-top: clamp(1.25rem, 3vw, 2.25rem);
}

.play-page h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4.5vw, 3.25rem);
  line-height: 1.15;
}

.play-page p {
  margin: 0.65rem 0 1rem;
  color: var(--muted);
}

.play-frame {
  display: block;
  width: 100%;
  height: clamp(25rem, 70vw, 42rem);
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--surface);
}

.play-page .play-credits {
  margin-top: 1.15rem;
  margin-bottom: 0.4rem;
}

.play-links {
  padding-top: 0;
}

.site-footer {
  margin-top: clamp(2rem, 4vw, 3.25rem);
  padding-block: 1.25rem 1.75rem;
  border-top: 1px solid #202a38;
  color: var(--muted);
}

.site-footer small {
  font-size: 0.875rem;
}

@media (max-width: 47rem) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-copy {
    order: -1;
    padding: 1.65rem 1.5rem 0.7rem;
  }

  .hero-art {
    position: relative;
    height: clamp(12rem, 48vw, 19rem);
  }

  .hero-art::after {
    background: linear-gradient(180deg, #060d20, transparent 36%);
  }
}

@media (max-width: 34rem) {
  .shell {
    width: calc(100% - 2rem);
  }

  .header-inner {
    min-height: 4rem;
    grid-template-columns: 1fr auto auto;
    column-gap: 0.75rem;
  }

  .brand {
    gap: 0.35rem;
    font-size: 0.95rem;
  }

  .brand img {
    width: 1.8rem;
  }

  .site-nav {
    gap: 0.65rem;
  }
}

@media (max-width: 24rem) {
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .brand,
  .repo-link {
    min-height: 3.25rem;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 1.4rem;
  }
}

@media (max-width: 22rem) {
  .hero h1 {
    font-size: 2.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .primary-link,
  .secondary-link {
    transition: none;
  }
}
