/* 紅包公道伯 v3：復古中式印刷 —— 火柴盒標籤、藏書票、錯位套色與紙紋 */
:root {
  --ink: #2b1d16;
  --paper: #f6edd8;
  --cream: #fbf3df;
  --ver: #d8432b;      /* 朱紅 */
  --ver-dark: #a82e1c;
  --jade: #1d8a5c;     /* 翠綠 */
  --jade-dark: #0f5c3b;
  --teal: #2a9d96;
  --yel: #f0b928;      /* 芥末黃 */
  --yel-light: #f6d97a;
  --muted: #6b5644;
  --serif: "Noto Serif TC", "Songti TC", serif;
  --hand: "LXGW WenKai TC", "PingFang TC", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.17  0 0 0 0 0.11  0 0 0 0 0.08  0 0 0 1.4 -0.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #11291d;
  color: var(--ink);
  font-family: var(--hand);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ver); }
[hidden] { display: none !important; }

.app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--jade);
  box-shadow: 0 0 60px rgba(0, 0, 0, .6);
}
/* 紙紋顆粒，蓋在所有東西上 */
.app::after {
  content: ""; position: absolute; inset: 0; z-index: 40; pointer-events: none;
  background-image: var(--grain); opacity: .5; mix-blend-mode: multiply;
}

