:root {
  --ink: #050505;
  --ink-2: #0c0a08;
  --felt: #14532d;
  --felt-hot: #1b8a46;
  --gold: #f5c518;
  --gold-hot: #ffd86b;
  --ember: #ff8a00;
  --royal: #2b6cb0;
  --cream: #f6e7c1;
  --muted: #cbb892;
  --crimson: #9b1c2c;
  --line: rgba(245, 197, 24, 0.38);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 92px;
  --rail-h: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font-family: Sora, sans-serif;
}

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

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.felt-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(27, 138, 70, 0.28), transparent 55%),
    radial-gradient(80% 50% at 100% 100%, rgba(255, 138, 0, 0.16), transparent 50%),
    linear-gradient(180deg, #050505 0%, #0a0806 100%);
  pointer-events: none;
}

.ember-glow {
  position: absolute;
  inset: auto 0 18% 0;
  height: 40%;
  background: radial-gradient(ellipse at center, rgba(245, 197, 24, 0.12), transparent 70%);
  pointer-events: none;
}

.screen, .site-shell {
  position: absolute;
  inset: 0;
}

.screen {
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 8;
}

.screen.is-on {
  display: flex !important;
}

.boot-seal {
  width: min(100%, 340px);
  text-align: center;
}

.boot-crest {
  width: 120px;
  height: 120px;
  margin: 0 auto 12px;
  filter: drop-shadow(0 8px 18px rgba(245, 197, 24, 0.35));
}

.boot-track {
  margin-top: 18px;
  height: 8px;
  border-radius: 999px;
  background: #1a140c;
  border: 1px solid var(--line);
  overflow: hidden;
}

.boot-track i {
  display: block;
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, var(--ember), var(--gold-hot));
}

.boot-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.brand-chip {
  display: inline-block;
  letter-spacing: 0.28em;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
}

.fire-title {
  font-family: Cinzel, serif;
  font-weight: 800;
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1.05;
  background: linear-gradient(180deg, #fff4c4 0%, #f5c518 38%, #ff8a00 78%, #9b1c2c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #3a1600) drop-shadow(0 10px 16px rgba(255, 138, 0, 0.35));
}

.fire-title.mini {
  font-size: clamp(18px, 5.4vw, 26px);
  filter: drop-shadow(0 1px 0 #3a1600);
}

.site-shell {
  display: none;
  flex-direction: column;
  padding-top: var(--safe-t);
}

.site-shell.is-on {
  display: flex;
}

.brand-rail {
  flex: 0 0 var(--rail-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(26, 18, 8, 0.92), rgba(5, 5, 5, 0.7));
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.brand-copy {
  min-width: 0;
}

.rail-orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #120e08;
  flex: 0 0 46px;
}

.rail-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#pages {
  flex: 1;
  min-height: 0;
  position: relative;
}

.page {
  position: absolute;
  inset: 0;
  display: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 12px);
}

.page.is-on {
  display: block;
}

.lede {
  margin: 10px 0 14px;
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.45;
  color: var(--muted);
}

.lede.slim {
  margin-top: 6px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.hero-well {
  position: relative;
  height: min(38vh, 280px);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 12px 30px rgba(0, 0, 0, 0.45);
}

.hero-hall {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-guide {
  position: absolute;
  right: 2%;
  bottom: 0;
  width: min(52%, 190px);
  height: 92%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.hero-flare {
  position: absolute;
  inset: auto 20% -20% 20%;
  height: 50%;
  background: radial-gradient(circle, rgba(255, 216, 107, 0.35), transparent 70%);
  pointer-events: none;
}

.felt-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #27a855 0%, #146b34 100%);
  border: 1px solid #8dffb2;
  box-shadow: 0 8px 0 #0b3d1c, 0 12px 22px rgba(0, 0, 0, 0.35);
  color: #f4fff7;
}

.felt-cta.slim {
  justify-content: center;
  box-shadow: 0 5px 0 #0b3d1c;
}

.felt-cta img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #0b2414;
}

.felt-cta em {
  display: block;
  font-style: normal;
  font-family: Cinzel, serif;
  font-size: 16px;
}

.felt-cta small {
  display: block;
  opacity: 0.85;
  font-size: 12px;
}

.pulse-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.pulse-pip {
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(20, 83, 45, 0.28);
}

.pulse-pip img {
  width: 28px;
  height: 28px;
  margin: 0 auto 4px;
  border-radius: 50%;
}

.pulse-pip b {
  display: block;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--gold-hot);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pulse-pip.is-open {
  box-shadow: 0 0 0 1px var(--gold), 0 0 16px rgba(245, 197, 24, 0.35);
}

.teaser-stack, .guide-stack, .chronicle-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.foil-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(245, 197, 24, 0.08), rgba(5, 5, 5, 0.5)),
    #120e0a;
  border: 1px solid var(--line);
}

