:root {
  --bg: #f8fafc;
  --ink: #111827;
  --ink-soft: #6b7280;
  --glass: rgba(255, 255, 255, 0.44);
  --glass-border: rgba(255, 255, 255, 0.72);
  --inner-glow: inset 0 1px 2px rgba(255, 255, 255, 0.9), inset 0 -8px 24px rgba(15, 23, 42, 0.05);
  --drop-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.14em;
}

#app {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  width: 44vmax;
  height: 44vmax;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.5;
}

.orb-a {
  background: radial-gradient(circle, rgba(186, 230, 253, 0.95) 0%, rgba(186, 230, 253, 0) 70%);
  top: -8vmax;
  left: -8vmax;
}

.orb-b {
  background: radial-gradient(circle, rgba(254, 240, 138, 0.6) 0%, rgba(254, 240, 138, 0) 70%);
  right: -12vmax;
  top: 20vh;
}

.orb-c {
  background: radial-gradient(circle, rgba(244, 114, 182, 0.42) 0%, rgba(244, 114, 182, 0) 70%);
  left: 22vw;
  bottom: -16vmax;
}

.screen {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 18px 24px;
}

.title {
  font-size: 12px;
  color: #9ca3af;
  text-transform: uppercase;
  margin: 6px 0 24px;
  text-align: center;
  width: 100%;
  font-family: "STZhongsong", "STFangsong", "FangSong", "SimSong", "Noto Sans SC", sans-serif;
  font-weight: 300;
  font-stretch: condensed;
  letter-spacing: 0.12em;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--inner-glow), var(--drop-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-mask {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.7);
}

.login-card {
  width: min(92vw, 420px);
  border-radius: 24px;
  padding: 26px;
  text-align: center;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.18em;
}

.btn.primary {
  color: #0f172a;
}

.void-grid {
  --entry-size: clamp(175px, 21vw, 294px);
  /* 3 列：直接用列宽决定卡片边长（避免被 1fr + 容器宽度限制“锁小”） */
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, var(--entry-size));
  justify-content: center;
  gap: 88px;
  margin-top: 18vh;
}

.entry {
  aspect-ratio: 1 / 1;
  width: var(--entry-size, 320px);
  height: auto;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease;
}

/* 文案块：收紧行盒 + 略下移，抵消大字汉字「字面在上、行盒偏上」带来的视觉偏高 */
.entry > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(calc(var(--entry-size, 200px) * 0.028));
}

.entry:hover {
  transform: translateY(-4px);
}

.entry-han {
  font-size: clamp(22px, 6vw, 46px);
  line-height: 1;
  margin: 0 0 8px;
  font-family: "STZhongsong", "STFangsong", "FangSong", "SimSong", "Noto Sans SC", sans-serif;
  font-weight: 300;
  font-stretch: condensed;
  letter-spacing: 0.06em;
}

.entry-en {
  font-size: clamp(9px, 2vw, 12px);
  line-height: 1;
  margin: 0;
  color: #6b7280;
  font-family: "STZhongsong", "STFangsong", "FangSong", "SimSong", "Noto Sans SC", sans-serif;
  font-weight: 300;
  font-stretch: condensed;
  letter-spacing: 0.08em;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  user-select: none;
}

.scene.active {
  display: flex;
}

.exit-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
}

.breath-ring {
  width: clamp(240px, 70vw, 380px);
  height: clamp(240px, 70vw, 380px);
  border-radius: 999px;
  position: relative;
  border: 1px solid var(--breath-stroke, rgba(253, 186, 116, 0.95));
  --breath-stroke: rgba(253, 186, 116, 0.95);
  --breath-fill: rgba(253, 186, 116, 0.22);
  display: grid;
  place-items: center;
  z-index: 2;
}

/* 息：整体垂直仍居中，呼吸圆环相对原位置再上移约 20% 视口高（margin 不参与 GSAP transform） */
#scene-breath .breath-ring {
  margin-top: -20vh;
}

