/* vkt Slice 样式
 *
 * 三条布局约定：
 *   1) **不滚动**。body 固定在一个视口内，用 dvh 而不是 vh——iOS 的 vh 会把地址栏
 *      算进去，导致底部按钮被顶到屏幕外。
 *   2) **画布铺满，物体在 44% 高度**。js/main.js 的 measure() 里 cy = h * 0.44，
 *      改一处就要改另一处。
 *   3) **颜色全部来自 JS 注入的变量**（六套场景主题由 Objects.nextTheme 轮换），
 *      CSS 只负责兜底：默认值就是「木砧板」方案，首帧不会闪成别的颜色。
 *      不做 prefers-color-scheme 双声明——本作背景恒为中深调（设计稿 §5.1
 *      「不要太浅」），不存在"浅色模式下闪一屏深色"的问题。
 */
:root {
  --bg: #3A2C22;
  --bg-2: #463529;
  --text: #F2E4CE;
  --text-dim: #C6B49A;
  --line: rgba(242, 228, 206, 0.16);
  --surface: rgba(242, 228, 206, 0.08);
  --blade: #F2E4CE;
  --accent: #E8C46A;
  --danger: #E4657A;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

html { height: 100%; background: var(--bg); }

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans", "Microsoft YaHei", sans-serif;
  transition: background 500ms ease, color 500ms ease;
}

button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 画布 ---------- */
#board {
  position: absolute;
  inset: 0;
  display: block;
  /* 手指在画布上的一切手势都归 App：不给浏览器抢，
     否则快速划动会被判成滚动、边缘拖动会触发橡皮筋 */
  touch-action: none;
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- 顶栏 ---------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  z-index: 2;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.icon-btn:active { transform: scale(0.92); }

.pill {
  margin-left: auto;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.pill.low { color: var(--danger); opacity: 1; }

/* ---------- 画布上的两行提示 ---------- */
.stat-line, .hint-line {
  position: absolute;
  left: 0; right: 0;
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  pointer-events: none;
}
.stat-line { top: calc(66px + var(--safe-t)); }
/* 底栏撤销后这条提示往下落：原先是给底栏语言行让位的 */
.hint-line { bottom: calc(30px + var(--safe-b)); opacity: 0.7; }

/* ---------- 语言行（现在住在设置抽屉里） ---------- */
.lang-row { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
.lang-chip {
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}
.lang-chip.active { color: var(--text); border-color: var(--line); }

.note { font-size: 11.5px; color: var(--text-dim); opacity: 0.65; }

.btn {
  padding: 8px 15px;
  border: 0;
  border-radius: 11px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(0.96); }
.btn.ghost { background: var(--surface); color: var(--text-dim); }
.btn.primary { background: var(--accent); color: #2A2118; font-weight: 600; }
.hidden { display: none !important; }

/* ---------- 配额卡片 ---------- */
.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 8, 6, 0.62);
  z-index: 10;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 330px;
  padding: 26px 22px 20px;
  border-radius: 20px;
  background: var(--bg-2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.modal-emoji { font-size: 34px; line-height: 1; }
.modal-card h2 { margin: 12px 0 8px; font-size: 17px; }
.modal-card p { margin: 0 0 6px; font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }
.rest-count {
  margin: 12px 0 0 !important;
  font-size: 21px !important;
  font-variant-numeric: tabular-nums;
  color: var(--text) !important;
}
.modal-actions {
  display: flex;
  gap: 9px;
  margin-top: 17px;
}
.modal-actions .btn { flex: 1; }

.card-close {
  position: absolute;
  top: 11px; right: 11px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(150px + var(--safe-b));
  transform: translateX(-50%);
  max-width: 78vw;
  padding: 9px 15px;
  border-radius: 12px;
  background: rgba(20, 16, 12, 0.92);
  color: var(--text);
  font-size: 12.5px;
  text-align: center;
  z-index: 20;
  pointer-events: none;
}



/* ================= 统一壳 =================
 * 与 pop / tally / bloom / screen 同一套：顶栏「← 标题 [配额] ⚙ ☰」+ 折叠菜单
 * + 内容页（说明）+ 设置抽屉 + 登录抽屉 + 确认弹窗。
 * 样式逐条对齐 bloom 的壳段，颜色换成本作的变量（--text / --text-dim /
 * --surface / --line / --bg-2 / --danger）。开合沿用本作既有的 .hidden class。
 */

/* hidden 属性也必须能关掉元素：.sheet / .modal / .menu-item 都自带 display，
   同优先级下后写的规则会赢，属性隐藏会静默失效（菜单里「个人信息」那一格就靠它）。 */
[hidden] { display: none !important; }

/* ---------- 顶栏的壳按钮 ---------- */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px; height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease;
}
.nav-btn:active { transform: scale(0.94); }

/* 标题不撑满：让 .pill 的 margin-left:auto 把配额和右侧两个按钮一起推到右边 */
.app-title {
  margin-left: 2px;
  max-width: 44vw;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 抽屉与遮罩 ---------- */
.backdrop {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(10, 8, 6, 0.52);
}

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  max-height: 84vh;                 /* 兜底：不认识 dvh 的老 iOS 会把整条声明丢掉 */
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.38);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 8px;
}
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(22px + var(--safe-b));
}

