/* ========== Main Scene ========== */
#app {
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: var(--z-scene);
  overflow: hidden;
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: var(--z-bg);
}

/* ========== Z-Index Layers ========== */
/* --z-bg: 0      → 背景主场景 */
/* --z-scene: 10  → 场景容器 */
/* --z-props: 20  → 茶具/杯筊等地面道具 */
/* --z-ui: 40     → UI表单/按钮 */
/* --z-dialogue: 50 → 对话框 */
/* --z-overlay: 90 → 全屏遮罩 */
/* --z-loading: 100 → 加载层 */

/* ========== Jiao Throwing Area (Item 11) ========== */
.jiao-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-props);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Two jiao sprites — symmetric, 25% smaller (90px from 120px) */
.jiao-pair {
  display: flex;
  gap: 20px;
  align-items: center;
}

/* 包裹层 —— 承载光环 halo，确保发光可见（img 无法生成伪元素） */
.jiao-sprite-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.jiao-sprite {
  width: 90px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: filter 0.3s ease, transform 0.3s ease;
  position: relative;
  z-index: 1;
}

/* 白色光环 halo —— radial-gradient 保证在任何背景上可见 */
.jiao-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 150px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.5) 35%, rgba(255, 255, 255, 0.15) 60%, transparent 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.jiao-glow.active {
  opacity: 1;
  animation: haloPulseWhite 1.2s ease-in-out infinite;
}

.jiao-sprite.holding {
  filter: drop-shadow(0 0 50px #fff), drop-shadow(0 0 100px rgba(255, 255, 255, 0.95)), drop-shadow(0 0 160px rgba(255, 255, 255, 0.8)), drop-shadow(0 0 220px rgba(255, 255, 255, 0.5));
  transform: scale(1.1);
}

/* Right cup — horizontally flipped */
.jiao-right {
  transform: scaleX(-1);
}

.jiao-right.holding {
  transform: scaleX(-1) scale(1.1);
}

/* Each sprite falls independently */
.jiao-sprite.falling-left {
  animation: jiaoFallLeft 0.8s var(--ease-out) forwards;
}

.jiao-sprite.falling-right {
  animation: jiaoFallRight 0.8s var(--ease-out) forwards;
}

/* ========== Jiao Result Display (Item 12) ========== */
.jiao-result {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-dialogue);
  display: none;
}

.jiao-result.show {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Result image with large white border */
.jiao-result-frame {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.6);
  animation: impactIn 0.5s var(--ease-out-expo) forwards;
}

.jiao-result-frame.exit {
  animation: impactOut 0.4s ease forwards;
}

.jiao-result-img {
  width: 260px;
  display: block;
}

/* ========== Tea Table (trapezoid wood) ========== */
.tea-table {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50dvw;
  height: 90px;
  z-index: 5;
  background: linear-gradient(180deg, #8a6a4f 0%, #6e5240 60%, #5a4334 100%);
  clip-path: polygon(12% 0, 88% 0, 100% 100%, 0% 100%);
  transition: opacity 1s ease, transform 1s var(--ease-out);
}

.tea-table.hidden {
  transform: translateX(-50%) translateY(100%);
  opacity: 0;
}

/* slide-out 退出类 —— 避开全局 .hidden{display:none!important} 冲突，保证过渡生效 */
.tea-table.exited {
  transform: translateX(-50%) translateY(100%);
  opacity: 0;
}

/* ========== Tea Set Area ========== */
.tea-area {
  position: absolute;
  bottom: calc(12% - 90px);
  left: 0;
  right: 0;
  z-index: var(--z-props);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 60px;
  transition: transform 1s var(--ease-out), opacity 1s ease 0.1s;
}

.tea-area.hidden {
  transform: translateY(100dvh);
  opacity: 0;
  pointer-events: none;
}

/* slide-out 退出类 —— 避开全局 .hidden{display:none!important} 冲突，保证过渡生效 */
.tea-area.exited {
  transform: translateY(100dvh);
  opacity: 0;
  pointer-events: none;
}

/* Each group — flex column, bottom-aligned */
.tea-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Base + bowl group — bowl sits on top of base */
.tea-base-group {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100px;
}

.tea-base {
  width: 90px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.tea-bowl {
  width: 100px;
  object-fit: contain;
  position: relative;
  z-index: 2;
  margin-bottom: -8px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transform: translateY(27px);
  transition: transform 0.3s var(--ease-out);
}

.tea-bowl.picked-up {
  cursor: grabbing;
  z-index: 100;
  position: fixed;
  transition: none;
}

.tea-cup-container {
  position: relative;
  width: 150px;
  height: 150px;
  cursor: pointer;
}

.tea-cup-img {
  width: 150px;
  position: absolute;
  bottom: 0;
  left: 0;
  object-fit: contain;
}

/* 茶宠包裹层 —— 承载光环 halo，确保发光可见 */
.tea-pet-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform: translateY(-20px);
}

.tea-pet {
  width: 80px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

/* 绿色光环 halo —— radial-gradient 保证可见，filter 作为增强 */
.tea-pet-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 130px;
  height: 130px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 50, 0.9) 0%, rgba(255, 200, 50, 0.45) 35%, rgba(255, 200, 50, 0.15) 60%, transparent 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 0;
}

