/*
Theme Name: SwitchROMs Knowledge
Theme URI: https://example.com
Author: Freebuff
Author URI: https://example.com
Description: A clean, white-mode Nintendo Switch ROMs information and knowledge platform. Semantic SEO-first architecture with comprehensive ROM metadata, compatibility data, and structured data.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: switch-roms
Tags: gaming, custom-menu, featured-images, theme-options, translation-ready
*/

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
  /* Core palette — light / white mode only */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f5f6f8;
  --color-bg-tertiary: #eceef1;
  --color-bg-card: #ffffff;
  --color-bg-card-hover: #f5f6f8;
  --color-bg-input: #f0f1f4;

  /* Accent - Red Nintendo-inspired (used sparingly) */
  --color-accent: #e60012;
  --color-accent-hover: #c5000f;
  --color-accent-soft: rgba(230, 0, 18, 0.08);
  --color-accent-medium: rgba(230, 0, 18, 0.15);

  /* Secondary accent - Blue */
  --color-blue: #0070f3;
  --color-blue-hover: #1a8aff;
  --color-blue-soft: rgba(0, 112, 243, 0.08);

  /* Tertiary accent - Green */
  --color-green: #1a8f4f;
  --color-green-soft: rgba(26, 143, 79, 0.10);

  /* Yellow warning */
  --color-yellow: #b7791f;
  --color-yellow-soft: rgba(183, 121, 31, 0.10);

  /* Text */
  --color-text-primary: #1a1a1f;
  --color-text-secondary: #4a4a55;
  --color-text-tertiary: #76768a;
  --color-text-inverse: #ffffff;

  /* Borders */
  --color-border: #e3e5ea;
  --color-border-light: #eef0f3;
  --color-border-hover: #cdd0d8;

  /* Format badges (subtle) */
  --color-nsp: #6d3bdb;
  --color-nsp-soft: rgba(109, 59, 219, 0.10);
  --color-xci: #0288a8;
  --color-xci-soft: rgba(2, 136, 168, 0.10);
  --color-nsz: #c2410c;
  --color-nsz-soft: rgba(194, 65, 12, 0.10);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 3rem;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-display: 'Inter', sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 1.75rem;
  --text-5xl: 2rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows — soft, light */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 0 0 rgba(0, 0, 0, 0);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --container-max: 1280px;
  --container-narrow: 900px;
  /* ROM cards render at 80% of the former size: the grid column is capped so
     each of the three cards lands at ~320px. Used by the ROM listing pages. */
  --container-rom-grid: 992px;
  --container-rom-listing: 1040px;
  --sidebar-width: 280px;
  --header-height: 64px;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: var(--color-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--color-blue-hover);
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-4xl); margin-bottom: var(--space-lg); }
h2 { font-size: var(--text-3xl); margin-bottom: var(--space-md); margin-top: var(--space-3xl); }
h3 { font-size: var(--text-2xl); margin-bottom: var(--space-md); margin-top: var(--space-2xl); }
h4 { font-size: var(--text-xl); margin-bottom: var(--space-sm); margin-top: var(--space-xl); }

