/* ============================================================
   Haunted House — atmospheric house / archive style
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Lora:ital,wght@0,400;0,600;1,400&family=Courier+Prime:wght@400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #182744;
  --ink-light: #334766;
  --parchment: #f4ead6;
  --parchment-dark: #dfc89d;
  --paper-edge: #b28b51;
  --midnight: #182744;
  --midnight-dark: #0d1729;
  --blood: #8d2419;
  --blood-dark: #54140f;
  --candle: #d69d37;
  --gold-bright: #f2cf77;
  --moss: #4d654a;
  --storm: #2b3033;
  --bg-dark: #0f0d0c;
  --bg-mid: #211813;
  --border: #b28b51;
  --shadow: rgba(0,0,0,0.55);
  --font-head:  'Playfair Display', Georgia, serif;
  --font-body:  'Lora', Georgia, serif;
  --font-mono:  'Courier Prime', 'Courier New', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background:
    radial-gradient(circle at 18% 4%, rgba(141, 36, 25, 0.18), transparent 24rem),
    radial-gradient(circle at 84% 12%, rgba(214, 157, 55, 0.14), transparent 26rem),
    linear-gradient(180deg, #0b0b0c 0%, var(--bg-dark) 38%, #1d130f 100%);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.25;
  color: var(--ink);
}

a {
  color: #214f87;
  text-decoration-color: rgba(33, 79, 135, 0.32);
  text-underline-offset: 0.18em;
}
a:hover { color: var(--candle); }

.site-nav {
  background: rgba(15, 13, 12, 0.92);
  border-bottom: 1px solid rgba(178, 139, 81, 0.48);
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 1.25rem;
}

.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
}

.nav-brand {
  font-family: var(--font-head);
  font-size: 1.18rem;
  font-weight: 900;
  color: var(--parchment-dark);
  text-decoration: none;
  white-space: nowrap;
}
.nav-brand:hover { color: var(--parchment); }

.nav-toggle {
  display: none;
  width: 2.65rem;
  height: 2.65rem;
  border: 1px solid rgba(242, 207, 119, 0.36);
  border-radius: 6px;
  background: rgba(24, 39, 68, 0.72);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.3rem;
  transition: background 0.2s, border-color 0.2s;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(24, 39, 68, 0.96);
  border-color: rgba(242, 207, 119, 0.68);
  outline: none;
}

.nav-toggle span {
  width: 1.35rem;
  height: 2px;
  background: var(--gold-bright);
  border-radius: 999px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-nav.menu-open .nav-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-nav.menu-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

.site-nav.menu-open .nav-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a {
  color: var(--parchment-dark);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(24, 39, 68, 0.94);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px rgba(242, 207, 119, 0.32);
}

.hero {
  min-height: clamp(440px, 72vh, 760px);
  background:
    radial-gradient(circle at 50% 28%, rgba(242, 207, 119, 0.12), transparent 20rem),
    linear-gradient(180deg, #1f2d41 0%, #162033 68%, #0f0d0c 100%);
  border-bottom: 1px solid rgba(178, 139, 81, 0.55);
  text-align: center;
  padding: clamp(2.35rem, 6vw, 4.5rem) 1.5rem 2.4rem;
  display: grid;
  justify-items: center;
  align-content: end;
  position: relative;
  overflow: hidden;
}

.hero:not(:has(.hero-cover)) {
  min-height: 180px;
  padding: clamp(1.55rem, 4vw, 2.65rem) 1.5rem;
  align-content: center;
}

.hero:not(:has(.hero-cover)) .hero-title {
  font-size: clamp(2.4rem, 6vw, 4rem);
}

.hero:not(:has(.hero-cover)) + .page-content {
  padding-top: 2rem;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(38, 54, 77, 0.28), transparent 22%, transparent 78%, rgba(38, 54, 77, 0.28)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 1px, transparent 1px, transparent 5px);
  pointer-events: none;
  mix-blend-mode: overlay;
}

.hero-title {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 900;
  color: #fff3d2;
  text-shadow: 0 4px 22px rgba(0,0,0,0.9), 0 0 30px rgba(141,36,25,0.45);
  letter-spacing: 0;
  position: relative;
  z-index: 1;
}

.hero-subtitle {
  font-family: var(--font-head);
  font-style: italic;
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  color: var(--parchment-dark);
  margin-top: 0.4rem;
  margin-bottom: 1.25rem;
  max-width: 38rem;
  position: relative;
  z-index: 1;
}

.hero-cover {
  display: inline-block;
  border: 1px solid rgba(244, 234, 214, 0.66);
  border-radius: 6px;
  box-shadow: 0 22px 58px rgba(0,0,0,0.74), 0 0 0 8px rgba(15,13,12,0.42);
  line-height: 0;
  transition: transform 0.24s, filter 0.24s;
  position: relative;
  z-index: 1;
}
.hero-cover:hover { transform: translateY(-3px) scale(1.01); filter: saturate(1.08) contrast(1.02); }
.hero-cover img {
  width: min(460px, 78vw);
  height: auto;
  display: block;
  border-radius: 5px;
}

.page-content {
  max-width: 980px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4.5rem;
}

.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0)),
    radial-gradient(circle at 8% 0%, rgba(214,157,55,0.13), transparent 16rem),
    var(--parchment);
  border: 1px solid rgba(178, 139, 81, 0.72);
  border-top: 4px solid var(--midnight);
  border-radius: 8px;
  padding: clamp(1.25rem, 3vw, 2.15rem);
  margin-bottom: 2rem;
  box-shadow: 0 16px 42px rgba(0,0,0,0.34);
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0.55rem;
  border: 1px solid rgba(178, 139, 81, 0.26);
  border-radius: 5px;
  pointer-events: none;
}

.card h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  color: var(--midnight);
  margin-bottom: 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(178, 139, 81, 0.58);
}

.card h3 {
  font-size: 1.2rem;
  color: #8a651f;
  margin: 1.2rem 0 0.5rem;
}

.card p { margin-bottom: 0.85rem; }
.card p:last-child { margin-bottom: 0; }

.manual-about-layout {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.manual-cover-link {
  display: block;
  flex: 0 0 auto;
}

.manual-cover-link img {
  width: min(120px, 36vw);
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: rgba(38, 24, 13, 0.08);
  border: 1px solid rgba(178, 139, 81, 0.5);
  border-radius: 4px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}

.manual-about-text {
  flex: 1 1 260px;
  align-self: center;
}

body:has(.hero-title) .spoiler-warning,
.spoiler-warning {
  display: block;
  box-sizing: border-box;
  width: 100%;
  background: #9b1c1c;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

.spoiler-warning strong {
  color: inherit;
}

code {
  background: rgba(38, 24, 13, 0.08);
  border: 1px solid rgba(178, 139, 81, 0.34);
  border-radius: 4px;
  font-family: var(--font-mono);
  padding: 0.05rem 0.28rem;
}

.ornament {
  text-align: center;
  color: var(--paper-edge);
  font-size: 1.4rem;
  letter-spacing: 0;
  margin: 1.2rem 0;
  user-select: none;
}

.console-wrap {
  background: linear-gradient(180deg, #201b17, #0a0908);
  border: 1px solid #4b3b29;
  border-radius: 8px;
  padding: clamp(0.7rem, 2.5vw, 1rem);
  margin: 1rem 0 0;
  overflow-x: auto;
  box-shadow: inset 0 0 22px rgba(0,0,0,0.82), 0 12px 28px rgba(0,0,0,0.26);
}

#hauntedConsole {
  background: #070605;
  color: #f1e6c9;
  font-family: var(--font-mono);
  font-size: clamp(13px, 2.5vw, 18px);
  width: 100%;
  max-width: 65ch;
  min-height: 22rem;
  resize: vertical;
  border: 1px solid rgba(223, 200, 157, 0.24);
  border-radius: 5px;
  outline: none;
  padding: 0.8rem;
  display: block;
}

.console-btns {
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  background: linear-gradient(180deg, var(--midnight), var(--midnight-dark));
  color: var(--gold-bright);
  border: 1px solid rgba(242, 207, 119, 0.3);
  padding: 0.55rem 1.05rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(13, 23, 41, 0.24);
  transition: transform 0.18s, background 0.18s, box-shadow 0.18s;
}
.btn:hover {
  background: linear-gradient(180deg, #223a63, var(--midnight));
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(13, 23, 41, 0.3);
}

.play-note {
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-light);
  margin-bottom: 0.75rem;
}

/* ── Links grid (other games) ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.game-link {
  display: block;
  background: var(--parchment-dark);
  border: 1px solid var(--border);
  border-left: 4px solid var(--candle);
  padding: 0.7rem 1rem;
  text-decoration: none;
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--ink);
  border-radius: 3px;
  transition: background 0.2s, border-color 0.2s;
}
.game-link:hover {
  background: var(--midnight);
  color: var(--gold-bright);
  border-left-color: var(--midnight);
}

.game-text {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: #181410;
  color: #f2e7cd;
  padding: 1rem 1.2rem;
  border-radius: 6px;
  border: 1px solid rgba(223, 200, 157, 0.24);
  border-left: 4px solid var(--candle);
  margin: 0.75rem 0;
  white-space: pre-wrap;
  line-height: 1.6;
  overflow-x: auto;
}

.map-figure {
  text-align: center;
  margin: 1.5rem 0;
}
.map-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow);
}
.map-figure figcaption {
  font-family: var(--font-head);
  font-style: italic;
  color: var(--ink-light);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.site-footer {
  background: rgba(15, 13, 12, 0.94);
  border-top: 1px solid rgba(178, 139, 81, 0.48);
  padding: 2rem 1.5rem 1.5rem;
  color: var(--parchment-dark);
  font-size: 0.88rem;
}
.site-footer a { color: var(--border); }
.site-footer a:hover { color: var(--parchment); }

.footer-heading {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--border);
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.games-footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.game-footer-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  width: min(220px, 42vw);
  transition: transform 0.2s;
}
.game-footer-link:hover { transform: translateY(-3px); }

.game-footer-link img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  display: block;
}

.game-footer-link span {
  font-family: var(--font-head);
  font-size: 0.82rem;
  color: var(--parchment-dark);
  text-align: center;
  line-height: 1.3;
}
.game-footer-link:hover span { color: var(--parchment); }

.footer-byline {
  text-align: center;
  border-top: 1px solid rgba(200,169,110,0.3);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

/* ── Shared lightbox ── */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 999;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  height: auto;
  border: 2px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}
