:root {
  --wine: #1a0508;
  --oxblood: #3b0b14;
  --ruby: #c8102e;
  --ruby-hot: #e31c3d;
  --gold: #f2c14e;
  --gold-deep: #c4922a;
  --bronze: #8a5a28;
  --cream: #f6e6c8;
  --mute: #d7c3a4;
  --line: rgba(242, 193, 78, 0.42);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --plaque: 56px;
  --dock: 86px;
}

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

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

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

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

[hidden] {
  display: none !important;
}

h1,
h2,
.mark,
.kicker,
.hud-mid strong {
  font-family: Cinzel, "Noto Serif Myanmar", serif;
}

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

.veil {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(90% 70% at 50% -8%, rgba(200, 16, 46, 0.38), transparent 58%),
    radial-gradient(80% 50% at 100% 100%, rgba(242, 193, 78, 0.14), transparent 52%),
    url("hall.png") center / cover no-repeat;
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}

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

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

.boot {
  display: none;
  min-height: 100dvh;
  padding: calc(28px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

.boot-crest {
  width: 118px;
  height: 118px;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: 0 0 0 3px var(--gold), 0 18px 40px rgba(0, 0, 0, 0.45);
  margin-bottom: 18px;
}

.mark {
  margin: 0;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: var(--gold);
  font-size: 12px;
}

.boot h1,
.home-stack > h1 {
  margin: 6px 0 10px;
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 2px 0 #6b1a16, 0 10px 24px rgba(0, 0, 0, 0.45);
}

.boot-en {
  margin: 0 0 6px;
  color: var(--cream);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.boot-my {
  margin: 0 0 16px;
  color: var(--mute);
  font-size: 14px;
}

.boot-play {
  margin-bottom: 16px;
}

.boot-track {
  width: min(240px, 70vw);
  height: 8px;
  border: 1px solid var(--line);
  background: rgba(59, 11, 20, 0.85);
  overflow: hidden;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

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

.shell {
  display: none;
  height: 100dvh;
  max-height: 100dvh;
  flex-direction: column;
  overflow: hidden;
}

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

.plaque {
  flex: 0 0 auto;
  height: calc(var(--plaque) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plaque-face {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 12px 6px 6px;
  background: linear-gradient(180deg, rgba(90, 18, 28, 0.92), rgba(26, 5, 8, 0.92));
  border: 1px solid var(--line);
  clip-path: polygon(12px 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 12px 100%, 0 50%);
}

.plaque-face img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 10px;
  flex: 0 0 auto;
}

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

.plaque-copy .mark {
  letter-spacing: 0.12em;
  font-size: 10px;
}

.plaque-copy strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seal {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: radial-gradient(circle at 40% 30%, #6b1820, #1a0508);
  display: grid;
  place-items: center;
  box-shadow: 0 0 16px rgba(242, 193, 78, 0.25);
}

.seal img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

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

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

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

.page-play.is-on {
  display: flex;
  overflow: hidden;
  padding: 4px 10px 8px;
}

.home-stack,
.page-intro {
  width: min(520px, 100%);
  margin: 0 auto;
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.lede,
.page-intro p {
  margin: 0 0 14px;
  color: var(--mute);
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.65;
}

.hero-well {
  position: relative;
  height: clamp(168px, 42vw, 230px);
  margin: 4px 0 16px;
  overflow: hidden;
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
  border: 1px solid var(--line);
  background: #140308;
}

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

.hero-lantern {
  position: absolute;
  top: 6%;
  width: 18%;
  max-width: 72px;
  animation: sway 3.6s ease-in-out infinite;
}

.hero-lantern.left {
  left: 8%;
}

.hero-lantern.right {
  right: 8%;
  animation-delay: -1.4s;
}

.hero-bowl {
  position: absolute;
  left: 50%;
  bottom: 4%;
  width: 58%;
  max-width: 240px;
  transform: translateX(-50%);
}

.hero-ruby,
.hero-gold {
  position: absolute;
  width: 14%;
  max-width: 54px;
}

.hero-ruby {
  left: 28%;
  top: 18%;
  animation: drop 2.8s ease-in infinite;
}

.hero-gold {
  right: 24%;
  top: 10%;
  animation: drop 3.2s ease-in infinite 0.6s;
}

@keyframes sway {
  0%,
  100% { transform: rotate(-6deg); }
  50% { transform: rotate(7deg); }
}

@keyframes drop {
  0% { transform: translateY(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(70px); opacity: 0; }
}

.lozenge {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #8a1624, #4a0c14);
  border: 1px solid var(--gold);
  color: var(--cream);
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 16px 100%, 0 50%);
  box-shadow: inset 0 0 18px rgba(242, 193, 78, 0.18), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.lozenge img {
  width: 52px;
  height: 36px;
  object-fit: contain;
}

.lozenge em {
  display: block;
  font-style: normal;
  font-family: "Noto Serif Myanmar", serif;
  font-size: clamp(16px, 4.4vw, 18px);
}

.lozenge small {
  color: var(--gold);
  font-size: 12px;
}

.pulse-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-chip {
  padding: 10px 12px;
  background: rgba(59, 11, 20, 0.72);
  border: 1px solid var(--line);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

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

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

.teaser,
.codex-stack,
.item-grid,
.seal-grid {
  display: grid;
  gap: 10px;
}

.cut-card,
.lore-pane,
.item-card,
.seal-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: linear-gradient(160deg, rgba(78, 14, 24, 0.9), rgba(20, 4, 8, 0.92));
  border: 1px solid var(--line);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}

.cut-card img,
.lore-pane img,
.item-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
}

.cut-card h2,
.lore-pane h2,
.item-card h2,
.seal-card h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--gold);
}

.cut-card p,
.lore-pane p,
.item-card p,
.seal-card p {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.55;
}

.page-intro {
  text-align: center;
  margin-bottom: 12px;
}

.page-intro img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 8px;
}

.page-intro h1 {
  margin: 0 0 6px;
  font-size: clamp(22px, 6vw, 28px);
  color: var(--gold);
}

.step-rail {
  list-style: none;
  margin: 0 auto 14px;
  padding: 0;
  width: min(520px, 100%);
  counter-reset: step;
}

.step-rail li {
  position: relative;
  padding: 12px 12px 12px 48px;
  margin-bottom: 8px;
  background: rgba(26, 5, 8, 0.72);
  border: 1px solid var(--line);
}

.step-rail li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 12px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--wine);
  background: var(--gold);
  font-family: Cinzel, serif;
  font-size: 13px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.step-rail h2 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--gold);
}

.step-rail p {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
}

.item-grid {
  width: min(520px, 100%);
  margin: 0 auto;
}

.ledger-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(520px, 100%);
  margin: 0 auto 12px;
}

