:root {
  --stage-w: 1125;
  --stage-h: 2436;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #dfcba8;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  user-select: none;
  -webkit-user-select: none;
}

img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.phone-stage {
  position: relative;
  width: min(100vw, calc(100svh * var(--stage-w) / var(--stage-h)));
  height: min(100svh, calc(100vw * var(--stage-h) / var(--stage-w)));
  overflow: hidden;
  background: #f5e7c8;
  box-shadow: 0 0 0 1px rgba(87, 56, 31, 0.16), 0 20px 55px rgba(55, 34, 18, 0.28);
  isolation: isolate;
  container-type: inline-size;
}

.phone-stage.is-dragging {
  cursor: grabbing;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px) scale(1.01);
  transition: opacity 0.38s ease, transform 0.38s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.cover-bg,
.state {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
}

.cover-bg {
  height: 100%;
  object-fit: cover;
}

.state.after {
  opacity: 0;
  transition: opacity 0.55s ease;
}

.scene.completed .state.after {
  opacity: 1;
}

.top-logo {
  position: absolute;
  left: 4.5%;
  top: 3.2%;
  z-index: 40;
  width: 18.7%;
  height: auto;
  animation: topIn 0.55s ease both;
}

.ai-note {
  position: absolute;
  right: 6.4%;
  top: 3.8%;
  z-index: 40;
  width: 35.5%;
  height: auto;
  animation: topIn 0.55s ease 0.08s both;
}

@keyframes topIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.cover-title {
  position: absolute;
  left: 0;
  top: 12.2%;
  z-index: 5;
  width: 83%;
  height: auto;
  animation: titleIn 0.86s cubic-bezier(0.2, 0.8, 0.2, 1) 0.22s both;
}

.start-btn {
  position: absolute;
  left: 50%;
  bottom: 13.5%;
  z-index: 7;
  width: 45%;
  transform: translateX(-50%);
  animation: startIn 0.72s ease 0.68s both, pulseStart 1.8s ease-in-out 1.4s infinite;
}

.start-btn img {
  width: 100%;
}

@keyframes titleIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
    filter: blur(4px);
  }
}

@keyframes startIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(18px) scale(0.92);
  }
}

@keyframes pulseStart {
  50% {
    transform: translateX(-50%) translateY(-4px) scale(1.025);
  }
}

.rhyme-layer {
  position: absolute;
  left: 0;
  top: 11.4%;
  z-index: 6;
  width: 80%;
  height: auto;
  opacity: 0;
  filter: drop-shadow(0 8px 14px rgba(80, 43, 23, 0.18));
}

.scene.active .rhyme-layer {
  animation: rhymeIn 0.62s cubic-bezier(0.2, 0.8, 0.2, 1) 0.18s both;
}

@keyframes rhymeIn {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(3px) drop-shadow(0 8px 14px rgba(80, 43, 23, 0.18));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.target {
  position: absolute;
  left: var(--tx);
  top: var(--ty);
  z-index: 8;
  width: 22%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 231, 128, 0.32), rgba(255, 224, 119, 0.08) 48%, rgba(255, 224, 119, 0));
  border: 2px dashed rgba(255, 219, 101, 0.85);
  box-shadow:
    0 0 0 7px rgba(255, 226, 118, 0.12),
    0 0 26px rgba(255, 221, 112, 0.56),
    0 0 52px rgba(255, 184, 74, 0.28);
  animation: targetPulse 1.5s ease-in-out infinite;
}

.scene.completed .target {
  opacity: 0;
  animation: none;
  transition: opacity 0.24s ease;
}

