:root {
  color-scheme: dark;
  --button-start: #e04663;
  --button-end: #ff9166;
  --bubble-text: rgba(157, 76, 86, 0.92);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050406;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #050406;
}

.opening-video {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 1;
  transform: translateZ(0);
  background: #050406;
}

.screen-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), transparent 22%, transparent 60%, rgba(0, 0, 0, 0.38)),
    radial-gradient(circle at 50% 42%, transparent 0 46%, rgba(0, 0, 0, 0.18) 76%, rgba(0, 0, 0, 0.34) 100%);
}

.fortune-bubble {
  position: fixed;
  left: 50%;
  top: 61dvh;
  z-index: 2;
  width: max-content;
  min-width: 0;
  max-width: min(78vw, 330px);
  min-height: 0;
  display: block;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  color: var(--bubble-text);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  line-height: 1.34;
  white-space: normal;
  overflow: visible;
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.98);
  transition:
    opacity 0.52s ease,
    transform 0.62s cubic-bezier(0.2, 0.78, 0.24, 1);
  pointer-events: none;
  -webkit-text-stroke: 0.35px rgba(255, 255, 255, 0.72);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72),
    0 3px 12px rgba(82, 41, 49, 0.22);
}

.fortune-bubble [data-fortune-text] {
  display: inline-block;
  min-width: 1em;
  max-width: min(78vw, 330px);
}

.is-speaking .fortune-bubble [data-fortune-text]::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(157, 76, 86, 0.7);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.68);
  vertical-align: 0.16em;
  animation: speech-dot 0.72s ease-in-out infinite;
}

.has-fortune .fortune-bubble {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@keyframes speech-dot {
  0%,
  100% {
    opacity: 0.28;
    transform: translateY(1px) scale(0.8);
  }

  45% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.miniapp-button {
  position: fixed;
  left: max(22px, env(safe-area-inset-left));
  right: max(22px, env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 3;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(135deg, var(--button-start), #f06378 50%, var(--button-end));
  box-shadow: 0 14px 30px rgba(224, 70, 99, 0.34);
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.miniapp-button:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: 0 8px 20px rgba(224, 70, 99, 0.28);
}

.miniapp-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.78);
  outline-offset: 4px;
}

.miniapp-fallback {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: end center;
  padding: 22px;
  background: rgba(5, 4, 6, 0);
  opacity: 0;
  transition:
    opacity 0.22s ease,
    background 0.22s ease;
}

.miniapp-fallback[hidden] {
  display: none;
}

.miniapp-fallback.is-visible {
  background: rgba(5, 4, 6, 0.42);
  opacity: 1;
}

.miniapp-fallback-panel {
  width: min(100%, 360px);
  padding: 22px 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 18px;
  color: #5f3941;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 46px rgba(20, 10, 14, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  transform: translateY(14px) scale(0.98);
  transition: transform 0.24s cubic-bezier(0.2, 0.78, 0.24, 1);
}

.miniapp-fallback.is-visible .miniapp-fallback-panel {
  transform: translateY(0) scale(1);
}

.miniapp-fallback-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.miniapp-fallback-copy {
  margin: 8px 0 18px;
  color: rgba(95, 57, 65, 0.72);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.miniapp-fallback-close {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(135deg, var(--button-start), var(--button-end));
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
}

@media (min-width: 680px) {
  .opening-video {
    object-fit: contain;
  }

  .miniapp-button {
    left: 50%;
    right: auto;
    width: 360px;
    transform: translateX(-50%);
  }

  .miniapp-button:active {
    transform: translateX(-50%) translateY(2px) scale(0.99);
  }
}

@media (max-width: 360px) {
  .fortune-bubble {
    top: 60dvh;
    min-width: 0;
    max-width: min(82vw, 300px);
    min-height: 0;
    padding: 0 4px;
    font-size: 15px;
  }

  .miniapp-button {
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
    min-height: 52px;
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
