/* 星河桥 · 日式乡村治愈系 UI */
:root {
  --ink: #6b5645;
  --ink-soft: #8d7761;
  --ink-faint: #a99378;
  --cream: #fffdf7;
  --pink: #ffb3c7;
  --pink-deep: #f08aa2;
  --pink-soft: #ffe4ec;
  --yellow: #ffe08a;
  --blue: #a9def0;
  --line: rgba(190, 160, 120, 0.22);
  --shadow-soft: 0 16px 40px rgba(150, 120, 80, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #d9f1ff;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }
#ui { position: absolute; inset: 0; pointer-events: none; }

/* ---------------- 顶部胶囊数据条 ---------------- */
#hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  max-width: calc(100vw - 20px);
  z-index: 35;
}
body.modal-open #hud { pointer-events: none; }
.hud-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.74);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(120, 100, 70, 0.16);
  white-space: nowrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 6px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #7c5f46;
}
.brand-star { color: #f6b93e; font-size: 17px; text-shadow: 0 1px 0 #fff; }
.hud-line { width: 1px; height: 20px; background: var(--line); flex: none; }
.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 0 2px;
}
.stat b { font-size: 15px; color: var(--ink); font-weight: 800; }
.stat span { letter-spacing: 0.5px; }
.ico { width: 18px; height: 18px; display: block; flex: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.62);
  color: #7a6350;
  font-size: 12.5px;
  font-weight: 650;
  font-family: inherit;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.chip:hover {
  background: #fffdf8;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(150, 120, 80, 0.18);
}
.chip:active { transform: translateY(0); }
.chip.is-done { opacity: 0.55; pointer-events: none; }
.chip.is-locked { opacity: 0.72; }
.chip-round {
  width: 30px; height: 30px; padding: 0;
  justify-content: center;
  font-weight: 800; color: var(--ink-faint);
}

