:root {
  --ink: #120308;
  --velvet: #1a0508;
  --wine: #4a0c18;
  --crimson: #c4122f;
  --gold: #e8c547;
  --gold-bright: #ffe28a;
  --gold-deep: #a67c1a;
  --cream: #f7ebd0;
  --mute: #d4c4a8;
  --line: rgba(232, 197, 71, 0.46);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --diadem-h: 56px;
  --dock-h: 92px;
  --chrome-top: calc(var(--diadem-h) + var(--safe-t));
  --chrome-bot: calc(var(--dock-h) + var(--safe-b));
  --play-h: calc(100vh - var(--chrome-top) - var(--chrome-bot));
}

* {
  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;
  overflow-y: auto;
  background: var(--ink);
  color: var(--cream);
  font-family: "Noto Sans Myanmar", Padauk, sans-serif;
  overflow-wrap: anywhere;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

body.is-play {
  overflow: hidden;
  height: 100%;
  height: 100vh;
  touch-action: manipulation;
}

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

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

h1,
h2,
.eyebrow,
.brand-mark,
.gold-btn,
.ghost-btn {
  font-family: "Noto Sans Myanmar", "Cinzel", serif;
}

.brand-mark {
  font-family: Cinzel, serif;
  letter-spacing: 0.22em;
  font-size: 0.68rem;
  color: var(--gold);
  margin: 0;
  text-transform: uppercase;
}

#app {
  min-height: 100%;
  position: relative;
}

.felt {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% -8%, rgba(232, 197, 71, 0.28), transparent 52%),
    radial-gradient(90% 50% at 100% 100%, rgba(196, 18, 47, 0.28), transparent 48%),
    url("hall.png") center / cover no-repeat;
  opacity: 0.38;
  pointer-events: none;
  z-index: 0;
}

.spark {
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 11px, rgba(232, 197, 71, 0.03) 11px 12px),
    radial-gradient(circle at 20% 80%, rgba(255, 226, 138, 0.08), transparent 36%);
  pointer-events: none;
  z-index: 0;
}

.screen,
.site-shell {
  position: relative;
  z-index: 1;
}

.screen {
  min-height: 100dvh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.boot-stage {
  width: min(92vw, 360px);
  text-align: center;
}

.boot-crest {
  width: 112px;
  height: 112px;
  margin: 0 auto 14px;
  border-radius: 22px;
  box-shadow: 0 0 0 2px var(--gold), 0 12px 32px rgba(0, 0, 0, 0.45);
}

.boot-stage h1 {
  font-family: Cinzel, serif;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  margin: 8px 0 10px;
  color: var(--gold-bright);
}

.boot-line {
  margin: 0 0 16px;
  color: var(--mute);
  line-height: 1.55;
  font-size: 0.92rem;
}

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

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

.site-shell {
  display: none;
}

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

.diadem {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--chrome-top);
  padding: var(--safe-t) 12px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(74, 12, 24, 0.96), rgba(18, 3, 8, 0.92));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.diadem-bezel {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 2px;
  border: 1px solid var(--gold);
  background: radial-gradient(circle at 40% 30%, #6e1524, #1a0508);
  flex-shrink: 0;
  overflow: hidden;
}

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

.diadem-name {
  flex: 1;
  min-width: 0;
}

.diadem-name strong {
  display: block;
  font-family: Cinzel, serif;
  font-size: 1.02rem;
  color: var(--gold-bright);
  line-height: 1.15;
}

.seal-chip {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 35% 30%, #5a1220, #120308);
  padding: 4px;
  flex-shrink: 0;
}

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

#pages {
  position: relative;
  padding-top: var(--chrome-top);
  padding-bottom: var(--chrome-bot);
}

.page {
  display: none;
  padding: 12px 12px 24px;
  touch-action: pan-y;
}

.page.is-on {
  display: block;
  height: auto;
  overflow: visible;
}

#screen-play.is-on {
  position: fixed;
  top: var(--chrome-top);
  left: 0;
  right: 0;
  bottom: var(--chrome-bot);
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  padding: 10px 12px 8px;
  z-index: 2;
  touch-action: manipulation;
}