.ledger-cell {
  text-align: center;
  padding: 12px 6px;
  background: rgba(59, 11, 20, 0.8);
  border: 1px solid var(--line);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
}

.ledger-cell b {
  display: block;
  color: var(--gold);
  font-family: Cinzel, serif;
  font-size: clamp(16px, 5vw, 22px);
}

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

.seal-grid {
  width: min(520px, 100%);
  margin: 0 auto;
}

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

.seal-card.is-off {
  opacity: 0.55;
}

.seal-card img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.codex-stack {
  width: min(520px, 100%);
  margin: 0 auto;
}

.lore-pane img {
  width: 64px;
  height: 64px;
}

.play-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 6px;
}

.play-hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.chip {
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: rgba(26, 5, 8, 0.8);
  color: var(--cream);
  font-size: 12px;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

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

.hud-mid strong {
  display: block;
  font-size: clamp(20px, 6vw, 28px);
  color: var(--gold);
  line-height: 1;
}

.meter-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.glaze {
  display: flex;
  gap: 4px;
}

.glaze i {
  width: 14px;
  height: 18px;
  background: var(--ruby);
  clip-path: polygon(50% 0, 100% 35%, 78% 100%, 22% 100%, 0 35%);
  box-shadow: 0 0 8px rgba(227, 28, 61, 0.45);
}

.glaze i.is-off {
  background: #3a1a1c;
  box-shadow: none;
}

.resonance {
  height: 10px;
  border: 1px solid var(--line);
  background: rgba(26, 5, 8, 0.85);
  overflow: hidden;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 50%, calc(100% - 6px) 100%, 6px 100%, 0 50%);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #100206;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}

#rubyCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 2, 4, 0.72);
  padding: 16px;
}

