/* ==========================================================================
   Hearthfire — page, overlays, and the type that sells the fire
   ========================================================================== */
:root {
  --ink: #150e0b;
  --ink-2: #1d1410;
  --stone: #2a1d18;
  --gold: #e9c37c;
  --gold-hi: #ffe3ab;
  --gold-dim: #a67c34;
  --cream: #f7ead6;
  --muted: #b6a08a;
  --ember: #ff8a3d;
  --red: #d5554a;
  --serif: Georgia, "Times New Roman", "Songti SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: #0c0706;
  color: var(--cream);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow-x: hidden; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hi); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px 60px; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 12px;
  border-bottom: 1px solid rgba(233, 195, 124, .1);
  margin-bottom: 12px;
}
.brand {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: .06em;
  color: var(--cream);
}
.brand-mark { font-size: 15px; filter: saturate(.9); }
.topnav { display: flex; gap: 16px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--gold); }

/* ------------------------------------------------------------------- stage */
.stage {
  position: relative;
  width: 100%;
  height: min(100dvh, 760px);
  min-height: 430px;
  background: #120c0a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(233, 195, 124, .09) inset;
  isolation: isolate;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
  appearance: none;
  border: 1px solid rgba(233, 195, 124, .35);
  background: linear-gradient(180deg, rgba(58, 39, 29, .95), rgba(33, 22, 17, .95));
  color: var(--cream);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.btn:hover { transform: translateY(-1px); border-color: rgba(233, 195, 124, .7); box-shadow: 0 10px 26px rgba(0, 0, 0, .45); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background: linear-gradient(180deg, #ffe6b0 0%, #e9c37c 45%, #b8842f 100%);
  color: #2a1708;
  border-color: rgba(255, 236, 190, .8);
  box-shadow: 0 10px 30px rgba(233, 160, 70, .28), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.primary:hover { box-shadow: 0 14px 38px rgba(233, 160, 70, .4), inset 0 1px 0 rgba(255, 255, 255, .6); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--cream); }
.btn.wide-btn { width: 100%; margin-top: 16px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.btns.col { flex-direction: column; }
.btns.col .btn { width: 100%; }

.link-btn {
  appearance: none; border: 0; background: none;
  color: var(--muted); font-family: var(--sans); font-size: 11.5px;
  letter-spacing: .1em; text-transform: uppercase; cursor: pointer;
  margin-top: 14px; padding: 6px;
}
.link-btn:hover { color: var(--gold); }

.icon-btn {
  appearance: none; border: 1px solid rgba(233, 195, 124, .22);
  background: rgba(20, 13, 10, .6); color: var(--gold);
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  cursor: pointer; line-height: 1;
}
.icon-btn:hover { border-color: rgba(233, 195, 124, .6); }
.icon-btn.pause {
  position: absolute; right: 12px; top: 12px; z-index: 6;
  display: none;
}
.icon-btn.pause.on { display: block; }
.icon-btn.back { background: none; border-color: rgba(233, 195, 124, .18); }

/* ----------------------------------------------------------------- overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(120% 80% at 50% 110%, rgba(255, 138, 61, .18) 0%, rgba(255, 138, 61, 0) 55%),
    radial-gradient(90% 70% at 50% 10%, rgba(120, 70, 30, .16) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, rgba(9, 6, 5, .92), rgba(9, 6, 5, .97));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
}
.overlay.show { display: flex; animation: fadeIn .28s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* -------------------------------------------------------------------- title */
#scrTitle { background: transparent; backdrop-filter: none; }
#scrTitle::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 45% at 50% 100%, rgba(255, 128, 48, .30) 0%, rgba(255, 90, 30, .06) 45%, rgba(0, 0, 0, 0) 70%),
    radial-gradient(120% 100% at 50% 0%, #241610 0%, #150e0b 55%, #0b0706 100%);
}
#scrTitle.show { display: flex; }
.title-inner { position: relative; text-align: center; max-width: 620px; padding: 10px 6px 26px; }
.kicker {
  margin: 0 0 8px;
  font-size: 9.5px; letter-spacing: .36em; text-transform: uppercase;
  color: var(--gold-dim); font-weight: 700;
}
.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 9vw, 82px);
  line-height: .98;
  letter-spacing: .01em;
  background: linear-gradient(180deg, #fff2d2 0%, #f0cd8c 38%, #c48f38 72%, #8a5f1e 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 28px rgba(255, 150, 60, .22));
}
.wordsub {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 2.4vw, 20px);
  letter-spacing: .14em;
  color: var(--gold);
}
.lede {
  margin: 18px auto 0;
  max-width: 470px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
}
.tiny { margin: 16px 0 0; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: rgba(182, 160, 138, .6); }

.embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.embers i {
  position: absolute; bottom: -12px; width: 3px; height: 3px; border-radius: 50%;
  background: #ffb066; box-shadow: 0 0 8px 2px rgba(255, 140, 60, .55);
  animation: rise linear infinite;
}
.embers i:nth-child(1) { left: 18%; animation-duration: 7s; animation-delay: 0s; }
.embers i:nth-child(2) { left: 31%; animation-duration: 9s; animation-delay: 1.4s; }
.embers i:nth-child(3) { left: 47%; animation-duration: 6.2s; animation-delay: .6s; }
.embers i:nth-child(4) { left: 59%; animation-duration: 8.4s; animation-delay: 2.2s; }
.embers i:nth-child(5) { left: 72%; animation-duration: 10s; animation-delay: .3s; }
.embers i:nth-child(6) { left: 84%; animation-duration: 7.4s; animation-delay: 1.9s; }
@keyframes rise {
  0% { transform: translateY(0) translateX(0) scale(.8); opacity: 0; }
  12% { opacity: .9; }
  70% { opacity: .5; }
  100% { transform: translateY(-70vh) translateX(26px) scale(1.2); opacity: 0; }
}

/* -------------------------------------------------------------------- panel */
.panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(44, 30, 23, .97), rgba(20, 14, 11, .98));
  border: 1px solid rgba(233, 195, 124, .18);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 226, 178, .08);
  text-align: center;
}
.panel::after {
  content: ""; position: absolute; inset: 7px; border-radius: 11px;
  border: 1px solid rgba(233, 195, 124, .07); pointer-events: none;
}
.panel.wide { max-width: 720px; text-align: left; }
.panel.small { max-width: 340px; }
.panel.brief { max-width: 480px; text-align: left; }
.panel.result { max-width: 430px; }