.play-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  gap: 8px;
}

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

.hud-cell {
  background: linear-gradient(180deg, rgba(74, 12, 24, 0.72), rgba(18, 3, 8, 0.78));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 10px;
  min-width: 0;
}

.hud-right {
  text-align: right;
}

.hud-cell span,
.hud-mini span {
  display: block;
  font-size: 0.68rem;
  color: var(--mute);
  line-height: 1.3;
}

.hud-cell strong,
.hud-mini strong {
  font-size: 0.92rem;
  color: var(--gold-bright);
  line-height: 1.3;
}

.crown-meter {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 3, 8, 0.72);
}

.crown-meter i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--gold-deep);
  background: #2a0a10;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}

.crown-meter i.is-on {
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--crimson));
  box-shadow: 0 0 10px rgba(232, 197, 71, 0.7);
}

.herald-row {
  display: grid;
  grid-template-columns: 64px 1fr 56px;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.rotate-btn,
.hud-mini {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(74, 12, 24, 0.8), rgba(18, 3, 8, 0.86));
  border-radius: 16px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
}

.rotate-btn img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.rotate-btn span,
.hud-mini span {
  font-size: 0.68rem;
}

.herald-trio {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  height: 64px;
}

.herald-gem {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 30% 30%, #4a0c18, #120308);
  overflow: hidden;
  margin: 0 -4px;
  opacity: 0.55;
  transform: scale(0.86);
}

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

.herald-gem.is-front {
  width: 56px;
  height: 56px;
  opacity: 1;
  transform: scale(1);
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(232, 197, 71, 0.35);
  z-index: 2;
}

.stage-wrap {
  position: relative;
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(74, 12, 24, 0.35), rgba(12, 2, 6, 0.88));
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  position: relative;
  z-index: 0;
}

.run-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 10px 12px 12px;
  background: linear-gradient(180deg, rgba(18, 3, 8, 0.62), rgba(18, 3, 8, 0.92));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.run-veil.is-on {
  display: flex;
}

.run-veil[hidden] {
  display: none !important;
}

.run-veil img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
}

.run-veil h2 {
  margin: 2px 0 6px;
  font-size: clamp(1rem, 4.6vw, 1.28rem);
  color: var(--gold-bright);
  line-height: 1.35;
  max-width: 100%;
}

.run-veil p {
  margin: 0 0 8px;
  color: var(--mute);
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 36ch;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.court-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
  width: min(100%, 320px);
}

.court-pill {
  border: 1px solid var(--line);
  background: rgba(18, 3, 8, 0.72);
  color: var(--cream);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.3;
}

.court-pill.is-on {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(196, 18, 47, 0.55), rgba(74, 12, 24, 0.9));
  color: var(--gold-bright);
}

.court-pill:disabled {
  opacity: 0.38;
}

.gold-btn,
.ghost-btn {
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 44px;
  line-height: 1.35;
  font-size: 0.92rem;
  width: min(100%, 280px);
  flex-shrink: 0;
}

.gold-btn {
  border: 1px solid var(--gold-bright);
  background: linear-gradient(180deg, #f0d56a, #b8891c);
  color: #2a0a10;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(232, 197, 71, 0.28);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  margin-top: 8px;
}

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(100%, 280px);
  margin-bottom: 12px;
}

.end-stats b {
  display: block;
  background: rgba(18, 3, 8, 0.7);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  font-size: 0.8rem;
  font-weight: 500;
}

.end-stats strong {
  display: block;
  color: var(--gold-bright);
  font-size: 1rem;
  margin-top: 2px;
}

.edict-banner {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--gold);
  background: linear-gradient(90deg, rgba(74, 12, 24, 0.94), rgba(18, 3, 8, 0.94));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.edict-banner[hidden] {
  display: none !important;
}

.edict-banner img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.edict-banner strong {
  display: block;
  color: var(--gold-bright);
  font-size: 0.88rem;
}

.edict-banner p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--mute);
  line-height: 1.35;
}

.edict-banner .ghost-btn {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 6px 12px;
  flex-shrink: 0;
}

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

