/* 为整幅作品设置低亮度梅色夜空与系统中文字体。 */
:root {
  color-scheme: dark;
  background: #0b050c;
  color: #f7e9ed;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --inset: clamp(18px, 4vw, 70px);
}
/* 用统一盒模型约束按钮和画布的边界。 */
* { box-sizing: border-box; }
/* 首尾两栏固定留出操作空间，中间画布使用剩余高度。 */
body {
  margin: 0;
  height: 100vh;
  height: 100svh;
  min-height: 290px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
/* 导航与控制栏从两侧对齐，并照顾手机的屏幕安全区。 */
header, footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-inline: max(var(--inset), env(safe-area-inset-left)) max(var(--inset), env(safe-area-inset-right));
}
/* 顶部根据可用高度调整留白。 */
header { padding-top: max(clamp(10px, 2.8vh, 30px), env(safe-area-inset-top)); }
/* 底部栏在手机上避开系统手势区域。 */
footer { padding-block: 5px max(clamp(12px, 3vh, 32px), env(safe-area-inset-bottom)); }
/* 提供返回作品墙的轻量文字入口。 */
.back { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: #e7d2db; text-decoration: none; font-size: 14px; }
/* 放大返回方向的箭头。 */
.back span { font-size: 21px; }
/* 主画面提供贺词与交互绘图层的定位上下文。 */
main { position: relative; min-height: 0; isolation: isolate; overflow: hidden; }
/* 桌面右侧展示树，左侧贺词按同一视觉中心对齐。 */
#stage { position: absolute; inset: 0 0 0 auto; display: block; width: 69%; height: 100%; cursor: grab; touch-action: none; mask-image: linear-gradient(90deg, transparent, #000 10%); }
/* 只在抓取旋转时改变指针。 */
#stage:active { cursor: grabbing; }
/* 贺词靠左排布，允许穿过文字操作画布。 */
.dedication { position: absolute; z-index: 1; left: clamp(26px, 7vw, 130px); top: 44%; transform: translateY(-50%); pointer-events: none; }
/* 中文作品名作为整张贺卡的题签。 */
h1 { margin: 0 0 15px; font-size: clamp(14px, 1.15vw, 19px); font-weight: 450; letter-spacing: .18em; color: #e9becd; }
/* 祝福语采用大字号衬线体，在流星着陆时淡入。 */
.greeting { margin: 0; font-family: Baskerville, "Times New Roman", serif; font-size: clamp(52px, 6.6vw, 125px); font-weight: 400; line-height: .98; letter-spacing: -.055em; opacity: 0; transition: opacity .8s ease; }
/* 树顶点亮后显示贺词。 */
main.lit .greeting { opacity: 1; }
/* 下行采用柔和的玫瑰色斜体。 */
.greeting em { color: #f2b6cd; }
/* 保持文字与图标按钮拥有足够大的触摸区域。 */
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 24px; background: transparent; color: #eddae2; font: inherit; font-size: 13px; cursor: pointer; }
/* 按浏览器能力隐藏不可用的控件。 */
[hidden] { display: none !important; }
/* 线性图标继承按钮颜色。 */
button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* 悬停提供轻微表面高光。 */
button:hover:enabled, .back:hover { color: white; background-color: #fed8eb0e; }
/* 保留清楚的键盘焦点指示。 */
:focus-visible { outline: 2px solid #f2aaca; outline-offset: -2px; }
/* 以文字说明当前设备可用的操控手势。 */
.gesture { margin: 0; color: #bfa9b7; font-size: 12px; letter-spacing: .04em; }
/* 默认呈现鼠标操作提示。 */
.touch-hint { display: none; }
/* 指针较粗的设备显示触摸操作。 */
@media (pointer: coarse) {
  /* 用双指缩放说明替换滚轮说明。 */
  .touch-hint { display: inline; }
  /* 触屏隐藏鼠标专属提示。 */
  .mouse-hint { display: none; }
}
/* 所有回放控制在一条半透明工具栏内对齐。 */
.controls { display: inline-flex; align-items: center; padding: 1px 4px; border: 1px solid #dac3d030; border-radius: 30px; background: #21131c7a; }
/* 用分隔线区分缩放与播放操作。 */
.zoom { display: flex; align-items: center; margin-left: 4px; padding-left: 4px; border-left: 1px solid #dac3d02c; }
/* 加减键使用一致的触摸目标。 */
.zoom button { min-width: 40px; padding: 0; font-size: 18px; }
/* 固定百分比宽度避免缩放时挤动工具栏。 */
output { min-width: 4ch; text-align: center; color: #edcedd; font: 12px/1.2 ui-monospace, monospace; }
/* 达到缩放上下限时淡化对应按钮。 */
button:disabled { opacity: .32; cursor: default; }
/* 窄屏竖排贺词与树体，并将控制栏居中。 */
@media (max-width: 700px) and (orientation: portrait) {
  /* 上方贺词独立成行，余下空间供画布使用。 */
  main { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  /* 收拢中文题签与祝福语的间距。 */
  .dedication { position: static; text-align: center; transform: none; padding: clamp(6px, 2.8vh, 28px) 12px 0; }
  /* 让较小的中文题签保持清晰。 */
  h1 { margin-bottom: 8px; font-size: 13px; }
  /* 手机贺词同排显示，将主要高度留给粒子树。 */
  .greeting { font-size: clamp(37px, 10.7vw, 66px); }
  /* 窄屏用一个单词间距取代桌面换行。 */
  .greeting br { display: none; }
  /* 补回英文贺词的词间留白。 */
  .greeting em { margin-inline-start: .14em; }
  /* 画布尺寸随手机旋转或工具栏变化自动更新。 */
  #stage { position: static; width: 100%; mask-image: none; }
  /* 上下排列操作提示与控制按钮。 */
  footer { flex-direction: column; gap: 8px; }
}
/* 较矮的横屏设备留出更多舞台高度。 */
@media (max-height: 480px) {
  /* 收紧头部边距。 */
  header { padding-top: env(safe-area-inset-top); }
  /* 收紧底部边距。 */
  footer { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  /* 防止大标题侵入树体。 */
  .greeting { font-size: clamp(36px, 7vw, 62px); }
}
/* 用户要求减少动态时立即显示当前帧对应的贺词。 */
@media (prefers-reduced-motion: reduce) {
  /* 取消贺词淡入。 */
  .greeting { transition: none; }
}