.panel h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(22px, 3.4vw, 30px);
  letter-spacing: .01em;
  color: var(--cream);
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid rgba(233, 195, 124, .12);
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 22px; }
.panel-head > div:nth-child(2) { flex: 1; }
.stars-total { text-align: right; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.stars-total b { display: block; font-family: var(--serif); font-size: 22px; color: var(--gold); }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(233, 195, 124, .1);
}
.panel-foot .tiny { margin: 0; text-align: right; }

.act-kicker {
  margin: 0 0 6px; font-size: 9px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold-dim); font-weight: 700;
}
.place {
  margin: 4px 0 0; font-family: var(--serif); font-style: italic;
  font-size: 13px; color: var(--gold);
}
.story {
  margin: 14px 0 0; font-size: 13.5px; line-height: 1.78; color: #d9c8b2;
}
.goal-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 18px; padding: 12px 8px;
  background: rgba(0, 0, 0, .26);
  border: 1px solid rgba(233, 195, 124, .1);
  border-radius: 10px;
}
.goal-row div { text-align: center; }
.goal-row span {
  display: block; font-size: 8.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 3px;
}
.goal-row b { font-family: var(--serif); font-size: 19px; color: var(--cream); font-weight: 600; }
.tool-note {
  margin-top: 12px; padding: 10px 12px; border-radius: 9px;
  background: rgba(233, 195, 124, .08);
  border: 1px dashed rgba(233, 195, 124, .35);
  font-size: 11.5px; line-height: 1.55; color: var(--gold);
}
.result .kicker { color: var(--gold); }
.res-line { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.res-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  margin: 18px 0 0; background: rgba(233, 195, 124, .12);
  border: 1px solid rgba(233, 195, 124, .12); border-radius: 10px; overflow: hidden;
}
.res-grid div { background: rgba(18, 12, 9, .92); padding: 10px 8px; }
.res-grid span { display: block; font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.res-grid b { font-family: var(--serif); font-size: 19px; color: var(--cream); font-weight: 600; }

.stars { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.stars i {
  width: 34px; height: 34px; display: block;
  background: rgba(255, 255, 255, .07);
  clip-path: polygon(50% 2%, 61% 37%, 98% 37%, 68% 58%, 79% 94%, 50% 72%, 21% 94%, 32% 58%, 2% 37%, 39% 37%);
  transform: scale(.94);
}
.stars i.on {
  background: linear-gradient(180deg, #fff0c8, #e9c37c 55%, #b8842f);
  box-shadow: 0 0 18px rgba(233, 195, 124, .45);
  animation: starPop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.stars i.on:nth-child(2) { animation-delay: .16s; }
.stars i.on:nth-child(3) { animation-delay: .32s; }
@keyframes starPop { from { transform: scale(.2) rotate(-30deg); opacity: 0; } to { transform: scale(.94) rotate(0); opacity: 1; } }

/* ---------------------------------------------------------------- chapter map */
.chapter-scroll { max-height: min(52vh, 430px); overflow-y: auto; padding-right: 4px; }
.chapter-scroll::-webkit-scrollbar { width: 6px; }
.chapter-scroll::-webkit-scrollbar-thumb { background: rgba(233, 195, 124, .25); border-radius: 3px; }
.act-block { margin-bottom: 14px; }
.act-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 4px 0 8px;
}
.act-head b {
  font-family: var(--serif); font-size: 12px; letter-spacing: .16em;
  color: var(--gold); text-transform: uppercase; font-weight: 600;
}
.act-head span { font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 7px; }
.ch {
  position: relative; appearance: none; cursor: pointer;
  border: 1px solid rgba(233, 195, 124, .16);
  background: linear-gradient(180deg, rgba(46, 31, 24, .9), rgba(26, 18, 14, .9));
  color: var(--cream); border-radius: 9px; padding: 7px 4px 5px;
  font-family: var(--serif); font-size: 14px; line-height: 1;
  transition: transform .14s ease, border-color .16s ease, background .16s ease;
}
.ch:hover { transform: translateY(-2px); border-color: rgba(233, 195, 124, .55); }
.ch .s { display: block; font-size: 7.5px; letter-spacing: 1px; color: var(--gold); height: 8px; margin-top: 3px; }
.ch.done { border-color: rgba(233, 195, 124, .45); background: linear-gradient(180deg, rgba(70, 48, 26, .95), rgba(38, 25, 15, .95)); }
.ch.locked { opacity: .34; cursor: not-allowed; }
.ch.locked:hover { transform: none; border-color: rgba(233, 195, 124, .16); }
.ch.current { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(233, 195, 124, .3), 0 0 18px rgba(233, 195, 124, .18); }

/* --------------------------------------------------------------------- doc */
.doc { max-width: 780px; margin: 44px auto 0; }
.doc h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(24px, 3.6vw, 36px); line-height: 1.24;
  margin: 0 0 14px; color: #fff1dc; letter-spacing: -.005em;
}
.doc .standfirst {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(15px, 2.2vw, 19px); line-height: 1.6; color: var(--gold);
  border-left: 2px solid rgba(233, 195, 124, .35); padding-left: 14px; margin: 0 0 22px;
}
.doc p { font-size: 14.5px; line-height: 1.85; color: #c9b8a4; margin: 0 0 15px; }
.doc strong { color: #f3e3cd; font-weight: 600; }
.doc h2 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(18px, 2.6vw, 23px);
  color: #f6e7d0; margin: 34px 0 10px; padding-top: 18px;
  border-top: 1px solid rgba(233, 195, 124, .1);
}
.doc ol.howto, .doc ul.howto { margin: 0 0 8px; padding-left: 20px; }
.doc ol.howto li, .doc ul.howto li {
  font-size: 14px; line-height: 1.75; color: #c9b8a4; margin: 0 0 8px;
}
.doc li strong { color: #f3e3cd; }
.doc table {
  width: 100%; border-collapse: collapse; margin: 6px 0 12px;
  font-size: 13px; table-layout: fixed;
}
.doc th, .doc td {
  text-align: left; padding: 9px 10px;
  border-bottom: 1px solid rgba(233, 195, 124, .1);
  color: #c9b8a4; overflow-wrap: break-word; vertical-align: top; line-height: 1.55;
}
.doc th {
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-dim); font-weight: 700;
  border-bottom-color: rgba(233, 195, 124, .25);
}
.doc td:first-child { color: #ecdbc4; }
.doc kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 4px; padding: 2px 5px; color: #efe0cb;
}
.doc code {
  font: 12.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, .06); padding: 2px 5px; border-radius: 4px; color: var(--gold);
}
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 24px 0 0; }
.tags span {
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); border: 1px solid rgba(233, 195, 124, .16);
  border-radius: 999px; padding: 5px 11px;
}