.page-intro img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  margin: 0 auto 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.page-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 5.5vw, 1.6rem);
  color: var(--gold-bright);
  line-height: 1.35;
}

.page-intro p {
  margin: 0;
  color: var(--mute);
  font-size: 0.9rem;
  line-height: 1.55;
}

.vault-legend {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--mute);
}

.vault-legend strong {
  color: var(--gold-bright);
}

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

.vault-cell {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 3, 8, 0.72);
  padding: 8px 6px 10px;
  text-align: center;
  min-width: 0;
}

.vault-cell img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  margin: 0 auto 6px;
  filter: grayscale(1) brightness(0.45);
}

.vault-cell.is-got img {
  filter: none;
}

.vault-cell.is-got {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(74, 12, 24, 0.7), rgba(18, 3, 8, 0.86));
}

.vault-cell em {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  color: var(--mute);
  line-height: 1.35;
}

.vault-cell.is-wide {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px;
}

.vault-cell.is-wide img {
  margin: 0;
  width: 56px;
  height: 56px;
}

.lore-stack,
.rite-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.lore-pane,
.rite-steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(74, 12, 24, 0.42), rgba(18, 3, 8, 0.78));
}

.lore-pane img,
.rite-steps img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 14px;
  flex-shrink: 0;
  background: #120308;
}

.lore-pane h2,
.rite-steps h2 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: var(--gold-bright);
  line-height: 1.35;
}

.lore-pane p,
.rite-steps p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--mute);
}

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

.crown-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  height: var(--chrome-bot);
  padding: 0 4px calc(8px + var(--safe-b));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px;
  overflow: visible;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(196, 18, 47, 0.28), transparent 46%),
    linear-gradient(180deg, rgba(74, 12, 24, 0.2), rgba(12, 2, 6, 0.96));
  border-top: 1px solid var(--line);
}

.crown-dock::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 10px;
  height: 18px;
  border-radius: 0 0 50% 50%;
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}

.dock-leaf,
.dock-seal {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  flex: 1;
  padding-bottom: 10px;
}

.dock-leaf img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid transparent;
}

.dock-leaf span {
  font-size: 0.62rem;
  color: var(--mute);
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock-leaf.is-lit img,
.dock-leaf.is-lit span {
  color: var(--gold-bright);
}

.dock-leaf.is-lit img {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(232, 197, 71, 0.35);
}

.dock-seal {
  flex: 1.15;
  padding-bottom: 6px;
}

.dock-seal img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(196, 18, 47, 0.35), 0 10px 22px rgba(0, 0, 0, 0.4);
  transform: translateY(-16px);
  background: #1a0508;
}

.dock-seal.is-lit img {
  box-shadow: 0 0 0 4px rgba(232, 197, 71, 0.28), 0 0 22px rgba(232, 197, 71, 0.45);
}

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

.sheet[hidden] {
  display: none;
}

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

.sheet-card h2 {
  margin: 6px 0 14px;
  color: var(--gold-bright);
  font-size: 1.15rem;
}

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

.sheet-note {
  color: var(--mute);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0 0 12px;
}

@media (max-width: 360px) {
  :root {
    --diadem-h: 52px;
    --dock-h: 86px;
  }

  .vault-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .herald-row {
    grid-template-columns: 56px 1fr 50px;
  }

  .dock-seal img {
    width: 52px;
    height: 52px;
  }
}

@media (max-height: 680px) {
  .herald-row {
    height: auto;
  }

  .herald-trio {
    height: 54px;
  }

  .herald-gem {
    width: 36px;
    height: 36px;
  }

  .herald-gem.is-front {
    width: 48px;
    height: 48px;
  }

  .rotate-btn,
  .hud-mini {
    min-height: 50px;
  }

  .page-intro img {
    width: 72px;
    height: 72px;
  }
}

@supports (height: 100dvh) {
  :root {
    --play-h: calc(100dvh - var(--chrome-top) - var(--chrome-bot));
  }
}

@media (min-width: 430px) {
  .page {
    padding-left: 18px;
    padding-right: 18px;
  }

  .vault-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
