/* 月光孤岛 · 样式：主场景 / 热区 / 弹窗 / 翻牌与粒子动效 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #070b1d; color: #f3ecd9; overflow: hidden;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#app { position: relative; max-width: 440px; height: 100dvh; margin: 0 auto; overflow: hidden; background: #0a1230; }

/* ---------- 主场景 ---------- */
#scene { position: absolute; inset: 0; overflow: hidden; animation: breathe 9s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025); } }
#bgImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: filter 1.2s ease; }
#scene.filter-aurora #bgImg { filter: saturate(1.1) brightness(1.02); }
#scene.filter-dusk #bgImg { filter: hue-rotate(-32deg) saturate(1.35) brightness(1.06) sepia(0.22); }
#scene.filter-firefly #bgImg { filter: brightness(0.86) saturate(1.05); }
#filterTint { position: absolute; inset: 0; pointer-events: none; transition: background 1.2s ease; mix-blend-mode: screen; }
#scene.filter-aurora #filterTint { background: linear-gradient(160deg, rgba(64,224,178,.20), rgba(64,120,255,.10) 45%, rgba(150,80,255,.16)); }
#scene.filter-dusk #filterTint { background: linear-gradient(170deg, rgba(255,130,170,.20), rgba(255,170,90,.12) 55%, rgba(90,40,120,.14)); }
#scene.filter-firefly #filterTint { background: radial-gradient(ellipse at 50% 78%, rgba(190,255,140,.12), transparent 60%); }

/* 萤火虫粒子 */
#fireflies { position: absolute; inset: 0; pointer-events: none; }
#scene:not(.filter-firefly) #fireflies { display: none; }
#fireflies i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #d8ff9e; box-shadow: 0 0 9px 3px rgba(200,255,140,.75);
  animation: fly 7s ease-in-out infinite; opacity: 0;
}
@keyframes fly {
  0% { transform: translate(0,0); opacity: 0; }
  15% { opacity: 1; } 50% { transform: translate(16px,-30px); opacity: .85; }
  85% { opacity: 1; } 100% { transform: translate(-10px,-58px); opacity: 0; }
}

/* ---------- 生态展示位 ---------- */
.eco { position: absolute; z-index: 3; pointer-events: none; }
.eco-whale { left: 57%; top: 79%; width: 37%; animation: swim 6s ease-in-out infinite; }
@keyframes swim { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-9px) rotate(1deg); } }
.eco-fox { left: 24%; top: 53%; width: 24%; animation: nap 4.5s ease-in-out infinite; }
@keyframes nap { 0%,100% { transform: translateY(0); } 50% { transform: translateY(2.5px); } }
.eco-jelly { left: 5%; top: 47%; width: 90px; height: 90px; }
.eco-jelly span {
  position: absolute; width: 20px; height: 15px; border-radius: 50% 50% 42% 42%;
  background: radial-gradient(circle at 50% 32%, rgba(255,235,250,.95), rgba(190,140,255,.55));
  box-shadow: 0 0 14px 4px rgba(200,150,255,.5); animation: drift 5s ease-in-out infinite;
}
.eco-jelly span:nth-child(1) { left: 4px; top: 12px; }
.eco-jelly span:nth-child(2) { left: 38px; top: 34px; animation-delay: 1.2s; }
.eco-jelly span:nth-child(3) { left: 12px; top: 56px; animation-delay: 2.1s; }
@keyframes drift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.eco-sakura { left: 41%; top: 39%; width: 110px; height: 60px; }
.eco-sakura i {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle, rgba(252,196,220,.95), rgba(244,150,190,.55));
  box-shadow: 0 0 12px 3px rgba(248,170,205,.45); animation: drift 6s ease-in-out infinite;
}
.eco-sakura i:nth-child(1) { left: 0; top: 14px; }
.eco-sakura i:nth-child(2) { left: 26px; top: 0; width: 38px; height: 38px; }
.eco-sakura i:nth-child(3) { left: 58px; top: 10px; }
.eco-sakura i:nth-child(4) { left: 16px; top: 26px; width: 24px; height: 24px; }
.eco-sakura i:nth-child(5) { left: 48px; top: 28px; width: 24px; height: 24px; }

