:root {
  --bg-deep: #0d2260;
  --bg-mid: #163a82;
  --bg-mid2: #1c4491;
  --gold: #f0d878;
  --gold-bright: #fff2b8;
  --ink: #fdf8e3;
  --ink-dim: #d7e0f2;
  --line: rgba(240, 216, 120, 0.28);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-deep);
  color: var(--ink);
  font-family: 'PT Sans', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 40% 80%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 85% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 10% 70%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 90% 85%, rgba(255,255,255,0.5), transparent);
  background-repeat: repeat;
  background-size: 600px 600px;
  opacity: 0.7;
}
.starfield-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(rgba(13,34,96,0.55), rgba(13,34,96,0.8)), url('images/starfield.jpg');
  background-size: cover;
  background-position: center;
}

.topnav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 24px;
}
.topnav .brand {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  letter-spacing: 0.24em;
  color: var(--gold-bright);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 14.5px;
}
.nav-links a { color: var(--ink-dim); }
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--gold-bright); }
.nav-links a.nav-cta {
  border: 1px solid var(--line);
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--gold-bright);
}
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    right: 24px;
    left: 24px;
    background: var(--bg-mid);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    z-index: 10;
  }
  .nav-links.open { display: flex; }
  .nav-toggle {
    display: inline-flex;
    background: none;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
  }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 24px 100px;
}
.wrap-wide {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 24px 100px;
}

.sigil-stage { margin: 24px auto 8px; display: flex; justify-content: center; }
.sigil-stage svg { width: 100%; max-width: 260px; height: auto; }

.hero-image-stage {
  margin: 20px auto 8px;
  max-width: 640px;
}
.hero-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  border: 1px solid var(--line);
}

h1 {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  font-size: clamp(30px, 5.5vw, 44px);
  text-align: center;
  line-height: 1.24;
  margin: 26px 0 16px;
}
h1 .accent { color: var(--gold-bright); font-style: italic; font-weight: 600; }

.lede {
  text-align: center;
  color: var(--ink-dim);
  font-size: 16px;
  max-width: 520px;
  margin: 0 auto 30px;
}

.cta-row { display: flex; justify-content: center; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.cta {
  appearance: none;
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #241a06;
  font-family: 'PT Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  padding: 15px 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.15s ease;
}
.cta:hover { transform: translateY(-1px); }
.cta.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 400;
}
.fineprint { text-align: center; font-size: 12.5px; color: var(--ink-dim); opacity: 0.75; margin-bottom: 40px; }

