:root {
  --obsidian: #12060a;
  --velvet: #1a080c;
  --wine: #3b0a12;
  --ruby: #c8102e;
  --gold: #e8c547;
  --gold-deep: #b8892a;
  --amber: #e8942a;
  --cream: #f6e8c8;
  --mute: #cbb79a;
  --line: rgba(232, 197, 71, 0.42);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --rail-h: 56px;
  --tumbler-h: 82px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--obsidian);
  color: var(--cream);
  font-family: Padauk, "Noto Sans Myanmar", sans-serif;
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: break-word;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
.eyebrow,
strong {
  font-family: Cinzel, Padauk, serif;
  letter-spacing: 0.04em;
}

#app {
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

.haze {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(90% 70% at 50% -8%, rgba(200, 16, 46, 0.32), transparent 52%),
    radial-gradient(80% 50% at 100% 100%, rgba(232, 197, 71, 0.14), transparent 46%),
    url("hero.png") center / cover no-repeat;
  opacity: 0.34;
  pointer-events: none;
  z-index: 0;
}

.glint {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: radial-gradient(circle at 18% 22%, rgba(255, 236, 180, 0.14) 0 1px, transparent 2px);
  background-size: 42px 42px;
  mix-blend-mode: screen;
  opacity: 0.4;
}

.boot,
.shell {
  position: relative;
  z-index: 2;
}

.boot {
  display: none;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}

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

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

.boot-dial {
  width: 132px;
  height: 132px;
  margin: 0 auto 14px;
  border-radius: 50%;
  padding: 6px;
  background:
    conic-gradient(from 210deg, var(--gold), var(--ruby), var(--gold-deep), var(--gold));
  box-shadow: 0 0 28px rgba(232, 197, 71, 0.35);
  animation: spinDial 8s linear infinite;
}

.boot-dial img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.boot h1,
.home-stack h1 {
  margin: 6px 0 8px;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  color: var(--gold);
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.boot-line,
.lede {
  margin: 0 0 16px;
  color: var(--mute);
  font-size: 0.98rem;
  max-width: 100%;
}

.boot-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(232, 197, 71, 0.16);
  overflow: hidden;
  border: 1px solid var(--line);
}

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

.shell {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}

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

.rail {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: calc(var(--rail-h) + var(--safe-t));
  padding: calc(8px + var(--safe-t)) 12px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(18, 6, 10, 0.96), rgba(26, 8, 12, 0.88));
  border-bottom: 1px solid var(--line);
}

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

.rail-mark img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--gold);
}

.rail-mark strong {
  display: block;
  font-size: 0.92rem;
  color: var(--gold);
}

.seal-hit {
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  flex: 0 0 auto;
}

.seal-hit img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
}

.ribbon-slot {
  display: flex;
  justify-content: center;
  pointer-events: none;
  margin: -4px 12px 0;
  position: relative;
  z-index: 7;
}

.ribbon-slot span {
  background: linear-gradient(180deg, #f3d98a, var(--gold-deep));
  color: #3b1608;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 14px 5px;
  max-width: min(220px, calc(100% - 8px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 100%, 0 100%);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

#pages {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 14px calc(var(--tumbler-h) + var(--safe-b) + 10px);
}

.hall {
  display: none;
  width: 100%;
}

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

.home-stack,
.page-intro {
  width: 100%;
}

.hero-well {
  position: relative;
  height: clamp(168px, 42vw, 230px);
  margin: 4px 0 16px;
  border-radius: 22px 8px 22px 8px;
  overflow: hidden;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 4px rgba(26, 8, 12, 0.45), 0 12px 28px rgba(0, 0, 0, 0.35);
}

.hero-room {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-gem,
.hero-box,
.hero-keeper {
  position: absolute;
  object-fit: cover;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.hero-gem {
  width: 18%;
  bottom: 12%;
  left: 8%;
}

.hero-box {
  width: 26%;
  bottom: 8%;
  right: 7%;
}

.hero-keeper {
  width: 34%;
  bottom: 0;
  left: 32%;
}

.ingot {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--gold);
  background:
    linear-gradient(180deg, rgba(200, 16, 46, 0.35), rgba(26, 8, 12, 0.2)),
    linear-gradient(90deg, #4a140c, #2a0c10);
  color: var(--cream);
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(232, 197, 71, 0.2), 0 10px 24px rgba(200, 16, 46, 0.25);
}

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

.ingot em {
  display: block;
  font-style: normal;
  font-weight: 700;
  color: var(--gold);
}

.ingot small {
  color: var(--mute);
}

.ingot.slim {
  width: auto;
  padding: 8px 14px;
}

.ingot.slim img {
  display: none;
}

.dial-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 8px;
  flex-wrap: wrap;
}

.dial-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: #2a1014;
}

.dial-row i.is-on {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.home-count {
  text-align: center;
  color: var(--mute);
  margin: 0 0 14px;
}

.facet-grid,
.lore-stack,
.guide-list,
.set-list {
  display: grid;
  gap: 10px;
}

.facet,
.lore,
.guide-list li,
.vault-card,
.relic {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(59, 10, 18, 0.72), rgba(18, 6, 10, 0.8));
  border-radius: 18px 6px 18px 6px;
  position: relative;
}

.facet::before,
.lore::before,
.vault-card::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ruby);
  box-shadow: 0 0 8px var(--ruby);
}

