/* 舞台：场景 + 形象 + 气泡。
   形象当前的动作写在 .avatar 的 data-action 上，这里据此决定显示哪些部件、播放哪些动画。 */

.stage {
  position: relative;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line, #24405c);
  background: #0d1b2a;
}
.stage-svg { display: block; width: 100%; height: auto; }

.bubble {
  position: absolute;
  top: 3%;
  left: 32%;
  transform: translateX(-50%);
  max-width: 70%;
  padding: 5px 12px;
  border-radius: 14px;
  background: #fff;
  color: #2a2440;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  animation: bubble-in .25s ease-out;
}
/* 气泡的位置（left）和小尾巴的偏移（--tail）由 stage.js 根据画面宽度计算 */
.bubble::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--tail, 0px));
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
@media (max-width: 520px) { .bubble { font-size: 12px; padding: 3px 9px; } }

/* 说明文字放在画面下方，不遮挡形象 */
.stage-caption {
  padding: 8px 14px;
  background: var(--card, #16283c);
  color: var(--text, #e6eef7);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 搏鱼时的读数：拉力和进度 */
.hud {
  position: absolute;
  top: 4%;
  right: 3%;
  width: 38%;
  max-width: 210px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(8, 18, 34, .72);
  color: #fff;
  font-size: 12px;
}
.hud-row { display: grid; grid-template-columns: 2.4em 1fr 2.8em; align-items: center; gap: 6px; }
.hud-row + .hud-row { margin-top: 4px; }
.hud-track { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.hud-fill { height: 100%; border-radius: 4px; background: #ffc857; transition: width .5s ease; }
.hud-progress .hud-fill { background: #6fd08c; }
.hud-tension.danger .hud-fill { background: #ff5d6c; animation: hud-flash .4s ease-in-out infinite alternate; }
.hud-tension.slack .hud-fill { background: #8fb6ff; }
.hud-value { text-align: right; font-variant-numeric: tabular-nums; }
@keyframes hud-flash { from { opacity: .55; } to { opacity: 1; } }
@media (max-width: 520px) { .hud { font-size: 10px; padding: 4px 6px; } }

/* 没有对应时段的背景图时，盖在白天图上的颜色 */
.sc-tint { mix-blend-mode: multiply; }

/* ---------- 按动作显示部件 ---------- */

.avatar [class*="show-"] { display: none; }
.avatar[data-action="idle"] .show-idle,
.avatar[data-action="fishing"] .show-fishing,
.avatar[data-action="smile"] .show-smile,
.avatar[data-action="cheer"] .show-cheer,
.avatar[data-action="amazed"] .show-amazed,
.avatar[data-action="sad"] .show-sad,
.avatar[data-action="cry"] .show-cry,
.avatar[data-action="win"] .show-win,
.avatar[data-action="lose"] .show-lose,
.avatar[data-action="write"] .show-write,
.avatar[data-action="sleep"] .show-sleep { display: inline; }

/* 相册缩略图：定格在动作的起始姿势，不播放动画 */
.stage.paused *, .stage.paused *::after { animation-play-state: paused !important; }
.stage.paused .av-sparkle, .stage.paused .av-zzz { opacity: 1; transform: none; animation: none !important; }

/* 图片皮肤的呼吸：整张图轻微地上下伸缩 */
.av-img { transform-origin: 100px 250px; animation: img-breathe 3.2s ease-in-out infinite alternate; }
@keyframes img-breathe { from { transform: scaleY(1); } to { transform: scaleY(1.012); } }

/* ---------- 钓到的鱼：越稀有越大、颜色越亮 ---------- */

.avatar[data-fish="none"] .av-fish { display: none !important; }
/* 有这种鱼的图片时显示图片，否则显示代码画的小鱼 */
.avatar[data-fishimg="1"] .av-fish-vec { display: none; }
.avatar:not([data-fishimg="1"]) .av-fish-img { display: none; }
.av-fish-size { transform-box: fill-box; transform-origin: center; }
.av-fish-glow { display: none; }
.avatar[data-fish="0"] .av-fish-size { transform: scale(.8); }
.avatar[data-fish="0"] .av-fish-body { fill: #c9d5e0; }
.avatar[data-fish="0"] .av-fish-fin { fill: #a9b8c7; }
.avatar[data-fish="1"] .av-fish-body { fill: #9be0a6; }
.avatar[data-fish="1"] .av-fish-fin { fill: #6cc37a; }
.avatar[data-fish="2"] .av-fish-size { transform: scale(1.15); }
.avatar[data-fish="2"] .av-fish-body { fill: #8cc8ff; }
.avatar[data-fish="2"] .av-fish-fin { fill: #5a9df0; }
.avatar[data-fish="3"] .av-fish-size { transform: scale(1.35); }
.avatar[data-fish="3"] .av-fish-body { fill: #cfa2ff; }
.avatar[data-fish="3"] .av-fish-fin { fill: #a06be8; }
.avatar[data-fish="4"] .av-fish-size { transform: scale(1.6); }
.avatar[data-fish="4"] .av-fish-body { fill: #ffe066; }
.avatar[data-fish="4"] .av-fish-fin { fill: #ffb62e; }
.avatar:is([data-fish="3"], [data-fish="4"]) .av-fish-glow {
  display: inline;
  transform-box: fill-box;
  transform-origin: center;
  animation: glow 1s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .35; transform: scale(.9); } to { opacity: .8; transform: scale(1.15); } }

/* 感叹号只在钓鱼且咬钩的鱼够稀有时出现 */
.avatar .av-alert { display: none; }
.avatar[data-action="fishing"]:is([data-tension="3"], [data-tension="4"], [data-tension="5"]) .av-alert {
  display: inline;
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: alert-pop .45s ease-in-out infinite alternate;
}

/* ---------- 一直在动的部分 ---------- */

.av-body { animation: breathe 3.2s ease-in-out infinite alternate; }
.av-head { transform-origin: 100px 138px; animation: head-bob 3.2s ease-in-out infinite alternate; }
.av-tail { transform-origin: 120px 194px; animation: tail-wag 1.9s ease-in-out infinite alternate; }
.av-backhair { transform-origin: 100px 90px; animation: hair-sway 3.2s ease-in-out infinite alternate; }
.av-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
.av-arm-l { transform-origin: 80px 149px; animation: arm-sway-l 3.2s ease-in-out infinite alternate; }
.av-arm-r { transform-origin: 120px 149px; animation: arm-sway-r 3.2s ease-in-out infinite alternate; }

@keyframes breathe { from { transform: translateY(0); } to { transform: translateY(-1.6px); } }
@keyframes head-bob { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
@keyframes tail-wag { from { transform: rotate(-5deg); } to { transform: rotate(7deg); } }
@keyframes hair-sway { from { transform: rotate(-.8deg); } to { transform: rotate(.8deg); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
@keyframes arm-sway-l { from { transform: rotate(3deg); } to { transform: rotate(-2deg); } }
@keyframes arm-sway-r { from { transform: rotate(-3deg); } to { transform: rotate(2deg); } }

/* ---------- 钓鱼 ---------- */

.avatar[data-action="fishing"] .av-arm-r { animation: none; transform: rotate(-62deg); }
.avatar[data-action="fishing"] .av-arm-l { animation: none; transform: rotate(-30deg); }
.av-rod { transform-origin: 150px 167px; animation: rod-idle 2.4s ease-in-out infinite alternate; }
.av-bobber { animation: bob 1.8s ease-in-out infinite alternate; }
.av-ripple { transform-box: fill-box; transform-origin: center; animation: ripple 2.2s ease-out infinite; }
.av-ripple.r2 { animation-delay: 1.1s; }

.avatar[data-tension="2"] .av-bobber { animation-duration: .9s; }
.avatar:is([data-tension="3"], [data-tension="4"], [data-tension="5"]) .av-bobber { animation: bob-hard .32s ease-in-out infinite alternate; }
.avatar:is([data-tension="3"], [data-tension="4"], [data-tension="5"]) .av-rod { animation: rod-pull .32s ease-in-out infinite alternate; }
.avatar:is([data-tension="3"], [data-tension="4"], [data-tension="5"]) .av-ripple { animation-duration: .9s; }
.avatar:is([data-tension="3"], [data-tension="4"], [data-tension="5"]) .av-ripple.r2 { animation-delay: .45s; }
.avatar:is([data-tension="4"], [data-tension="5"]) .av-body { animation: tug .32s ease-in-out infinite alternate; }

@keyframes rod-idle { from { transform: rotate(-1deg); } to { transform: rotate(1.2deg); } }
@keyframes rod-pull { from { transform: rotate(1deg); } to { transform: rotate(5deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(3px); } }
@keyframes bob-hard { from { transform: translate(-2px, 2px); } to { transform: translate(2px, 9px); } }
@keyframes ripple { from { transform: scale(.3); opacity: .9; } to { transform: scale(2); opacity: 0; } }
@keyframes tug { from { transform: translateX(0); } to { transform: translateX(2.5px); } }
@keyframes alert-pop { from { transform: scale(.9); } to { transform: scale(1.15); } }

/* ---------- 开心 ---------- */

.avatar[data-action="cheer"] .av-body { animation: jump .55s ease-in-out infinite alternate; }
.avatar[data-action="cheer"] .av-shadow { transform-box: fill-box; transform-origin: center; animation: shadow-jump .55s ease-in-out infinite alternate; }
.avatar[data-action="cheer"] .av-arm-l { animation: cheer-l .28s ease-in-out infinite alternate; }
.avatar[data-action="cheer"] .av-arm-r { animation: cheer-r .28s ease-in-out infinite alternate; }
.avatar[data-action="cheer"] .av-tail { animation-duration: .35s; }
.av-sparkle { transform-box: fill-box; transform-origin: center; animation: sparkle 1.1s ease-in-out infinite; }
.av-sparkle.s2 { animation-delay: .35s; }
.av-sparkle.s3 { animation-delay: .7s; }
.av-fish { transform-box: fill-box; transform-origin: center; animation: fish-flop .5s ease-in-out infinite alternate; }

@keyframes jump { from { transform: translateY(0); } to { transform: translateY(-13px); } }
@keyframes shadow-jump { from { transform: scale(1); } to { transform: scale(.78); } }
@keyframes cheer-l { from { transform: rotate(96deg); } to { transform: rotate(122deg); } }
@keyframes cheer-r { from { transform: rotate(-96deg); } to { transform: rotate(-122deg); } }
@keyframes sparkle { 0%, 100% { transform: scale(.2) rotate(0deg); opacity: 0; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }
@keyframes fish-flop { from { transform: translateY(4px) rotate(-14deg); } to { transform: translateY(-8px) rotate(12deg); } }

/* ---------- 笑一笑（钓到普通的鱼） ---------- */

.avatar[data-action="smile"] .av-body { animation: hop .8s ease-in-out infinite alternate; }
.avatar[data-action="smile"] .av-arm-r { animation: wave-r .4s ease-in-out infinite alternate; }

@keyframes hop { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@keyframes wave-r { from { transform: rotate(-104deg); } to { transform: rotate(-128deg); } }

/* ---------- 惊喜（钓到史诗、传说） ---------- */

.avatar[data-action="amazed"] .av-body { animation: jump-high .36s ease-in-out infinite alternate; }
.avatar[data-action="amazed"] .av-shadow { transform-box: fill-box; transform-origin: center; animation: shadow-jump .36s ease-in-out infinite alternate; }
.avatar[data-action="amazed"] .av-arm-l { animation: cheer-l .18s ease-in-out infinite alternate; }
.avatar[data-action="amazed"] .av-arm-r { animation: cheer-r .18s ease-in-out infinite alternate; }
.avatar[data-action="amazed"] .av-tail { animation-duration: .2s; }
.avatar[data-action="amazed"] .av-sparkle { animation-duration: .7s; }
.av-shock { animation: shock .36s ease-in-out infinite alternate; }

@keyframes jump-high { from { transform: translateY(0); } to { transform: translateY(-22px); } }
@keyframes shock { from { opacity: .3; } to { opacity: 1; } }

/* ---------- 胜利 ---------- */

.avatar[data-action="win"] .av-body { animation: jump .45s ease-in-out infinite alternate; }
.avatar[data-action="win"] .av-shadow { transform-box: fill-box; transform-origin: center; animation: shadow-jump .45s ease-in-out infinite alternate; }
.avatar[data-action="win"] .av-arm-r { animation: wave-r .22s ease-in-out infinite alternate; }
.avatar[data-action="win"] .av-arm-l { animation: none; transform: rotate(-28deg); }
.avatar[data-action="win"] .av-tail { animation-duration: .3s; }
.av-confetti { transform-box: fill-box; transform-origin: center; animation: confetti 1.8s linear infinite; }
.av-confetti.k2 { animation-delay: .6s; animation-duration: 2.2s; }
.av-confetti.k3 { animation-delay: 1.2s; animation-duration: 1.5s; }

@keyframes confetti {
  from { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  to { transform: translateY(230px) rotate(540deg); opacity: .2; }
}

/* ---------- 难过 ---------- */

.avatar:is([data-action="sad"], [data-action="lose"]) .av-body { animation: none; transform: translateY(2px); }
.avatar:is([data-action="sad"], [data-action="lose"], [data-action="cry"]) .av-head { animation: droop 1.6s ease-in-out infinite alternate; }
.avatar:is([data-action="sad"], [data-action="lose"], [data-action="cry"]) .av-tail { animation: none; transform: rotate(12deg); }
.avatar:is([data-action="sad"], [data-action="lose"], [data-action="cry"]) :is(.av-arm-l, .av-arm-r) { animation: none; }
.av-sweat { transform-box: fill-box; animation: sweat 1.2s ease-in infinite; }

@keyframes droop { from { transform: rotate(5deg); } to { transform: rotate(8deg); } }
@keyframes sweat { from { transform: translateY(-4px); opacity: 1; } to { transform: translateY(12px); opacity: 0; } }

/* ---------- 哭（跑掉的是大鱼） ---------- */

.avatar[data-action="cry"] .av-body { animation: sob .14s ease-in-out infinite alternate; }
.av-tear { transform-box: fill-box; animation: tear-l .7s ease-in infinite; }
.av-tear.tr { animation-name: tear-r; }
.av-tear.t2 { animation-delay: .35s; }

@keyframes sob { from { transform: translate(-1.2px, 2px); } to { transform: translate(1.2px, 2px); } }
@keyframes tear-l { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(-22px, 30px); opacity: 0; } }
@keyframes tear-r { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(22px, 30px); opacity: 0; } }

/* ---------- 失败 ---------- */

.av-cloud { animation: cloud-bob 2s ease-in-out infinite alternate; }
.av-rain { animation: rain .5s linear infinite; }

@keyframes cloud-bob { from { transform: translateX(-3px); } to { transform: translateX(3px); } }
@keyframes rain { from { transform: translateY(0); opacity: 1; } to { transform: translateY(10px); opacity: 0; } }

/* ---------- 写日记 ---------- */

.avatar[data-action="write"] .av-arm-l { animation: none; transform: rotate(-25deg); }
.avatar[data-action="write"] .av-arm-r { animation: scribble .3s ease-in-out infinite alternate; }
.avatar[data-action="write"] .av-head { animation: none; transform: rotate(-3deg); }

@keyframes scribble { from { transform: rotate(31deg); } to { transform: rotate(40deg); } }

/* ---------- 睡觉 ---------- */

.avatar[data-action="sleep"] .av-head { animation: nod 3.4s ease-in-out infinite alternate; }
.avatar[data-action="sleep"] .av-tail { animation-duration: 4.5s; }
.avatar[data-action="sleep"] .av-arm-l, .avatar[data-action="sleep"] .av-arm-r { animation: none; }
.av-zzz { transform-box: fill-box; animation: zzz 3s ease-in-out infinite; opacity: 0; }
.av-zzz.z2 { animation-delay: .9s; }
.av-zzz.z3 { animation-delay: 1.8s; }

@keyframes nod { from { transform: rotate(3deg); } to { transform: rotate(10deg); } }
@keyframes zzz { 0% { transform: translate(-4px, 6px); opacity: 0; } 30%, 70% { opacity: 1; } 100% { transform: translate(6px, -8px); opacity: 0; } }

/* ---------- 场景里会动的东西 ---------- */

.sc-cloud { animation: drift 46s linear infinite alternate; }
.sc-cloud.c2 { animation-duration: 70s; animation-direction: alternate-reverse; }
.sc-star { animation: twinkle 2.6s ease-in-out infinite alternate; }
.sc-star.t2 { animation-delay: .9s; animation-duration: 3.4s; }
.sc-star.t3 { animation-delay: 1.7s; animation-duration: 2.1s; }
.sc-shimmer { animation: shimmer 4s ease-in-out infinite alternate; }
.sc-shimmer.m2 { animation-duration: 5.5s; animation-direction: alternate-reverse; }
.sc-flow { stroke-dasharray: 14 22; animation: flow 2.4s linear infinite; }
.sc-aurora { animation: aurora 9s ease-in-out infinite alternate; }
.sc-sway { transform-box: fill-box; transform-origin: center bottom; animation: sway 3.6s ease-in-out infinite alternate; }
.sc-swim { transform-box: fill-box; transform-origin: center; animation: swim 5s ease-in-out infinite alternate; }

@keyframes drift { from { transform: translateX(-14px); } to { transform: translateX(40px); } }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }
@keyframes shimmer { from { transform: translateX(-8px); opacity: .25; } to { transform: translateX(10px); opacity: .7; } }
@keyframes flow { from { stroke-dashoffset: 36; } to { stroke-dashoffset: 0; } }
@keyframes aurora { from { opacity: .16; transform: translateX(-10px); } to { opacity: .38; transform: translateX(12px); } }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
@keyframes swim { from { transform: translateX(-5px); } to { transform: translateX(6px); } }
@keyframes bubble-in { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%); } }

/* 系统设置了"减少动态效果"时，全部停下 */
@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::after { animation: none !important; }
}

/* ---------- 预览页 ---------- */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 14px; }
.gallery figure { margin: 0; }
.gallery figcaption { margin-top: 6px; color: var(--muted, #8fa6bf); font-size: 13px; text-align: center; }
.gallery-title { margin: 22px 0 10px; font-size: 16px; }
