/* 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(96px + var(--safe-b)); opacity: 0.7; }

/* ---------- 底部 ---------- */
#dock {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 14px calc(10px + var(--safe-b));
  z-index: 2;
  pointer-events: none;
}
#dock > * { pointer-events: auto; }

.lang-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.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); }

.dock-actions { display: flex; align-items: center; gap: 10px; }
.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;
}

/* ---------- 尊重系统的减弱动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  body, .icon-btn, .btn, .lang-chip, .pill { transition: none !important; }
  .icon-btn:active, .btn:active { transform: none; }
}
