/* vkt Pop 泡泡减压 —— 软糯但不寡淡 */
:root {
  --bg: #EAD9C2;
  --text: #3A2E22;
  --pill-bg: rgba(0, 0, 0, 0.08);
  --card: #FFF8EF;
  --card-shadow: rgba(0, 0, 0, 0.25);
  --muted: rgba(58, 46, 34, 0.55);
  --danger: #C0392B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* 屏蔽 iOS 长按呼出 */
  overscroll-behavior: none;   /* 屏蔽下拉刷新 / 橡皮筋 */
  transition: background 0.5s ease;
}

/* ---------- 顶栏（仅标题 / 配额胶囊 / 音效 / 账号） ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0 14px;
  display: flex; align-items: center; gap: 10px;
}
#appTitle { font-size: 17px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: var(--pill-bg); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pill.low { color: #C0392B; font-weight: 700; }
.icon-btn {
  border: 0; background: var(--pill-bg); width: 36px; height: 36px;
  border-radius: 999px; font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: inherit; padding: 0;
}
/* 顶栏两侧的返回 / 菜单：不带底色，和系列其余几款一致 */
.nav-btn {
  width: 40px; height: 40px; font-size: 18px;
  background: transparent; color: var(--text);
  text-decoration: none;
}

/* ---------- 泡泡板 ---------- */
#board {
  position: absolute;
  inset: calc(52px + env(safe-area-inset-top)) 0 0 0;
  touch-action: none; overflow: hidden;
}
.bubble {
  position: absolute; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 32% 28%,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.28) 14%,
    var(--c1) 46%,
    var(--c2) 100%);
  box-shadow:
    inset -6px -9px 14px rgba(0, 0, 0, 0.28),
    inset 4px 6px 10px rgba(255, 255, 255, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.12);
}
.bubble.gold {
  box-shadow:
    inset -6px -9px 14px rgba(120, 84, 0, 0.35),
    inset 4px 6px 10px rgba(255, 240, 180, 0.5),
    0 0 12px rgba(255, 200, 60, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.12);
}
/* 待机漂浮：极轻微的上下呼吸，让整版"活着"。
   will-change 只在 .live 下声明——常驻 will-change 会让每一颗泡泡即使静止时
   也占一个合成层，150 颗就是 150 层，中低端机上显存与合成开销都很实在。
   （低端机连 .live 都不会加，见 main.js 的 LIVE 判断） */
#board.live .bubble {
  animation-name: bob;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  will-change: transform;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