.tea-pet-halo.active {
  opacity: 1;
  animation: haloPulseGreen 1.5s ease-in-out infinite;
}

.tea-pet.glowing {
  animation: glowPulse 1.5s ease-in-out infinite;
}

/* Pouring stream — 单条竖直矩形，椭圆径向渐变暖棕色，摆动+蒙版 */
.pour-stream {
  position: fixed;
  width: 25px;
  z-index: 101;
  pointer-events: none;
  transform-origin: 50% 0%;
  /* 椭圆蒙版：裁掉四角硬边 */
  border-radius: 12px;
  overflow: hidden;
}

.pour-stream.stream-a {
  background: radial-gradient(ellipse 70% 80% at 50% 50%,
      rgba(220, 150, 70, 0.85) 0%,
      rgba(220, 150, 70, 0.6) 35%,
      rgba(220, 150, 70, 0.3) 65%,
      transparent 100%);
  animation: streamSway 1.2s ease-in-out infinite, streamFadeA 0.8s ease-in-out infinite;
}

.pour-stream.stream-b {
  background: radial-gradient(ellipse 60% 70% at 50% 45%,
      rgba(230, 165, 85, 0.8) 0%,
      rgba(230, 165, 85, 0.5) 40%,
      rgba(230, 165, 85, 0.25) 70%,
      transparent 100%);
  animation: streamSway 1.2s ease-in-out infinite, streamFadeB 0.8s ease-in-out infinite;
}

/* ========== Bowl Hint —— 茶碗提示语 + 跳动箭头 ========== */
.bowl-hint {
  position: absolute;
  bottom: calc(100% - 50px);
  left: calc(60% + 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  z-index: var(--z-ui);
  pointer-events: none;
}

/* 字体排版与 step4 .jiao-instruction 一致，颜色用主题色 */
.bowl-hint-text {
  font-family: var(--sans);
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--accent-red);
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* 箭头与 step4 .jiao-arrow 一致（↓字符 + triangleBounce），外层顺时针旋转45度对准茶碗 */
.bowl-hint-arrow {
  font-size: 40px;
  font-weight: 600;
  color: var(--accent-red);
  line-height: 1;
  display: inline-block;
  transform: rotate(45deg);
  margin-left: -80px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.bowl-hint-arrow>span {
  display: inline-block;
  animation: triangleBounce 1.2s ease-in-out infinite;
}

/* ========== Interpret Button ========== */
.interpret-btn-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 80px));
  z-index: var(--z-ui);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Larger interpret button — +50% size */
.btn.interpret-btn {
  font-size: 21px;
  padding: 18px 48px;
  border-width: 2px;
}

/* 解读按钮解锁后持续闪烁 */
.btn.interpret-btn.ready {
  animation: interpretBlink 1.2s ease-in-out infinite;
}

/* ========== Slide transitions ========== */
.slide-up-enter {
  animation: slideUp 0.6s var(--ease-out) forwards;
}

.slide-down-exit {
  animation: slideDown 0.6s var(--ease-out) forwards;
}