p {
  margin-bottom: var(--space-md);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

ul, ol {
  list-style: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

/* ============================================
   LAYOUT UTILITIES
   ============================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  padding: var(--space-4xl) 0;
}

.section--alt {
  background-color: var(--color-bg-secondary);
}

.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2,
.grid-3,
.grid-4 { grid-template-columns: 1fr; }
.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ROM listings render at 80% of the full content width: the grid is capped
   and centred, which shrinks each card to ~320px while keeping the 3-up
   rhythm. Applies to every ROM grid (homepage, archive, taxonomies, search,
   related) so the cards stay the same size everywhere. Card grids that hold
   plain .card items are deliberately left at full width. */
.grid.grid-3:has(> .rom-card) {
  max-width: var(--container-rom-grid);
  margin-left: auto;
  margin-right: auto;
}

/* Keep the section heading that introduces a ROM grid on the same edge as
   the cards, so the capped grid never looks accidentally off-centre. */
.section:has(.grid.grid-3 > .rom-card) > .container > .section-header {
  max-width: var(--container-rom-grid);
  margin-left: auto;
  margin-right: auto;
}

/* The homepage "From the Blog" grid mirrors the ROM grid width, so its heading
   and cards line up with the "Popular Game ROMs" section above it. */
.grid.blog-grid {
  max-width: var(--container-rom-grid);
  margin-left: auto;
  margin-right: auto;
}

.section.blog-section > .container > .section-header {
  max-width: var(--container-rom-grid);
  margin-left: auto;
  margin-right: auto;
}

/* On ROM listing pages the headings, filter tools and breadcrumbs share the
   cards' column instead of hanging out to the left of it. Scoped to <main>,
   so the header and footer keep the full site width. */
.post-type-archive-rom main .container,
.search main .container,
.tax-emulator main .container,
[class*="tax-rom_"] main .container {
  max-width: var(--container-rom-listing);
}

.flex {
  display: flex;
  align-items: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-gap-sm { gap: var(--space-sm); }
.flex-gap-md { gap: var(--space-md); }
.flex-gap-lg { gap: var(--space-lg); }

/* ============================================
   HEADER / NAVIGATION
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0f1117;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #1f2230;
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--text-xl);
  font-weight: var(--weight-extrabold);
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-brand span {
  color: #ffffff;
}

.main-nav {
  display: none;
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  flex-direction: column;
  background: #0f1117;
  border-bottom: 1px solid #1f2230;
  padding: var(--space-md);
  gap: var(--space-xs);
  box-shadow: var(--shadow-lg);
  z-index: 90;
}

.main-nav.is-open {
  display: flex;
}

.main-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  width: 100%;
}

.main-nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.main-nav a.active {
  color: #ffffff;
  background: var(--color-accent);
}

/* Header dropdown (Genres) */
.nav-dropdown {
  position: relative;
}

.nav-drop-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-drop-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-caret {
  font-size: 10px;
  transition: transform var(--transition-fast);
}

.nav-dropdown.is-open .nav-caret {
  transform: rotate(180deg);
}

.nav-drop-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: 120;
}

.nav-dropdown.is-open .nav-drop-menu {
  display: block;
}

.nav-drop-menu a {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

.nav-drop-menu a:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.nav-drop-empty {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
}

/* Hero search (homepage) — large, dominant; buttons wrap below */
.hero-search {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.hero-search input {
  flex: 1 1 280px;
  padding: 16px 18px 16px 48px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-lg);
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition-fast);
}

.hero-search input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.hero-search input::placeholder {
  color: var(--color-text-tertiary);
}

.hero-search__icon {
  position: absolute;
  left: 16px;
  top: 28px;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.hero-search .btn {
  padding: 12px 24px;
  font-size: var(--text-base);
}

/* Compact browse buttons under the hero search */
.hero-actions .btn {
  padding: 5px 12px;
}

/* Mobile hamburger */
.menu-toggle {
  display: block;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: var(--space-sm);
  font-size: var(--text-xl);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: var(--space-4xl) 0 var(--space-xl);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3xl);
  margin-bottom: var(--space-3xl);
}

.footer-brand {
  /* The brand is a link home, so it needs to sit on its own line like the
     block element it replaced. */
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
  transition: color var(--transition-fast);
}

.footer-brand span:last-child {
  color: var(--color-accent);
}

.footer-brand:hover,
.footer-brand:hover span:last-child {
  color: var(--color-accent-hover);
}

.footer-desc {
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.footer-col h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-lg);
}

.footer-col ul li {
  margin-bottom: var(--space-sm);
}

.footer-col ul li a {
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-col ul li a:hover {
  color: var(--color-text-primary);
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  text-align: center;
}

.footer-bottom p {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin: 0;
}

/* ============================================
   BREADCRUMBS
   ============================================ */
.breadcrumbs {
  padding: var(--space-md) 0;
  font-size: var(--text-sm);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumbs li:not(:last-child)::after {
  content: '›';
  color: var(--color-text-tertiary);
  margin-left: var(--space-xs);
}

.breadcrumbs a {
  color: var(--color-text-tertiary);
}

.breadcrumbs a:hover {
  color: var(--color-accent);
}

.breadcrumbs .current {
  color: var(--color-text-secondary);
}

/* ============================================
   CARDS
   ============================================ */
 .card {
   position: relative;
   background: var(--color-bg-card);
   border: 1px solid var(--color-border);
   border-radius: var(--radius-lg);
   overflow: hidden;
   transition: all var(--transition-base);
 }

 /* Stretched link: makes the whole card clickable when it contains a link */
 .stretched-link::after {
   content: "";
   position: absolute;
   inset: 0;
   z-index: 1;
 }

.card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-body {
  padding: var(--space-md);
}

/* ROM Card — reference-style box: dark badges, centered title,
   inset rounded image, then the meta row. */
.rom-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.05);
}

.rom-card:hover {
  background: var(--color-bg-card);
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.07), 0 14px 32px rgba(15, 23, 42, 0.10);
}

