:root {
  --wine: #14080a;
  --velvet: #2a0c10;
  --panel: #3a1418;
  --gold: #f0b429;
  --orange: #f5a114;
  --amber: #ffd36a;
  --ruby: #c41e3a;
  --jade: #1f9a58;
  --sapphire: #1e5cb3;
  --cream: #fff4dc;
  --mute: #cbb48a;
  --line: rgba(240, 180, 41, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --rail: 64px;
  --head: 56px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--wine);
  color: var(--cream);
  font-family: "Noto Sans Myanmar", "Padauk", "Myanmar Text", sans-serif;
}

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

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

[hidden] {
  display: none !important;
}

#app {
  height: 100dvh;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.velvet {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #6b1d18 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 100%, #1e3a6a 0%, transparent 45%),
    linear-gradient(180deg, #1a090c, #0c0506);
  pointer-events: none;
}

.dust {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, rgba(255, 211, 106, 0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 18%, rgba(245, 161, 20, 0.4) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 40% 70%, rgba(255, 244, 220, 0.25) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 64%, rgba(240, 180, 41, 0.35) 50%, transparent 51%);
  animation: drift 18s linear infinite;
  opacity: 0.7;
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-40px); }
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8;
}

.view.is-on { display: flex; }

.boot-card {
  width: min(86vw, 340px);
  text-align: center;
  padding: 28px 20px 24px;
  background:
    linear-gradient(180deg, rgba(90, 30, 24, 0.9), rgba(20, 8, 10, 0.95));
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 4px rgba(240, 180, 41, 0.08),
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 211, 106, 0.35);
  clip-path: polygon(12% 0, 88% 0, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0 88%, 0 12%);
}

.boot-card img {
  width: 112px;
  height: 112px;
  margin: 0 auto 10px;
  filter: drop-shadow(0 8px 16px rgba(245, 161, 20, 0.35));
}

.mark {
  display: inline-block;
  font-family: Cinzel, serif;
  font-weight: 800;
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--orange);
  text-transform: lowercase;
  background: linear-gradient(90deg, #f5a114, #ffd36a, #f5a114);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.boot-card h1, .hero-copy h1 {
  font-family: Cinzel, serif;
  font-weight: 800;
  font-size: clamp(22px, 6.4vw, 30px);
  color: var(--amber);
  margin-top: 4px;
}

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

.boot-track {
  margin-top: 16px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 211, 106, 0.15);
  overflow: hidden;
}

.boot-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--orange), var(--amber));
  animation: fill 1.15s ease forwards;
}

@keyframes fill { to { width: 100%; } }

.shell {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding-top: var(--safe-t);
  z-index: 2;
}

.shell.is-on { display: grid; }

.pediment {
  height: var(--head);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: relative;
}

.pediment::before,
.pediment::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.pediment::before { top: 0; }
.pediment::after { bottom: 0; opacity: 0.4; }

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

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.4);
}

.brand strong {
  display: block;
  font-family: Cinzel, serif;
  font-size: 13px;
  color: var(--amber);
  white-space: nowrap;
}

.gear {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  gap: 3px;
  background: rgba(58, 20, 24, 0.8);
}

.gear span {
  display: block;
  width: 14px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}

.pages {
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.page {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 14px 12px;
  display: none;
  -webkit-overflow-scrolling: touch;
}

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

#page-play.is-on {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 6px;
}

.hero-copy { padding: 4px 2px 10px; }

.kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--orange);
}

.lede {
  margin-top: 8px;
  color: var(--mute);
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.55;
}

.hero-well {
  border-radius: 18px 18px 42px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  max-height: 28vh;
}

.hero-well img {
  width: 100%;
  height: 28vh;
  object-fit: cover;
}