/* ───── 錯位套色的兩個版 ───── */
.plate-fill {
  --nl: none; --kf: none;
  stroke: none;
  transform: translate(3px, 2.2px);
}
.plate-line {
  stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round;
}
.y  { fill: var(--nf, var(--yel)); }
.y2 { fill: var(--nf, var(--yel-light)); }
.r  { fill: var(--nf, var(--ver)); }
.t  { fill: var(--nf, var(--teal)); }
.c  { fill: var(--nf, var(--cream)); }
.o  { fill: var(--nf, #a5652e); }
.o2 { fill: var(--nf, #f3c85e); }
.p  { fill: var(--nf, #ef8c74); }
.k  { fill: var(--kf, var(--ink)); }
.sw { fill: var(--cream); }
.sy { fill: var(--yel); }
.sr { fill: var(--ver); }
.sp { fill: #ef8c74; }
.ln { fill: none; stroke: var(--nl, var(--ink)); }
.thin { stroke-width: 1.6; }
.wl { fill: none; stroke: var(--nl, var(--cream)); stroke-width: 1.4; }
.nost { stroke: none; }
.lantern-word { font-family: var(--serif); font-weight: 900; font-size: 25px; }
.vtext { font-family: var(--serif); font-weight: 900; font-size: 19px; }
.couplet-word { fill: var(--kf, var(--ink)); font-family: var(--serif); font-weight: 900; font-size: 20px; }
.moon-cloud { animation: drift 9s ease-in-out infinite; }
@keyframes drift { 50% { transform: translateX(8px); } }
.seal-word { fill: var(--cream); font-family: var(--serif); font-weight: 900; font-size: 13px; }

/* ───── 頂部 ───── */
.topbar {
  position: absolute; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 14px 8px;
  transition: background .3s;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name {
  /* 橫批式招牌 */
  padding: 4px 14px 5px; background: var(--ver); border: 2.5px solid var(--ink); border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--ver), inset 0 0 0 3.5px var(--yel), 3px 3px 0 var(--ink);
  font-family: var(--serif); font-weight: 900; font-size: 18px; letter-spacing: 4px; color: var(--yel);
}
.seal-mini {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: var(--ver); color: var(--cream); border: 2px solid var(--ink); border-radius: 4px;
  font-family: var(--serif); font-weight: 900; font-size: 11px; line-height: 1; writing-mode: vertical-rl; letter-spacing: 1px;
  box-shadow: inset 0 0 0 2px var(--ver), inset 0 0 0 3px var(--cream);
}
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 6px;
  border: 2px solid var(--ink); background: var(--cream); box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--serif); font-weight: 900; font-size: 15px;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.app.scrolled .topbar { background: var(--jade-dark); }

/* ───── 對話場景 ───── */
.stage { position: relative; flex: 1 1 auto; min-height: 220px; overflow: hidden; }
.stage::before {
  /* 角落雲紋點綴 */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background:
    radial-gradient(circle at 8% 30%, var(--yel-light) 0 3px, transparent 4px),
    radial-gradient(circle at 92% 22%, var(--yel-light) 0 3px, transparent 4px),
    radial-gradient(circle at 14% 58%, var(--yel-light) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 52%, var(--yel-light) 0 2px, transparent 3px);
}
.scene-art { position: absolute; inset: 0; width: 100%; height: 100%; }

.gdcup { cursor: pointer; pointer-events: all; }
.steam { animation: steam 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes steam { 0%, 100% { opacity: .3; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-3px); } }
.scene-art { transition: none; }
.lantern { animation: swing 3.4s ease-in-out infinite; transform-box: view-box; }
.l1 { transform-origin: 98px 100px; }
.l2 { transform-origin: 262px 100px; animation-delay: -1.7s; }
@keyframes swing { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

.sage-head { animation: nod 6s ease-in-out infinite; transform-box: view-box; transform-origin: 180px 186px; }
.beard { animation: nod 6s ease-in-out infinite; transform-box: view-box; transform-origin: 180px 186px; }
.eyes { animation: blink 4.6s infinite; transform-box: view-box; transform-origin: 180px 159px; }
.happy { display: none; }
.mouth { transform-box: fill-box; transform-origin: center; transform: scaleY(.15); }
.sage.talking .mouth { animation: talk .24s ease-in-out infinite alternate; }
.sage.talking .mustache { animation: stache .24s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.sage.thinking .sage-head, .sage.thinking .beard { animation: ponder 1.3s ease-in-out infinite; }
.sage.is-happy .eyes { display: none; }
.sage.is-happy .happy { display: inline; }
.lapcat { animation: purr 2.4s ease-in-out infinite; transform-box: view-box; transform-origin: 184px 304px; }
.cat-tail { animation: wag 1.8s ease-in-out infinite; transform-box: view-box; transform-origin: 156px 302px; }
.cat-eyes { animation: blink 3.8s infinite; animation-delay: -1.2s; transform-box: view-box; transform-origin: 208px 257px; }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(1.4deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes talk { from { transform: scaleY(.15); } to { transform: scaleY(1.1); } }
@keyframes stache { to { transform: translateY(-1.2px) scaleX(1.05); } }
@keyframes ponder { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
@keyframes purr { 50% { transform: scale(1.015, .985); } }
@keyframes wag { 50% { transform: rotate(10deg); } }

/* ───── 對話框 ───── */
.dialog {
  position: relative; z-index: 3; flex: 0 0 auto;
  padding: 0 14px calc(12px + var(--safe-b));
  background: var(--jade);
  max-height: 64dvh; display: flex; flex-direction: column;
}
.dialog::before {
  /* 回紋飾帶 */
  content: ""; display: block; height: 12px; margin: 0 -14px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cpath d='M1 11 V1 H11 V8 H5 V5 H8' fill='none' stroke='%23f0b928' stroke-width='1.6'/%3E%3Cpath d='M13 11 V1 H23 V8 H17 V5 H20' fill='none' stroke='%23f0b928' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x center / 24px 12px,
    var(--ver);
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
}
.echo {
  align-self: flex-end; margin: 8px 2px 0; padding: 3px 12px;
  border-radius: 4px; background: var(--yel-light); border: 2px solid var(--ink);
  font-size: 14px; color: var(--ink); max-width: 85%;
  animation: pop .25s ease-out;
}
.box {
  position: relative; margin-top: 20px;
  padding: 22px 18px 18px; min-height: 108px;
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5.5px var(--ver), 4px 4px 0 var(--jade-dark);
  cursor: pointer;
}
.nameplate {
  position: absolute; top: -18px; left: 12px;
  padding: 2px 14px 3px; border-radius: 3px;
  background: var(--ver); color: var(--cream); border: 2.5px solid var(--ink);
  font-family: var(--serif); font-weight: 900; letter-spacing: 5px; font-size: 16px;
  box-shadow: 2px 2px 0 var(--ink);
}
.line { margin: 0; font-size: 18px; line-height: 1.7; min-height: 3.4em; white-space: pre-wrap; }
.more { position: absolute; right: 16px; bottom: 8px; color: var(--ver); font-size: 13px; animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(3px); } }

.choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; margin-top: 14px; overflow-y: auto; padding: 2px 6px 6px 2px; -webkit-overflow-scrolling: touch; }
.choices.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.choice {
  position: relative; width: 100%;
  padding: 10px 14px 10px 38px; text-align: left;
  border: 2px solid var(--ink); border-radius: 6px;
  background: var(--paper); font-size: 16px; line-height: 1.35;
  box-shadow: 3px 3px 0 var(--ink);
  animation: pop .25s ease-out both;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.choice::before {
  /* 銅錢 */
  content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border: 2px solid var(--ink); border-radius: 50%;
  background: linear-gradient(var(--ink), var(--ink)) center / 5px 5px no-repeat, var(--yel);
}
.choice small { display: block; color: var(--muted); font-size: 13px; }
.choice:hover { background: #fffaf0; }
.choice:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.choice.primary { background: var(--ver); color: var(--cream); }
.choice.primary small { color: var(--cream); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.input-row { display: flex; gap: 8px; min-width: 0; }
.input-row .choice { flex: 0 0 auto; white-space: nowrap; }
.input-row input, .input-row textarea {
  flex: 1; min-width: 0; padding: 10px 12px;
  border: 2px solid var(--ink); border-radius: 6px; background: #fffaf0;
  font: inherit; font-size: 16px; color: var(--ink);
}
.input-row textarea { resize: none; height: 64px; width: 100%; }
.input-row input:focus, .input-row textarea:focus { outline: 3px solid var(--yel); outline-offset: 1px; }
.input-row .choice { width: auto; padding-left: 16px; }
.input-row .choice::before { display: none; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick .choice { padding: 8px 6px; text-align: center; font-size: 15px; }
.quick .choice::before { display: none; }

.dialog-foot { display: flex; justify-content: space-between; align-items: center; min-height: 24px; margin-top: 6px; }
.link-btn { background: none; border: 0; color: var(--cream); font-size: 14px; padding: 4px 0; font-weight: 700; text-shadow: 1px 1px 0 var(--ink); }
.ai-badge { font-size: 12px; color: var(--cream); opacity: .85; }

/* ───── 秤人情 ───── */
.verdict { position: absolute; inset: 0; z-index: 5; overflow-y: auto; overflow-x: hidden; background: var(--paper); animation: fadein .35s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.v-stage { position: relative; height: 100dvh; min-height: 580px; overflow: hidden; background: var(--teal); }
.v-stage::after {
  /* 標籤外框 */
  content: ""; position: absolute; inset: 7px; z-index: 12; pointer-events: none;
  border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 0 0 0 7px var(--cream), 0 0 0 9px var(--ink), inset 0 0 0 4px var(--cream), inset 0 0 0 6px var(--ink);
}
.v-rays {
  position: absolute; left: 50%; top: 66%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(from 0deg, var(--yel-light) 0 6deg, var(--yel) 6deg 12deg);
  animation: spin 60s linear infinite; opacity: .95;
}
.v-rays::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, transparent 12%, rgba(42, 157, 150, .55) 26%, rgba(42, 157, 150, .95) 34%);
}
@keyframes spin { to { transform: rotate(360deg); } }
.v-floor {
  position: absolute; left: -15%; right: -15%; bottom: -14%; height: 42%;
  background: var(--jade); border-top: 3px solid var(--ink); border-radius: 50% 50% 0 0 / 34% 34% 0 0;
}
.v-title.gone { opacity: 0; transform: translate(-50%, -10px); }
.v-title {
  position: absolute; left: 50%; top: calc(66px + var(--safe-t)); transform: translateX(-50%); z-index: 8;
  padding: 4px 22px 5px; background: var(--ver); color: var(--cream); white-space: nowrap;
  border: 2.5px solid var(--ink); font-family: var(--serif); font-weight: 900; font-size: 18px; letter-spacing: 5px;
  box-shadow: 3px 3px 0 var(--ink);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%);
  transition: opacity .4s, transform .4s;
}
.v-status {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; z-index: 8;
  color: var(--cream); font-family: var(--serif); font-weight: 900; font-size: 21px; letter-spacing: 3px;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink);
  transition: opacity .3s;
}
.v-status .dots i { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: var(--cream); border: 2px solid var(--ink); animation: dot 1.2s infinite; }
.v-status .dots i:nth-child(2) { animation-delay: .2s; }
.v-status .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.scale-box { position: absolute; left: 50%; bottom: 17%; width: 150px; margin-left: -75px; z-index: 3; }
.scale { display: block; width: 100%; overflow: visible; }
.ink { stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.dial-brand { font-family: var(--serif); font-size: 13px; font-weight: 900; fill: var(--ver); }
.tick-label { font-family: var(--serif); font-size: 10px; font-weight: 900; fill: var(--ink); }
.needle { transform-origin: 100px 140px; transform: rotate(-150deg); }
.needle.jitter { transition: transform .12s ease-out; }
.essence {
  position: absolute; left: 50%; top: 2px; width: 130px; height: 130px; margin: -65px 0 0 -65px;
  border-radius: 50%; pointer-events: none; z-index: 4;
  background: radial-gradient(circle, #fff3c4 0%, var(--yel) 22%, rgba(216, 67, 43, .9) 46%, rgba(216, 67, 43, 0) 70%);
  animation: essence 1.1s ease-in-out infinite;
}
.essence.charge { animation: charge .6s ease-in forwards; }
.essence.spent { animation: none; opacity: .3; transform: scale(.7); transition: opacity .6s, transform .6s; }
@keyframes essence { 0%, 100% { transform: scale(.72); opacity: .8; } 50% { transform: scale(1.05); opacity: 1; } }
@keyframes charge { to { transform: scale(2); opacity: 1; } }

.ring { position: absolute; inset: 0; pointer-events: none; }
.cat { position: absolute; left: 0; top: 0; width: 84px; height: 97px; margin: -94px 0 0 -42px; will-change: transform; }
.cat svg { width: 100%; height: 100%; overflow: visible; display: block; }
.cat .bob { animation: bob .6s ease-in-out infinite alternate; transform-box: view-box; transform-origin: 0px 78px; }
.cat .arm-l { transform-box: view-box; transform-origin: -20px 2px; animation: armL .6s ease-in-out infinite alternate; }
.cat .arm-r { transform-box: view-box; transform-origin: 30px 2px; animation: armR .6s ease-in-out infinite alternate; }
.cat .leg-l { transform-box: view-box; transform-origin: -14px 50px; animation: legL .6s ease-in-out infinite alternate; }
.cat .leg-r { transform-box: view-box; transform-origin: 14px 52px; animation: legR .6s ease-in-out infinite alternate; }
.cat .tail { transform-box: view-box; transform-origin: 26px 40px; animation: tailw .9s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0) rotate(-5deg); } to { transform: translateY(-7px) rotate(5deg); } }
@keyframes armL { from { transform: rotate(-35deg); } to { transform: rotate(35deg); } }
@keyframes armR { from { transform: rotate(-35deg); } to { transform: rotate(35deg); } }
@keyframes legL { from { transform: rotate(-12deg); } to { transform: rotate(14deg); } }
@keyframes legR { from { transform: rotate(14deg); } to { transform: rotate(-12deg); } }
@keyframes tailw { from { transform: rotate(-16deg); } to { transform: rotate(18deg); } }
.cat.sleeping { width: 104px; height: 60px; margin: -56px 0 0 -52px; }
.cat.sleeping .sleep-body { transform-box: view-box; transform-origin: 94px 92px; animation: snooze 2.8s ease-in-out infinite; }
.cat.sleeping .sleep-tail { transform-box: view-box; transform-origin: 156px 62px; animation: tailw 3.2s ease-in-out infinite alternate; }
.cat.sleeping .z { animation: zfloat 2.4s ease-in-out infinite; opacity: 0; }
@keyframes snooze { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, 1.05); } }
@keyframes zfloat { 0% { opacity: 0; transform: translate(0, 6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(-8px, -14px); } }
.ring.cheer .arm-l { animation: cheerL .35s ease-in-out infinite alternate; }
.ring.cheer .arm-r { animation: cheerR .35s ease-in-out infinite alternate; }
.ring.cheer .bob { animation-duration: .35s; }
@keyframes cheerL { from { transform: rotate(10deg); } to { transform: rotate(30deg); } }
@keyframes cheerR { from { transform: rotate(-10deg); } to { transform: rotate(-30deg); } }

.flyer { position: absolute; left: 50%; top: 21%; width: 104px; height: 130px; margin-left: -52px; z-index: 7; opacity: 0; pointer-events: none; }
.pocket { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(4px 4px 0 var(--ink)); }
.pocket-word { font-family: var(--serif); font-size: 52px; font-weight: 900; fill: var(--yel); }
.bills { position: absolute; left: 6px; right: 6px; top: 16px; height: 60px; }
.bill {
  position: absolute; left: 50%; top: 0; width: 96px; height: 50px; margin-left: -48px;
  border: 2px solid var(--ink); border-radius: 3px; background: #9fd0c6;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55), inset 0 0 0 4.5px rgba(43, 29, 22, .55);
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px;
  font-family: var(--serif); font-weight: 900; font-size: 13px; transform-origin: 50% 100%;
}
.bill::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; border: 1.5px solid rgba(43, 29, 22, .6);
  background: linear-gradient(rgba(43, 29, 22, .6), rgba(43, 29, 22, .6)) center / 6px 6px no-repeat, rgba(255, 255, 255, .5);
}
.bill small { font-size: 9px; writing-mode: vertical-rl; letter-spacing: 1px; }
.bill.d500 { background: #e9bd78; }
.bill.d100 { background: #f0a28c; }
.bills .more-chip {
  position: absolute; right: -22px; top: -58px; z-index: 2;
  background: var(--yel); border: 2px solid var(--ink); border-radius: 3px;
  padding: 1px 8px; font-size: 13px; font-weight: 900; font-family: var(--serif); opacity: 0;
}
.burst {
  position: absolute; left: 50%; top: 0; width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border-radius: 50%; z-index: 6; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, #fff7d6, var(--yel) 35%, rgba(216, 67, 43, .75) 60%, rgba(216, 67, 43, 0) 72%);
}

.announce { position: absolute; left: 0; right: 0; top: calc(21% + 140px); text-align: center; z-index: 8; opacity: 0; transform: scale(.4); }
.announce.on { animation: announce .5s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes announce { to { opacity: 1; transform: scale(1); } }
.announce-amount {
  font-family: var(--serif); font-weight: 900; font-size: 62px; line-height: 1; color: var(--cream); letter-spacing: 1px;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 6px 6px 0 var(--ver);
}
.announce-amount small { font-size: 24px; margin-left: 4px; }
.announce-meaning {
  display: inline-block; margin-top: 10px; padding: 3px 18px 4px; background: var(--yel);
  border: 2px solid var(--ink); font-family: var(--serif); font-weight: 900; font-size: 16px; letter-spacing: 2px;
  box-shadow: 3px 3px 0 var(--ink);
  clip-path: polygon(0 0, 100% 0, 95% 50%, 100% 100%, 0 100%, 5% 50%);
}
.scroll-hint {
  position: absolute; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 13;
  padding: 7px 18px; border-radius: 4px; border: 2px solid var(--ink);
  background: var(--cream); box-shadow: 3px 3px 0 var(--ink); font-family: var(--serif); font-weight: 900; font-size: 15px;
  animation: hint 1.2s ease-in-out infinite;
}
@keyframes hint { 50% { transform: translate(-50%, 4px); } }
.confetti { position: absolute; top: -20px; z-index: 11; pointer-events: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ink); background: linear-gradient(var(--ink), var(--ink)) center / 4px 4px no-repeat, var(--yel);
  animation: drop linear forwards; }
.confetti.env { width: 12px; height: 16px; border-radius: 2px; background: var(--ver); }
@keyframes drop { to { transform: translate(var(--dx, 0), 110dvh) rotate(var(--rot, 360deg)); } }

/* ───── 判決書 ───── */
.v-body { position: relative; padding: 22px 16px calc(28px + var(--safe-b)); background: var(--paper); }
.decree {
  position: relative; padding: 16px 18px 14px; background: #fffaf0;
  border: 6px double var(--ink); box-shadow: 4px 4px 0 var(--jade-dark);
}
.decree-head { display: flex; align-items: center; justify-content: space-between; }
.decree-title { font-family: var(--serif); font-weight: 900; font-size: 24px; letter-spacing: 4px; color: var(--ver); }
.seal-big {
  display: inline-grid; place-items: center; width: 54px; height: 54px; transform: rotate(-8deg);
  background: var(--ver); color: var(--cream); border-radius: 4px; text-align: center;
  font-family: var(--serif); font-weight: 900; font-size: 15px; line-height: 1.15; letter-spacing: 2px;
  box-shadow: inset 0 0 0 3px var(--ver), inset 0 0 0 4.5px var(--cream);
  opacity: .92;
}
.case-title { margin: 8px 0 0; font-size: 16px; font-weight: 700; }
.range { color: var(--muted); font-size: 14px; margin-top: 2px; }
.decree-text { margin: 12px 0 0; padding-top: 12px; border-top: 1.5px dashed var(--muted); font-size: 18px; line-height: 1.8; min-height: 2em; }
.decree-sign { text-align: right; color: var(--muted); margin-top: 6px; font-size: 14px; }
.card { margin-top: 16px; padding: 14px 16px; background: #fffaf0; border: 2px solid var(--ink); border-radius: 4px; box-shadow: 3px 3px 0 var(--ink); }
.card h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 900; font-size: 17px; letter-spacing: 3px; color: var(--jade-dark); }
.card h3::before { content: "◆"; color: var(--ver); font-size: 12px; margin-right: 6px; vertical-align: 2px; }
.weights, .tips { list-style: none; margin: 0; padding: 0; }
.weights li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1.5px dashed #d8c9a6; font-size: 15px; }
.weights li:last-child { border-bottom: 0; }
.weights li::before {
  content: ""; flex: 0 0 auto; width: 15px; height: 17px; margin-right: -4px; background: var(--ink);
  clip-path: polygon(30% 0, 70% 0, 70% 20%, 100% 100%, 0 100%, 30% 20%);
}
.weights .w-label { flex: 1; }
.weights .w-effect { color: var(--ver); font-weight: 700; white-space: nowrap; }
.tips li { position: relative; padding: 4px 0 4px 20px; font-size: 15px; line-height: 1.6; }
.tips li::before { content: ""; position: absolute; left: 0; top: 9px; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink);
  background: linear-gradient(var(--ink), var(--ink)) center / 3px 3px no-repeat, var(--yel); }
.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; flex: 1; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); font: inherit; font-size: 16px; color: var(--ink); }
.field-row, .btn-row { display: flex; gap: 10px; }
.btn { flex: 1; padding: 11px 10px; border-radius: 4px; border: 2px solid var(--ink); background: var(--paper); font-family: var(--serif); font-weight: 900; font-size: 16px; letter-spacing: 1px; box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn.primary { background: var(--ver); color: var(--cream); }
.actions { margin-top: 20px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }

/* ───── 抽屜 ───── */
.sheet-backdrop { position: absolute; inset: 0; z-index: 18; background: rgba(17, 41, 29, .55); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 19; max-height: 78%; overflow-y: auto;
  padding: 16px 16px calc(20px + var(--safe-b)); background: var(--paper);
  border-top: 3px solid var(--ink); border-radius: 10px 10px 0 0; animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 21px; letter-spacing: 3px; color: var(--ver); }
.about p { line-height: 1.75; font-size: 15px; }
.about-h { margin: 16px 0 6px; font-family: var(--serif); font-weight: 900; font-size: 17px; color: var(--jade-dark); letter-spacing: 2px; }
.quotes { list-style: none; margin: 0; padding: 0; }
.quotes li { padding: 10px 0 10px 14px; border-left: 3px solid var(--ver); margin: 8px 0; background: #fffaf0; }
.quotes q { display: block; font-family: var(--serif); font-weight: 900; font-size: 16px; line-height: 1.6; quotes: "「" "」"; }
.quotes cite { display: block; font-style: normal; font-size: 13px; color: var(--ver); margin: 2px 0 4px; }
.quotes span { display: block; font-size: 14px; line-height: 1.65; color: var(--muted); padding-right: 8px; }
.about code { background: #efe3c4; padding: 1px 6px; border-radius: 3px; }
.history { list-style: none; padding: 0; margin: 12px 0 0; }
.history li { border-bottom: 1.5px dashed #d8c9a6; }
.history button { width: 100%; padding: 12px 4px; background: none; border: 0; text-align: left; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.history .h-amt { color: var(--ver); font-family: var(--serif); font-weight: 900; white-space: nowrap; font-size: 18px; }
.history .h-sub { display: block; font-size: 13px; color: var(--muted); }
.history .empty { padding: 20px 0; color: var(--muted); text-align: center; }

/* 開場：登入或直接問 */
.welcome { position: absolute; inset: 0; z-index: 15; display: grid; place-items: end center; padding: 0 16px calc(28px + var(--safe-b)); background: linear-gradient(transparent 35%, rgba(17, 41, 29, .78)); animation: fadein .4s ease-out; }
.welcome-card { width: 100%; padding: 18px 18px 14px; background: var(--paper); border: 3px solid var(--ink); border-radius: 6px; box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5.5px var(--ver), 4px 4px 0 var(--jade-dark); }
.welcome-title { font-family: var(--serif); font-weight: 900; font-size: 26px; letter-spacing: 6px; color: var(--ver); text-align: center; }
.welcome-sub { text-align: center; margin: 6px 0 14px; font-size: 16px; line-height: 1.6; }
.welcome-card .btn.wide + .hint { margin: 6px 0 12px; text-align: center; }
.welcome-card .hint:last-child { text-align: center; margin-bottom: 0; }

/* 紅包簿 */
.record-card .btn.wide { margin-top: 8px; }
.btn[disabled] { opacity: .65; box-shadow: none; transform: none; }
.record-summary { margin: 12px 0; padding: 10px 12px; background: var(--yel-light); border: 2px solid var(--ink); border-radius: 4px; font-weight: 700; font-size: 15px; }
.ledger-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.ledger-sum div { padding: 8px 12px; background: var(--ver); color: var(--cream); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 2px 2px 0 var(--ink); }
.ledger-sum small { display: block; font-size: 12px; opacity: .85; }
.ledger-sum b { display: block; font-family: var(--serif); font-weight: 900; font-size: 20px; }
.ledger { list-style: none; padding: 0; margin: 10px 0 0; }
.ledger li { border-bottom: 1.5px dashed #d8c9a6; }
.ledger .empty { padding: 20px 0; color: var(--muted); text-align: center; line-height: 1.6; }
.lg-head { width: 100%; display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 10px 2px; background: none; border: 0; text-align: left; }
.lg-date { text-align: center; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 3px; padding: 3px 0; }
.lg-date.nodate { border-style: dashed; color: var(--muted); }
.lg-date b { display: block; font-family: var(--serif); font-weight: 900; font-size: 15px; }
.lg-date small, .lg-main small { display: block; font-size: 11px; color: var(--muted); }
.lg-main b { display: block; font-size: 16px; }
.lg-main small { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.lg-amt { font-family: var(--serif); font-weight: 900; font-size: 18px; color: var(--ver); white-space: nowrap; }
.lg-amt::after { content: " 元"; font-size: 12px; }
.lg-detail { padding: 0 2px 12px 62px; }
.lg-detail p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.lg-del { padding: 6px 12px; font-size: 13px; flex: none; }

/* 帳號 */
.about-p { line-height: 1.7; font-size: 15px; }
a.btn { display: block; text-align: center; text-decoration: none; color: inherit; }
a.btn.primary { color: var(--cream); }
.link-btn-block { margin-top: 6px; }
.account-card { display: flex; gap: 12px; align-items: center; margin: 14px 0 6px; padding: 12px; background: #fffaf0; border: 2px solid var(--ink); border-radius: 4px; }
.account-card img { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; background: var(--yel-light); }
.account-card b { display: block; font-size: 17px; }
.merge-box { margin-top: 12px; padding: 12px; background: var(--yel-light); border: 2px solid var(--ink); border-radius: 4px; }
.merge-box p { margin: 0 0 8px; font-size: 15px; line-height: 1.6; }
.account-actions { margin-top: 12px; }
.toast {
  position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 25;
  padding: 8px 16px; background: var(--ink); color: var(--cream); border-radius: 4px; font-size: 14px;
  box-shadow: 3px 3px 0 var(--ver); animation: pop .25s ease-out; white-space: normal; width: max-content; max-width: 88%; text-align: center; line-height: 1.5;
}

/* 分享 */
.fmt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.fmt-btn { padding: 8px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); font-family: var(--serif); font-weight: 900; font-size: 15px; }
.fmt-btn.on { background: var(--jade); color: var(--cream); box-shadow: inset 2px 2px 0 var(--jade-dark); }
.share-preview { margin: 12px 0; min-height: 120px; display: grid; place-items: center; background: #efe3c4; border: 2px solid var(--ink); border-radius: 4px; padding: 10px; }
.share-preview img { display: block; width: auto; max-width: 100%; max-height: 46dvh; height: auto; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.share-loading { margin: 0; color: var(--muted); font-size: 15px; }
.social-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.social-row .btn { padding: 9px 2px; font-size: 13px; letter-spacing: 0; }
.btn.wide { display: block; width: 100%; margin-top: 10px; }

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