/* --------------------------------------------------------------------- faq */
.faq { max-width: 780px; margin: 40px auto 0; padding-top: 8px; }
.faq h2 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(19px, 2.6vw, 24px);
  color: #f6e7d0; margin: 0 0 14px; border-top: 1px solid rgba(233, 195, 124, .1); padding-top: 20px;
}
.faq h3 { font-size: 14px; margin: 16px 0 5px; color: #f0e0c9; font-weight: 600; }
.faq p { font-size: 13.5px; line-height: 1.8; color: #bda991; margin: 0; }

.foot {
  max-width: 780px; margin: 40px auto 0; padding-top: 16px;
  border-top: 1px solid rgba(233, 195, 124, .08);
  font-size: 11px; color: rgba(182, 160, 138, .55); line-height: 1.7;
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 640px) {
  .wrap { padding: 0 10px 40px; }
  .stage { border-radius: 10px; height: 100dvh; min-height: 520px; }
  .topbar { padding: 8px 2px 10px; }
  .topnav { gap: 10px; font-size: 10px; }
  .panel { padding: 22px 16px 18px; }
  .doc { margin-top: 30px; }
  .doc table { font-size: 12px; }
  .doc th, .doc td { padding: 7px 7px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .stage { height: 100dvh; min-height: 320px; }
  .overlay { padding: 8px; }
  .panel { padding: 16px 18px; }
  .panel h2 { font-size: 20px; }
  .story { font-size: 12px; line-height: 1.6; margin-top: 8px; }
  .goal-row { margin-top: 10px; padding: 8px; }
  .title-inner { padding-bottom: 10px; }
  .lede { margin-top: 10px; font-size: 12px; }
}
