:root {
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --bg: #f7f5ef;
  --paper: #fffdf8;
  --ink: #3b4a41;
  --ink-soft: #7d8a80;
  --ink-faint: #98a397;
  --line: #e5e1d5;
  --accent: #86a487;
  --accent-deep: #6d8f75;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

.app { position: fixed; inset: 0; overflow: hidden; }

#stage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.is-hidden { display: none !important; }

/* ---------- 顶部信息 ---------- */
.hud {
  position: absolute;
  top: calc(18px + var(--sat));
  left: 20px;
  right: 62px;
  z-index: 4;
  pointer-events: none;
}

.hud-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.hud-item b {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.hud-item i {
  font-style: normal;
  margin-left: 4px;
  font-size: 10px;
  color: var(--ink-faint);
}

.bar {
  margin-top: 8px;
  height: 3px;
  border-radius: 3px;
  background: rgba(109, 143, 117, .14);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width .25s ease;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: absolute;
  top: calc(84px + var(--sat));
  left: 50%;
  z-index: 5;
  transform: translate(-50%, -6px);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 253, 248, .94);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: .06em;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 声音按钮 ---------- */
.mute-btn {
  position: absolute;
  top: calc(16px + var(--sat));
  right: 16px;
  z-index: 7;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, .86);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}

.mute-btn:active { transform: scale(.94); }
.mute-btn .ico { width: 18px; height: 18px; }
.mute-btn .ico-off { display: none; }
.mute-btn.is-muted .ico-on { display: none; }
.mute-btn.is-muted .ico-off { display: block; }
.mute-btn.is-muted { color: var(--ink-faint); }

/* ---------- 小抄道具栏 ---------- */
.tools {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--sab));
  z-index: 5;
  display: flex;
  gap: 7px;
  pointer-events: none;
}

.tool {
  flex: 1 1 0;
  min-width: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, .92);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(59, 74, 65, .06);
  transition: transform .12s ease, border-color .2s ease, background .2s ease;
}

.tool .glyph {
  font-size: 16px;
  line-height: 1.1;
  color: var(--accent-deep);
  letter-spacing: 0;
}

.tool:active { transform: scale(.96); border-color: var(--accent); background: #eef4ec; }
.tool:disabled { opacity: .42; cursor: default; }
.tool:disabled:active { transform: none; border-color: var(--line); background: rgba(255, 253, 248, .92); }

/* ---------- 覆盖层 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--sat)) 18px calc(20px + var(--sab));
}

.sheet {
  width: min(100%, 372px);
  padding: 28px 26px 24px;
  border: 1px solid rgba(214, 210, 195, .9);
  border-radius: 26px;
  background: rgba(255, 253, 248, .97);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 48px rgba(59, 74, 65, .11);
  text-align: center;
  animation: rise .42s cubic-bezier(.2, .8, .3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--ink-faint);
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: .14em;
  text-indent: .14em;
  color: var(--ink);
}

h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .06em;
}

.lede {
  margin: 4px 0 20px;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: .06em;
}

.rules {
  margin: 0 0 18px;
  padding: 14px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.rules p {
  margin: 0;
  padding: 4px 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
  display: flex;
  gap: 10px;
}

.rules .num {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--accent);
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}

.rules b { color: var(--ink); font-weight: 600; }

/* 主题切换 */
.theme-row { margin: 0 0 18px; }

.theme-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 0 0 8px;
  min-height: 9px;
}

.theme-dots i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.theme-btn {
  font-family: inherit;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .06em;
  cursor: pointer;
}

.theme-btn:active { background: rgba(109, 143, 117, .09); transform: scale(.97); }

.btn {
  font-family: inherit;
  border: 0;
  border-radius: 999px;
  padding: 13px 28px;
  font-size: 14px;
  letter-spacing: .16em;
  text-indent: .16em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}

.btn--primary {
  width: 100%;
  color: #fffdf8;
  background: var(--accent-deep);
  box-shadow: 0 8px 18px rgba(109, 143, 117, .24);
}

.btn--primary:hover { background: #62836a; }
.btn--primary:active { transform: translateY(1px) scale(.985); box-shadow: 0 4px 10px rgba(109, 143, 117, .2); }

.btn--ghost {
  padding: 12px 18px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: .08em;
  text-indent: .08em;
}

.btn--ghost:hover { background: rgba(109, 143, 117, .07); }
.btn--ghost:active { transform: scale(.97); }

.foot-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .02em;
}

.day-note {
  margin: 5px 0 0;
  min-height: 15px;
  font-size: 10px;
  letter-spacing: .16em;
  color: #b8bfb3;
}

/* ---------- 结算 ---------- */
.sheet--result { padding: 26px 22px 24px; }

#dump {
  display: block;
  width: 100%;
  height: 96px;
  margin: 12px 0 6px;
}

.loot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 4px;
  min-height: 24px;
  margin: 4px 0 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .6);
  font-size: 10.5px;
  color: var(--ink-soft);
  letter-spacing: .02em;
}

.chip .dot { width: 7px; height: 7px; border-radius: 50%; }

.verdict {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: .04em;
}

.aside {
  margin: 6px 0 18px;
  min-height: 18px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-faint);
  letter-spacing: .03em;
}

.btn-row { display: flex; flex-direction: column; gap: 9px; }
.btn-row .btn--ghost { width: 100%; }

/* ---------- 横屏轻提示 ---------- */
.rotate-hint {
  display: none;
  position: absolute;
  bottom: calc(8px + var(--sab));
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .1em;
  pointer-events: none;
}

@media (orientation: landscape) and (max-height: 520px) {
  .rotate-hint { display: block; }
  .sheet { padding: 14px 20px; }
  h1 { font-size: 26px; }
  .lede { margin-bottom: 10px; }
  .rules { margin-bottom: 10px; padding: 8px 12px; }
  .theme-row { margin-bottom: 10px; }
  #dump { height: 64px; margin: 6px 0; }
}

@media (max-height: 720px) {
  .sheet { padding: 20px 22px 18px; }
  h1 { font-size: 30px; }
  .lede { margin-bottom: 14px; }
  .rules { margin-bottom: 12px; padding: 9px 12px; }
  .theme-row { margin-bottom: 12px; }
  #dump { height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