@keyframes targetPulse {
  50% {
    opacity: 0.52;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.tool-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: 22.58%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.phone-stage.in-game .tool-layer {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tool-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tool-instruction {
  position: absolute;
  left: 5.5%;
  top: 15%;
  z-index: 3;
  color: #5b2d1d;
  max-width: 88%;
  font-size: clamp(15px, 3.35cqw, 27px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(255, 246, 213, 0.82);
}

.tool-prop {
  position: absolute;
  left: var(--x);
  bottom: var(--y, 18%);
  z-index: 3;
  width: var(--w);
  transform: translateX(-50%);
  touch-action: none;
  filter: drop-shadow(0 9px 10px rgba(60, 34, 18, 0.26));
  display: grid;
  justify-items: center;
  gap: 4px;
}

.tool-prop img {
  width: 100%;
  height: auto;
  min-height: 0;
  object-fit: contain;
}

.prop-label {
  display: block;
  width: max-content;
  max-width: 150%;
  color: #6b3624;
  font-size: clamp(12px, 2.55cqw, 20px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(255, 246, 213, 0.82);
}

.tool-prop::after {
  content: "";
  position: absolute;
  left: -12%;
  right: -12%;
  top: -10%;
  bottom: 18%;
  border: 2px solid rgba(255, 235, 145, 0.72);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tool-prop:hover::after,
.tool-prop.active::after {
  opacity: 1;
  transform: scale(1);
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 85;
  bottom: auto;
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: 4px;
  filter: drop-shadow(0 14px 18px rgba(60, 34, 18, 0.34));
  will-change: transform;
}

.drag-ghost img {
  width: 100%;
}

.drag-ghost .prop-label {
  opacity: 0;
}

.next-btn {
  position: absolute;
  right: 4.5%;
  top: -18%;
  z-index: 6;
  width: 23%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.95);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.next-btn img {
  width: 100%;
}

.next-label {
  display: none;
}

.next-btn.final-replay {
  width: 27%;
  aspect-ratio: 2.64;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 8% 50%, rgba(177, 50, 34, 0) 0 12%, #b72e22 13% 74%, rgba(177, 50, 34, 0) 75%),
    linear-gradient(90deg, #a9271f, #c23a2b 54%, #9f251d);
  box-shadow: 0 8px 14px rgba(73, 37, 20, 0.18);
}

.next-btn.final-replay img {
  opacity: 0;
}

.next-btn.final-replay .next-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff8e8;
  font-size: clamp(16px, 4.4cqw, 34px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 2px 2px rgba(80, 24, 16, 0.42);
}

.phone-stage.ready-next .next-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.line-replay-btn {
  position: absolute;
  left: 6.2%;
  top: 25.8%;
  z-index: 31;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 24%;
  min-height: 34px;
  padding: 8px 14px 9px;
  color: #fff6e6;
  background: rgba(111, 55, 36, 0.88);
  border: 1px solid rgba(255, 236, 184, 0.55);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(70, 39, 23, 0.22);
  font-size: clamp(12px, 2.75cqw, 20px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.speaker-icon {
  width: 1.1em;
  height: 1.1em;
  object-fit: contain;
  flex: 0 0 auto;
}

.line-replay-btn span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.phone-stage.ready-next .line-replay-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 26%;
  z-index: 80;
  min-width: 190px;
  padding: 11px 18px;
  color: #fffaf0;
  background: rgba(103, 55, 38, 0.92);
  border-radius: 999px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
  box-shadow: 0 12px 26px rgba(68, 38, 23, 0.24);
}

.toast.show {
  animation: toast 1.3s ease both;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  18%,
  78% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
}

.page-flip {
  position: absolute;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(270deg, rgba(90, 55, 28, 0.18), rgba(255, 249, 230, 0.72) 42%, rgba(255, 255, 255, 0.92) 50%, rgba(255, 249, 230, 0.45) 58%, rgba(90, 55, 28, 0));
  transform-origin: left center;
}

.page-flip.turn {
  animation: pageTurn 0.72s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageTurn {
  0% {
    opacity: 0;
    transform: perspective(900px) rotateY(0deg) translateX(-45%);
  }
  25% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: perspective(900px) rotateY(72deg) translateX(35%);
  }
}

@media (max-height: 680px) {
  .target {
    width: 19%;
  }

  .toast {
    bottom: 24%;
    font-size: 14px;
  }
}