/* ---------- 热区 ---------- */
.hotspot { position: absolute; z-index: 4; width: 76px; text-align: center; transition: transform .18s ease; }
.hotspot:active { transform: scale(.92); }
.hotspot img { width: 100%; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); animation: glowPulse 2.8s ease-in-out infinite; }
@keyframes glowPulse {
  0%,100% { filter: drop-shadow(0 0 3px rgba(255,236,170,.35)) drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
  50% { filter: drop-shadow(0 0 16px rgba(255,236,170,.95)) drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
}
.hs-label {
  display: inline-block; margin-top: 2px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; letter-spacing: 1px; color: #ffeec2;
  background: rgba(8,12,34,.55); border: 1px solid rgba(255,226,150,.4); backdrop-filter: blur(3px);
}
.hs-bottle { left: 8%; top: 68%; width: 68px; }
.hs-owl { left: 57%; top: 26%; width: 70px; }
.hs-fire { left: 73%; top: 61%; width: 72px; }
.hs-spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #ffb84d; box-shadow: 0 0 8px 2px rgba(255,160,60,.8); animation: rise 2.2s linear infinite; }
.hs-spark.s1 { left: 40%; top: 22%; } .hs-spark.s2 { left: 58%; top: 30%; animation-delay: .7s; } .hs-spark.s3 { left: 50%; top: 12%; animation-delay: 1.3s; }
@keyframes rise { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-34px); opacity: 0; } }
.hotspot.done { opacity: .45; }
.hotspot.done img { animation: none; filter: grayscale(.4) drop-shadow(0 4px 10px rgba(0,0,0,.45)); }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, rgba(5,8,24,.72), transparent);
}
.island-name { font-size: 19px; letter-spacing: 4px; font-weight: 600; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.sand-pill {
  display: inline-block; margin-top: 5px; padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; color: #ffe9ad; background: rgba(10,14,38,.62);
  border: 1px solid rgba(255,220,130,.45); backdrop-filter: blur(4px);
}
.sand-pill b { font-size: 14px; }
.hud-right { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.hud-btn {
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; color: #eef;
  background: rgba(10,14,38,.62); border: 1px solid rgba(160,190,255,.4); backdrop-filter: blur(4px);
}
.hud-btn.on { color: #ffe9ad; border-color: rgba(255,220,130,.65); }

/* ---------- 底部栏 ---------- */
#dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(5,8,24,.78), transparent);
}
.dock-btn {
  flex: 1; padding: 13px 6px; border-radius: 14px; font-size: 14.5px; letter-spacing: 1px;
  background: rgba(16,22,52,.82); border: 1px solid rgba(160,190,255,.35); color: #e8ecff; backdrop-filter: blur(5px);
}
.dock-btn.primary { background: linear-gradient(135deg, #b98a2e, #8a5f1c); border-color: rgba(255,226,150,.7); color: #fff7e0; font-weight: 600; }

/* ---------- 弹窗通用 ---------- */
.modal {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(3,5,16,.62); backdrop-filter: blur(3px); animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: relative; width: 100%; max-height: 86dvh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  animation: up .3s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes up { from { transform: translateY(46px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet.dark { background: linear-gradient(180deg, #141b3e, #0b1029); border-top: 1px solid rgba(150,180,255,.28); }
.sheet.center { text-align: center; }
.close-x {
  position: absolute; right: 12px; top: 8px; width: 34px; height: 34px; font-size: 24px; line-height: 1;
  color: rgba(240,240,255,.75); z-index: 2;
}
.sheet-title { font-size: 18px; letter-spacing: 2px; margin-bottom: 6px; padding-right: 30px; }
.sheet-sub { font-size: 13px; line-height: 1.65; color: rgba(226,232,255,.75); margin-bottom: 14px; }
.big-btn {
  width: 100%; padding: 13px; border-radius: 13px; font-size: 15.5px; font-weight: 600; letter-spacing: 2px;
  background: linear-gradient(135deg, #e07840, #b84a1e); color: #fff2df; box-shadow: 0 6px 18px rgba(224,110,50,.35);
}
.mini-btn {
  margin-top: 14px; padding: 9px 18px; border-radius: 999px; font-size: 13px;
  border: 1px solid rgba(255,220,130,.55); color: #ffe9ad; background: rgba(255,220,130,.08);
}
.mini-btn:disabled { opacity: .4; }

/* ---------- 漂流瓶信笺 ---------- */
.sheet.letter {
  background: linear-gradient(180deg, #f7efdb, #efe2c4); color: #4a3b28;
  border-top: 3px solid #c9a86a;
}
.sheet.letter .close-x { color: rgba(90,70,40,.6); }
.letter-from { font-size: 12px; letter-spacing: 1px; color: #9a7c4c; margin-bottom: 10px; }
.letter-text { font-size: 16.5px; line-height: 1.95; letter-spacing: .5px; min-height: 96px; }
.letter-sign { text-align: right; font-size: 12.5px; color: #9a7c4c; margin: 10px 0 16px; }
.reply-title { font-size: 13px; color: #8a6c3e; border-top: 1px dashed rgba(150,120,70,.5); padding-top: 13px; margin-bottom: 10px; }
.reply-list { display: flex; flex-direction: column; gap: 9px; }
.reply-btn {
  padding: 12px 14px; border-radius: 12px; text-align: left; font-size: 14.5px; color: #5d4526;
  background: rgba(255,252,244,.85); border: 1px solid rgba(180,145,85,.55); transition: transform .15s ease, background .15s;
}
.reply-btn:active { transform: scale(.98); background: #ffedb8; }

/* 扔瓶动画 */
#throwBottle {
  position: absolute; z-index: 30; left: 16%; top: 62%; font-size: 40px; pointer-events: none;
  animation: throwBack 1.15s ease-in forwards;
}
@keyframes throwBack {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  55% { transform: translate(-46px, 66px) rotate(-160deg); opacity: 1; }
  100% { transform: translate(-70px, 130px) rotate(-300deg) scale(.55); opacity: 0; }
}

/* ---------- 抽卡 ---------- */
.fan-wrap { overflow-x: auto; overflow-y: hidden; padding: 16px 2px 10px; scrollbar-width: none; }
.fan-wrap::-webkit-scrollbar { display: none; }
.fan { display: flex; gap: 0; width: max-content; padding: 26px 14px 6px; }
.fan-card {
  width: 74px; margin-left: -26px; transform-origin: 50% 118%; transition: transform .22s ease;
  border-radius: 9px; box-shadow: 0 8px 18px rgba(0,0,0,.5); flex: none;
}
.fan-card:first-child { margin-left: 0; }
.fan-card img { width: 100%; display: block; border-radius: 9px; border: 1px solid rgba(230,195,110,.65); }
.fan-card:active { transform: translateY(-14px) scale(1.06) !important; }
.card-stage { position: relative; text-align: center; padding-top: 8px; }
.flip { width: 208px; height: 292px; margin: 6px auto 2px; perspective: 900px; }
.flip-inner { position: relative; width: 100%; height: 100%; }
.flip { position: relative; }
.flip-face {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform .85s cubic-bezier(.3,.7,.3,1);
}
.flip-face img { width: 100%; height: 100%; object-fit: cover; }
.flip-back { transform: rotateY(0deg); }
.flip-front {
  transform: rotateY(180deg); padding: 26px 18px;
  background: linear-gradient(165deg, #fdf6e0, #f3e3ba 55%, #ecd9a8);
  border: 2px solid #c9a24e; color: #4c3a1c;
  display: flex; flex-direction: column; align-items: center;
}
.flip.flipped .flip-back { transform: rotateY(-180deg); }
.flip.flipped .flip-front { transform: rotateY(0deg); }
.cf-name { font-size: 25px; letter-spacing: 6px; font-weight: 700; margin-top: 8px; }
.cf-key { margin: 9px 0 14px; padding: 3px 13px; border-radius: 999px; font-size: 12.5px; letter-spacing: 2px; color: #8a5f1c; border: 1px solid rgba(160,118,40,.6); }
.cf-lines { font-size: 14px; line-height: 2.05; text-align: center; }
.particles { position: absolute; inset: 0; pointer-events: none; }
.particles i {
  position: absolute; left: 50%; top: 42%; width: 6px; height: 6px; border-radius: 50%;
  background: #ffe9a8; box-shadow: 0 0 10px 3px rgba(255,220,130,.8); animation: burst 1.15s ease-out forwards;
}
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }

/* ---------- 篝火 ---------- */
#worryInput {
  width: 100%; border-radius: 13px; border: 1px solid rgba(170,190,255,.35); resize: none;
  background: rgba(255,255,255,.06); color: #f5f2e8; padding: 13px; font-size: 15px; line-height: 1.6;
  font-family: inherit; margin-bottom: 13px; outline: none;
}
#worryInput:focus { border-color: rgba(255,190,110,.7); }
.burn-stage { position: relative; height: 190px; margin-top: 16px; }
.burn-paper {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  width: 200px; min-height: 104px; padding: 13px; border-radius: 6px;
  background: linear-gradient(180deg, #f8f1de, #eee0c0); color: #5a4630;
  font-size: 13.5px; line-height: 1.7; word-break: break-all; box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
.burn-paper.burning { animation: burnAway 2s ease-in forwards; }
@keyframes burnAway {
  0% { filter: brightness(1); opacity: 1; transform: translateX(-50%) scale(1); }
  35% { filter: brightness(1.25) sepia(.7) hue-rotate(-18deg); }
  70% { filter: brightness(.55) sepia(1) hue-rotate(-30deg); opacity: .75; transform: translateX(-50%) scale(.93) rotate(-2deg); }
  100% { filter: brightness(.15) grayscale(.7); opacity: 0; transform: translateX(-50%) translateY(-26px) scale(.8) rotate(3deg); }
}
.burn-sparks i {
  position: absolute; left: 50%; bottom: 26px; width: 6px; height: 6px; border-radius: 50%;
  background: #ffb84d; box-shadow: 0 0 10px 3px rgba(255,150,50,.85); animation: sparkUp 1.6s ease-out forwards;
}
@keyframes sparkUp { to { transform: translate(var(--dx), var(--dy)) scale(.25); opacity: 0; } }
.heal-text { margin-top: 14px; font-size: 15px; line-height: 1.85; color: #ffe3c2; text-align: center; }

/* ---------- 图鉴 ---------- */
.gallery-list { display: flex; flex-direction: column; gap: 11px; }
.g-item {
  display: flex; align-items: center; gap: 13px; padding: 13px; border-radius: 15px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(160,190,255,.2);
}
.g-item .g-emoji { font-size: 31px; width: 46px; text-align: center; }
.g-item .g-info { flex: 1; }
.g-item .g-name { font-size: 15.5px; letter-spacing: 1px; }
.g-item .g-desc { font-size: 12px; color: rgba(226,232,255,.65); margin-top: 3px; line-height: 1.5; }
.g-buy {
  padding: 9px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap;
  background: linear-gradient(135deg, #b98a2e, #8a5f1c); color: #fff7e0; font-weight: 600;
}
.g-buy:disabled { background: rgba(255,255,255,.12); color: rgba(255,255,255,.45); font-weight: 400; }
.g-owned { font-size: 13px; color: #9fe8b4; white-space: nowrap; padding-right: 4px; }

/* ---------- 壁纸 ---------- */
#posterImg { width: min(272px, 74vw); border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.55); border: 1px solid rgba(255,226,150,.4); }

/* ---------- Toast ---------- */
#toast {
  position: absolute; z-index: 40; left: 50%; bottom: 108px; transform: translateX(-50%);
  max-width: 84%; padding: 10px 18px; border-radius: 999px; text-align: center;
  background: rgba(8,11,30,.92); border: 1px solid rgba(255,226,150,.5);
  color: #ffedb5; font-size: 13.5px; line-height: 1.55; animation: fadeIn .2s ease;
}