.breath-text {
  z-index: 3;
}

.breath-bg-switcher {
  z-index: 3;
}

.breath-visual-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.8s ease, background 0.8s ease;
  /* 浅蓝偏白基底：避免波浪透明叠层时露出“纯白空洞感” */
  background: radial-gradient(
    ellipse 120% 90% at 50% 5%,
    rgba(147, 197, 253, 0.12) 0%,
    rgba(248, 250, 252, 0.16) 52%,
    rgba(248, 250, 252, 0.1) 100%
  );
}

/* 壁炉：整层底纯黑；背景不参与渐变，避免顶部未被 fire 层盖住时出现慢半拍变黑 */
.breath-visual-bg.breath-visual-bg--fire {
  background: #000000;
  transition: opacity 0.8s ease, background 0s linear;
}

/* 海浪：纸质底色（画布内同色平涂，此处保证未遮罩区域一致） */
.breath-visual-bg.breath-visual-bg--waves {
  background: #f7f5f2;
}

.breath-ink-wave-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}

/* 旧版 SVG 波浪已由水墨 Canvas 取代，保留 DOM 节点以兼容 breath 时间轴引用 */
.breath-wave-layer {
  display: none;
}

.breath-rain-bg {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 25%, rgba(34, 197, 94, 0.14) 0%, rgba(248, 250, 252, 0) 55%),
    radial-gradient(ellipse 70% 45% at 85% 20%, rgba(59, 130, 246, 0.12) 0%, rgba(248, 250, 252, 0) 60%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.08) 0%, rgba(248, 250, 252, 0) 55%),
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.08) 0 20%, transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.07) 0 22%, transparent 38%);
  filter: blur(0px);
}

.breath-rain-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.08) 0 2px, transparent 3px),
    radial-gradient(circle at 40% 60%, rgba(255, 255, 255, 0.06) 0 2px, transparent 3px);
  opacity: 0.7;
  filter: blur(10px);
}

/* 炉火层占视口高度 73% 贴底；顶区由 .breath-visual-bg--fire 纯黑铺满，避免不同步闪屏 */
.breath-fire-bg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: 73%;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  mix-blend-mode: normal;
}

.breath-fire-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000000;
  pointer-events: none;
}

.breath-fire-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
}

/* 壁炉：满屏降雪（随 breathVisualBg 淡入淡出，置于炉火层之上） */
.breath-fire-snow-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  pointer-events: none;
  z-index: 4;
}

/* 猫咪：黑底 + 粉色花瓣飘落 + 插画（锚点 65% 屏高） */
.breath-cat-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
}

.breath-cat-room {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000000;
}

.breath-cat-petals {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.breath-cat-sakura {
  position: absolute;
  top: -8%;
  left: var(--sk-left, 10%);
  width: clamp(9px, 2vw, 16px);
  height: clamp(12px, 2.6vw, 21px);
  border-radius: 60% 40% 60% 40%;
  opacity: 0;
  background: radial-gradient(ellipse 70% 80% at 35% 30%, rgba(255, 228, 240, 0.95), rgba(251, 182, 206, 0.88) 45%, rgba(244, 114, 182, 0.55) 78%, rgba(219, 39, 119, 0.35));
  box-shadow: 0 0 10px rgba(251, 182, 206, 0.35);
  animation: breath-cat-sakura-fall var(--sk-dur, 12s) linear infinite;
  animation-delay: var(--sk-delay, 0s);
  transform: rotate(var(--sk-rot0, 18deg));
  will-change: transform, opacity;
}

@keyframes breath-cat-sakura-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--sk-rot0, 18deg));
    opacity: 0;
  }
  6% {
    opacity: 0.88;
  }
  100% {
    transform: translate3d(var(--sk-drift, 12px), 118vh, 0) rotate(calc(var(--sk-rot0, 18deg) + 320deg));
    opacity: 0;
  }
}