.lozenge {
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd36a 0%, #f5a114 42%, #c47a0a 100%);
  color: #3a1408;
  box-shadow:
    0 8px 0 #7a3e08,
    0 14px 24px rgba(245, 161, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.lozenge.slim { justify-content: center; margin-top: 12px; }

.lozenge img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.lozenge em {
  font-style: normal;
  font-weight: 700;
  font-size: 15px;
  display: block;
}

.lozenge small {
  display: block;
  opacity: 0.8;
  font-size: 11px;
}

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

.stat {
  text-align: center;
  padding: 10px 4px;
  background: rgba(58, 20, 24, 0.7);
  border: 1px solid var(--line);
  clip-path: polygon(10% 0, 90% 0, 100% 20%, 100% 80%, 90% 100%, 10% 100%, 0 80%, 0 20%);
}

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

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

.tease {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.facet {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: linear-gradient(90deg, rgba(90, 28, 22, 0.8), rgba(20, 8, 10, 0.5));
  border: 1px solid var(--line);
  border-radius: 16px 6px 16px 6px;
}

.facet img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
}

.facet h2 {
  font-size: 14px;
  color: var(--amber);
  margin-bottom: 4px;
}

.facet p {
  font-size: 12px;
  color: var(--mute);
  line-height: 1.45;
}

.play-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.hud-name { min-width: 0; }

.hud-name small {
  display: block;
  font-family: Cinzel, serif;
  font-size: 10px;
  color: var(--orange);
  letter-spacing: 0.18em;
}

.hud-name strong {
  display: block;
  font-size: clamp(14px, 4vw, 17px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.pill {
  min-width: 42px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 8, 10, 0.7);
  font-size: 12px;
  text-align: center;
}

.hint {
  margin: 6px 0 8px;
  font-size: 12px;
  color: var(--mute);
  line-height: 1.4;
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0c0506 url("chamber.jpg") center/cover;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

#board {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.play-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-shrink: 0;
}

.bar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(58, 20, 24, 0.85);
  color: var(--amber);
  font-size: 12px;
  white-space: nowrap;
}

.pad {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.pad-mid {
  display: flex;
  gap: 22px;
}

.pad button {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, #5a221c, #2a0c10);
  border: 1px solid var(--gold);
  color: var(--amber);
  font-size: 14px;
}

.page-title {
  font-size: 18px;
  color: var(--amber);
  margin: 4px 0 12px;
}

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

.chamber {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: rgba(58, 20, 24, 0.75);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  min-width: 0;
  clip-path: polygon(12% 0, 100% 0, 100% 88%, 88% 100%, 0 100%, 0 12%);
}

.chamber.is-open { box-shadow: inset 0 0 18px rgba(245, 161, 20, 0.18); }
.chamber.is-done { border-color: var(--gold); }
.chamber.is-lock { opacity: 0.45; }

.chamber b {
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1.3;
}

.chamber small {
  font-size: 10px;
  color: var(--mute);
}

.vault-hero {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 12px;
  max-height: 22vh;
}

.vault-hero img {
  width: 100%;
  height: 22vh;
  object-fit: cover;
}

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

.relic {
  padding: 12px 10px;
  background: rgba(58, 20, 24, 0.75);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.relic b {
  display: block;
  font-family: Cinzel, serif;
  font-size: 22px;
  color: var(--amber);
}

.relic span {
  font-size: 12px;
  color: var(--mute);
}

.lore-list, .guide-list {
  display: grid;
  gap: 12px;
}

.scroll, .rule {
  padding: 12px;
  background: linear-gradient(180deg, rgba(90, 28, 22, 0.55), rgba(20, 8, 10, 0.7));
  border: 1px solid var(--line);
  border-radius: 16px;
}

.scroll img {
  width: 100%;
  height: 28vw;
  max-height: 140px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
}

.scroll h3, .rule h3 {
  color: var(--amber);
  font-size: 15px;
  margin-bottom: 6px;
}

.scroll p, .rule p {
  font-size: 13px;
  color: var(--mute);
  line-height: 1.5;
}

.rail {
  position: relative;
  height: calc(var(--rail) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background:
    linear-gradient(180deg, rgba(90, 36, 18, 0.2), rgba(20, 8, 10, 0.96));
  border-top: 1px solid var(--line);
}

.rail::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 10px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, #7a3e08, var(--gold), #7a3e08);
  box-shadow: 0 0 10px rgba(245, 161, 20, 0.45);
}

.rail-fire {
  position: absolute;
  top: 4px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff4dc 0%, var(--orange) 55%, transparent 70%);
  box-shadow: 0 0 12px var(--orange);
  transition: left 0.28s ease;
  pointer-events: none;
  z-index: 2;
}

.votive {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  position: relative;
}

.votive::before {
  content: "";
  width: 1px;
  height: 10px;
  background: var(--gold);
  opacity: 0.7;
}

.bead {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--g) 45%, #3a1408);
  box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.35);
}

.votive small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(9px, 2.5vw, 11px);
  color: var(--mute);
}

.votive.is-on {
  transform: translateY(-6px);
}

.votive.is-on small { color: var(--amber); }

.votive.is-on .bead {
  box-shadow: 0 0 12px var(--g);
  transform: scale(1.15);
}

.sheet, .modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 2, 4, 0.72);
  display: grid;
  place-items: end center;
  padding: 16px 16px calc(16px + var(--safe-b));
}

.modal { place-items: center; }

.sheet-card, .modal-card {
  width: min(100%, 420px);
  background: linear-gradient(180deg, #4a1a16, #1a090c);
  border: 1px solid var(--line);
  border-radius: 22px 22px 8px 8px;
  padding: 18px 16px;
}

.modal-card {
  text-align: center;
  border-radius: 18px;
}

.modal-card img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  margin: 0 auto 10px;
}

.sheet-card h3, .modal-card h3 {
  color: var(--amber);
  margin-bottom: 12px;
}

.modal-card p {
  color: var(--mute);
  font-size: 13px;
}

.toggle, .danger, .ghost {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.toggle { background: rgba(245, 161, 20, 0.12); color: var(--amber); }
.danger { background: rgba(196, 30, 58, 0.18); color: #ffb3b8; }
.ghost { color: var(--mute); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--rail) + var(--safe-b) + 12px);
  transform: translateX(-50%);
  z-index: 30;
  max-width: 86vw;
  padding: 8px 14px;
  border-radius: 999px;
  background: #3a1418;
  border: 1px solid var(--gold);
  font-size: 12px;
}

@media (max-height: 680px) {
  :root { --rail: 58px; --head: 50px; }
  .hero-well, .hero-well img { max-height: 22vh; height: 22vh; }
  .boot-card img { width: 88px; height: 88px; }
  .pad button { width: 40px; height: 32px; }
}

@media (max-width: 340px) {
  .facet { grid-template-columns: 56px minmax(0, 1fr); }
  .facet img { width: 56px; height: 56px; }
  .lozenge img { width: 36px; height: 36px; }
}

@media (min-width: 430px) {
  .pages { max-width: 480px; margin: 0 auto; width: 100%; }
  .rail, .pediment { max-width: 480px; margin: 0 auto; width: 100%; }
}
