@import url('https://fonts.googleapis.com/css2?family=RocknRoll+One&display=swap');

* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background-color: #262220;
}
body {
  display: flex;
  justify-content: center;
  overscroll-behavior: none;
}

/* 元のアプリと同じ縦横比（1080:1840）を基準にして、縦長の画面では高さいっぱいまで広げる */
.stage {
  position: relative;
  width: min(100vw, calc(100vh * 1080 / 1840));
  width: min(100vw, calc(100dvh * 1080 / 1840));
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: #fffdec;
  touch-action: none;
}
.stage__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* ---- 読み込み画面 ---- */
.preload {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fffdec;
  transition: opacity 0.4s ease-in-out;
}
.preload--hidden {
  opacity: 0;
  pointer-events: none;
}
.preload__text-wrapper {
  position: absolute;
  top: calc(50% - 100px);
  left: 0;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
}
.preload__text {
  width: 160px;
  animation: floating-text 2s ease-in-out infinite;
}
@keyframes floating-text {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
  100% {
    transform: translateY(0);
  }
}
.preload__bar {
  position: absolute;
  top: calc(50% - 10px);
  left: 0;
  width: 0;
  height: 24px;
  background-image: url('../loading/bar_bg.png');
  background-size: 1px 100%;
  background-position: center center;
  background-repeat: repeat-x;
  transition: width 0.6s ease-in-out;
}
.preload__icon {
  position: relative;
  z-index: 2;
  width: 100px;
  transform-origin: center 52%;
  animation: preload-icon 1.4s cubic-bezier(0.01, 0.275, 0.05, 1) infinite;
}
@keyframes preload-icon {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
.preload__error {
  position: absolute;
  top: calc(50% + 80px);
  left: 8%;
  width: 84%;
  font-family: 'RocknRoll One', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #564240;
  text-align: center;
}

/* ---- 3D の画面に重ねる操作用のボタン（見た目は 3D 側で描く） ---- */
.a11y-controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.a11y-controls button {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: transparent;
  font-size: 1px;
  pointer-events: auto;
  cursor: pointer;
}
/* お参りの間は画面のどこを押しても鈴緒を振れる */
.a11y-controls #btn-bell {
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.a11y-controls #btn-bell:focus-visible {
  outline-offset: -6px;
}
.a11y-controls button:focus-visible {
  outline: 3px solid #d23332;
  outline-offset: 3px;
}
.a11y-controls button[hidden] {
  display: none;
}

/* ---- 結果画面 ---- */
.result-ui {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  font-family: 'RocknRoll One', sans-serif;
}
.result-ui[hidden] {
  display: none;
}
.result-ui__credit {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  font-feature-settings: 'palt';
  color: #564240;
  text-align: center;
  font-size: clamp(11px, 3.1cqw, 14px);
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-shadow:
    0 0 0.28em #fff,
    0 0 0.28em #fff,
    0 0 0.28em #fff,
    0 0 0.28em #fff,
    0 0 0.28em #fff,
    0 0 0.28em #fff;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  will-change: transform;
}
.result-ui__credit p {
  margin: 0 0 0.8em;
}
.result-ui__credit small {
  display: block;
  font-size: 0.86em;
  margin-top: 4px;
}
.result-ui__credit a {
  color: #d23332;
  pointer-events: auto;
}
.result-ui__buttons {
  position: absolute;
  bottom: 0;
  left: 3%;
  width: 94%;
  padding-bottom: 6%;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
}
.result-ui--ready .result-ui__buttons {
  opacity: 1;
}
.result-ui__button {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  top: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  transition:
    opacity 0.2s ease-in-out,
    top 0.2s ease-in-out;
}
.result-ui__button img {
  display: block;
  width: 94%;
  height: auto;
}
.result-ui__button:hover,
.result-ui__button:active,
.result-ui__button:focus-visible {
  opacity: 0.8;
  top: 0.4rem;
}
.result-ui__button:focus-visible {
  outline: 3px solid #d23332;
  outline-offset: 2px;
  border-radius: 999px;
}

.stage {
  container-type: inline-size;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

@media screen and (max-width: 640px) {
  .preload__text-wrapper {
    top: calc(50% - 16vw);
  }
  .preload__text {
    width: 24vw;
    animation-name: floating-text-mobile;
  }
  @keyframes floating-text-mobile {
    0% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(-4vw);
    }
    100% {
      transform: translateY(0);
    }
  }
  .preload__bar {
    top: calc(50% - 2vw);
    height: 4vw;
  }
  .preload__icon {
    width: 16vw;
  }
  .result-ui__buttons {
    left: 0;
    width: 100%;
    height: 28vw;
    gap: 3.6vw;
    padding-bottom: 0;
  }
  .result-ui__button img {
    width: 44vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preload__text,
  .preload__icon {
    animation: none;
  }
}