/* ---------------- 世界内 E 提示 ---------------- */
.prompt {
  position: absolute;
  left: 0; top: 0;
  transform: translate(-50%, -115%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid #fff;
  box-shadow: 0 10px 26px rgba(140, 110, 80, 0.24);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 20;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.prompt.show {
  opacity: 1;
  transform: translate(-50%, -115%) scale(1);
  pointer-events: auto;
  cursor: pointer;
  animation: prompt-bob 2.1s ease-in-out infinite;
}
.prompt-key {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff7e6;
  border: 1.5px solid #ead8bc;
  color: #8a735e;
  font-size: 12.5px;
  font-weight: 800;
}
.prompt-text { letter-spacing: 0.5px; padding-right: 3px; }

/* ---------------- Toast ---------------- */
.toast {
  position: absolute;
  left: 50%; bottom: 34px;
  transform: translate(-50%, 12px);
  padding: 9px 20px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.94);
  border: 1px solid #fff;
  box-shadow: 0 12px 30px rgba(150, 120, 80, 0.2);
  color: #7a6350;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 弹层卡片 ---------------- */
#modal-root.open { pointer-events: auto; }
.mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(122, 104, 82, 0.2);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: mask-in 0.24s ease;
  z-index: 30;
}
.card {
  position: relative;
  width: min(760px, 93vw);
  max-height: 87vh;
  overflow: auto;
  padding: 30px 32px 26px;
  border-radius: 30px;
  background: linear-gradient(158deg, rgba(255, 253, 247, 0.97), rgba(255, 246, 235, 0.95));
  border: 1.5px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 30px 70px rgba(140, 110, 80, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: var(--ink);
  animation: card-pop 0.34s cubic-bezier(0.2, 1.25, 0.4, 1);
}
.card::-webkit-scrollbar { width: 8px; }
.card::-webkit-scrollbar-thumb { background: rgba(200, 175, 140, 0.4); border-radius: 8px; }
.card-close {
  position: absolute;
  right: 18px; top: 18px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 246, 232, 0.9);
  color: #a48b70;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
  z-index: 2;
}
.card-close .ico { width: 16px; height: 16px; }
.card-close:hover { background: #fff; transform: rotate(90deg); }

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 2px;
  color: var(--ink-faint);
  font-weight: 700;
  text-transform: uppercase;
}
.card-head { padding-right: 40px; }
.card-head h2 {
  margin: 6px 0 8px;
  font-size: 27px;
  letter-spacing: 1px;
  font-weight: 800;
  color: #6a523f;
}
.card-head p { margin: 0 0 18px; font-size: 13px; color: var(--ink-soft); }

/* 纪念页 */
.memorial-card { width: min(720px, 93vw); }
.m-top { display: flex; align-items: center; gap: 20px; padding-right: 36px; }
.portrait {
  width: 106px; height: 106px;
  flex: none;
  border-radius: 50%;
  padding: 7px;
  background: linear-gradient(155deg, #fff7e8, #ffe4ec 70%, #e8f4ff);
  border: 4px solid #fff;
  box-shadow: 0 10px 24px rgba(200, 160, 120, 0.22), inset 0 0 0 1px rgba(240, 200, 170, 0.35);
}
.pet-art { width: 100%; height: 100%; display: block; }
.comp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 6px 0 14px; }
.comp-card {
  padding: 12px 12px 10px;
  border-radius: 20px;
  text-align: center;
  background: #fffaf1;
  border: 1.6px solid #f2e2c8;
  box-shadow: 0 6px 16px rgba(190, 150, 110, 0.1);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.comp-card[data-comp] { cursor: pointer; }
.comp-card[data-comp]:hover { transform: translateY(-3px); background: #fffdf8; box-shadow: 0 12px 24px rgba(190, 150, 110, 0.16); }
.comp-card.active { border-color: #f0a6ba; box-shadow: 0 12px 24px rgba(240, 150, 175, 0.18); }
.comp-card.locked { opacity: 0.82; }
.comp-card.locked .comp-name { color: #7d6854; }
.comp-card.locked .comp-sub { color: #9a8470; }
.comp-art {
  width: 66px; height: 66px;
  margin: 0 auto 7px;
  padding: 6px;
  border-radius: 50%;
  background: linear-gradient(150deg, #fff7e8, #ffe8ef 70%, #eaf6ff);
  border: 3px solid #fff;
}
.comp-name { font-size: 14px; font-weight: 800; color: #6b5645; }
.comp-sub { font-size: 11.5px; line-height: 1.45; color: #a08a74; margin-top: 3px; min-height: 33px; }
.lock-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  margin: 2px 0 14px;
  border-radius: 16px;
  background: #fff4dd;
  color: #8a7157;
  font-size: 12.5px;
  line-height: 1.6;
}
.lock-note b { color: #e08a3c; white-space: nowrap; }
#comp-claim { width: 100%; }
.m-title { flex: 1; min-width: 0; }
.m-title h2 { margin: 4px 0 8px; font-size: 32px; font-weight: 800; letter-spacing: 1.5px; color: #6a523f; }
.m-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.badge.tier1 { background: #fff3df; color: #997f55; border: 1px solid #f0dfc0; }
.badge.tier2 { background: #ffe6ee; color: #cb7d92; border: 1px solid #ffd0dc; }
.badge.tier3 { background: #e7f5ff; color: #6f9dbb; border: 1px solid #cfe9f8; }
.price-tag {
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}
.m-doodle { display: flex; gap: 2px; opacity: 0.55; align-self: flex-start; padding-top: 6px; }
.m-doodle .ico { width: 20px; height: 20px; }
.m-quote {
  margin: 18px 0 4px;
  padding: 16px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.9);
  font-size: 14.5px;
  line-height: 1.8;
  color: #7c6652;
}
.m-gifts { margin-top: 16px; }
.gift-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #7c6652;
}
.gift-head small { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.gift-actions { display: flex; gap: 10px; }
.gift-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px 9px;
  border-radius: 16px;
  border: 1px solid #f2e4d0;
  background: rgba(255, 255, 255, 0.75);
  color: #7a6350;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.gift-btn .ico { width: 24px; height: 24px; }
.gift-btn em { font-style: normal; font-size: 10.5px; color: var(--ink-faint); font-weight: 600; }
.gift-btn:hover { transform: translateY(-2px); background: #fff; box-shadow: 0 8px 18px rgba(180, 140, 100, 0.16); }
.m-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(190, 160, 120, 0.35);
  font-size: 12px;
  color: var(--ink-faint);
}
.link-btn {
  border: none;
  background: rgba(255, 255, 255, 0.7);
  color: #b0707f;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease;
}
.link-btn:hover { background: #fff; }

/* 认领 */
.tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tier-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 18px 12px 16px;
  border-radius: 22px;
  border: 2px solid #f2e4d0;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, border 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.tier-card:hover { transform: translateY(-3px); background: #fffdf7; box-shadow: 0 12px 26px rgba(180, 140, 100, 0.16); }
.tier-card.selected {
  border-color: #ffb3c7;
  background: linear-gradient(165deg, #fffdf8, #fff0f4);
  box-shadow: 0 12px 28px rgba(240, 140, 160, 0.2);
}
.tier-glyph { width: 62px; height: 62px; margin-bottom: 2px; }
.tier-glyph svg { width: 100%; height: 100%; display: block; }
.tier-name { font-size: 15px; font-weight: 800; letter-spacing: 0.5px; }
.tier-price { font-size: 22px; font-weight: 800; color: #d97f95; letter-spacing: 0.5px; }
.tier-price span { font-size: 11px; font-weight: 600; color: var(--ink-faint); margin-left: 2px; }
.tier-blurb { font-size: 11px; color: var(--ink-soft); line-height: 1.55; min-height: 34px; }
.tier-check {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 10px;
  font-weight: 700;
  color: #d97f95;
  background: #ffe4ec;
  padding: 2px 7px;
  border-radius: 999px;
}
.claim-note { margin-top: 16px; font-size: 11.5px; color: var(--ink-faint); text-align: center; }
.chosen-tier {
  margin: 4px 0 16px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px dashed rgba(220, 170, 190, 0.7);
  font-size: 12.5px;
  color: #b0707f;
  font-weight: 700;
}
.field { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 12px; }
.field input, .field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 15px;
  border-radius: 14px;
  border: 1.5px solid #f0e1cc;
  background: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border 0.16s ease, box-shadow 0.16s ease;
  resize: vertical;
}
.field textarea { min-height: 74px; line-height: 1.6; }
.field input:focus, .field textarea:focus {
  border-color: #ffb3c7;
  box-shadow: 0 0 0 4px rgba(255, 179, 199, 0.18);
}
.type-select { display: flex; gap: 10px; margin: 2px 0 12px; }
.type-select button {
  flex: 1;
  padding: 9px;
  border-radius: 13px;
  border: 1.5px solid #f0e1cc;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.16s ease;
}
.type-select button.active {
  border-color: #ffb3c7;
  color: #d97f95;
  background: #fff0f4;
}
.claim-actions { display: flex; gap: 10px; margin-top: 18px; }
.primary-btn {
  flex: 1;
  padding: 13px 18px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #ffb9cb, #ff9fb8);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(240, 130, 155, 0.3);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(240, 130, 155, 0.36); }
.ghost-btn {
  padding: 13px 20px;
  border-radius: 16px;
  border: 1.5px solid #f0e1cc;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* 礼物铺 */
.shop-grid { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.shop-art {
  width: 52px; height: 52px;
  flex: none;
  border-radius: 16px;
  background: linear-gradient(160deg, #fff7ea, #ffeaf0);
  display: grid;
  place-items: center;
}
.shop-art .ico { width: 32px; height: 32px; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 14.5px; font-weight: 800; }
.shop-desc { font-size: 11.5px; color: var(--ink-faint); margin: 2px 0 4px; }
.shop-price { display: flex; align-items: center; gap: 3px; font-size: 12px; color: #b08a4f; font-weight: 700; }
.shop-price .ico { width: 14px; height: 14px; }
.shop-price b { font-size: 14px; }
.shop-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.owned { font-size: 10.5px; color: var(--ink-faint); }
.buy-btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: none;
  background: #ffe0e8;
  color: #c46f86;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.16s ease;
}
.buy-btn:hover { background: #ffd0dc; transform: translateY(-1px); }
.shop-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed rgba(190, 160, 120, 0.35);
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}
.shop-foot b { color: #b08a4f; font-size: 14px; margin: 0 2px; }

/* 纪念墙 */
.wall-list { display: flex; flex-direction: column; gap: 9px; }
.wall-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.wall-portrait {
  width: 48px; height: 48px;
  flex: none;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(160deg, #fff7ea, #ffe7ee);
  border: 2px solid #fff;
}
.wall-main { flex: 1; min-width: 0; }
.wall-name { font-size: 14.5px; font-weight: 800; }
.wall-meta { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.wall-gifts { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

/* 玩法 */
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.help-item {
  padding: 12px 15px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.help-item b { display: block; font-size: 13px; margin-bottom: 4px; color: #7a5f47; }
.help-item span { font-size: 11.5px; line-height: 1.65; color: var(--ink-soft); }
.help-foot { margin-top: 14px; font-size: 11.5px; color: var(--ink-faint); text-align: center; }

/* ---------------- Loading ---------------- */
#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(165deg, #eaf9ff, #fff8ec);
  z-index: 100;
  transition: opacity 0.5s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
.load-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  font-weight: 700;
  color: #9a8066;
  letter-spacing: 1px;
}
.load-star { color: #f6b93e; animation: twinkle 1.6s ease-in-out infinite; }

/* ---------------- 动画 ---------------- */
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-pop {
  0% { opacity: 0; transform: translateY(18px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes prompt-bob {
  0%, 100% { transform: translate(-50%, -115%) scale(1); }
  50% { transform: translate(-50%, -122%) scale(1.02); }
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.86); }
}
.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* 调试：JS 错误直接显示出来 */
.js-error {
  position: fixed;
  top: 8px; left: 8px;
  max-width: 70vw;
  padding: 10px 14px;
  background: #ffe3e3;
  color: #a13b3b;
  border: 1px solid #f5b5b5;
  border-radius: 10px;
  font-family: Consolas, monospace;
  font-size: 12px;
  z-index: 999;
}

@media (max-width: 1240px) {
  .hud-pill { gap: 5px; padding: 7px 10px; }
  .stat span { display: none; }
  .brand { font-size: 14px; letter-spacing: 1px; }
  .chip { padding: 5px 9px; font-size: 11.5px; }
  .chip .ico { width: 16px; height: 16px; }
}
@media (max-width: 900px) {
  #hud { top: 10px; }
  .brand { display: none; }
  .hud-line { display: none; }
  .chip-round { display: none; }
  .card { padding: 24px 20px 20px; }
  .tier-grid { grid-template-columns: 1fr; }
  .comp-grid { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
  .m-top { gap: 14px; }
  .portrait { width: 82px; height: 82px; }
  .m-title h2 { font-size: 26px; }
  .gift-actions { flex-direction: column; }
}