.facet img,
.lore img,
.guide-list img,
.vault-card img,
.relic img,
.page-intro img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.facet h2,
.lore h2,
.guide-list h2,
.vault-card h2,
.relic h2,
.page-intro h1 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  color: var(--gold);
}

.facet p,
.lore p,
.guide-list p,
.vault-card p,
.page-intro p {
  margin: 0;
  color: var(--mute);
  font-size: 0.95rem;
}

.text-hit {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: transparent;
  border: 0;
  color: var(--gold);
  text-decoration: underline;
  padding: 8px;
}

.page-intro {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.page-intro h1 {
  font-size: clamp(1.2rem, 5vw, 1.6rem);
}

.wing-band {
  margin-bottom: 16px;
}

.wing-band h2 {
  margin: 0;
  color: var(--gold);
  font-size: 1.05rem;
}

.wing-band .line {
  margin: 0 0 8px;
  color: var(--mute);
}

.vault-card {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
}

.vault-card .meta {
  margin-top: 4px;
  color: var(--gold);
  font-size: 0.82rem;
}

.vault-card.is-locked {
  opacity: 0.48;
}

.vault-card.is-cleared {
  box-shadow: inset 0 0 0 1px var(--gold);
}

.record-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.record-strip article {
  text-align: center;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(59, 10, 18, 0.6);
}

.record-strip b {
  display: block;
  color: var(--gold);
  font-size: 1.2rem;
}

.record-strip span {
  color: var(--mute);
  font-size: 0.8rem;
}

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

.relic {
  flex-direction: column;
  min-width: 0;
}

.relic.is-on {
  border-color: var(--gold);
}

.guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(59, 10, 18, 0.65);
}

.set-row i {
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: #2a1014;
  border: 1px solid var(--line);
  position: relative;
}

.set-row i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mute);
}

.set-row.is-on i {
  background: rgba(200, 16, 46, 0.55);
  border-color: var(--gold);
}

.set-row.is-on i::after {
  left: 20px;
  background: var(--gold);
}

.set-row.danger {
  color: #ffb4b4;
  justify-content: center;
}