.field { padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field-label {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field-label:empty { display: none; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  font-size: 14px;
}
.switch-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 44px; height: 26px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sw-label { color: var(--text); }

.sheet .lang-row { justify-content: flex-start; }
.sheet .note { margin: 8px 0 0; font-size: 12px; line-height: 1.5; opacity: 1; }

/* ---------- 折叠菜单：底部抽屉 ---------- */
.menu-list {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  padding: 10px 10px calc(12px + var(--safe-b));
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.38);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.menu-item:active { background: var(--surface); }
.menu-ico { flex: 0 0 auto; width: 24px; font-size: 17px; text-align: center; }
.menu-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 内容页（说明） ---------- */
.page-view {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + var(--safe-t)) 14px 10px;
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 16px; font-weight: 700; }
.page-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 16px calc(22px + var(--safe-b));
}
.page-placeholder { margin: 0; font-size: 14px; color: var(--text-dim); text-align: center; }
/* 占位页是一句居中的话；内容页是长文，必须顶对齐 —— 长文居中会让第一行
   跑到屏幕中间、下面还藏着一半。 */
.page-view.doc .page-body { align-items: flex-start; justify-content: flex-start; }

.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 {
  display: grid; gap: 8px;
  margin: 0; padding-left: 20px;
  font-size: 14px; line-height: 1.6;
}
.doc-list li { list-style: disc; }
.doc-h { margin: 24px 0 10px; font-size: 14px; font-weight: 600; }
.doc-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px; line-height: 1.55;
  color: var(--text-dim);
}
.doc-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.doc-k { flex: 0 0 auto; font-size: 13px; color: var(--text-dim); }
.doc-link {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;        /* 邮箱 / 长 URL 不许把行撑破 */
}
.doc-link:active { opacity: .7; }

/* ---------- 登录 / 个人信息抽屉 ---------- */
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--accent); }

.code-row { display: flex; gap: 8px; margin-top: 10px; }
/* 验证码那一行：输入框占满剩余宽度、按钮按内容宽度。
   反过来写会把输入框挤成一个小方块（tally 踩过）。 */
.code-row .code-input { flex: 1 1 auto; min-width: 0; }
.code-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* Turnstile 用 interaction-only：平时完全隐形、高度 0，
   只有 Cloudflare 真要用户点一下时才现形 —— 所以没内容时不留空白 */
.turnstile-box:not(:empty) { margin-top: 12px; }

.form-msg {
  min-height: 18px;
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--danger);
  word-break: break-word;
}
.form-msg.ok { color: #6FBF8B; }
/* 人机校验未就绪是「状态」，不是「用户做错了什么」——比错误红字弱一档 */
.form-hint {
  margin: 8px 0 0;
  font-size: 12px; line-height: 1.5;
  color: var(--text-dim);
  word-break: break-word;
}

.or-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.or-line { flex: 1; height: 1px; background: var(--line); }
.or-txt { font-size: 12px; color: var(--text-dim); }

/* Google 官方按钮：白底描边 + 四色 G，深浅主题都不变（品牌规范） */
.btn.google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}
.g-ico { flex: 0 0 auto; width: 18px; height: 18px; }

#authLoginArea .btn { width: 100%; margin-top: 10px; }
#authLoginArea .code-row .btn,
#authLoginArea .btn.google { margin-top: 0; }

/* ---------- 资料顶部的头像 + 昵称 ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.profile-id { flex: 1; min-width: 0; }
.avatar {
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  font-size: 20px; font-weight: 700;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.user-nick {
  margin: 0;
  font-size: 16px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-email { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); word-break: break-all; }
.user-line { margin: 6px 0; font-size: 14px; color: var(--text-dim); }
#authUserArea .btn { width: 100%; margin-top: 14px; }

.btn.danger { background: transparent; color: var(--danger); }

/* ---------- 尊重系统的减弱动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  body, .icon-btn, .btn, .lang-chip, .pill { transition: none !important; }
  .icon-btn:active, .btn:active { transform: none; }
}
