:root {
  --bg: #d9e3e8;
  --text: #2f3540;
  --muted: rgba(47, 53, 64, 0.62);
  --button-bg: rgba(255, 255, 255, 0.18);
  --button-border: rgba(47, 53, 64, 0.2);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

.app {
  position: relative;
  display: grid;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.035)),
    var(--bg);
  color: var(--text);
  transition: background-color 520ms ease, color 420ms ease;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  position: relative;
  z-index: 2;
  grid-area: 1 / 1;
  display: flex;
  min-height: 100dvh;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 9vh 24px calc(13vh + var(--safe-bottom));
  transition: opacity 360ms ease, transform 420ms ease, filter 420ms ease;
}

.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(5px);
}

.intro {
  width: min(82vw, 430px);
  transform: translateY(-3vh);
  text-align: center;
}

.intro h1 {
  margin: 0 0 42px;
  font-size: clamp(30px, 8vw, 44px);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.35;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 400;
  line-height: 2;
}

.intro p + p {
  margin-top: 26px;
}

.message-screen {
  padding-bottom: calc(20vh + var(--safe-bottom));
}

.message-wrap {
  width: min(84vw, 520px);
  transform: translateY(-4vh);
  text-align: center;
  will-change: opacity, transform, filter;
}

.message-wrap h2 {
  margin: 0;
  font-size: clamp(29px, 8.4vw, 48px);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.message-wrap p {
  margin: 28px 0 0;
  font-size: clamp(17px, 4.7vw, 23px);
  font-weight: 400;
  line-height: 2;
  letter-spacing: 0.01em;
  white-space: pre;
}

.message-wrap.is-rolling {
  animation: floatText 180ms ease;
}

.message-wrap.is-result {
  animation: settleText 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hint {
  position: absolute;
  right: 24px;
  bottom: calc(42px + var(--safe-bottom));
  left: 24px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.85;
  letter-spacing: 0.04em;
  transition: opacity 260ms ease, transform 260ms ease;
}

.actions {
  position: absolute;
  z-index: 4;
  right: 20px;
  bottom: calc(26px + var(--safe-bottom));
  left: 20px;
  display: flex;
  justify-content: center;
  transition: opacity 320ms ease 180ms, transform 360ms ease 180ms, filter 320ms ease 180ms;
}

.actions button {
  min-width: 124px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--button-border);
  border-radius: 999px;
  color: currentColor;
  background: var(--button-bg);
  backdrop-filter: blur(12px);
  box-shadow: none;
  cursor: pointer;
}

.actions button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.actions button:active {
  transform: translateY(1px);
}

.toast {
  position: absolute;
  z-index: 6;
  right: 24px;
  bottom: calc(90px + var(--safe-bottom));
  left: 24px;
  margin: auto;
  width: fit-content;
  max-width: min(78vw, 360px);
  padding: 11px 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  opacity: 0;
  color: currentColor;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(14px);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 240ms ease, transform 240ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ambient {
  position: absolute;
  z-index: 1;
  width: 54vmax;
  height: 54vmax;
  border-radius: 50%;
  opacity: 0.16;
  filter: blur(42px);
  background: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  animation: breathe 11s ease-in-out infinite alternate;
}

.ambient-one {
  top: -18vmax;
  left: -20vmax;
}

.ambient-two {
  right: -28vmax;
  bottom: -22vmax;
  opacity: 0.1;
  animation-duration: 15s;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.08;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.4) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.22) 1px, transparent 1px);
  background-size: 19px 19px;
  mix-blend-mode: soft-light;
}

@keyframes breathe {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }

  to {
    transform: translate3d(3vmax, 2vmax, 0) scale(1.08);
  }
}

@keyframes floatText {
  from {
    opacity: 0.58;
    transform: translateY(-2vh) scale(0.985);
    filter: blur(3px);
  }

  to {
    opacity: 1;
    transform: translateY(-4vh) scale(1);
    filter: blur(0);
  }
}

@keyframes settleText {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.985);
    filter: blur(8px);
  }

  100% {
    opacity: 1;
    transform: translateY(-4vh) scale(1);
    filter: blur(0);
  }
}

@media (min-width: 720px) {
  .screen {
    padding-inline: 40px;
  }

  .hint {
    bottom: calc(52px + var(--safe-bottom));
  }
}

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