.lightbox-close {
  position: absolute;
  top: 1rem; right: 1.25rem;
  color: var(--parchment);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-head);
}
.zoomable {
  cursor: zoom-in;
  transition: opacity 0.2s;
}
.zoomable:hover { opacity: 0.88; }

/* ── Resource links ── */
.resource-list {
  list-style: none;
  padding: 0;
}
.resource-list li {
  padding: 0.4rem 0;
}

#play .resource-list {
  padding-left: 1.5rem;
}

/* ── Info table ── */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  border: 1px solid rgba(178, 139, 81, 0.5);
}
.info-table td {
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(178, 139, 81, 0.5);
  vertical-align: top;
}
.info-table td:first-child {
  font-weight: 600;
  color: var(--ink-light);
  white-space: nowrap;
  width: 40%;
}

ol {
  padding-left: 1.5rem;
}

li + li {
  margin-top: 0.18rem;
}

@media (max-width: 600px) {
  .site-nav { padding: 0 0.85rem; }
  .nav-inner {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.7rem 0;
  }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.25rem;
    padding-top: 0.55rem;
  }
  .site-nav.menu-open .nav-links {
    display: flex;
  }
  .nav-links a {
    display: block;
    font-size: 0.94rem;
    padding: 0.58rem 0.72rem;
    border-radius: 6px;
  }
  .hero {
    min-height: 520px;
    padding: 2rem 1rem 1.75rem;
  }
  .hero:not(:has(.hero-cover)) {
    min-height: 155px;
    padding: 1.45rem 1rem;
  }
  .hero:not(:has(.hero-cover)) .hero-title {
    font-size: clamp(2.4rem, 6vw, 4rem);
  }
  .page-content { padding: 2rem 0.85rem 3rem; }
  .info-table td,
  .info-table tr,
  .info-table tbody {
    display: block;
    width: 100%;
  }
  .info-table tr {
    border-bottom: 1px solid rgba(178, 139, 81, 0.5);
    padding: 0.5rem 0;
  }
  .info-table td {
    border-bottom: 0;
    padding: 0.1rem 0;
  }
  .info-table td:first-child {
    width: 100%;
    white-space: normal;
  }
  .game-footer-link { width: min(220px, 86vw); }
}
