/* ==========================================================================
   转生投胎事务所 · 样式
   视觉方向 A：冥纸黄 / 朱砂 / 奈何夜 / 灯笼金 / 墨。2px 墨线 + 不模糊的硬投影。
   ========================================================================== */

/* 字体自托管（tools/build_fonts.py 精简生成，只含页面用到的字；SIL OFL 1.1，授权见 fonts/OFL-*.txt）。
   不依赖 Google Fonts：它在中国大陆无法稳定访问 */
@font-face { font-family: "ZCOOL QingKe HuangYou"; src: url("fonts/zcool-qingke-huangyou.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Serif SC"; src: url("fonts/noto-serif-sc-500.woff2") format("woff2"); font-weight: 300 600; font-display: swap; }
@font-face { font-family: "Noto Serif SC"; src: url("fonts/noto-serif-sc-900.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }

:root {
  /* 顶部安全区：手机上跟随系统（刘海屏），桌面手机外壳里为药丸挖孔的高度 */
  --safe-top: env(safe-area-inset-top, 0px);
  --paper: #EFE6CF;
  --paper-2: #F4E7B8;
  --paper-3: #FBF4DC;
  --ink: #1C1A17;
  --ink-2: #4A453C;
  --muted: #6B6355;
  --rule: #D9CBA0;
  --dash: #8A7F64;
  --night: #1F1C2C;
  --night-2: #2A2640;
  --night-line: #4A4560;
  --night-text: #EDE6D6;
  --night-title: #F4ECDC;
  --night-muted: #B9B0A0;
  --night-dim: #8F8778;
  --gold: #F5B83D;
  --red: #C21F30;
  --on-red: #FFF8EC;
  --hl: #FFF6D9;

  /* 字号只用 5 级（抽签页国家名 96px 是单独一屏的主角，例外） */
  --fs-xs: 12px;
  --fs-sm: 15px;
  --fs-md: 18px;
  --fs-lg: 24px;
  --fs-xl: 44px;

  --f-title: "ZCOOL QingKe HuangYou", "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-body: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #15131D;
  color: var(--ink);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  overflow-x: clip; /* 不能用 hidden：会让底部按钮栏的 sticky 失效 */
}

/* ---------- 按钮：按下去有实体感 ---------- */
.btn {
  height: 58px;
  border: 2px solid var(--ink);
  background: transparent;
  font-family: var(--f-body);
  font-weight: 900;
  font-size: var(--fs-md);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn.primary {
  background: var(--red);
  color: var(--on-red);
  box-shadow: 4px 4px 0 var(--ink);
}
.btn.primary:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn.ghost:active { transform: translate(2px, 2px); }
.btn:focus-visible, .link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ==========================================================================
   P0 首页
   ========================================================================== */
.hero {
  background: var(--night);
  color: var(--night-text);
  padding: calc(20px + var(--safe-top)) 20px 56px;
  display: flex;
  flex-direction: column;
}
.bar { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.brand { font-family: var(--f-title); font-size: var(--fs-md); color: var(--night-title); letter-spacing: 1px; }
.calling {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--night-line); border-radius: 999px;
  padding: 4px 12px 4px 8px; font-size: var(--fs-xs); color: #D8CFBE;
  font-variant-numeric: tabular-nums;
}
.calling i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 184, 61, .25);
  animation: breathe 2.4s ease-in-out infinite;
}
.calling b { font-weight: 500; }

.friend {
  margin-top: 16px;
  background: var(--paper-2); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--gold);
  padding: 12px 14px; font-size: var(--fs-sm); font-weight: 900;
}

.h-title {
  margin: 40px 0 0;
  font-family: var(--f-title); font-weight: 400;
  font-size: var(--fs-xl); line-height: 1.12; color: var(--night-title);
}
.meta { margin: 14px 0 0; font-size: var(--fs-xs); line-height: 1.6; color: var(--night-muted); }

.map-wrap { position: relative; margin: 32px -8px 0; }
.map-wrap canvas { display: block; width: 100%; touch-action: manipulation; cursor: pointer; }
.bubble {
  position: absolute; transform: translate(-50%, calc(-100% - 12px));
  background: var(--paper-3); color: var(--ink);
  border: 2px solid var(--ink); padding: 6px 10px;
  font-size: var(--fs-xs); font-weight: 900; white-space: nowrap; pointer-events: none;
  animation: pop .18s ease-out;
}

.intro { margin: 32px 0 0; font-size: var(--fs-md); line-height: 1.85; color: #E4DCCB; }

.counters { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ctr {
  border: 1.5px solid var(--night-line); border-radius: 4px;
  padding: 16px 14px; display: flex; flex-direction: column; gap: 6px;
}
.ctr b {
  font-family: var(--f-title); font-weight: 400; font-size: var(--fs-xl); line-height: 1;
  color: var(--gold); font-variant-numeric: tabular-nums; display: inline-block; transform-origin: left center;
}
.ctr b.pale { color: var(--night-text); }
.ctr span { font-size: var(--fs-xs); line-height: 1.5; color: var(--night-muted); }
.bump { animation: bump .22s ease-out; }

.meme { margin: 20px 0 0; font-size: var(--fs-sm); color: var(--gold); min-height: 1.6em; }
.meme.swap { animation: fadeIn .5s ease-out; }

.scroll-hint {
  margin-top: 44px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  color: var(--night-dim); font-size: var(--fs-xs);
}
.scroll-hint svg { animation: nudge 1.8s ease-in-out infinite; }
/* 入场只有地图点亮这一个编排时刻，文字不做依次淡入 */

/* 公告栏 */
.board-wrap { padding: 56px 20px 40px; }
.board {
  position: relative; background: var(--paper-2);
  border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  padding: 28px 18px 22px; display: flex; flex-direction: column; gap: 18px;
}
.pin { position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 2px solid var(--ink); }
.pin.l { left: 22px; } .pin.r { right: 22px; }
.board-k { font-size: var(--fs-xs); color: var(--muted); }
.board h2 { margin: 6px 0 0; font-weight: 900; font-size: var(--fs-lg); line-height: 1.35; }
.rows { display: flex; flex-direction: column; gap: 12px; }
.row {
  display: grid; grid-template-columns: 82px minmax(0, 1fr) 48px;
  align-items: center; gap: 10px; padding: 4px 6px; margin: 0 -6px;
}
.row .n { font-size: var(--fs-sm); }
.row .bar-t { height: 10px; background: #E3D3A0; position: relative; }
.row .bar-f { position: absolute; inset: 0 auto 0 0; background: var(--ink); transform-origin: left; }
.row .p { font-size: var(--fs-sm); text-align: right; font-variant-numeric: tabular-nums; }
/* 朱砂只留给按钮和印章：中国这一行用墨色描边 + 浅底高亮 */
.row.cn { background: var(--hl); outline: 2px solid var(--ink); }
.row.cn .n { font-weight: 900; }
.row.rest { margin-top: 0; padding-top: 12px; border-top: 1px dashed var(--dash); }
.row.rest .n { font-size: var(--fs-xs); line-height: 1.4; color: var(--ink-2); }
.row.rest .bar-f { background: #B5A77F; }
.board.seen .bar-f { animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; }

.cn-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--hl); border: 2px solid var(--ink); padding: 12px 14px;
}
.seal {
  flex-shrink: 0; border: 3px solid var(--red); border-radius: 50%; color: var(--red);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 900; line-height: 1.15; transform: rotate(-12deg);
}
.cn-box .seal { width: 64px; height: 64px; font-size: var(--fs-sm); }
.cn-box p { margin: 0; font-size: var(--fs-sm); line-height: 1.6; }
.cn-box b { font-family: var(--f-title); font-weight: 400; font-size: var(--fs-lg); }
.src { font-size: var(--fs-xs); line-height: 1.6; color: var(--muted); }

/* 底部留出悬浮按钮 + 渐隐遮罩的高度，最后的内容不会被永久挡住 */
.foot { padding: 8px 20px 150px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; color: var(--muted); font-size: var(--fs-xs); }
.foot nav { display: flex; gap: 20px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: var(--fs-xs); }

.cta-bar {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--paper); border-top: 2px solid var(--ink);
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px;
}
.cta-bar.duo { flex-direction: row; gap: 12px; }
.cta-bar.duo .ghost { width: 112px; flex-shrink: 0; font-size: var(--fs-sm); }
.cta-bar.duo .primary { flex: 1; font-size: var(--fs-md); letter-spacing: 0; }

/* 首页底部：方案 D，悬浮按钮 + 渐隐遮罩。遮罩颜色跟随按钮背后的区域（夜色 / 纸面）切换 */
.cta-float {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 5;
  width: min(430px, 100%); padding: 0 16px calc(26px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.cta-float::before, .cta-float::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 170px;
  transition: opacity .35s ease;
}
.cta-float::before { background: linear-gradient(to bottom, rgba(31, 28, 44, 0), var(--night) 62%); }
.cta-float::after { background: linear-gradient(to bottom, rgba(239, 230, 207, 0), var(--paper) 62%); opacity: 0; }
.cta-float.on-paper::before { opacity: 0; }
.cta-float.on-paper::after { opacity: 1; }
.cta-float .take {
  position: relative; z-index: 1; pointer-events: auto; width: 100%; height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.cta-float .take span { font-size: var(--fs-md); letter-spacing: 4px; line-height: 1; }
.cta-float .take small { font-size: var(--fs-xs); font-weight: 500; line-height: 1; opacity: .85; }

/* ==========================================================================
   取号小票
   ========================================================================== */
.layer { position: fixed; inset: 0; z-index: 20; }
.scrim { position: absolute; inset: 0; background: rgba(28, 26, 23, .62); animation: fadeIn .2s ease-out; }
.ticket-layer { display: flex; align-items: center; justify-content: center; padding: 24px; }
.ticket {
  position: relative; width: min(330px, 100%);
  background: var(--paper-2); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
  display: flex; animation: print .45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.ticket .l { width: 62%; padding: 16px; display: flex; flex-direction: column; gap: 2px; border-right: 2px dashed var(--ink); }
.ticket .r { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.ticket small { font-size: var(--fs-xs); color: var(--muted); }
.ticket .no { font-family: var(--f-title); font-size: var(--fs-xl); line-height: 1; }
.ticket .win { font-weight: 900; font-size: var(--fs-md); }
.ticket .notch { position: absolute; left: calc(62% - 9px); width: 16px; height: 16px; border-radius: 50%; background: #5B5548; border: 2px solid var(--ink); }
.ticket .notch.t { top: -9px; } .ticket .notch.b { bottom: -9px; }

/* ==========================================================================
   P1a 抽签
   ========================================================================== */
.roll {
  position: fixed; inset: 0; z-index: 10; max-width: 430px; margin: 0 auto;
  background: var(--night); color: var(--night-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.roll-label { font-size: var(--fs-sm); letter-spacing: 4px; color: var(--night-muted); }
.roll-name-wrap { position: relative; display: flex; align-items: center; justify-content: center; padding: 0 24px; }
.roll-name { font-family: var(--f-title); font-size: 96px; line-height: 1; color: var(--night-title); white-space: nowrap; }
.roll-name.tick { animation: tick .09s ease-out; }
.roll-name.final { color: var(--gold); animation: settle .4s cubic-bezier(.2, .9, .3, 1.3); }
.roll-odds { font-size: var(--fs-sm); color: var(--night-muted); font-variant-numeric: tabular-nums; }
.roll-odds b { color: var(--gold); font-weight: 900; }
.ding {
  position: absolute; right: -14px; top: -30px; width: 52px; height: 52px;
  border: 3px solid var(--red); border-radius: 50%; color: var(--red);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: var(--fs-lg);
  transform: rotate(-14deg); animation: thump .35s cubic-bezier(.2, .9, .3, 1.2) both;
}

/* ==========================================================================
   P1b 投胎通知书
   ========================================================================== */
.n-head {
  background: var(--ink); color: var(--paper); height: calc(56px + var(--safe-top)); padding: var(--safe-top) 20px 0;
  display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--ink);
}
.n-head b { font-weight: 900; font-size: var(--fs-md); letter-spacing: 4px; }
.n-head span { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.n-body { padding: 36px 20px 48px; display: flex; flex-direction: column; }
.n-id { position: relative; display: flex; flex-direction: column; gap: 6px; padding-right: 84px; }
.k { font-size: var(--fs-xs); color: var(--muted); }
.n-name { margin: 0; font-family: var(--f-title); font-weight: 400; font-size: var(--fs-xl); line-height: 1.08; }
.n-orig { font-size: var(--fs-sm); color: var(--muted); }
.n-id .seal { position: absolute; right: -2px; top: 0; width: 78px; height: 78px; font-size: var(--fs-md); opacity: .92; animation: thump .45s .25s cubic-bezier(.2, .9, .3, 1.2) both; }
.n-story { margin: 22px 0 0; font-size: var(--fs-md); line-height: 1.85; }
.chip {
  margin-top: 18px; align-self: flex-start; display: inline-flex; align-items: center; gap: 10px;
  background: var(--night); color: var(--night-text); padding: 8px 14px 8px 10px; border-radius: 999px; font-size: var(--fs-xs);
}
.sec-t { font-family: var(--f-title); font-size: var(--fs-lg); }
.card {
  margin-top: 36px; background: var(--paper-3); border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  padding: 20px 18px; display: flex; flex-direction: column; gap: 20px;
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; row-gap: 18px; }
.f { display: flex; flex-direction: column; gap: 4px; }
.f b { font-weight: 900; font-size: var(--fs-sm); line-height: 1.45; }
.split { padding-top: 16px; border-top: 1px solid var(--rule); }
.stripes { display: flex; align-items: flex-end; gap: 5px; height: 28px; margin: 4px 0; }
.stripes i { width: 9px; display: block; background: var(--rule); }
.stripes i.on { background: var(--ink); }
.sec { margin-top: 40px; display: flex; flex-direction: column; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--night); color: var(--night-text); padding: 14px 10px; display: flex; flex-direction: column; gap: 6px; }
.tile small { font-size: var(--fs-xs); color: var(--night-muted); line-height: 1.35; }
.tile b { font-family: var(--f-title); font-weight: 400; font-size: var(--fs-lg); line-height: 1; color: var(--gold); }
.n-map { margin-top: 40px; background: var(--night); padding: 20px 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.n-map canvas { display: block; width: 100%; }
.n-map span { font-size: var(--fs-xs); color: var(--night-muted); }
.fact { margin: 16px 0 0; font-size: var(--fs-sm); line-height: 1.85; }
.fact b { font-weight: 900; }
.vs-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr); align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.vs-row.h { font-size: var(--fs-xs); color: var(--muted); padding-bottom: 6px; }
.vs-row.d { padding: 12px 0; border-top: 1px solid var(--rule); }
.vs-row .me { font-weight: 900; font-size: var(--fs-sm); }
.vs-row .lab { text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.vs-row .ot { text-align: right; font-size: var(--fs-sm); color: var(--ink-2); }
.vs-row.h .ot { font-size: var(--fs-xs); color: var(--muted); }
.vs-t .vs { color: var(--muted); }
.peer { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); }
.peer .av {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: var(--fs-sm);
}
.peer b { display: block; font-weight: 900; font-size: var(--fs-sm); }
.peer span { font-size: var(--fs-xs); color: var(--ink-2); }
.peer-note { margin: 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: var(--fs-xs); line-height: 1.7; color: var(--ink-2); }

/* ==========================================================================
   出生卡弹层
   ========================================================================== */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(64px + var(--safe-top)); max-width: 430px; margin: 0 auto;
  background: var(--paper); border-top: 2px solid var(--ink);
  display: flex; flex-direction: column; padding: 0 15px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto; animation: slideUp .32s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet-h { height: 58px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 5px; }
.sheet-h b { font-family: var(--f-title); font-weight: 400; font-size: var(--fs-lg); }
.x { width: 44px; height: 44px; border: 2px solid var(--ink); background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.preview { display: flex; justify-content: center; padding: 4px 6px 6px 0; }
.preview canvas { width: min(360px, 100%); height: auto; display: block; box-shadow: 6px 6px 0 var(--ink); }
.sheet .btn.primary { margin-top: 24px; flex-shrink: 0; font-size: var(--fs-md); letter-spacing: 2px; }
.hint { margin: 12px 0 0; text-align: center; font-size: var(--fs-xs); color: var(--muted); }

.save-layer { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.save-layer .scrim { background: rgba(14, 13, 20, .9); }
.save-layer img { position: relative; width: min(330px, 100%); height: auto; border: 2px solid var(--ink); }
.save-layer p { position: relative; margin: 0; color: var(--night-text); font-size: var(--fs-sm); }
.save-layer .btn { position: relative; height: 48px; padding: 0 28px; color: var(--night-text); border-color: var(--night-text); }

/* ==========================================================================
   页脚弹窗：卡通风（粗墨线 + 硬投影 + 对话气泡）
   ========================================================================== */
.modal-layer { display: flex; align-items: center; justify-content: center; padding: calc(20px + var(--safe-top)) 16px 20px; }
.modal {
  position: relative; width: min(380px, 100%); max-height: 82dvh; overflow-y: auto;
  background: var(--paper-3); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
  animation: modalIn .28s cubic-bezier(.2, .9, .3, 1.25) both;
}
.modal-h {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 14px 12px 18px; background: var(--paper-3); border-bottom: 2px solid var(--ink);
}
.modal-h b { font-family: var(--f-title); font-weight: 400; font-size: var(--fs-lg); }
.modal-who { display: flex; align-items: center; gap: 12px; }
.modal-who .modal-baby { width: 56px; height: 56px; border: 2px solid var(--ink); background: var(--night); image-rendering: pixelated; }
.modal .x:focus { outline: none; }
.modal .x:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.modal-b { padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-b p { margin: 0; font-size: var(--fs-sm); line-height: 1.8; }
.modal-b h3 { margin: 6px 0 0; font-size: var(--fs-sm); font-weight: 900; }
.bubble-p {
  position: relative; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 14px;
}
.bubble-p::before {
  content: ''; position: absolute; left: 22px; top: -11px; width: 16px; height: 16px;
  background: var(--paper); border-left: 2px solid var(--ink); border-top: 2px solid var(--ink); transform: rotate(45deg);
}
.mail b { font-size: var(--fs-md); font-weight: 900; word-break: break-all; user-select: all; -webkit-user-select: all; }
.note { color: var(--ink-2); }
.src-list, .hot-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.src-list li { font-size: var(--fs-sm); line-height: 1.7; padding: 8px 0 8px 16px; border-top: 1px solid var(--rule); position: relative; }
.src-list li:first-child { border-top: 0; padding-top: 0; }
.src-list li:first-child::before { top: 9px; }
.src-list li::before { content: ''; position: absolute; left: 2px; top: 17px; width: 6px; height: 6px; background: var(--ink); }
.hot-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.hot-list span { font-size: var(--fs-sm); line-height: 1.5; }
.hot-list b { font-size: var(--fs-md); font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
/* 心理援助：暖色气泡 + 暖色号码牌，不用冷冰冰的黑底 */
.bubble-p.warm { background: #FCE3A8; }
.bubble-p.warm::before { background: #FCE3A8; }
#helpLayer .hot-list li { border-top: 0; padding: 6px 0; }
#helpLayer .hot-list b { background: #FFF1CF; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 10px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-size: var(--fs-sm); white-space: nowrap; animation: pop .2s ease-out;
}

/* ==========================================================================
   开局称号 · 稀有出生 · 通知书底纹
   ========================================================================== */
/* 通知书底色：两组同心圆细线交叠的淡防伪纹 */
#notice {
  background-color: var(--paper);
  background-image:
    repeating-radial-gradient(circle at 0% 0%, rgba(120, 100, 60, 0) 0 22px, rgba(120, 100, 60, .07) 22px 23px),
    repeating-radial-gradient(circle at 100% 35%, rgba(120, 100, 60, 0) 0 22px, rgba(120, 100, 60, .05) 22px 23px);
}
.n-title {
  margin-top: 6px; align-self: flex-start;
  background: var(--ink); color: var(--gold); font-weight: 900; font-size: var(--fs-xs); line-height: 1;
  padding: 6px 16px 6px 10px; clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%);
}
.rare-banner {
  margin-top: 16px; background: var(--gold); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.rare-banner div { display: flex; flex-direction: column; gap: 2px; }
.rare-banner b { font-weight: 900; font-size: var(--fs-sm); }
.rare-banner small { font-size: var(--fs-xs); color: #3A3122; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.card .f b { font-size: var(--fs-sm); }

/* 抽签定格：稀有出生 */
.ding.rare { border-color: var(--gold); background: var(--gold); color: var(--ink); box-shadow: 0 0 0 4px rgba(245, 184, 61, .25); }
.roll-rare { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rare-tag {
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink); box-shadow: 4px 4px 0 #000;
  padding: 8px 16px; font-weight: 900; font-size: var(--fs-sm); animation: pop .3s ease-out;
}
.rare-combo { font-size: var(--fs-xs); color: var(--night-muted); }
/* 极稀有 / 传说：金色粒子散开一次；传说再加一次全屏金色闪光 */
.roll-fx { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.roll-fx i {
  position: absolute; width: 8px; height: 8px; margin: -4px; background: var(--gold); border-radius: 50%;
  animation: burst 1.1s cubic-bezier(.2, .8, .3, 1) both;
}
.roll-fx .flash { position: fixed; inset: 0; background: var(--gold); animation: flash .9s ease-out both; }

/* ---------- keyframes ---------- */
@keyframes burst { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.4); } }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, calc(-100% - 6px)) scale(.92); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes print { from { opacity: 0; transform: translateY(40px) rotate(-2deg); } to { opacity: 1; transform: none; } }
@keyframes tick { from { opacity: .35; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes settle { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes thump { 0% { opacity: 0; transform: rotate(-14deg) scale(2.4); } 70% { opacity: 1; transform: rotate(-14deg) scale(.92); } 100% { opacity: 1; transform: rotate(-14deg) scale(1); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.toast { animation-name: toastIn; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 系统开启「减弱动态效果」：保留淡入和颜色变化，去掉位移、缩放和循环 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition: none !important; }
}

/* ==========================================================================
   桌面端手机外壳（≥768px）。原创的通用手机造型：深色圆角边框 + 顶部药丸挖孔。
   手机上外壳完全不生效（display: contents），布局与原来一致。
   ========================================================================== */
#device, .d-screen { display: contents; }
.d-status { display: none; }

@media (min-width: 768px) {
  body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden;
    background: radial-gradient(circle at 50% 35%, #2A2738 0%, #15131D 70%);
  }
  #device {
    display: block; position: relative; flex-shrink: 0; width: 414px; height: 868px; padding: 12px;
    border-radius: 56px; background: #0E0D14;
    box-shadow: 0 0 0 2px #2E2B3D, 0 0 0 4px #0E0D14, 0 30px 80px rgba(0, 0, 0, .55);
    transform: scale(var(--dev-s, 1)); transform-origin: center center;
  }
  /* 机身侧键（装饰） */
  #device::before, #device::after { content: ''; position: absolute; width: 4px; border-radius: 2px; background: #2E2B3D; }
  #device::before { left: -6px; top: 180px; height: 64px; }
  #device::after { right: -6px; top: 220px; height: 96px; }
  :root { --safe-top: 44px; }
  .d-screen {
    display: block; position: relative; width: 390px; height: 844px;
    border-radius: 44px; overflow: hidden; background: var(--night);
    transform: translateZ(0); /* 让 position: fixed 的元素以屏幕区为准 */
  }
  /* 沉浸式：不单独占一条状态栏，药丸挖孔作为浮层叠在最上层，各页面顶部背景延伸到挖孔后面 */
  .d-status { display: block; position: absolute; top: 0; left: 0; right: 0; height: 44px; z-index: 100; pointer-events: none; background: transparent; }
  .d-island { position: absolute; left: 50%; top: 11px; width: 112px; height: 30px; margin-left: -56px; border-radius: 15px; background: #000; }
  /* 整屏滚动；禁止回弹，否则滚到顶继续下拉会露出 #app 的纸色底，形成挖孔下方的色差条 */
  #app {
    height: 100%; min-height: 0; max-width: none; margin: 0;
    overflow-x: hidden; overflow-y: auto; scrollbar-width: none; overscroll-behavior: none;
  }
  #app::-webkit-scrollbar { display: none; }
  .roll { max-width: none; }
  .sheet { max-width: none; }
  .cta-float { width: 100%; }
}
