/* Game entrance: choose a matter, then the deity answers. */

html.shrine-on,
html.shrine-on body { overflow: hidden; height: 100%; }

.shrine {
  position: fixed;
  inset: 0;
  z-index: 120;
  color: #f6ecd4;
  font-family: "Noto Serif SC", "Songti SC", serif;
}
.shrine[hidden] { display: none !important; }
.shrine-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 5, 3, 0.08) 0%, rgba(8, 5, 3, 0.05) 42%, rgba(8, 5, 3, 0.42) 100%),
    url("../img/shrine-hall.jpg?v=2") center center / cover no-repeat;
}
.shrine-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 42%, transparent 36%, rgba(8, 5, 3, 0.22) 100%);
}

.shrine-pick,
.shrine-talk { position: absolute; inset: 0; }
.shrine-talk {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.shrine-pick {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.8rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  overflow: auto;
}
.shrine-head { position: relative; z-index: 1; max-width: 36rem; }
.shrine-kicker {
  margin: 0 0 0.35rem;
  letter-spacing: 0.42em;
  font-size: 0.78rem;
  color: #e4c77a;
}
.shrine-head h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.8rem);
  font-weight: 650;
  line-height: 1.25;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.quest-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.65rem;
}
.quest {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.45rem 0.7rem 0.45rem 0.45rem;
  border: 1px solid rgba(228, 199, 122, 0.42);
  border-radius: 16px;
  background: rgba(16, 10, 8, 0.72);
  color: inherit;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.quest img {
  width: 64px;
  height: 84px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 12px;
}
.quest b { display: block; font-size: 1.05rem; letter-spacing: 0.06em; }
.quest em, .quest span {
  display: block;
  font-style: normal;
  color: rgba(246, 236, 212, 0.78);
  font-size: 0.86rem;
}
.quest i {
  font-style: normal;
  color: #e4c77a;
  letter-spacing: 0.14em;
  font-size: 0.92rem;
}
.quest:hover, .quest:focus-visible {
  border-color: #e4c77a;
  outline: none;
  background: rgba(36, 22, 14, 0.82);
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}
.stage img,
.stage video {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  height: 100%;
  width: auto;
  max-width: none;
  transform: translateX(-50%);
  object-fit: cover;
  object-position: center center;
  background: transparent;
}
.edition {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.edition button {
  border: 1px solid rgba(228, 199, 122, 0.45);
  border-radius: 999px;
  background: rgba(16, 10, 8, 0.55);
  color: rgba(246, 236, 212, 0.82);
  padding: 0.32rem 0.9rem;
  font: inherit;
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  cursor: pointer;
}
.edition button.is-on {
  color: #1a120c;
  background: #e4c77a;
  border-color: #e4c77a;
}
.rig { position: absolute; pointer-events: none; }
.rig .lid,
.rig .mouth { position: absolute; display: block; }
.rig .lid {
  background: #c48968;
  border-radius: 45% 45% 50% 50%;
  transform: scaleY(0.05);
  transform-origin: center top;
  opacity: 0;
}
.rig.is-blink .lid { animation: lid 0.16s linear; }
.rig .mouth {
  background: radial-gradient(ellipse at 50% 35%, #9a3830, #3a100e 72%);
  border-radius: 50%;
  transform: scaleY(0.2);
  transform-origin: center;
  opacity: 0;
}
.stage.is-talking .mouth {
  opacity: 1;
  animation: talk 0.2s ease-in-out infinite;
}
@keyframes lid {
  0% { opacity: 0.95; transform: scaleY(0.05); }
  42% { opacity: 0.95; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(0.05); }
}
@keyframes talk {
  0%, 100% { transform: scaleY(0.22); }
  50% { transform: scaleY(1); }
}
@keyframes caret {
  50% { opacity: 0.2; transform: translateY(3px); }
}

.dlg {
  position: relative;
  z-index: 2;
  flex: 0 1 auto;
  width: auto;
  max-height: min(42dvh, 100%);
  margin: 0 max(3.8rem, calc(env(safe-area-inset-right) + 3.1rem)) max(0.55rem, env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  padding: clamp(0.7rem, 1.6vh, 1.15rem) clamp(0.85rem, 2vw, 1.25rem) clamp(0.6rem, 1.4vh, 1rem);
  overflow: auto;
  border: 1px solid rgba(228, 199, 122, 0.55);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(28, 16, 10, 0.78), rgba(12, 8, 6, 0.94));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.dlg-name { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; align-items: baseline; }
.dlg-name b { font-size: clamp(1.35rem, 4.4vw, 2.3rem); letter-spacing: 0.12em; color: #f3d78a; }
.dlg-name em { font-style: normal; font-size: clamp(0.95rem, 3.2vw, 1.64rem); letter-spacing: 0.08em; color: rgba(246, 236, 212, 0.7); }
.dlg.is-wait { cursor: pointer; }
.dlg.is-you { border-color: rgba(246, 236, 212, 0.72); }
.dlg.is-you .dlg-name b { color: #f6ecd4; letter-spacing: 0.2em; }
.dlg-line {
  min-height: 1.45em;
  margin: 0.45rem 0 0.15rem;
  font-size: clamp(1.12rem, 4.4vw, 2.24rem);
  line-height: 1.4;
}
.dlg .dlg-next {
  position: absolute;
  right: 1rem;
  bottom: 0.85rem;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #e4c77a;
  border-radius: 0;
  background: transparent;
  animation: caret 0.9s steps(2, end) infinite;
}
.dlg-choices {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.7rem;
}
.dlg .dlg-choices button {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  border: 1px solid rgba(228, 199, 122, 0.4);
  border-left: 3px solid #e4c77a;
  background: rgba(228, 199, 122, 0.08);
  padding: 0.55rem 0.85rem;
  font-size: clamp(0.98rem, 3.6vw, 1.72rem);
  letter-spacing: 0.04em;
  line-height: 1.35;
}
.dlg .dlg-choices button:hover,
.dlg .dlg-choices button:focus-visible {
  background: rgba(228, 199, 122, 0.2);
  outline: none;
  transform: translateX(4px);
}
.dlg-actions, .dlg-share { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }
.dlg-actions { padding-top: 0.7rem; border-top: 1px solid rgba(228, 199, 122, 0.28); }
.dlg button, .dlg a {
  border: 1px solid rgba(228, 199, 122, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #f6ecd4;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
}
.dlg-enter, .dlg a:hover, .dlg button:hover { background: rgba(228, 199, 122, 0.16); }
.dlg-share[hidden], .dlg-choices[hidden], .dlg-actions[hidden], .dlg-next[hidden], .shrine-talk[hidden] { display: none !important; }

@media (min-width: 900px) {
  .shrine-pick {
    display: grid;
    grid-template-columns: minmax(16rem, 0.8fr) minmax(22rem, 1.1fr);
    align-items: end;
    justify-content: stretch;
    gap: 2.5rem;
    padding: 6vh 6vw 7vh;
  }
  .quest-grid { grid-template-columns: 1fr 1fr; }
  .quest:last-child { grid-column: 1 / -1; }
  .shrine.is-live .quest:last-child { grid-column: auto; }
  .dlg {
    align-self: center;
    width: min(40rem, 58vw);
    margin: 0 auto 4vh;
  }
}

.approach {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #070604;
}
.approach[hidden] { display: none !important; }
.approach.is-out { opacity: 0; transition: opacity 0.28s ease; pointer-events: none; }
.approach-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #070604;
}
.approach-skip {
  position: absolute;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  padding: 0.38rem 0.85rem;
  border: 1px solid rgba(244, 231, 196, 0.45);
  border-radius: 999px;
  background: rgba(12, 8, 6, 0.42);
  color: #f4e7c4;
  letter-spacing: 0.18em;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 0.82rem;
  cursor: pointer;
}
.approach-play { display: none; }
.approach.needs-tap .approach-play {
  display: block;
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.7rem 1.4rem;
  border: 1px solid #e4c77a;
  border-radius: 999px;
  background: rgba(12, 8, 6, 0.72);
  color: #f4e7c4;
  letter-spacing: 0.22em;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 0.95rem;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .stage.is-talking .mouth, .rig.is-blink .lid, .dlg .dlg-next { animation: none; }
  .dlg .dlg-choices button:hover { transform: none; }
}