/* Dark pill badges sit above the title (not overlaid on the image). */
.rom-card__badges {
  position: static;
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.rom-card .badge {
  background: #16233f;
  color: #ffffff;
  border-color: #16233f;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--weight-bold);
  font-size: 0.7rem;
}

.rom-card .rom-card__image {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
}

.rom-card .rom-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.rom-card:hover .rom-card__image img {
  transform: scale(1.04);
}

.rom-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-4xl);
  color: var(--color-text-tertiary);
}

.rom-card__title {
  text-align: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Reserve two lines so covers and meta rows line up across a row. */
  min-height: calc(2 * var(--leading-tight) * 1em);
}

.rom-card__title a {
  color: var(--color-text-primary);
}

.rom-card__title a:hover {
  color: var(--color-accent);
}

.rom-card__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.rom-card__meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}


/* Lead image on a ROM post: the featured image, shown directly under the
   title (it doubles as the post's first screenshot). */
.rom-lead-image {
  margin: var(--space-lg) 0 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  aspect-ratio: 16 / 9;
}

.rom-lead-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   ROM AD SLOT (banner + button)
   ============================================ */
.rom-ad {
  margin-top: var(--space-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  text-align: center;
}

.rom-ad__banner {
  display: block;
  width: 100%;
  line-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.rom-ad__banner img {
  display: block;
  width: 100%;
  height: auto;
}

/* Pasted ad network snippet: let it manage its own size and centring. */
.rom-ad__code {
  width: 100%;
  text-align: center;
  overflow: hidden;
}

.rom-ad__code ins,
.rom-ad__code iframe,
.rom-ad__code img {
  max-width: 100%;
  margin: 0 auto;
}

/* The button is wider than its label, so it needs its own centring on top of
   the centring of the .rom-ad wrapper. */
.rom-ad__button {
  min-width: 200px;
  align-self: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* ============================================
   ROM RATING (visitor stars)
   ============================================ */
.rom-rating {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md) var(--space-xl);
}

.rom-rating__summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.rom-rating__stars-static,
.rom-rating__pick {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.rom-star {
  color: var(--color-border-hover);
  font-size: var(--text-lg);
  line-height: 1;
}

.rom-star.is-filled {
  color: #f5a524;
}

.rom-rating__value {
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  font-size: var(--text-base);
}

.rom-rating__count {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.rom-rating__prompt {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.rom-rating__prompt[hidden] {
  display: none;
}

.rom-rating__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.rom-rating__pick {
  gap: 0;
}

.rom-rating__star {
  background: none;
  border: none;
  padding: 0 1px;
  font-size: var(--text-2xl);
  line-height: 1;
  color: var(--color-border-hover);
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.rom-rating__star:hover,
.rom-rating__star.is-hover,
.rom-rating__star.is-picked {
  color: #f5a524;
  transform: translateY(-1px);
}

.rom-rating__thanks,
.rom-rating__note,
.rom-rating__error {
  font-size: var(--text-sm);
  margin: 0;
  color: var(--color-green);
}

.rom-rating__note {
  color: var(--color-text-tertiary);
  margin-left: auto;
}

.rom-rating__error {
  color: var(--color-accent);
}

.rom-rating__thanks[hidden],
.rom-rating__note[hidden],
.rom-rating__error[hidden] {
  display: none;
}

.rom-rating.is-thanks .rom-rating__prompt {
  display: none;
}

@media (max-width: 767px) {
  .rom-rating__prompt {
    margin-left: 0;
    width: 100%;
  }
}

/* Entity Card (generic) */
.entity-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
}

.entity-card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-card-hover);
}

.entity-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.entity-card__info h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: 2px;
  margin-top: 0;
}

.entity-card__info p {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin: 0;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge--nsp {
  background: var(--color-nsp-soft);
  color: var(--color-nsp);
}

.badge--xci {
  background: var(--color-xci-soft);
  color: var(--color-xci);
}

.badge--nsz {
  background: var(--color-nsz-soft);
  color: var(--color-nsz);
}

.badge--accent {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.badge--blue {
  background: var(--color-blue-soft);
  color: var(--color-blue);
}

.badge--green {
  background: var(--color-green-soft);
  color: var(--color-green);
}

.badge--yellow {
  background: var(--color-yellow-soft);
  color: var(--color-yellow);
}

.badge--genre {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  margin: 0;
}

.section-header__link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.section-header__link:hover {
  color: var(--color-accent-hover);
}

/* ============================================
   ROM METADATA TABLE
   ============================================ */
.meta-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.meta-table tr {
  border-bottom: 1px solid var(--color-border);
}

.meta-table tr:last-child {
  border-bottom: none;
}

.meta-table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  width: auto;
  /* Labels wrap on phones so the table never pushes past the content width. */
  white-space: normal;
}

.meta-table td {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  /* Long unbroken values (title IDs, firmware strings) must wrap too. */
  overflow-wrap: anywhere;
}

.meta-table a {
  color: var(--color-blue);
}

/* ============================================
   HERO / HUB PAGE
   ============================================ */
.hero {
  padding: var(--space-4xl) 0 var(--space-3xl);
  text-align: center;
}

.hero h1 {
  font-size: var(--text-5xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-lg);
}

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

.hero p {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 720px;
  margin: 0 auto var(--space-xl);
  line-height: var(--leading-relaxed);
}

/* ============================================
   COMPARISON TABLE
   ============================================ */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: var(--space-xl) 0;
}

.comparison-table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
}

.comparison-table td {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table td:first-child {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

/* ============================================
   FAQ ACCORDION
   ============================================ */
.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}

.faq-item summary {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  background: var(--color-bg-card);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: var(--text-lg);
  color: var(--color-text-tertiary);
  transition: transform var(--transition-fast);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item .faq-answer {
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
}

.faq-item .faq-answer p {
  margin-bottom: var(--space-sm);
}

.faq-item .faq-answer p:last-child {
  margin-bottom: 0;
}

/* ============================================
   ROM TABLE OF CONTENTS (collapsible, starts closed)
   ============================================ */
.toc-toggle {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  overflow: hidden;
  margin-bottom: var(--space-2xl);
}

.toc-toggle > summary {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  background: var(--color-bg-tertiary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  transition: background var(--transition-fast);
}

.toc-toggle > summary:hover {
  background: var(--color-border-light);
}

.toc-toggle > summary::-webkit-details-marker {
  display: none;
}

.toc-toggle > summary h2 {
  margin: 0;
  padding: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: var(--leading-tight);
}

.toc-toggle > summary::after {
  content: '+';
  font-size: var(--text-2xl);
  line-height: 1;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.toc-toggle[open] > summary::after {
  transform: rotate(45deg);
}

.toc-toggle__body {
  border-top: 1px solid var(--color-border);
}

/* Neutralise the standalone .toc card styling inside the toggle. */
.toc-toggle .toc {
  background: none;
  border: none;
  border-radius: 0;
  padding: var(--space-lg);
  margin: 0;
}

/* Single, vertically stacked column at every viewport width. */
.toc-toggle .toc ul {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xs);
}

/* ============================================
   GENERATED KEY FEATURES LIST
   ============================================ */
.feature-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  margin: var(--space-lg) 0 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-xl);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

.feature-list li::before {
  content: '✓';
  position: absolute;
  left: var(--space-md);
  top: var(--space-sm);
  color: var(--color-green);
  font-weight: var(--weight-bold);
}

.feature-list strong { color: var(--color-text-primary); }

@media (min-width: 768px) {
  .feature-list { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   GAMEPLAY SCREENSHOT GALLERY
   ============================================ */
.screenshot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.screenshot-grid .screenshot {
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
}

.screenshot-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform var(--transition-base);
}

.screenshot-grid .screenshot:hover img { transform: scale(1.03); }

@media (min-width: 768px) {
  .screenshot-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-sm);
  padding: var(--space-lg) 0 var(--space-md);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-xl);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xl) 0;
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: all var(--transition-fast);
}

.pagination a {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.pagination a:hover {
  background: var(--color-bg-card-hover);
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}

.pagination .current {
  background: var(--color-accent);
  color: white;
  border: 1px solid var(--color-accent);
}

/* ============================================
   TABLE OF CONTENTS
   ============================================ */
.toc {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.toc h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
  margin-top: 0;
}

.toc ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.toc a {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toc a:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* Nested post TOC: h3 entries sit slightly inwards of their h2 parent. */
.toc__sublist {
  margin-top: var(--space-xs);
  padding-left: var(--space-lg);
  border-left: 2px solid var(--color-border);
}

.toc__item--h2 > a {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

.toc__item--h3 a {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* ============================================
   ARTICLE CONTENT
   ============================================ */
.entry-content {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.entry-content h2 {
  font-size: var(--text-2xl);
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.entry-content h2:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: var(--space-xl);
}

.entry-content h3 {
  font-size: var(--text-xl);
}

.entry-content p {
  margin-bottom: var(--space-md);
}

.entry-content ul,
.entry-content ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-xl);
}

.entry-content ul {
  list-style: disc;
}

.entry-content ol {
  list-style: decimal;
}

.entry-content li {
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

.entry-content code {
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--color-accent);
}

.entry-content pre {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
}

.entry-content pre code {
  background: none;
  padding: 0;
  color: var(--color-text-primary);
}

.entry-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  background: var(--color-bg-card);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.entry-content img {
  border-radius: var(--radius-md);
  margin: var(--space-lg) 0;
}

/* ============================================
   ADMIN DASHBOARD
   ============================================ */
.admin-wrap {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  display: none;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  padding: var(--space-lg);
}

.admin-sidebar .admin-logo {
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.admin-sidebar .admin-logo span {
  color: var(--color-accent);
}

.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.admin-sidebar nav a.active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.admin-content {
  padding: var(--space-2xl);
  overflow-y: auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2xl);
}

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-xs);
}

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.admin-table td {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--color-bg-card-hover);
}

/* Admin buttons */
.btn {
  display: inline-flex;
  align-items: center;
  /* inline-flex ignores text-align, so the label is centred with flex
     instead. Matters for any button wider than its own text. */
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  color: white;
}

.btn--secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-bg-card-hover);
  color: var(--color-text-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

/* Admin form fields */
.field-group {
  margin-bottom: var(--space-xl);
}

.field-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast);
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.field-group textarea {
  min-height: 120px;
  resize: vertical;
}