.breath-cat-art {
  position: absolute;
  left: 50%;
  top: 65%;
  z-index: 2;
  transform: translate(-50%, -50%);
  width: min(92vw, 520px);
  max-width: 100%;
  pointer-events: none;
}

.breath-cat-nap-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(48vh, 460px);
  object-fit: contain;
  image-rendering: auto;
}

.breath-drop {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 999px;
  /* opacity 由渐变 alpha 控制，避免 CSS opacity 上限导致“透明度>1”失效 */
  opacity: 1;
  --rain-intensity: 1;
  background: linear-gradient(
    to bottom,
    rgba(147, 197, 253, 0) 0%,
    rgba(147, 197, 253, calc(0.28 * var(--rain-intensity))) 35%,
    rgba(147, 197, 253, calc(0.12 * var(--rain-intensity))) 70%,
    rgba(147, 197, 253, 0) 100%
  );
  filter: blur(0.4px);
  mix-blend-mode: screen;
}

.breath-petal-layer {
  position: absolute;
  inset: 0;
  transform-origin: center;
}

.breath-petal-layer--outer {
  --petal-distance: clamp(96px, 26vw, 128px);
  --petal-w: clamp(84px, 22vw, 132px);
  --petal-h: clamp(40px, 10vw, 72px);
}

.breath-petal-layer--inner {
  --petal-distance: clamp(68px, 20vw, 104px);
  --petal-w: clamp(68px, 16vw, 108px);
  --petal-h: clamp(32px, 8vw, 60px);
}

.breath-petal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--petal-w);
  height: var(--petal-h);
  transform-origin: center;
  clip-path: polygon(
    50% 0%,
    63% 9%,
    75% 24%,
    88% 44%,
    82% 62%,
    66% 82%,
    50% 92%,
    34% 82%,
    18% 62%,
    12% 44%,
    25% 24%,
    37% 9%
  );
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.18) 44%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), var(--breath-fill));
  box-shadow:
    inset 0 0 18px rgba(255, 255, 255, 0.18),
    0 0 22px rgba(255, 255, 255, 0.06);
  opacity: 0.95;
}

.breath-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 13%;
  height: 13%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.82), var(--breath-fill) 62%, rgba(255, 255, 255, 0));
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.18);
  opacity: 0.88;
}

.breath-ring {
  --petal-distance: clamp(40px, 12vw, 58px);
}

.breath-text {
  margin-top: 30px;
  font-size: clamp(12px, 3vw, 16px);
  color: #4b5563;
}

.breath-bg-switcher {
  position: absolute;
  /* 往上移动，靠近“息”的呼吸环/花瓣区域（随屏幕高度自适应） */
  bottom: clamp(80px, 16vh, 220px);
  display: flex;
  gap: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.chip {
  border-radius: 999px;
  padding: 16px 20px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  /* 瘦金体风格：不同系统字体名不一，这里给多级回退 */
  font-family: "STZhongsong", "STFangsong", "FangSong", "SimSong", "Noto Sans SC", sans-serif;
  font-weight: 300;
  font-stretch: condensed;
  letter-spacing: 0.06em;
}

.shape-wrap {
  width: min(90vw, 680px);
  height: min(70vh, 760px);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.shape-canvas {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  display: block;
  touch-action: none;
}

.shape-hint {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  pointer-events: none;
  font-size: clamp(12px, 2.6vw, 18px);
  font-weight: 300;
  letter-spacing: 0.08em;
  font-family: "STZhongsong", "STFangsong", "FangSong", "SimSong", "Noto Sans SC", sans-serif;
  color: rgba(107, 114, 128, 0.9);
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 2;
}

.shape-hint.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-6px);
}

/* 触：整页居中；单用 flex 时易与绝对定位的 exit-hint 叠算产生轻微偏移 */
#scene-pop.scene.active {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 20px 16px calc(64px + env(safe-area-inset-bottom, 0));
  box-sizing: border-box;
}

