/* A tabletop-inspired frame for the collection. */
html, body {
  background: #171714;
  color: #eee7d5;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}

body > .window-top-bar,
body > nav.game-nav { flex-shrink: 0; }

button, input { font-family: inherit; }

nav.game-nav {
  justify-content: center;
  gap: 0.25rem;
  background: #24231f;
  border-bottom: 1px solid #6a5a3c;
}

body nav.game-nav { margin: 0 0 16px; }

nav.game-nav a {
  color: #d3c7ac;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

nav.game-nav a:hover,
nav.game-nav a.active {
  color: #fff3d3;
  background: #4a3e2d;
  box-shadow: none;
  transform: none;
}

#content-wrapper {
  flex: 1;
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 3rem) 2rem;
}

header.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 210px);
  align-items: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  text-align: left;
  margin: 0;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border: 1px solid #9a8055;
  border-radius: 12px;
  background: #302d24;
  box-shadow: inset 0 0 0 4px #1c1c19, inset 0 0 0 5px #625238;
}

.eyebrow {
  color: #d3ba83;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

header h1,
.featured-section h2,
.worlds-section h2,
.about-section h2,
footer h3 {
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0.01em;
}

header h1 {
  color: #f3e5bf;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 0.5rem 0 0.8rem;
}

header .subtitle {
  color: #e3d8c0;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 38rem;
}

.hero-meta {
  color: #d3ba83;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  margin-top: 0.8rem;
}

.hero-link {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  border: 1px solid #c1a56f;
  border-radius: 3px;
  background: #806b45;
  color: #fffaf0;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease;
}

.hero-link:hover { background: #a48756; }

.hero-card {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
  padding: 6px;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.hero-card-figure figcaption {
  color: #d3ba83;
  font-size: 0.75rem;
  text-align: center;
}

.featured-section,
.worlds-section,
.about-section {
  padding: 2rem 0;
  border-bottom: 1px solid #554b37;
}

.worlds-section { scroll-margin-top: 120px; }

.featured-section h2,
.worlds-section h2,
.about-section h2 {
  margin: 0.3rem 0 1rem;
  color: #f1e4c4;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.2;
}

.featured-carousel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  padding: 0.4rem;
}

.card-item:hover,
.card-item:focus-visible {
  transform: translateY(-4px);
}

.portal-section {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.portal-tile {
  --portal-accent: #d5b3b0;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 1rem;
  border: 1px solid #6a5a3c;
  border-top: 3px solid var(--portal-accent);
  border-radius: 4px;
  background: linear-gradient(160deg, #302d24, #22221d);
  color: #f0eadc;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.portal-tile.earthbound { --portal-accent: #95bdc6; }
.portal-tile.mother3 { --portal-accent: #d7b878; }
.portal-tile.undertale { --portal-accent: #ddd58c; }
.portal-tile.deltarune { --portal-accent: #85c7c3; }
.portal-tile:hover { background: #393529; transform: translateY(-2px); }
.portal-logo {
  display: block;
  width: 100%;
  max-width: 180px;
  height: 45px;
  margin-bottom: 0.8rem;
  object-fit: contain;
  object-position: left center;
}
.portal-tile.undertale .portal-logo,
.portal-tile.deltarune .portal-logo { mix-blend-mode: screen; }
.portal-tile .description { color: #d0c7b5; font-size: 0.8rem; line-height: 1.4; margin: 0.6rem 0 1rem; }
.portal-count { color: var(--portal-accent); font-size: 0.78rem; font-weight: 600; margin-top: auto; }

.about-section {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}

.about-copy { color: #d0c7b5; max-width: 44rem; }
.about-copy p + p { margin-top: 0.75rem; }

footer.page-footer {
  text-align: left;
  padding: 1.5rem 0 0;
  border-radius: 0;
  color: #d0c7b5;
}

footer h3 {
  margin: 0.3rem 0 0.6rem;
  color: #f1e4c4;
  font-size: 1.5rem;
  text-transform: none;
}

footer .disclaimer { color: #b6ad9b; font-size: 0.8rem; margin-top: 1rem; }
.card-modal .modal-content { background: #292820; border: 1px solid #9a8055; }
.card-modal .modal-close,
.card-modal .nav-buttons button { color: #f0eadc; background: #4a3e2d; }
:focus-visible { outline: 2px solid #e4d3b5; outline-offset: 3px; }

@media (min-width: 900px) and (min-height: 640px) {
  #content-wrapper {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(min-content, 1.3fr) minmax(min-content, 1fr) auto;
    align-content: stretch;
    gap: clamp(0.5rem, 1.5vh, 1.25rem) 2rem;
    min-height: 0;
    padding-top: 0;
    padding-bottom: clamp(1rem, 2vh, 1.5rem);
  }

  header.page-header {
    grid-template-columns: minmax(0, 1fr) minmax(100px, 30%);
    gap: 1.5rem;
    padding: clamp(1rem, 1.5vw, 1.5rem);
  }
  header h1 { font-size: clamp(2.4rem, 3.8vw, 3.5rem); margin: 0.2rem 0 0.4rem; }
  header .subtitle { font-size: clamp(0.9rem, 1.1vw, 1rem); line-height: 1.35; margin: 0; }
  .hero-meta { margin-top: 0.4rem; }
  .hero-link { margin-top: 0.6rem; padding: 0.4rem 0.75rem; }
  .hero-card { max-height: min(28vh, 260px); }

  .worlds-section,
  .about-section { padding: 0; border: 0; }
  .featured-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem clamp(1rem, 2vw, 1.75rem);
    border: 1px solid #554b37;
    background: #201f1a;
  }
  .featured-section h2,
  .worlds-section h2,
  .about-section h2 { font-size: clamp(1.5rem, 2vw, 2rem); margin: 0.15rem 0 0.5rem; }
  .featured-carousel { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.75rem; padding: 0.4rem 0; }
  .worlds-section { display: flex; flex-direction: column; grid-column: 1 / -1; }
  .portal-section { flex: 1; }
  .portal-tile { min-height: 160px; padding: clamp(0.6rem, 1vw, 1rem); }
  .portal-logo { height: clamp(32px, 5vh, 45px); margin-bottom: 0.5rem; }
  .portal-tile .description { font-size: clamp(0.8rem, 0.9vw, 0.95rem); margin: 0.4rem 0 0.6rem; }
  .about-section { display: block; }
  .about-section,
  footer.page-footer { border-top: 1px solid #554b37; padding-top: 0.75rem; }
  .about-copy { font-size: 0.9rem; line-height: 1.35; }
  .about-copy p + p { margin-top: 0.3rem; }
  footer.page-footer { margin: 0; font-size: 0.9rem; line-height: 1.35; }
  footer h3 { font-size: clamp(1.5rem, 2vw, 2rem); margin: 0.15rem 0 0.5rem; }
  footer p { margin-bottom: 0.4rem; }
  footer .disclaimer { margin-top: 0.4rem; }
}

@media (min-width: 900px) and (min-height: 640px) and (max-height: 850px) {
  body nav.game-nav { margin-bottom: 12px; }
  header.page-header { padding: 1rem 1.25rem; }
  header h1 { font-size: clamp(2.4rem, 3.2vw, 3rem); }
  .featured-section { padding: 0.5rem 1.25rem; }
  .featured-section h2,
  .worlds-section h2,
  .about-section h2,
  footer h3 { font-size: 1.5rem; }
  .featured-carousel { padding: 0; }
  .portal-tile { min-height: 145px; padding: 0.6rem 0.75rem; }
  .portal-logo { height: 30px; margin-bottom: 0.35rem; }
  .portal-tile .description { margin: 0.25rem 0 0.35rem; }
  footer.page-footer p { line-height: 1.35; margin-bottom: 0.2rem; }
}

@media (max-width: 768px) {
  .portal-section { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-carousel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  header.page-header { grid-template-columns: minmax(0, 1fr) minmax(75px, 29%); gap: 0.75rem; padding: 1.25rem; }
  header h1 { font-size: 1.75rem; }
  header .subtitle { font-size: 0.9rem; }
  .hero-card { max-height: 180px; }
  .portal-section { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-tile { min-height: 175px; }
  .featured-carousel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about-section { grid-template-columns: 1fr; gap: 0.5rem; }
}

@media (max-width: 600px) {
  .worlds-section { scroll-margin-top: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-tile:hover, .card-item:hover { transform: none; }
}
