/* 界面字体：和小红书版、宣传视频一样的站酷快乐体（网页版用整套字体，小红书版由 build.mjs 按用到的字裁剪成 Tale） */
@font-face {
  font-family: "TaleWeb";
  src: url("./fonts/tale-zh.woff2") format("woff2");
  unicode-range: U+3000-303F, U+3400-9FFF, U+FF00-FFEF;
  font-display: swap;
}

:root {
  --ink: #4a3b2c;
  --ink-soft: rgba(74, 59, 44, 0.68);
  --paper: rgba(255, 249, 238, 0.86);
  --paper-solid: #fff9ee;
  --gold: #d9a441;
  --accent: #c8743e;
  --serif: "TaleWeb", "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }
/* 站酷快乐体只有一种字重，假粗体会糊 */
html, body, button, input { font-synthesis: none; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e9eef0;
  font-family: var(--serif);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

#ui {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

button {
  font-family: var(--serif);
  color: var(--ink);
  border: none;
  cursor: pointer;
  pointer-events: auto;
}

.muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* ---------- 领地列表 ---------- */

.realm-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; text-align: left; }
.realm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(120, 95, 60, 0.07);
  border: 1.5px solid transparent;
  font-family: var(--serif);
  text-align: left;
}
.realm-item.here { border-color: var(--gold); background: rgba(255, 246, 222, 0.9); }
.realm-item.locked { opacity: 0.55; cursor: default; }
.realm-item b { display: block; font-size: 15px; letter-spacing: 0.14em; }
.realm-item span { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.realm-item i { font-style: normal; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.fade-out { position: fixed; inset: 0; background: #f4efe6; opacity: 0; transition: opacity 0.6s ease; z-index: 100; pointer-events: none; }
.fade-out.show { opacity: 1; }

/* ---------- 图标 ---------- */

.ico {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.16em;
  margin-right: 0.22em;
  flex: none;
}
.ico.coin {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8 0 18%, #f2c45a 40%, #c98c2a 100%);
  box-shadow: inset 0 0 0 1.5px rgba(150, 95, 20, 0.45);
}
.ico.star {
  background: linear-gradient(160deg, #fff4c4, #f2c45a 55%, #d4932f);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.ico.flying {
  position: fixed;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  z-index: 50;
  pointer-events: none;
  transition: transform 0.7s cubic-bezier(.5,-0.3,.7,1), opacity 0.7s ease;
}

/* ---------- 顶栏 ---------- */

.hud-top {
  position: absolute;
  top: 14px;
  left: 18px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}
.intro .hud-top { opacity: 1; transform: none; }
.realm-name {
  font-size: 26px;
  letter-spacing: 0.3em;
  font-weight: 600;
  color: #fffaf0;
  text-shadow: 0 2px 14px rgba(90, 70, 40, 0.4);
}
.realm-sub {
  margin-top: 4px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: #fffaf0;
  text-shadow: 0 1px 8px rgba(90, 70, 40, 0.55);
}
.res { display: flex; gap: 8px; padding-top: 2px; }
.pill {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(80, 60, 30, 0.14);
  font-size: 15px;
}
.pill b { font-weight: 600; min-width: 1.6em; font-variant-numeric: tabular-nums; }
.pill span { margin-left: 6px; font-size: 12px; color: var(--ink-soft); }
.pill.pulse { animation: pulse 0.45s ease; }
@keyframes pulse { 40% { transform: scale(1.12); } }

/* ---------- 右侧愿望 ---------- */

.hud-right {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 248px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transition: opacity 1s ease 0.4s;
}
.ready .hud-right { opacity: 1; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(80, 60, 30, 0.14);
  font-size: 13.5px;
  letter-spacing: 0.1em;
  transition: transform 0.15s ease, background 0.2s ease;
}
.chip:active { transform: scale(0.96); }
.chip em {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-style: normal;
  font-size: 11.5px;
  line-height: 18px;
  text-align: center;
  letter-spacing: 0;
}
.chip em.show { display: inline-block; }

.wishes { display: flex; flex-direction: column; gap: 7px; width: 100%; pointer-events: auto; }
.wishes-hidden .wishes { display: none; }
.wish {
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(80, 60, 30, 0.13);
  border: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.wish.done { border-color: rgba(217, 164, 65, 0.7); }
.wish-who { font-size: 11.5px; letter-spacing: 0.12em; color: var(--ink-soft); }
.wish-text { margin-top: 3px; font-size: 13.5px; line-height: 1.45; letter-spacing: 0.03em; }
.wish-foot { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.wish-reward { display: flex; align-items: center; gap: 2px; }
.wish-prog { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.claim {
  padding: 4px 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f6cf74, #e5a54b);
  color: #4a2f12;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  box-shadow: 0 3px 10px rgba(200, 130, 40, 0.35);
  animation: glow 1.6s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 3px 16px rgba(240, 170, 60, 0.7); } }

/* ---------- 左下工具与右下进度 ---------- */

.hud-tools {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 1s ease 0.6s;
}
.ready .hud-tools { opacity: 1; }

.progress {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(80, 60, 30, 0.14);
  font-size: 13px;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 1s ease 0.6s;
}
.ready .progress { opacity: 1; }
.progress-bar { width: 110px; height: 5px; border-radius: 5px; background: rgba(120, 95, 60, 0.15); overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #f2c66d, #e39a52);
  transition: width 0.6s cubic-bezier(.2,.9,.3,1.2);
}

/* ---------- 建造面板 ---------- */

.panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 560px;
  max-width: calc(100% - 28px);
  padding: 12px 14px;
  border-radius: 20px;
  background: var(--paper);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(80, 60, 30, 0.22);
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(.2,.9,.3,1.1);
}
.panel.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.panel:not(.show) * { pointer-events: none; }
.panel-open .hud-tools, .panel-open .progress, .panel-open .wishes { opacity: 0; pointer-events: none; }
.panel-open .wishes * { pointer-events: none; }
.panel-open .hud-tools * { pointer-events: none; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.panel-title { font-size: 17px; font-weight: 600; letter-spacing: 0.16em; }
.panel-desc { margin-top: 2px; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.04em; }
.panel-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(120, 95, 60, 0.1);
  font-size: 18px;
  line-height: 28px;
  padding: 0;
  flex: none;
}
.cards {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cards::-webkit-scrollbar { display: none; }
.card {
  position: relative;
  flex: none;
  width: 86px;
  padding: 6px 4px 7px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1.5px solid transparent;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.card:active { transform: scale(0.97); }
.card.on { border-color: var(--gold); background: rgba(255, 246, 222, 0.95); }
.card img { width: 64px; height: 64px; display: block; margin: 0 auto; pointer-events: none; }
.card-name { margin-top: 2px; font-size: 13px; letter-spacing: 0.08em; }
.card-sub { margin-top: 1px; font-size: 11.5px; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; }
.card-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #7aa04a;
  color: #fff;
  font-size: 10.5px;
  letter-spacing: 0;
}
.info { display: flex; gap: 22px; padding: 6px 4px 2px; font-size: 14px; flex-wrap: wrap; }
.info > div { display: flex; align-items: center; gap: 6px; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-note { font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.build-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f6cf74, #e5a54b);
  color: #4a2f12;
  font-size: 14.5px;
  letter-spacing: 0.14em;
  box-shadow: 0 5px 16px rgba(200, 130, 40, 0.35);
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.build-btn:active { transform: scale(0.96); }
.build-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.build-btn.danger { background: rgba(120, 95, 60, 0.14); color: var(--ink); box-shadow: none; }

/* ---------- 金币泡与飘字 ---------- */

#bubbles { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.bubble {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  padding: 4px 9px 4px 6px;
  border-radius: 999px;
  background: rgba(255, 250, 236, 0.92);
  box-shadow: 0 4px 14px rgba(80, 60, 30, 0.22);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  animation: bob 2.4s ease-in-out infinite;
  will-change: transform;
}
.bubble.full { background: linear-gradient(180deg, #fff1c4, #f6cf74); }
@keyframes bob { 50% { margin-top: -4px; } }
.float {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: 16px;
  font-weight: 600;
  color: #fff3c8;
  text-shadow: 0 1px 6px rgba(120, 70, 10, 0.6);
  animation: rise 1.2s ease-out forwards;
  pointer-events: none;
}
.float.small { font-size: 13px; }
@keyframes rise { to { margin-top: -36px; opacity: 0; } }

/* ---------- 提示 ---------- */

.tooltip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 8px 13px;
  border-radius: 12px;
  background: var(--paper);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(80, 60, 30, 0.18);
  opacity: 0;
  transform: translate(16px, 12px) scale(0.96);
  transform-origin: top left;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; transform: translate(16px, 12px) scale(1); }
.tooltip-name { font-size: 15px; letter-spacing: 0.14em; font-weight: 600; }
.tooltip-desc { margin-top: 3px; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.06em; }

.toasts {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.toast {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(74, 59, 44, 0.82);
  color: #fff8ea;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- 落成 ---------- */

.finale {
  position: absolute;
  bottom: 104px;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 2.4s ease, transform 2.4s ease;
}
.finale.show { opacity: 1; transform: none; }
.finale-title {
  font-size: 40px;
  letter-spacing: 0.36em;
  padding-left: 0.36em;
  color: #fff6e2;
  text-shadow: 0 0 28px rgba(255, 190, 110, 0.55), 0 2px 10px rgba(40, 30, 60, 0.4);
}
.finale-sub, .finale-next {
  margin-top: 12px;
  font-size: 15px;
  letter-spacing: 0.22em;
  color: rgba(255, 244, 225, 0.92);
  text-shadow: 0 1px 10px rgba(40, 30, 60, 0.5);
}
.finale-next { font-size: 13px; opacity: 0.8; }
.finale-actions {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 10px);
  display: flex;
  gap: 12px;
  opacity: 0;
  transition: opacity 1s ease, transform 1s ease;
}
.finale-actions.show { opacity: 1; transform: translate(-50%, 0); }
.finale-actions:not(.show) button { pointer-events: none; }
.finale-actions button {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 6px 24px rgba(30, 20, 50, 0.25);
  font-size: 14px;
  letter-spacing: 0.12em;
}
.finale-on .hud-right, .finale-on .hud-tools, .finale-on .progress, .finale-on #bubbles { opacity: 0; pointer-events: none; }
.finale-on .hud-right *, .finale-on .hud-tools * { pointer-events: none; }

/* ---------- 观赏模式 ---------- */

.view-exit {
  position: absolute;
  right: 16px;
  bottom: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.viewing .view-exit { opacity: 0.85; pointer-events: auto; }
.viewing .hud-top, .viewing .hud-right, .viewing .hud-tools, .viewing .progress, .viewing #bubbles, .viewing .toasts {
  opacity: 0 !important;
}
.viewing .hud-right *, .viewing .hud-tools *, .viewing #bubbles * { pointer-events: none; }

/* ---------- 弹窗 ---------- */

.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(40, 30, 20, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal.show { opacity: 1; pointer-events: auto; }
/* 弹窗盖在建造栏上面；矮屏（横屏手机）放不下时弹窗自己滚动（和小红书版 xhs.css 一样） */
.modal { z-index: 30; }
.modal-body { max-height: calc(100% - 16px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal:not(.show) * { pointer-events: none; }
.modal-body {
  width: 340px;
  max-width: calc(100% - 32px);
  padding: 20px 22px 16px;
  border-radius: 20px;
  background: var(--paper-solid);
  box-shadow: 0 20px 60px rgba(40, 30, 20, 0.3);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}
.modal-body p { margin: 8px 0; }
.modal-title { font-size: 19px; font-weight: 600; letter-spacing: 0.2em; }
.modal-big { margin: 8px 0; font-size: 28px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.modal-actions { margin-top: 14px; display: flex; justify-content: center; gap: 10px; }
.modal-actions button {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(120, 95, 60, 0.12);
  font-size: 14px;
  letter-spacing: 0.12em;
}
.modal-actions button.primary { background: linear-gradient(180deg, #f6cf74, #e5a54b); color: #4a2f12; }

/* ---------- 矮屏（横屏手机） ---------- */

@media (max-height: 460px) {
  .hud-top { top: 10px; left: 14px; }
  .realm-name { font-size: 20px; }
  .realm-sub { display: none; }
  .pill { padding: 4px 10px 4px 8px; font-size: 13.5px; }
  .hud-right { width: 210px; top: 10px; gap: 6px; }
  .wish { padding: 6px 10px; }
  .wish-text { font-size: 12px; line-height: 1.4; }
  .wish-foot { margin-top: 3px; }
  .panel { padding: 8px 12px; bottom: 6px; width: 520px; border-radius: 16px; }
  .panel-desc { display: none; }
  .panel-title { font-size: 15px; }
  .panel-close { width: 24px; height: 24px; line-height: 24px; font-size: 16px; }
  .cards { margin: 5px 0 6px; }
  .card { width: 70px; padding: 4px 3px 5px; }
  .card img { width: 44px; height: 44px; }
  .card-name { font-size: 12px; }
  .build-btn { padding: 7px 16px; font-size: 13.5px; }
  .hud-tools { bottom: 10px; left: 14px; }
  .progress { bottom: 10px; right: 14px; }
  .finale-title { font-size: 30px; }
  .finale { bottom: 80px; }
}
@media (max-width: 640px) {
  .hud-top { flex-direction: column; gap: 8px; left: 12px; }
  .hud-right { width: 200px; right: 10px; top: 96px; }
  .realm-sub { display: none; }
}

/* 展示模式：隐藏经营相关的界面 */
body.showcase .res,
body.showcase .hud-right,
body.showcase #castle-progress {
  display: none;
}

/* ---------- 自由搭建 ---------- */

body.freebuild .res,
body.freebuild .hud-right,
body.freebuild #castle-progress,
body.freebuild #panel {
  display: none;
}
body.freebuild .hud-tools { top: 22px; right: 18px; left: auto; bottom: auto; }
.bp-btn b { font-weight: 600; font-size: 12.5px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.bp-btn.off { opacity: 0.55; }
.bp-btn.off b { text-decoration: line-through; }

.build-tray {
  position: absolute;
  left: 50%;
  bottom: 14px;
  display: flex;
  gap: 14px;
  max-width: calc(100% - 28px);
  padding: 8px 12px 9px;
  border-radius: 20px;
  background: var(--paper);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(80, 60, 30, 0.2);
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x;
  pointer-events: auto;
  opacity: 0;
  transform: translate(-50%, 24px);
  transition: opacity 0.6s ease 0.4s, transform 0.6s cubic-bezier(.2,.9,.3,1.1) 0.4s, background 0.2s ease;
}
.build-tray::-webkit-scrollbar { display: none; }
.ready .build-tray { opacity: 1; transform: translate(-50%, 0); }
.build-tray.drop-cancel { background: rgba(240, 222, 210, 0.92); }
/* 收起把手（traytab.js）：--tray-h 是建造栏的高度；收起时建造栏滑到屏幕底边外，只剩把手 */
body.tray-moved .build-tray { transition: opacity 0.25s ease, transform 0.3s cubic-bezier(.2,.9,.3,1), background 0.2s ease; }
body.tray-off .build-tray { opacity: 0; transform: translate(-50%, calc(100% + 30px)); pointer-events: none; }
body.tray-off .build-tray * { pointer-events: none; }
.tray-tab {
  position: absolute;
  left: 50%;
  bottom: 14px;
  display: flex;
  align-items: center;
  height: 20px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(80, 60, 30, 0.16);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.2em;
  cursor: pointer;
  touch-action: none;
  pointer-events: auto;
  opacity: 0;
  transform: translate(-50%, calc(-1 * var(--tray-h, 0px) - 6px));
  transition: opacity 0.6s ease 0.4s, transform 0.3s cubic-bezier(.2,.9,.3,1), height 0.2s ease;
}
.tray-tab::before { content: ''; position: absolute; top: -10px; right: -10px; bottom: -8px; left: -10px; }
.tray-tab:hover { color: var(--ink); }
.tray-tab i {
  width: 7px;
  height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.tray-tab span { display: none; margin-left: 8px; }
.ready .tray-tab { opacity: 0.92; }
body.tray-off .tray-tab { height: 28px; transform: translate(-50%, 0); }
body.tray-off .tray-tab i { transform: translateY(2px) rotate(-135deg); }
body.tray-off .tray-tab span { display: inline; }
.viewing .tray-tab, .finale-on .tray-tab, .recording .tray-tab { opacity: 0; pointer-events: none; }
.tray-group { flex: none; }
.tray-group + .tray-group { padding-left: 14px; border-left: 1px solid rgba(120, 95, 60, 0.15); }
.tray-title { font-size: 11.5px; letter-spacing: 0.3em; color: var(--ink-soft); padding: 0 0 4px 4px; }
.tray-cards { display: flex; gap: 6px; }
.build-card { width: 74px; padding: 4px 3px 6px; touch-action: pan-x; cursor: grab; }
.build-card img { width: 54px; height: 54px; }
.build-card img:not([src]) { visibility: hidden; }
/* 分组收成标签：只展开一组，其余只露出标题 */
.build-tray.tabbed .tray-title { cursor: pointer; }
.build-tray.tabbed .tray-group:not(.open) { align-self: center; }
.build-tray.tabbed .tray-group:not(.open) .tray-cards { display: none; }
.build-tray.tabbed .tray-group:not(.open) .tray-title {
  padding: 22px 12px;
  border-radius: 14px;
  font-size: 14px;
  letter-spacing: 0.25em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  writing-mode: vertical-rl;
}
.build-tray.tabbed .tray-group:not(.open) .tray-title:hover { background: rgba(255, 255, 255, 0.85); }

.build-actions {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  will-change: transform;
}
.build-actions.show { opacity: 1; }
.build-actions.show .ba-buttons { pointer-events: auto; }
/* 全局的 button { pointer-events: auto } 会盖过父元素的 none：收起来（透明）的操作条还停在上一座建筑头顶，
   照样吃手指，两指一按上去浏览器就发 pointercancel，镜头不动（2026-11-07 查到） */
.build-actions:not(.show) button, .viewing .build-actions button { pointer-events: none; }
.ba-label {
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(74, 59, 44, 0.78);
  color: #fff8ea;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.ba-label b { font-weight: 600; }
.ba-label span:not(:empty)::before { content: '·'; margin: 0 6px; opacity: 0.6; }
.build-actions.bad .ba-label { background: rgba(176, 72, 58, 0.88); }
.ba-buttons {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(80, 60, 30, 0.18);
}
.ba-buttons button {
  min-width: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: transparent;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ba-buttons button:hover { background: rgba(120, 95, 60, 0.1); }
.ba-buttons button:active { transform: scale(0.94); }
.ba-buttons button[data-act="ccw"], .ba-buttons button[data-act="cw"] { padding: 0; font-size: 17px; }
.ba-buttons button.primary {
  background: linear-gradient(180deg, #f2c66d, #e39a52);
  color: #fff;
  text-shadow: 0 1px 2px rgba(120, 60, 10, 0.3);
}
.build-actions:not(.styled) [data-act="style"],
.build-actions:not(.growable) [data-act="up"],
.build-actions:not(.growable) [data-act="down"],
.build-actions:not(.editing) [data-act="delete"],
.build-actions.editing [data-act="cancel"],
.build-actions:not(.span) [data-act="flip"],
.build-actions.span [data-act="ccw"],
.build-actions.span [data-act="cw"],
.build-actions.fixed-rot [data-act="ccw"],
.build-actions.fixed-rot [data-act="cw"],
.build-actions.drawing .ba-buttons button:not([data-act="cancel"]) {
  display: none;
}
.build-actions.bad:not(.editing) [data-act="ok"] { opacity: 0.5; }

.viewing .build-tray, .viewing .build-actions { opacity: 0; pointer-events: none; }
.viewing .build-tray * { pointer-events: none; }
.finale-on .build-tray { opacity: 0; pointer-events: none; }
.finale-on .build-tray * { pointer-events: none; }

@media (max-height: 460px) {
  .build-tray { bottom: 6px; padding: 5px 10px 6px; }
  .tray-title { display: none; }
  .build-tray.tabbed .tray-title { display: block; }
  .build-tray.tabbed .tray-group.open .tray-title { display: none; }
  .build-card { width: 60px; }
  .build-card img { width: 40px; height: 40px; }
  body.freebuild .hud-tools { top: 10px; }
}
@media (max-width: 640px) {
  .build-tray { left: 12px; right: 12px; max-width: none; transform: translateY(24px); }
  .ready .build-tray { transform: none; }
  .build-card { width: 64px; }
  .build-card img { width: 44px; height: 44px; }
  body.freebuild .hud-tools { top: auto; bottom: 128px; right: 12px; flex-direction: column; align-items: flex-end; }
}

/* ---------- 开始画面：云海浮岛 + 四张领地卡片（src/title.js） ---------- */

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow: hidden;
  background: #e6eef3;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.title-screen.show { opacity: 1; }
.title-screen.gone { opacity: 0; transition-duration: 0.8s; pointer-events: none; }
.title-screen.gone * { pointer-events: none; }
.title-bg {
  position: absolute;
  inset: -2%;
  background: url("./title/bg.jpg") center / cover no-repeat;
  animation: title-breathe 24s ease-in-out infinite alternate;
}
@keyframes title-breathe { from { transform: scale(1); } to { transform: scale(1.05) translateY(-0.6%); } }
.title-clouds { position: absolute; inset: 0; pointer-events: none; }
.title-cloud { position: absolute; left: 0; height: auto; will-change: transform; }
.title-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
}
.title-head { text-align: center; margin-bottom: 34px; }
.title-name {
  font-size: 50px;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: #4a3b2c;
  text-shadow: 0 0 18px rgba(255, 252, 244, 0.95), 0 2px 0 rgba(255, 255, 255, 0.6);
}
.title-sub {
  margin-top: 10px;
  font-size: 17px;
  letter-spacing: 0.18em;
  color: rgba(74, 59, 44, 0.78);
  text-shadow: 0 0 10px rgba(255, 252, 244, 0.95);
}
.title-dots i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 3px 3px;
  border-radius: 50%;
  background: var(--gold);
  animation: title-dot 1.2s ease-in-out infinite;
}
.title-dots i:nth-child(2) { animation-delay: 0.2s; }
.title-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes title-dot { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.title-cards { display: flex; justify-content: center; width: 100%; max-width: 1180px; }
.title-card {
  position: relative;
  flex: 0 1 210px;
  margin: 0 11px;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff9ee;
  border: 4px solid #fffaf0;
  box-shadow: 0 10px 26px rgba(92, 72, 48, 0.2), 0 2px 6px rgba(92, 72, 48, 0.12);
  text-align: left;
  transition: transform 0.35s ease, opacity 0.45s ease, box-shadow 0.35s ease;
  animation: title-card-in 0.8s ease both;
}
.title-card:nth-child(2) { animation-delay: 0.08s; }
.title-card:nth-child(3) { animation-delay: 0.16s; }
.title-card:nth-child(4) { animation-delay: 0.24s; }
.title-card:nth-child(5) { animation-delay: 0.32s; }
@keyframes title-card-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
/* 3:4：老内核没有 aspect-ratio，用撑高的伪元素 */
.title-card::before { content: ""; display: block; padding-top: 133%; }
.title-art {
  position: absolute;
  inset: 0;
  background: center 30% / cover no-repeat;
  opacity: 0.88;
}
.title-card[data-realm="sakura"] .title-art { background-image: url("./title/sakura.jpg"); }
.title-card[data-realm="academy"] .title-art { background-image: url("./title/academy.jpg"); }
.title-card[data-realm="spring"] .title-art { background-image: url("./title/spring.jpg"); }
.title-card[data-realm="alpine"] .title-art { background-image: url("./title/alpine.jpg"); }
.title-card[data-realm="garden"] .title-art { background-image: url("./title/garden.jpg"); }
/* 下半截渐变成纸色，写名字 */
.title-art::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48%;
  background: linear-gradient(to top, rgba(255, 249, 238, 0.97) 0%, rgba(255, 249, 238, 0.86) 45%, rgba(255, 249, 238, 0) 100%);
}
.title-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 14px 14px; text-align: center; }
.title-text b { display: block; font-weight: normal; font-size: 23px; letter-spacing: 0.12em; color: #4a3b2c; }
.title-text i { display: block; margin-top: 4px; font-style: normal; font-size: 13px; color: rgba(74, 59, 44, 0.72); }
.title-tags { position: absolute; top: 9px; left: 9px; right: 9px; text-align: left; }
.title-tags em {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  color: #4a3b2c;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 1px 4px rgba(92, 72, 48, 0.16);
}
.title-tags em.new { color: #fff; background: #d98a5a; }
.title-card:hover { transform: translateY(-6px); box-shadow: 0 16px 32px rgba(92, 72, 48, 0.24), 0 2px 6px rgba(92, 72, 48, 0.12); }
.title-card:active { transform: scale(0.97); }
.title-screen.picked .title-card { opacity: 0; transform: scale(0.94); pointer-events: none; }
.title-screen.picked .title-card.on { opacity: 1; transform: scale(1.06); }

@media (max-height: 460px) {
  .title-inner { padding: 12px 16px 14px; }
  .title-head { margin-bottom: 16px; }
  .title-name { font-size: 32px; }
  .title-sub { margin-top: 6px; font-size: 13px; }
  .title-cards { max-width: 860px; }
  .title-card { flex-basis: 150px; margin: 0 6px; border-width: 3px; border-radius: 12px; }
  .title-text { padding: 0 8px 9px; }
  .title-text b { font-size: 17px; }
  .title-text i { margin-top: 2px; font-size: 10.5px; }
  .title-tags { top: 6px; left: 6px; }
  .title-tags em { padding: 2px 7px; font-size: 10px; margin: 0 4px 4px 0; }
}
@media (max-width: 640px) {
  .title-bg { background-position: 14% center; }
  .title-head { margin-bottom: 22px; }
  .title-name { font-size: 36px; }
  .title-sub { font-size: 14px; letter-spacing: 0.1em; }
  .title-cards { flex-wrap: wrap; max-width: 380px; }
  .title-card { flex: 0 0 calc(50% - 16px); margin: 0 8px 16px; }
  .title-text b { font-size: 19px; }
  .title-text i { font-size: 11px; }
}

/* ---------- 英文界面（2026-11-11）：Fredoka 圆体（OFL，src/fonts/），可变字重 ----------
   快乐体的拉丁字母偏细偏怪，英文不用它；中文排版用的大字距在英文里显得松散，统一收回去，标题另给一点 */
@font-face {
  font-family: "TaleLatin";
  src: url("./fonts/Fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
html[lang="en"] {
  --serif: "TaleLatin", "TaleWeb", "Avenir Next", "Helvetica Neue", sans-serif;
}
html[lang="en"] body { font-weight: 450; }
html[lang="en"] body * { letter-spacing: 0.01em !important; }
html[lang="en"] .title-name { letter-spacing: 0.04em !important; font-weight: 600; }
html[lang="en"] .title-text b { font-weight: 600; }
html[lang="en"] .modal-actions button,
html[lang="en"] .chip { white-space: nowrap; }
html[lang="en"] .modal-actions { flex-wrap: wrap; }
/* 英文句子长，窄屏上提示条换行，不跑出屏幕 */
html[lang="en"] .toast { white-space: normal; max-width: calc(100vw - 32px); text-align: center; border-radius: 18px; line-height: 1.35; }

/* ---------- 公开网页版（web/build.mjs 接在 style.css 后面） ---------- */

/* 画质菜单：四个并排的按钮，当前这一档描金 */
.web-quality { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 4px; }
.web-quality button {
  padding: 7px 14px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: rgba(120, 95, 60, 0.12);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.web-quality button.on { border-color: var(--gold); background: rgba(217, 164, 65, 0.18); }

/* 打不开时的提示 */
#web-fault {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #f4efe4;
  color: var(--ink);
  text-align: center;
}
#web-fault[hidden] { display: none; }
#web-fault-title { font-size: 24px; font-weight: 600; }
#web-fault-msg { max-width: 420px; line-height: 1.5; }
#web-fault-detail { max-width: 560px; font-size: 11px; color: var(--ink-soft); word-break: break-all; user-select: text; -webkit-user-select: text; }
.web-noscript { position: fixed; inset: 0; margin: 0; padding: 40vh 16px 0; text-align: center; background: #f4efe4; }

/* 横屏手机（矮屏）：弹窗紧凑一点，菜单的按钮不用滚动就看得到 */
@media (max-height: 460px) {
  .modal-body { padding: 12px 18px 10px; font-size: 13px; line-height: 1.45; }
  .modal-body p { margin: 5px 0; }
  .modal-actions { margin-top: 8px; }
}