.tumbler {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  padding: 0 6px var(--safe-b);
  background:
    linear-gradient(180deg, transparent, rgba(18, 6, 10, 0.2) 12%),
    linear-gradient(180deg, #2a0c12 0%, #12060a 70%);
  border-top: 1px solid var(--gold);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
}

.tumbler-rail {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: var(--tumbler-h);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  padding: 0 4px;
}

.tumbler-rail::-webkit-scrollbar {
  display: none;
}

.peg {
  flex: 1 1 0;
  min-width: 0;
  max-width: 56px;
  height: 62px;
  margin: 0 1px 8px;
  border: 1px solid var(--gold-deep);
  padding: 8px 2px 6px;
  background: radial-gradient(circle at 50% 30%, #4a1418, #1a080c 72%);
  clip-path: polygon(50% 0, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  z-index: 1;
}

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

.peg span {
  font-size: 0.62rem;
  line-height: 1.1;
  color: var(--mute);
  max-width: 100%;
}

.peg-crown {
  max-width: 64px;
  height: 70px;
  z-index: 2;
  margin-bottom: 12px;
  background: radial-gradient(circle at 50% 30%, #8a1a24, #2a080c 74%);
}

.peg.is-on {
  transform: translateY(-10px) scale(1.08);
  z-index: 4;
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.45);
  background: radial-gradient(circle at 50% 28%, #c8102e, #1a080c 70%);
}

.peg.is-on span {
  color: var(--gold);
}

body.is-play .tumbler {
  --tumbler-h: 70px;
}

body.is-play .peg span {
  display: none;
}

body.is-play .peg {
  height: 52px;
}

.play-shell {
  position: relative;
  min-height: calc(100dvh - var(--rail-h) - var(--tumbler-h) - var(--safe-t) - var(--safe-b) - 36px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.play-hud,
.combo-bar,
.result-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-hud {
  justify-content: space-between;
}

.hud-title {
  min-width: 0;
  text-align: center;
}

.hud-title h1 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--gold);
}

.chip {
  border: 1px solid var(--line);
  background: rgba(26, 8, 12, 0.8);
  color: var(--cream);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.chip:disabled {
  opacity: 0.4;
}

.combo-bar {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 8px;
  background: rgba(59, 10, 18, 0.55);
  justify-content: space-between;
}

.combo-dial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  overflow: hidden;
  transform: rotate(var(--turn, 0deg));
  flex: 0 0 auto;
}

.combo-dial img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.combo-pins {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.combo-pins i {
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-style: normal;
}

.combo-pins i.is-on {
  background: var(--gold);
  color: #3b1608;
  border-color: var(--gold);
}

.combo-moves {
  text-align: right;
}

.combo-moves small {
  display: block;
  color: var(--mute);
  font-size: 0.68rem;
}

.combo-moves b {
  color: var(--gold);
  font-size: 1.05rem;
}

.board-mount {
  flex: 1;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

.filament {
  display: grid;
  gap: 3px;
  padding: 6px;
  background: rgba(12, 4, 8, 0.72);
  border: 1px solid var(--gold);
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgba(200, 16, 46, 0.2);
}

.cell {
  position: relative;
  border: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #14080c;
}

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

.cell .gem {
  position: absolute;
  inset: 12%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.cell .pin {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 0.62rem;
  font-style: normal;
  color: #3b1608;
  background: var(--gold);
  min-width: 14px;
  height: 14px;
  border-radius: 99px;
  display: grid;
  place-items: center;
}

.cell.is-wall img {
  filter: saturate(0.8);
}

.cell.is-thread {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.cell.is-thread::after {
  content: "";
  position: absolute;
  background: linear-gradient(90deg, #f3d98a, var(--amber));
  box-shadow: 0 0 8px var(--amber);
  z-index: 2;
}

.cell[data-from="l"]::after {
  left: -35%;
  width: 70%;
  height: 18%;
  top: 41%;
}

.cell[data-from="r"]::after {
  right: -35%;
  width: 70%;
  height: 18%;
  top: 41%;
}

.cell[data-from="u"]::after {
  top: -35%;
  height: 70%;
  width: 18%;
  left: 41%;
}

.cell[data-from="d"]::after {
  bottom: -35%;
  height: 70%;
  width: 18%;
  left: 41%;
}

.cell.is-head {
  box-shadow: inset 0 0 0 2px #fff3c4, 0 0 12px var(--amber);
  z-index: 3;
}

.cell.is-well {
  box-shadow: inset 0 0 12px var(--amber);
}

.arrow-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 0.9rem;
  text-shadow: 0 0 6px #000;
}

.resin-drop,
.lock-dot {
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  top: 35%;
  left: 35%;
}

.resin-drop {
  background: rgba(232, 148, 42, 0.7);
}

.lock-dot {
  background: var(--ruby);
  box-shadow: 0 0 8px var(--ruby);
}

.toast {
  margin: 0;
  text-align: center;
  color: var(--gold);
  min-height: 1.2em;
  font-size: 0.9rem;
}

.result-mask {
  position: absolute;
  inset: 0;
  background: rgba(12, 4, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 5;
}

.result-mask[hidden] {
  display: none !important;
}

.result-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #3b0a12, #12060a);
}

.result-card img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  margin: 0 auto 8px;
  border-radius: 16px;
}

.result-card h2 {
  margin: 0 0 6px;
  color: var(--gold);
}

.result-row {
  justify-content: center;
  margin-top: 10px;
}

body.is-calm .boot-dial,
body.is-calm .peg.is-on,
body.is-calm .combo-dial {
  animation: none;
  transform: none;
}

body.is-calm .glint {
  display: none;
}

@keyframes spinDial {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 360px) {
  :root {
    --tumbler-h: 74px;
  }

  .peg {
    height: 56px;
    margin: 0 0 8px;
  }

  .peg-crown {
    height: 62px;
  }

  .peg span {
    font-size: 0.52rem;
  }

  .hero-well {
    height: 150px;
  }

  .relic-grid,
  .record-strip {
    grid-template-columns: 1fr 1fr;
  }

  .combo-bar {
    flex-wrap: wrap;
  }
}

@media (min-width: 430px) {
  .peg {
    width: 58px;
  }

  .hero-well {
    height: 240px;
  }
}

@media (max-height: 620px) {
  .hero-well {
    height: 132px;
  }

  .play-shell {
    min-height: 0;
  }

  .board-mount {
    min-height: 180px;
  }
}