.foil-card img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
}

.foil-card h2 {
  font-family: Cinzel, serif;
  font-size: 16px;
  color: var(--gold-hot);
  margin-bottom: 4px;
}

.foil-card p {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.lock-barrel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 560px);
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background:
    linear-gradient(180deg, #5a3d16 0%, #2a1b0b 38%, #140e08 100%);
  border-radius: 28px 28px 0 0;
  border: 1px solid #e0b43a;
  border-bottom: 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45), inset 0 8px 0 rgba(255, 216, 107, 0.18);
  z-index: 6;
}

.barrel-shine {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 6px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 244, 196, 0.45), transparent);
  pointer-events: none;
}

.lock-pin {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px 10px;
  transform: translateY(10px);
  opacity: 0.72;
}

.lock-pin.is-set {
  transform: translateY(-8px);
  opacity: 1;
}

.lock-pin .nib {
  width: 14px;
  height: 10px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(#ffe38a, #c48a12);
  box-shadow: 0 2px 0 #6a4308;
}

.lock-pin.is-set .nib {
  height: 16px;
  box-shadow: 0 0 12px var(--gold);
}

.lock-pin img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.lock-pin span {
  font-size: 10px;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.05;
  text-align: center;
  max-width: 100%;
}

.zone-cylinder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.zone-card {
  position: relative;
  min-height: 112px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  text-align: left;
  padding: 10px;
  background: #120e0a;
}

.zone-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.38;
}

.zone-card span, .zone-card strong, .zone-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.zone-card strong {
  font-family: Cinzel, serif;
  font-size: 15px;
  color: var(--gold-hot);
}

.zone-card small {
  font-size: 11px;
  color: var(--muted);
}

.zone-card.is-lock {
  filter: grayscale(0.4);
  opacity: 0.7;
}

.zone-card.is-on {
  box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(245, 197, 24, 0.28);
}

.chamber-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chamber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(18, 14, 10, 0.9);
  text-align: left;
}

.chamber-row img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
}

.chamber-row strong {
  display: block;
  font-size: 14px;
}

.chamber-row small {
  color: var(--muted);
  font-size: 12px;
}

.chamber-row.is-lock {
  opacity: 0.55;
}

.chamber-row.is-done {
  border-color: var(--felt-hot);
}

.run-stage {
  display: none;
}

.run-stage.is-on, .zone-stage.is-on {
  display: block;
}

.zone-stage {
  display: none;
}

.run-hud {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.hud-back {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--royal);
  font-size: 12px;
  font-weight: 700;
}

.hud-title strong {
  display: block;
  font-family: Cinzel, serif;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-pips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-align: right;
}

.run-hint {
  margin: 8px 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.board-frame {
  width: 100%;
  max-width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(20, 83, 45, 0.5), rgba(8, 20, 12, 0.9)),
    url("chamber-felt.png") center / cover;
  border: 1px solid var(--line);
  overflow: hidden;
}

.board {
  display: grid;
  width: 100%;
  max-height: min(52vh, 420px);
  margin: 0 auto;
  gap: 3px;
  touch-action: none;
}

.cell {
  position: relative;
  appearance: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 7px;
  background: #1a120c;
  border: 1px solid rgba(245, 197, 24, 0.15);
  overflow: hidden;
}