.overlay-card {
  width: min(320px, 100%);
  text-align: center;
  padding: 18px 14px;
  background: linear-gradient(180deg, #4a1018, #1a0508);
  border: 1px solid var(--gold);
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
}

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

.overlay-card p {
  margin: 0 0 14px;
  color: var(--mute);
}

.overlay-card .row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.gong-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(59, 11, 20, 0.88);
  clip-path: polygon(20px 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 20px 100%, 0 50%);
}

.gong-btn img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.gong-btn.is-ready {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(242, 193, 78, 0.35);
  animation: pulse 1.1s ease-in-out infinite;
}

.gong-btn.is-live {
  background: linear-gradient(90deg, #6b1820, #a67c2a);
}

@keyframes pulse {
  0%,
  100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

.diadem-dock {
  position: relative;
  flex: 0 0 auto;
  height: calc(var(--dock) + var(--safe-b));
  padding: 0 8px calc(6px + var(--safe-b));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.diadem-arc {
  position: absolute;
  left: 8%;
  right: 8%;
  top: -18px;
  height: 54px;
  width: 84%;
  margin: 0 auto;
  object-fit: contain;
  opacity: 0.92;
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45));
}

.sockets {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  align-items: end;
}

.socket {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 4px;
  color: var(--mute);
}

.socket img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: grayscale(0.35) brightness(0.9);
}

.socket span {
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.socket.is-on {
  color: var(--gold);
  transform: translateY(-8px);
}

.socket.is-on img {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 8px rgba(242, 193, 78, 0.65));
}

.socket.is-on::after {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--ruby);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: 0 0 8px var(--ruby-hot);
}

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

.sheet-card {
  width: min(420px, 100%);
  padding: 16px;
  background: linear-gradient(180deg, #4a1018, #140308);
  border: 1px solid var(--gold);
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sheet-head h2 {
  margin: 0;
  color: var(--gold);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(242, 193, 78, 0.16);
}

.toggle input {
  display: none;
}

.toggle i {
  width: 46px;
  height: 24px;
  border: 1px solid var(--line);
  background: #2a0a10;
  position: relative;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

.toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 16px;
  height: 16px;
  background: var(--mute);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transition: left 0.18s ease;
}

.toggle input:checked + i {
  background: #6b1820;
  border-color: var(--gold);
}

.toggle input:checked + i::after {
  left: 24px;
  background: var(--gold);
}

.ghost {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  color: var(--mute);
}

.shell.is-play .diadem-arc {
  opacity: 0.55;
  height: 40px;
  top: -8px;
}

.shell.is-play {
  --dock: 72px;
}

@media (max-height: 640px) {
  :root {
    --plaque: 48px;
    --dock: 70px;
  }

  .hero-well {
    height: 132px;
  }

  .teaser {
    grid-template-columns: 1fr;
  }

  .shell.is-play .plaque-copy strong {
    font-size: 12px;
  }

  .gong-btn span {
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  :root {
    --plaque: 52px;
    --dock: 78px;
  }

  .hero-well {
    height: 150px;
  }

  .lozenge {
    clip-path: none;
    border-radius: 0;
  }

  .socket span {
    font-size: 9px;
  }

  .gong-btn {
    min-height: 44px;
  }
}

@media (min-width: 420px) {
  .teaser {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-height: 740px) {
  .hero-well {
    height: 240px;
  }
}