/* ============================================
   MOBILE-FIRST RESPONSIVE
   Base styles target mobile; enhance upward with min-width.
   ============================================ */
@media (min-width: 768px) {
  :root {
    --text-5xl: 2.5rem;
    --text-4xl: 2rem;
    --text-3xl: 1.75rem;
    --space-4xl: 4rem;
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(3, 1fr); }

  .footer-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-2xl); }

  .main-nav {
    display: flex;
    position: static;
    flex-direction: row;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    gap: var(--space-xs);
  }
  .main-nav { margin-left: auto; }
  .main-nav a { width: auto; }
  .menu-toggle { display: none; }

  .section-header { flex-direction: row; align-items: center; gap: var(--space-md); }

  .footer-bottom { flex-direction: row; text-align: left; }

  .meta-table th {
    width: 200px;
    white-space: nowrap;
    padding: var(--space-md) var(--space-lg);
  }

  .meta-table td { padding: var(--space-md) var(--space-lg); }

  .filter-bar { overflow-x: visible; flex-wrap: wrap; padding-bottom: var(--space-lg); }

  .hero h1 { font-size: var(--text-5xl); }
}

@media (min-width: 1024px) {
  :root {
    --text-5xl: 3rem;
    --text-4xl: 2.25rem;
    --text-3xl: 1.875rem;
    --space-4xl: 6rem;
  }

  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }

  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--space-3xl); }

  .admin-wrap { grid-template-columns: 240px 1fr; }
  .admin-sidebar { display: block; }
}