.section-eyebrow { text-align: center; font-size: 13px; letter-spacing: 0.14em; color: var(--gold); margin-bottom: 10px; }
h2.section-title {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  font-size: clamp(22px, 4vw, 28px);
  text-align: center;
  line-height: 1.3;
  margin-bottom: 30px;
}
h2.section-title .accent { color: var(--gold-bright); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 50px; }
.card {
  background: var(--bg-mid);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 22px;
}
.icon-badge {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(205, 164, 94, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.icon-badge svg { width: 22px; height: 22px; }
.card h3 { font-family: 'Playfair Display', serif; font-size: 19px; font-weight: 500; margin-bottom: 10px; }
.card p { color: var(--ink-dim); font-size: 14.5px; margin-bottom: 14px; }
.card .meta { font-size: 12.5px; color: var(--gold-bright); letter-spacing: 0.04em; margin-bottom: 12px; }
.card .link { font-size: 13.5px; color: var(--gold-bright); }

.quiz-card {
  background: var(--bg-mid);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 30px;
  max-width: 460px;
  margin: 0 auto;
}
.quiz-card p.q-lede { text-align: center; color: var(--ink-dim); font-size: 14.5px; margin-bottom: 24px; }
.date-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; margin-bottom: 8px; }
.date-row select, .text-field {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: 'PT Sans', sans-serif;
  font-size: 15px;
  padding: 12px 10px;
  border-radius: 10px;
  appearance: none;
  text-align: center;
  cursor: pointer;
}
.text-field { cursor: text; margin-bottom: 8px; text-align: left; }
.date-row select:focus, .text-field:focus { outline: 1px solid var(--gold-bright); }
.err-msg { color: #e08a8a; font-size: 13px; text-align: center; min-height: 18px; margin: 6px 0 4px; }
.quiz-card .cta { width: 100%; justify-content: center; margin-top: 14px; }
.pair-block { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.pair-block:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.pair-label { font-size: 13px; color: var(--gold-bright); letter-spacing: 0.06em; margin-bottom: 10px; text-align: center; }

.tabs { display: flex; justify-content: center; gap: 8px; max-width: 560px; margin: 0 auto 32px; flex-wrap: wrap; }
.tab-btn { background: transparent; border: 1px solid var(--line); color: var(--ink-dim); font-family: 'PT Sans', sans-serif; font-size: 14px; padding: 10px 18px; border-radius: 999px; cursor: pointer; }
.tab-btn.active { background: rgba(205, 164, 94, 0.12); border-color: var(--gold); color: var(--gold-bright); }
.panel { display: none; }
.panel.active { display: block; }

.result { display: none; background: var(--bg-mid); border: 1px solid var(--line); border-radius: 20px; padding: 40px 32px; max-width: 540px; margin: 0 auto; }
.result.show { display: block; animation: reveal 0.5s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.result .num { font-family: 'Playfair Display', serif; font-size: 56px; color: var(--gold-bright); text-align: center; line-height: 1; font-weight: 600; }
.result .num-pair { display: flex; justify-content: center; gap: 28px; }
.result .num-pair .num { font-size: 44px; }
.result .num-label { text-align: center; font-size: 13px; color: var(--ink-dim); letter-spacing: 0.1em; margin: 10px 0 26px; }
.result h3 { font-family: 'Playfair Display', serif; font-size: 22px; text-align: center; margin-bottom: 16px; font-weight: 500; }
.result p { color: var(--ink-dim); font-size: 15px; margin-bottom: 14px; }
.result .leak { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }
.result .leak b { color: var(--gold-bright); }
.retry { display: block; text-align: center; margin-top: 22px; font-size: 13.5px; color: var(--ink-dim); text-decoration: underline; cursor: pointer; background: none; border: none; font-family: 'PT Sans', sans-serif; }

.auth-card {
  background: var(--bg-mid);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 34px;
  max-width: 400px;
  margin: 40px auto 0;
}
.auth-card h2 { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 500; text-align: center; margin-bottom: 8px; }
.auth-card p.sub { text-align: center; color: var(--ink-dim); font-size: 14px; margin-bottom: 26px; }
.field-label { font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; display: block; }
.field-group { margin-bottom: 16px; }
.auth-card input[type="email"], .auth-card input[type="password"], .auth-card input[type="text"] {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: 'PT Sans', sans-serif;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 10px;
}
.auth-card input:focus { outline: 1px solid var(--gold-bright); }
.auth-card .cta { width: 100%; justify-content: center; margin-top: 10px; }
.auth-switch { text-align: center; font-size: 13.5px; color: var(--ink-dim); margin-top: 20px; }
.auth-switch a { color: var(--gold-bright); text-decoration: underline; }
.auth-note { text-align: center; font-size: 12px; color: var(--ink-dim); opacity: 0.7; margin-top: 14px; }

.article-body { max-width: 640px; margin: 0 auto; color: var(--ink-dim); font-size: 15.5px; }
.article-body h3 { font-family: 'Playfair Display', serif; color: var(--ink); font-size: 20px; font-weight: 500; margin: 26px 0 10px; }
.article-body p { margin-bottom: 14px; }
.back-link { display: block; text-align: center; margin: 30px 0; color: var(--gold-bright); font-size: 14px; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 50px; }
.book-card {
  background: var(--bg-mid);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.book-cover {
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--bg-mid2), var(--bg-deep));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.book-cover svg { width: 30px; height: 30px; margin-bottom: 12px; }
.book-cover .book-title-on-cover {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: var(--gold-bright);
  line-height: 1.3;
}
.book-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 242, 184, 0.1);
  color: var(--gold-bright);
}
.book-card h3 { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.book-card .author { font-size: 12.5px; color: var(--ink-dim); margin-bottom: 10px; }
.book-card p.desc { color: var(--ink-dim); font-size: 14px; margin-bottom: 14px; flex-grow: 1; }
.book-card .price-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.book-card .price { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--gold-bright); }
.book-card .cta { width: 100%; justify-content: center; padding: 11px 20px; font-size: 14.5px; }
.book-card .cta.ghost { background: transparent; }

footer {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: 60px;
  padding-bottom: 40px;
  font-size: 12.5px;
  color: var(--ink-dim);
  opacity: 0.6;
}

@media (max-width: 480px) {
  .quiz-card, .result, .auth-card { padding: 28px 20px; }
  .date-row { grid-template-columns: 1fr; }
  .result .num-pair { gap: 16px; }
}