.pop-grid {
  width: min(90vw, 620px);
  max-width: 100%;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.bubble {
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset -4px -6px 10px rgba(15, 23, 42, 0.08), inset 6px 10px 14px rgba(255, 255, 255, 0.8), 0 6px 18px rgba(15, 23, 42, 0.1);
  /* 勿过渡 background，否则捏扁时会出现叠化/错位的切换感 */
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  transition-property: transform, box-shadow;
}

/* 点击后先略缩小，仍为玻璃；捏扁图由 .popped-texture 延迟挂上 */
.bubble.popped {
  transform: scale(0.94);
  box-shadow: inset -3px -5px 8px rgba(15, 23, 42, 0.1), inset 5px 8px 12px rgba(255, 255, 255, 0.75), 0 4px 14px rgba(15, 23, 42, 0.09);
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  transition-property: transform, box-shadow;
}

/* 0.5s 后整格替换为捏扁图（无描边提亮，与 --glass-border 一致） */
.bubble.popped.popped-texture {
  background-color: #f6f7f9;
  background-image: url("./assets/bubble-popped.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-color: var(--glass-border);
  filter: brightness(1.14) saturate(0.88);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.92),
    inset 0 -3px 10px rgba(15, 23, 42, 0.1),
    0 3px 10px rgba(15, 23, 42, 0.1);
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  transition-property: transform, box-shadow;
}

.traces-area,
.slice-area,
.listen-area {
  width: min(90vw, 720px);
  min-height: 62vh;
  border-radius: 24px;
  padding: 16px;
}

.slice-area {
  position: relative;
  overflow: hidden;
}

.slice-hint {
  position: relative;
  z-index: 2;
  pointer-events: none;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 10px;
}

.slice-soap-stage {
  position: relative;
  width: 100%;
  height: min(52vh, 480px);
  min-height: 300px;
  border-radius: 20px;
  overflow: hidden;
  background: transparent;
  touch-action: none;
}

.slice-soap-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  vertical-align: top;
  cursor: grab;
  touch-action: none;
}

.slice-knife-canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  vertical-align: top;
}

.slice-soap-canvas:active {
  cursor: grabbing;
}

/* 裁场景：避免 .exit-hint 叠在玻璃卡片之上挡住下半区刀/皂体（DOM 中 hint 在 slice-area 之后） */
#scene-slice .slice-area {
  z-index: 2;
}
#scene-slice .exit-hint {
  z-index: 0;
  pointer-events: none;
}

.traces-area {
  position: relative;
  overflow: hidden;
}

.traces-hint {
  position: relative;
  z-index: 2;
  pointer-events: none;
  font-size: 11px;
  color: #6b7280;
}

.traces-leaves-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  pointer-events: auto;
  touch-action: manipulation;
}

.listen-bell-wrap {
  margin-top: 14vh;
  width: 100%;
  height: min(48vh, 420px);
  min-height: 280px;
  position: relative;
  touch-action: none;
  cursor: pointer;
  border-radius: 20px;
  overflow: hidden;
}

.listen-chimes-canvas {
  display: block;
  width: 100%;
  height: 100%;
  vertical-align: top;
}

@media (max-width: 760px) {
  .void-grid {
    --entry-size: clamp(110px, 26vw, 150px);
    grid-template-columns: repeat(2, var(--entry-size));
    justify-content: center;
    gap: 88px;
    margin-top: 13vh;
  }
}

.splash-mask {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.splash-card {
  width: min(86vw, 520px);
  padding: 22px 18px;
  border-radius: 28px;
  text-align: center;
}

.splash-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.splash-sub {
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
  font-weight: 700;
}

.splash-orb {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  margin: 0 auto 12px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.95), rgba(255,255,255,.15) 55%, rgba(191,219,254,.22) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 18px 40px rgba(15,23,42,.08);
  border: 1px solid rgba(255,255,255,.7);
}