@media (max-width: 480px) {
  .container { padding: 0 var(--space-md); }
}

/* ============================================
   ROM REQUEST FORM
   ============================================ */
.notice {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  background: var(--color-green-soft);
  color: var(--color-green);
  border: 1px solid var(--color-green);
  font-size: var(--text-sm);
}

.notice--error {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.request-form {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-top: var(--space-xl);
}

.request-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.request-list li {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  position: relative;
}

.request-list li strong {
  color: var(--color-text-primary);
  font-size: var(--text-base);
}

.request-list li p {
  margin: var(--space-sm) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.request-date {
  float: right;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.request-replies {
  margin-top: var(--space-md);
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-md);
}

.reply-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.reply-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
}

.reply-list li {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
}

.reply-list li p {
  margin: var(--space-xs) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.reply-date {
  float: right;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  font-weight: var(--weight-normal);
}

.reply-form {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.reply-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.reply-row input {
  flex: 1 1 160px;
}

.reply-form input,
.reply-form textarea {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font: inherit;
  font-size: var(--text-sm);
}

.btn--sm {
  padding: var(--space-xs) var(--space-lg);
  font-size: var(--text-sm);
  align-self: flex-start;
}

.custom-buttons-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* ============================================
   ROM REQUEST FORM (honeypot)
   ============================================ */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.btn--lg {
  padding: var(--space-md) var(--space-2xl);
  font-size: var(--text-base);
}

.btn--secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover {
  background: var(--color-border);
}

.muted {
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide-up {
  animation: slideUp 0.5s ease forwards;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .site-header,
  .site-footer,
  .menu-toggle,
  .filter-bar,
  .pagination {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}

/* ============================================
   HOMEPAGE — GET THE ROMS / POPULAR ANCHOR
   ============================================ */
html { scroll-behavior: smooth; }

/* Offset the smooth-scroll target so the sticky header never covers the
   section heading when "Get the ROMs" jumps to the Popular grid. */
#popular-roms,
#loading-guides {
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.hero-cta {
  display: flex;
  justify-content: center;
}

.hero-cta__button {
  font-size: var(--text-base);
  padding: var(--space-sm) var(--space-xl);
}

/* ============================================
   LOADING / INSTALLING GUIDES (macro -> micro)
   ============================================ */
.rom-loading-guides__intro {
  color: var(--color-text-secondary);
  max-width: 820px;
  margin-bottom: 0;
}

.loading-guides__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.loading-guide {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.loading-guide:hover {
  transform: translateY(-2px);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.loading-guide__emu {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
}

.loading-guide__title {
  font-weight: var(--weight-semibold);
  color: var(--color-accent);
}

/* ============================================
   LOAD & PLAY PROMO (directly before the FAQ)
   ============================================ */
#load-play {
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.rom-load-play__intro {
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 820px;
}

.rom-load-play__intro a {
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================
   GENRE PILLS
   Homepage browse chips (Browse All ROMs + genre links). Rounded pill,
   soft accent fill and accent label — matches the reference chip design.
   ============================================ */
.genre-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border: 1px solid rgba(230, 0, 18, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.genre-pill:hover {
  background: var(--color-accent-medium);
  border-color: var(--color-accent);
  color: var(--color-accent-hover);
}

/* ============================================
   COMMENTS (ROM posts)
   Themed comment thread + form. Threaded replies nest under their parent.
   ============================================ */
.comments-area {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--color-border);
}

.comments-title {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-lg);
  text-align: center;
}

.comment-list,
.comment-list .children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-list .children {
  margin: var(--space-lg) 0 0 var(--space-lg);
  padding-left: var(--space-lg);
  border-left: 2px solid var(--color-border);
}

.comment-list > li + li,
.comment-list .children > li + li {
  margin-top: var(--space-lg);
}

.comment-body {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.comment-author {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  line-height: 1.2;
}

.comment-author .avatar {
  display: block;
  border-radius: var(--radius-full);
}

.comment-author .fn {
  font-weight: var(--weight-semibold);
  font-style: normal;
  color: var(--color-text-primary);
}

.comment-metadata {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.comment-metadata a {
  color: inherit;
  text-decoration: none;
}

.comment-content {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  overflow-wrap: anywhere;
}

.comment-content p {
  margin: 0 0 var(--space-sm);
}

.comment-content p:last-child {
  margin-bottom: 0;
}

.comment-awaiting-moderation {
  display: inline-block;
  margin-top: var(--space-xs);
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--color-text-tertiary);
}

.comment .reply {
  margin-top: var(--space-sm);
}

.comment-reply-link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  text-decoration: none;
}

.comment-reply-link:hover {
  text-decoration: underline;
}

.no-comments {
  text-align: center;
  color: var(--color-text-tertiary);
}

/* Comment form */
.comment-respond {
  margin-top: var(--space-2xl);
}

.comment-reply-title {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-md);
}

.comment-reply-title small a {
  margin-left: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.comment-notes,
.comment-notes-link,
.logged-in-as {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.comment-notes-link {
  color: var(--color-text-tertiary);
  margin-top: var(--space-xs);
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.comment-form p {
  margin: 0;
}

.comment-form label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus,
.comment-form input[type="url"]:focus,
.comment-form textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.comment-form textarea {
  min-height: 120px;
  resize: vertical;
}

.comment-form .comment-form-author,
.comment-form .comment-form-email {
  flex: 1 1 240px;
}

.comment-form .form-submit {
  margin-top: var(--space-sm);
}

.comment-form input[type="submit"] {
  cursor: pointer;
}

@media (min-width: 768px) {
  .comment-form {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .comment-form .comment-form-comment,
  .comment-form .form-submit,
  .comment-form .comment-notes,
  .comment-form .comment-notes-link,
  .comment-form .logged-in-as {
    flex: 1 1 100%;
  }
}