.cell.wall {
  background: linear-gradient(180deg, #3a2a16, #1a1208);
  box-shadow: inset 0 0 0 1px #6a4a18;
}

.cell.floor, .cell.start, .cell.exit, .cell.relic, .cell.key, .cell.plate, .cell.gate, .cell.rift, .cell.mist {
  background: radial-gradient(circle at 30% 20%, #1f6a3c, #0d2a18);
}

.cell.rift {
  background: repeating-linear-gradient(45deg, #0a0a0a, #0a0a0a 4px, #3a1a08 4px, #3a1a08 8px);
}

.cell.mist::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(200, 200, 210, 0.45);
  backdrop-filter: blur(2px);
}

.cell.gate {
  background: linear-gradient(180deg, #8a6a18, #3a2808);
}

.cell.gate.is-open {
  background: radial-gradient(circle at 30% 20%, #1f6a3c, #0d2a18);
}

.cell.plate::before {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px solid #8dffb2;
}

.cell.plate.is-held::before {
  background: rgba(245, 197, 24, 0.45);
}

.cell.echoing {
  box-shadow: inset 0 0 12px var(--gold-hot);
}

.cell.has-trace::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: url("echo-sigil.png") center / contain no-repeat;
  opacity: 0.9;
  pointer-events: none;
}

.cell .token {
  position: absolute;
  inset: 6%;
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.cell .loot {
  position: absolute;
  inset: 16%;
  object-fit: contain;
  z-index: 1;
}

.cell.exit .loot {
  inset: 8%;
}

.cell.is-walk {
  box-shadow: inset 0 0 0 1px rgba(255, 216, 107, 0.55);
}

.run-tools {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.tool-btn {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #16110b;
  font-size: 12px;
  font-weight: 700;
}

.tool-btn.echo {
  background: linear-gradient(180deg, #3a2a10, #1a1208);
  color: var(--gold-hot);
}

.tool-btn img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.relic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0;
}

.relic-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #120e0a;
}

.relic-card.is-off {
  filter: grayscale(1);
  opacity: 0.45;
}

.relic-card img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
}

.relic-card h3 {
  font-family: Cinzel, serif;
  color: var(--gold-hot);
  font-size: 16px;
}

.relic-card p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.stat-ribbon {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-ribbon div {
  padding: 10px 6px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(20, 83, 45, 0.25);
}

.stat-ribbon b {
  display: block;
  font-family: Cinzel, serif;
  color: var(--gold);
  font-size: 18px;
}

.stat-ribbon span {
  font-size: 11px;
  color: var(--muted);
}

.chronicle-stack article {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(43, 108, 176, 0.12), transparent 40%),
    #120e0a;
}

.chronicle-stack h3 {
  font-family: Cinzel, serif;
  color: var(--gold-hot);
  margin-bottom: 6px;
}

.chronicle-stack p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.sheet {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 12;
  padding: 16px 16px calc(16px + var(--safe-b));
}

.sheet[hidden] {
  display: none;
}

.sheet-card {
  width: min(100%, 440px);
  max-height: min(78vh, 560px);
  overflow: auto;
  padding: 18px;
  border-radius: 22px;
  background: #120e0a;
  border: 1px solid var(--line);
}

.sheet-card.win {
  text-align: center;
}

.sheet-card.win img {
  width: 92px;
  height: 92px;
  margin: 0 auto 8px;
  border-radius: 20px;
}

.sheet-card h2 {
  font-family: Cinzel, serif;
  margin: 6px 0 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(245, 197, 24, 0.12);
  font-size: 14px;
}

.fine {
  margin: 10px 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px);
  transform: translateX(-50%);
  width: min(92%, 360px);
  padding: 10px 12px;
  border-radius: 12px;
  background: #2b6cb0;
  color: #fff;
  font-size: 13px;
  z-index: 14;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

body.reduce .ember-glow, body.reduce .hero-flare, body.reduce .boot-track i {
  animation: none;
}

@media (max-width: 360px) {
  .hero-well {
    height: min(32vh, 220px);
  }
  .lock-pin span {
    font-size: 8px;
  }
  .lock-pin img {
    width: 22px;
    height: 22px;
  }
  .run-tools {
    grid-template-columns: 1fr;
  }
  .hud-pips {
    font-size: 9px;
  }
  .board {
    max-height: 42vh;
    gap: 2px;
  }
  .foil-card {
    grid-template-columns: 52px minmax(0, 1fr);
  }
  .brand-rail {
    padding: 6px 8px;
  }
  .pulse-pip b {
    font-size: 9px;
  }
  .felt-cta em {
    font-size: 14px;
  }
}

@media (min-width: 430px) {
  .page {
    padding-left: 20px;
    padding-right: 20px;
  }
  .relic-grid {
    grid-template-columns: 1fr 1fr;
  }
  .hero-well {
    height: min(42vh, 320px);
  }
}

@media (min-height: 780px) {
  .board {
    max-height: 56vh;
  }
}