/* 金色泡泡微闪 */
.bubble.gold::after {
  content: ''; position: absolute; left: 18%; top: 14%;
  width: 26%; height: 26%; border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  filter: blur(1px);
  animation: shimmer 1.8s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.25); }
}
@media (prefers-reduced-motion: reduce) {
  #board.live .bubble, .bubble.gold::after { animation: none; }
  /* 抽屉/面板的升起同理：系统关了动效就别自己烧 */
  .menu-list, .sheet { animation: none; }
}
.residue {
  position: absolute; border-radius: 50%; pointer-events: none;
  border: 2px dashed var(--residue, rgba(0, 0, 0, 0.18));
}
.residue.fading { animation: residueFade 1.5s forwards; }
@keyframes residueFade { to { opacity: 0; } }
.ring {
  position: absolute; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.75);
  will-change: transform, opacity;
}
.shard {
  position: absolute; border-radius: 50% 50% 50% 0; pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- 升级卡片 ---------- */
.card {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--card); color: var(--text);
  border-radius: 20px; padding: 22px 20px; z-index: 30;
  box-shadow: 0 10px 40px var(--card-shadow);
  text-align: center;
}
.card-close {
  position: absolute; top: 10px; right: 10px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 6px;
}
.card-emoji { font-size: 34px; margin-bottom: 6px; }
.card h2 { font-size: 17px; margin: 0 0 6px; }
.card p { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.countdown { font-size: 20px !important; font-weight: 700; color: var(--text) !important; font-variant-numeric: tabular-nums; margin: 10px 0 14px !important; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn.primary { background: #C9526B; color: #fff; }
.btn.primary:disabled { opacity: 0.5; }
.btn.ghost { background: var(--pill-bg); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
/* 发信按钮在人机校验未就绪时会被禁用 —— 得让人看出"不是不能点，是还没准备好" */
.btn:disabled { cursor: not-allowed; }

/* ---------- Google 登录 ---------- */
/* 「或」分隔线：把邮箱这条路和 Google 那条路视觉上分开 */
.or-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.or-line { flex: 1; height: 1px; background: var(--pill-bg); }
.or-txt { font-size: 12px; color: var(--muted); }

/* Google 官方按钮样式：白底描边 + 四色 G。深浅主题都不变（品牌规范要求） */
.btn.google {
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.google:disabled { opacity: 0.5; }
.g-ico { width: 18px; height: 18px; flex: 0 0 auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); color: var(--text);
  border-radius: 22px 22px 0 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px var(--card-shadow);
  max-height: 85vh; overflow-y: auto;
  animation: sheetIn 300ms cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-section { margin-top: 16px; }
.sheet-label { font-size: 13px; color: var(--muted); margin: 0 0 8px; }

/* ---------- 折叠菜单（底部抽屉，对齐 tally / screen） ----------
   手机上拇指够不到屏幕右上角，菜单从底部升起、每项 ≥48px 触摸目标才是
   标准触摸交互。开合一律用 .hidden（本款的历史约定，不是 tally 的 hidden 属性），
   下面 .hidden 带 !important，能盖掉这里的 display: flex。 */
.backdrop {
  position: fixed; inset: 0; z-index: 38;
  background: rgba(0, 0, 0, 0.5);
}
.menu-list {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; flex-direction: column;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  background: var(--card); color: var(--text);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px var(--card-shadow);
  animation: sheetIn 300ms cubic-bezier(0.32, 0.72, 0, 1);
}
.menu-item {
  display: flex; align-items: center; gap: 14px;
  border: 0; background: none; color: var(--text);
  min-height: 52px;              /* ≥ 48px 触摸目标 */
  padding: 10px 14px;
  font-size: 16px; border-radius: 12px;
  cursor: pointer; text-align: left; font-family: inherit;
  white-space: nowrap;
}
.menu-item:active { background: var(--pill-bg); }
.menu-ico { flex: 0 0 auto; font-size: 18px; width: 24px; text-align: center; }
.menu-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------- 占位页（菜单次级页面） ---------- */
.page-view {
  position: fixed; inset: 0; z-index: 46;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
}
.page-head {
  flex: 0 0 auto;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0 10px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--pill-bg);
}
.page-head-pad { flex: 0 0 40px; }   /* 和右侧关闭键等宽，标题才真居中 */
.page-title {
  flex: 1; font-size: 17px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-body { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 20px; }
.page-placeholder { font-size: 15px; color: var(--muted); text-align: center; margin: 0; }

/* ---------- 内容页（「说明」：下半部分是联系作者 / 隐私政策） ----------
   占位页是一句居中的话；内容页是长文，必须顶对齐 + 可滚动 —— 长文居中会让
   第一行跑到屏幕中间、下面还藏着一半。 */
.page-view.doc .page-body {
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 18px 18px 28px;
}

.doc-block { width: 100%; max-width: 520px; margin: 0 auto; }

.doc-p { font-size: 14px; line-height: 1.6; margin: 0 0 12px; }

.doc-list {
  margin: 0; padding-left: 20px;
  font-size: 14px; line-height: 1.6;
  display: grid; gap: 8px;
}
.doc-list li { list-style: disc; }

/* 分节标题：把「怎么玩」和「联系作者 / 隐私政策」分开。
   不画上边框 —— 它上面那条 .doc-note 已经有 border-top，再画一条就是双线。 */
.doc-h { font-size: 14px; font-weight: 600; margin: 24px 0 10px; }

.doc-note {
  font-size: 13px; line-height: 1.55; color: var(--muted);
  margin: 16px 0 0; padding-top: 12px;
  border-top: 1px solid var(--pill-bg);
}

.doc-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--pill-bg);
}
.doc-k { flex: 0 0 auto; font-size: 13px; color: var(--muted); }

.doc-link {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px;
  color: var(--text);
  text-decoration: underline;
  /* 邮箱 / 长 URL 不许把行撑破 */
  overflow-wrap: anywhere;
}
.doc-link:active { opacity: .7; }

/* 账号面板：邮箱验证码或 Google 授权，没有密码 */
.field { margin-bottom: 2px; }
select.input {
  appearance: none; -webkit-appearance: none; background-image: none;
  padding-right: 14px; cursor: pointer;
}
/* 人机校验容器。widget 渲染前它是空的，空着也占 10px 就会在邮箱框下留一道缝 */
.turnstile-box { margin: 2px 0 0; }
.turnstile-box:not(:empty) { margin: 12px 0 10px; }

/* 提示与记录 */
.hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.recap {
  margin: 14px 0 4px; padding: 12px 14px;
  border-radius: 12px; background: var(--pill-bg);
}
.user-line { font-size: 13px; color: var(--muted); margin: 0 0 6px; line-height: 1.5; }
.recap .user-line:last-child { margin-bottom: 0; }
.stats-list { display: flex; flex-direction: column; gap: 6px; }
.stats-list .user-line { margin: 0; }
.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-chip {
  border: 1px solid var(--pill-bg); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text); cursor: help;
}
#authArea .btn + .btn, #userArea .btn + .btn { margin-top: 8px; }

.input {
  width: 100%; border: 1px solid var(--pill-bg); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; margin-bottom: 10px;
  background: transparent; color: var(--text); outline: none;
}
.code-row { display: flex; gap: 8px; }
.code-row .input { flex: 1; }
.code-row .btn { width: auto; white-space: nowrap; padding: 0 14px; font-size: 13px; }
.auth-msg { font-size: 13px; min-height: 18px; margin: 2px 0 8px; color: #C0392B; }
.auth-msg.ok { color: #3E8A4F; }
/* ---------- 资料面板顶部的头像 + 昵称 ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; }
.profile-id { flex: 1; min-width: 0; }
.avatar {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--pill-bg);
  font-size: 20px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-nick { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 13px; color: var(--muted); margin: 2px 0 0; word-break: break-all; }
.user-paid { font-size: 14px; color: var(--muted); margin: 0 0 12px; }

.lang-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-chip {
  border: 1px solid var(--pill-bg); border-radius: 999px;
  background: transparent; color: var(--text);
  padding: 7px 13px; font-size: 13px; cursor: pointer;
}
.lang-chip.active { background: #C9526B; color: #fff; border-color: #C9526B; }

/* ---------- 确认弹窗（登出前问一句） ----------
   层级必须高过账号面板（.sheet 40）——登出既可能从菜单发起，也可能从面板里的
   按钮发起，后者开着面板；盖不住的话弹窗会被压在面板底下，看起来像没反应。 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
}
.modal-card {
  width: 100%; max-width: 340px;
  background: var(--card); color: var(--text);
  border-radius: 18px; padding: 20px;
  box-shadow: 0 18px 50px var(--card-shadow);
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 70;
  background: rgba(0, 0, 0, 0.78); color: #fff;
  padding: 9px 18px; border-radius: 999px; font-size: 14px;
  max-width: 86vw; text-align: center;
}
.hidden { display: none !important; }
