/* 麻將療癒師 — 溫暖木質 × 米白 療癒風 */
:root {
  --paper: #F7F1E6;
  --paper-2: #EFE5D4;
  --paper-3: #E7DAC5;
  --card: #FFFCF6;
  --card-2: #FBF5EA;
  --ink: #3B2F25;
  --ink-soft: #6E5D4C;
  --muted: #A08F7C;
  --line: #E8DCCB;
  --line-2: #DCCBB4;
  --wood-hi: #D2AE84;
  --wood: #B88B5E;
  --wood-mid: #A27447;
  --wood-deep: #7E5636;
  --walnut: #5E3F27;
  --sage: #8FA88F;
  --jade: #5E7F66;
  --jade-deep: #46644F;
  --jade-soft: #E4ECE1;
  --honey: #C9A063;
  --honey-soft: #F3E7CF;
  --rose: #B05A4C;
  --rose-deep: #8E4236;
  --rose-soft: #F6E4DE;
  --danger: #A04A3E;
  --shadow-sm: 0 1px 2px rgba(74, 52, 30, .06), 0 2px 6px rgba(74, 52, 30, .05);
  --shadow: 0 1px 2px rgba(74, 52, 30, .05), 0 4px 10px rgba(74, 52, 30, .06), 0 12px 28px rgba(74, 52, 30, .07);
  --shadow-lg: 0 2px 4px rgba(74, 52, 30, .06), 0 12px 24px rgba(74, 52, 30, .1), 0 28px 56px rgba(74, 52, 30, .12);
  --radius: 20px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --serif: "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC", "Songti TC", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  /* textures */
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='240'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.012 .18' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 .22  0 0 0 0 .12  0 0 0 0 .05  0 0 0 .5 -.05'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --wood-bg:
    var(--grain),
    repeating-linear-gradient(91deg, rgba(255, 236, 205, .07) 0 1px, transparent 1px 6px),
    radial-gradient(120% 80% at 25% 20%, rgba(255, 228, 190, .35), transparent 60%),
    linear-gradient(160deg, #C59a6c 0%, #A97A4D 45%, #8C603B 100%);
  --linen:
    var(--noise),
    repeating-linear-gradient(0deg, rgba(120, 90, 55, .022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 90, 55, .022) 0 1px, transparent 1px 3px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; color: var(--ink); font-family: var(--sans);
  font-size: 16px; line-height: 1.55; min-height: 100%; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html { background: var(--paper); }
body { min-height: 100dvh; background: var(--linen), radial-gradient(140% 90% at 50% -10%, #FDF9F1 0%, var(--paper) 55%, #F1E8D8 100%);
  background-attachment: fixed; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, .brand, .serif { font-family: var(--serif); font-weight: 700; letter-spacing: .04em; }
#app { max-width: 28rem; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--safe-b) + 1rem);
  padding-left: var(--safe-l); padding-right: var(--safe-r); position: relative; }
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 6rem); transform: translateX(-50%);
  background: rgba(59, 47, 37, .92); color: var(--card); padding: .7rem 1.2rem; border-radius: 999px;
  font-size: .9rem; z-index: 80; max-width: 90%; box-shadow: var(--shadow-lg); letter-spacing: .04em;
  backdrop-filter: blur(8px); animation: toastIn .32s var(--spring); }
#toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- chrome ---------- */
.topbar { display: flex; align-items: center; gap: .6rem; padding: calc(var(--safe-t) + .75rem) 1rem .7rem;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(rgba(247, 241, 230, .94), rgba(247, 241, 230, .82));
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid rgba(220, 203, 180, .55); }
.topbar h1 { font-size: 1.12rem; margin: 0; flex: 1; text-align: center; letter-spacing: .1em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; min-width: 42px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-soft); background: var(--card); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  transition: transform .15s var(--ease), background .15s; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.92); background: var(--paper-2); }
.page { padding: .9rem 1.1rem 1.6rem; }
.hero + .page { padding-top: .2rem; }
.hist.page { padding-top: .2rem; }

/* ---------- home ---------- */
.hero { text-align: center; padding: calc(var(--safe-t) + 2.4rem) 1rem 1.4rem; position: relative; }
.logo-tile { width: 74px; height: 96px; margin: 0 auto 1.1rem; position: relative;
  background: linear-gradient(180deg, #FFFDF8 0%, #F6EEDF 100%);
  border-radius: 12px; display: grid; place-items: center;
  color: var(--jade); font-family: var(--serif); font-weight: 900; font-size: 2.3rem;
  box-shadow: 0 0 0 1px #E9DCC6, 0 6px 0 -1px var(--wood-mid), 0 6px 0 0 var(--wood-deep),
    0 12px 22px rgba(94, 63, 39, .28);
  transform: rotate(-5deg); animation: tileIn .7s var(--spring) both; }
.logo-tile::after { content: ""; position: absolute; inset: 6px; border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(184, 139, 94, .35); }
@keyframes tileIn { from { opacity: 0; transform: translateY(-10px) rotate(-12deg); } to { opacity: 1; transform: rotate(-5deg); } }
.hero .brand { font-size: 2rem; margin: 0; letter-spacing: .22em; color: var(--walnut); padding-left: .22em; }
.hero p { margin: .45rem 0 0; color: var(--muted); letter-spacing: .5em; font-size: .8rem; padding-left: .5em; }
.hero p::before, .hero p::after { content: ""; display: inline-block; width: 22px; height: 1px; background: var(--line-2);
  vertical-align: middle; margin: 0 .7em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 54px; padding: .7rem 1.2rem; border-radius: 16px; font-weight: 700; width: 100%;
  letter-spacing: .12em; font-size: 1rem;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), background .16s, filter .16s; }
.btn:active { transform: scale(.975); }
.btn-primary { color: #FFF8EE; text-shadow: 0 1px 0 rgba(60, 35, 15, .35);
  background: var(--grain), linear-gradient(180deg, #A97A4D 0%, #8A5E3A 100%);
  box-shadow: inset 0 1px 0 rgba(255, 230, 200, .35), inset 0 -2px 0 rgba(60, 35, 15, .25),
    0 2px 4px rgba(94, 63, 39, .18), 0 10px 22px rgba(94, 63, 39, .22); }
.btn-primary:active { filter: brightness(.94); box-shadow: inset 0 1px 0 rgba(255, 230, 200, .25), 0 4px 10px rgba(94, 63, 39, .2); }
.btn-ghost { background: var(--card); color: var(--ink-soft); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.btn-ghost:active { background: var(--paper-2); }
.btn-soft { color: #FFFCF4; background: linear-gradient(180deg, #7C9A82 0%, #5E7F66 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 2px 4px rgba(70, 100, 79, .16), 0 10px 22px rgba(70, 100, 79, .2); }
.btn-danger { background: var(--rose); color: #FFF7F3; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 8px 18px rgba(176, 90, 76, .25); }
.btn-row { display: flex; gap: .65rem; }
.btn-row .btn { flex: 1; }
.btn[disabled] { opacity: .4; pointer-events: none; filter: saturate(.5); }

.section-label { display: flex; align-items: center; gap: .6rem; font-size: .76rem; color: var(--muted);
  letter-spacing: .28em; margin: 1.6rem 0 .7rem; font-weight: 500; }
.section-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow), inset 0 0 0 1px rgba(232, 220, 203, .6); padding: 1rem 1.1rem; }
.table-card { display: block; width: 100%; text-align: left; padding: 1rem 1.1rem 1rem 1.3rem; margin-bottom: .75rem;
  background: var(--card); border-radius: var(--radius); position: relative; overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(232, 220, 203, .7);
  transition: transform .18s var(--ease), box-shadow .18s; animation: rise .45s var(--ease) both; }
.table-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--wood-bg); }
.table-card:active { transform: scale(.985); box-shadow: var(--shadow-sm); }
.table-card:nth-child(2) { animation-delay: .04s; } .table-card:nth-child(3) { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.table-card .row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.table-card h3 { margin: 0; font-size: 1.06rem; color: var(--walnut); }
.table-card .meta, .meta { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: .7rem; padding: .15rem .6rem; border-radius: 999px;
  background: var(--jade-soft); color: var(--jade-deep); font-weight: 700; letter-spacing: .1em; white-space: nowrap; }
.pill.done { background: var(--paper-2); color: var(--muted); }
.names { margin: .4rem 0 0; color: var(--ink-soft); font-size: .88rem; letter-spacing: .04em; }
.empty { text-align: center; color: var(--muted); padding: 1.8rem .8rem; font-size: .9rem; letter-spacing: .06em;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: rgba(255, 252, 246, .5); }
.foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 2rem; line-height: 1.9; letter-spacing: .05em; }
.linkish { color: var(--wood-deep); text-decoration: underline; text-decoration-color: var(--wood-hi); text-underline-offset: 3px;
  background: none; padding: 0; min-height: 0; font-weight: 500; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: .85rem; }
label.field span, .lbl { display: block; font-size: .78rem; color: var(--ink-soft); margin-bottom: .35rem; letter-spacing: .08em; }
input[type=text], input[type=number], select {
  width: 100%; min-height: 50px; padding: .55rem .9rem; border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--card); outline: none; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 2px rgba(74, 52, 30, .05); transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #BFAF9B; }
input:focus, select:focus { border-color: var(--wood); box-shadow: 0 0 0 4px rgba(184, 139, 94, .16), inset 0 1px 2px rgba(74, 52, 30, .04); }
.players-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .65rem; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.preset, .choice { min-height: 52px; border-radius: 14px; background: var(--card); font-weight: 700; letter-spacing: .06em;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); color: var(--ink-soft); font-variant-numeric: tabular-nums;
  transition: transform .15s var(--ease), background .2s, color .2s, box-shadow .2s; }
.preset:active, .choice:active { transform: scale(.97); }
.preset.on { color: #FFF8EE; text-shadow: 0 1px 0 rgba(60,35,15,.3);
  background: var(--grain), linear-gradient(180deg, #A97A4D, #8A5E3A);
  box-shadow: inset 0 1px 0 rgba(255,230,200,.3), 0 6px 14px rgba(94, 63, 39, .22); }
.num-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .55rem; }
.seg { display: flex; background: var(--paper-2); border-radius: 14px; padding: 4px; gap: 4px; box-shadow: inset 0 1px 2px rgba(74,52,30,.08); }
.seg button { flex: 1; min-height: 44px; font-size: .9rem; font-weight: 700; color: var(--ink-soft); border-radius: 11px; letter-spacing: .1em; transition: background .2s, color .2s; }
.seg button.on { background: var(--card); color: var(--walnut); box-shadow: var(--shadow-sm); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.choice { min-height: 48px; font-weight: 600; font-size: .92rem; }
.choice.on { background: var(--jade-soft); color: var(--jade-deep); box-shadow: inset 0 0 0 1.5px var(--jade); }
details.more { margin: 1.2rem 0; background: var(--card); border-radius: 18px; padding: .2rem 1rem .7rem;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
details.more summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; font-weight: 700;
  cursor: pointer; color: var(--ink-soft); letter-spacing: .14em; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s var(--ease); margin-right: .3rem; }
details.more[open] summary::after { transform: rotate(-135deg); }
.hint { font-size: .78rem; color: var(--muted); margin: .25rem 0 .8rem; line-height: 1.75; letter-spacing: .03em; }

/* ---------- game ---------- */
.status-row { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .7rem; }
.chip { background: var(--card); border-radius: 999px; padding: .25rem .75rem; font-size: .8rem; color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line); }
.chip.gold { background: var(--honey-soft); color: var(--wood-deep); box-shadow: none; font-weight: 700; }
.dong-banner { margin: 0 1rem .8rem; padding: .85rem 1rem; border-radius: 16px; text-align: center; background: var(--wood-bg); color: #FFF8EE; box-shadow: var(--shadow); }
.dong-banner strong { display: block; font-family: var(--serif); font-size: 1.45rem; letter-spacing: .12em; }
.dong-banner.ok { background: var(--jade); }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; padding: 0 1rem; }

/* 十字型牌桌 */
.table-cross {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7.6rem, 1.18fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(9.6rem, auto) auto;
  gap: .5rem .45rem;
  padding: 1rem .8rem .4rem;
  user-select: none; -webkit-user-select: none;
  position: relative;
}
.table-cross::before { /* soft felt halo behind the table */
  content: ""; position: absolute; left: 8%; right: 8%; top: 14%; bottom: 14%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(184, 139, 94, .16), transparent); pointer-events: none; z-index: 0; }
.seat-top { grid-column: 2; grid-row: 1; }
.seat-left { grid-column: 1; grid-row: 2; align-self: center; }
.seat-right { grid-column: 3; grid-row: 2; align-self: center; }
.seat-bottom { grid-column: 2; grid-row: 3; }

.seat { position: relative; z-index: 1; text-align: center; min-height: 112px; padding: .8rem .55rem .7rem;
  border-radius: 20px; cursor: pointer; touch-action: none; -webkit-touch-callout: none;
  background: linear-gradient(180deg, #FFFDF8 0%, var(--card-2) 100%);
  box-shadow: 0 0 0 1px rgba(220, 203, 180, .75), 0 4px 0 -1px #E4D3BA, 0 4px 0 0 #D5BF9F, var(--shadow);
  transition: transform .18s var(--ease), box-shadow .2s var(--ease), opacity .2s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.seat:active { transform: scale(.965); }
.seat .nm { font-weight: 700; font-size: 1.02rem; color: var(--ink); letter-spacing: .06em; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .sw { font-size: .7rem; color: var(--muted); letter-spacing: .16em; margin-top: .05rem; }
.seat .score { font-family: var(--serif); font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1, "lnum" 1;
  font-size: 1.6rem; font-weight: 700; margin-top: .3rem; letter-spacing: .01em; line-height: 1.15; color: var(--ink-soft); }
.score.pos { color: var(--jade); }
.score.neg { color: var(--rose); }
.score.bump { animation: bump .6s var(--spring); }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.18); } 100% { transform: scale(1); } }
.delta { position: absolute; left: 50%; top: -.75rem; z-index: 3; box-shadow: 0 2px 6px rgba(74,52,30,.15); transform: translateX(-50%); font-size: .78rem; font-weight: 700;
  font-variant-numeric: tabular-nums; padding: .05rem .45rem; border-radius: 999px; pointer-events: none;
  animation: floatUp 1.6s var(--ease) forwards; white-space: nowrap; }
.delta.pos { color: var(--jade-deep); background: var(--jade-soft); }
.delta.neg { color: var(--rose-deep); background: var(--rose-soft); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; transform: translate(-50%, 0); }
  75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px); } }

.seat.dealer { background: linear-gradient(180deg, #FFFBF1 0%, #F8EDD8 100%);
  box-shadow: 0 0 0 1.5px var(--honey), 0 0 0 5px rgba(201, 160, 99, .16), 0 4px 0 -1px #E4D3BA, 0 4px 0 0 #CDB08A, var(--shadow); }
.badge-z { position: absolute; top: -9px; right: -6px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--serif); font-size: .8rem; font-weight: 900; color: #FFF8EE;
  background: var(--grain), radial-gradient(circle at 35% 30%, #B98A5E, #7E5636);
  box-shadow: 0 0 0 2px var(--card), 0 3px 8px rgba(94, 63, 39, .35); text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.lian { font-size: .75rem; color: var(--wood-deep); font-weight: 700; }

.table-center {
  grid-column: 2; grid-row: 2; position: relative; z-index: 1;
  border-radius: 22px; color: #FFF7EA; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: .7rem .45rem .65rem; min-height: 9.6rem;
  background: var(--wood-bg);
  box-shadow: inset 0 1px 0 rgba(255, 232, 200, .35), inset 0 0 0 1px rgba(255, 232, 200, .12),
    inset 0 -10px 24px rgba(60, 35, 15, .18), 0 2px 4px rgba(94, 63, 39, .2), 0 14px 30px rgba(94, 63, 39, .28);
  text-shadow: 0 1px 1px rgba(60, 35, 15, .35);
}
.table-center::before { content: ""; position: absolute; inset: 6px; border-radius: 17px; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 210, .28); }
.table-center .wind { font-family: var(--serif); font-size: 1.4rem; font-weight: 900; letter-spacing: .18em; line-height: 1.2; padding-left: .18em; }
.table-center .sub { font-size: .72rem; color: rgba(255, 244, 228, .82); margin-top: .1rem; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.table-center .dealer-line { font-family: var(--serif); font-weight: 700; margin-top: .3rem; font-size: .95rem; letter-spacing: .08em;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-center .dong { margin-top: .45rem; font-weight: 700; font-size: .74rem; display: flex; flex-direction: column; align-items: center; line-height: 1.35; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: rgba(255, 250, 240, .92); color: var(--wood-deep); text-shadow: none;
  border-radius: 12px; padding: .25rem .7rem; letter-spacing: .04em; box-shadow: 0 2px 6px rgba(60, 35, 15, .2); }
.table-center .dong .amt { font-size: .66rem; font-weight: 500; opacity: .8; }
.table-center .dong.ok { background: var(--jade-soft); color: var(--jade-deep); }
.table-center .dong.soft { background: rgba(255, 250, 240, .9); color: var(--wood-deep); }

.seat.drag-src { opacity: .35; transform: scale(.96); }
.seat.drop-on { box-shadow: 0 0 0 2px var(--jade), 0 0 0 7px rgba(94, 127, 102, .18), var(--shadow-lg) !important; transform: scale(1.05); }
.seat-ghost { position: fixed; z-index: 70; pointer-events: none; margin: 0;
  box-shadow: 0 0 0 1px rgba(220, 203, 180, .8), 0 22px 44px rgba(74, 52, 30, .32) !important;
  transform: scale(1.07) rotate(-3deg); opacity: .97; }
.gesture-hint { text-align: center; color: var(--muted); font-size: .72rem; padding: .7rem 1rem .1rem; line-height: 1.6; letter-spacing: .08em; }
.gesture-hint b { color: var(--wood-deep); font-weight: 700; }

.dock { position: sticky; bottom: 0; z-index: 10; padding: .8rem 1.1rem calc(var(--safe-b) + .8rem);
  background: linear-gradient(rgba(247, 241, 230, 0), rgba(247, 241, 230, .96) 35%); display: flex; gap: .6rem; margin-top: .6rem; }
.dock .btn-primary { flex: 1.6; }
.dock .btn-ghost { flex: 1; }

.hist { margin: .2rem 0 0; }
.hist-item { background: var(--card); border-radius: 18px; padding: .85rem 1rem .85rem 1.15rem; margin-bottom: .6rem; position: relative;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(232, 220, 203, .7); animation: rise .35s var(--ease) both; }
.hist-item::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--wood-hi); }
.hist-item .hd { display: flex; justify-content: space-between; gap: .5rem; font-size: .74rem; color: var(--muted); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.hist-item .bd { margin-top: .25rem; font-weight: 700; font-family: var(--serif); color: var(--walnut); letter-spacing: .05em; }
.hist-item .pay { font-size: .84rem; color: var(--ink-soft); margin-top: .3rem; line-height: 1.7; font-variant-numeric: tabular-nums; }
.hist-item .fee { color: var(--wood-deep); font-size: .8rem; margin-top: .15rem; }
.hist-item.t-zhahu::before { background: var(--rose); }
.hist-item.t-zimo::before { background: var(--jade); }

/* ---------- sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(59, 42, 28, .38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .25s ease; }
.sheet { width: 100%; max-width: 28rem; max-height: min(92dvh, 920px); overflow: auto; overscroll-behavior: contain;
  background: var(--linen), linear-gradient(180deg, #FCF8F0, var(--paper));
  border-radius: 28px 28px 0 0; padding: .7rem 1.2rem calc(var(--safe-b) + 1.2rem);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, .8) inset, 0 -12px 40px rgba(59, 42, 28, .22);
  animation: up .38s var(--ease); }
.overlay.still, .overlay.still .sheet { animation: none; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet h2 { margin: .3rem 0 .9rem; font-size: 1.25rem; text-align: center; color: var(--walnut); letter-spacing: .12em; }
.sheet h2 + .hint { text-align: center; margin-top: -.5rem; }
.handle { width: 44px; height: 5px; background: var(--line-2); border-radius: 5px; margin: 0 auto .7rem; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.who button { min-height: 58px; border-radius: 16px; background: var(--card); font-weight: 700; letter-spacing: .06em; color: var(--ink);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); transition: transform .15s var(--ease), background .2s, color .2s; }
.who button:active { transform: scale(.97); }
.who button.on { background: var(--jade); color: #FFFCF4; box-shadow: 0 6px 14px rgba(70, 100, 79, .25); }
.who.big { grid-template-columns: 1fr; gap: .6rem; }
.who.big button { min-height: 66px; font-size: 1.15rem; font-family: var(--serif); display: flex; align-items: center; justify-content: center; gap: .5rem; }
.who.big button small { font-family: var(--sans); font-size: .72rem; color: var(--muted); font-weight: 500; letter-spacing: .1em; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper button { width: 52px; height: 52px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 1.5rem; line-height: 1; }
.stepper input { text-align: center; font-size: 1.4rem; font-weight: 700; }
.preview { background: var(--card); border-radius: 18px; padding: .8rem 1.05rem; margin: .8rem 0; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px var(--line); }
.preview ul { margin: 0; padding: 0; }
.preview li { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  height: 2.05rem; border-bottom: 1px dashed var(--line); font-size: .9rem; color: var(--ink-soft); }
.preview li:last-child { border-bottom: 0; }
.preview li span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview li strong { flex: none; min-width: 4.5ch; text-align: right; font-family: var(--serif); font-size: 1.05rem; color: var(--walnut);
  font-variant-numeric: tabular-nums; }
#recordPreviewBox { contain: layout; }
.helper-sec { margin-bottom: 1rem; }
.helper-sec h3 { display: flex; align-items: center; gap: .5rem; font-family: var(--sans); font-size: .74rem; color: var(--muted); letter-spacing: .24em; margin: 0 0 .5rem; font-weight: 600; }
.helper-sec h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.checks { display: flex; flex-wrap: wrap; gap: .45rem; }
.checks label, .chk { display: inline-flex; align-items: center; gap: .3rem; min-height: 42px; padding: 0 .85rem;
  background: var(--card); border-radius: 999px; font-size: .86rem; color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line); transition: background .2s, color .2s; }
.chk input { display: none; }
.checks label.on, .chk.on { background: var(--jade-soft); color: var(--jade-deep); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--jade); }
.counter { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 54px; padding: .2rem .35rem .2rem .9rem;
  background: var(--card); border-radius: 16px; margin-top: .4rem; box-shadow: inset 0 0 0 1px var(--line); font-size: .9rem; }
.counter .pm { display: flex; gap: .3rem; }
.counter .pm button { width: 42px; height: 42px; border-radius: 50%; background: var(--paper-2); font-size: 1.15rem; color: var(--wood-deep); }
.counter .pm button:active { background: var(--paper-3); }

/* 自摸／放槍／詐胡 */
.act-big { min-height: 74px; font-size: 1.3rem; border-radius: 20px; font-weight: 800; width: 100%; font-family: var(--serif); letter-spacing: .4em; padding-left: 1.6em; }
.act-big small { font-family: var(--sans); font-size: .72rem; font-weight: 500; letter-spacing: .1em; opacity: .85; margin-left: -.2em; }
.act-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.act-row .act-big { flex-direction: column; gap: .15rem; min-height: 96px; letter-spacing: .3em; padding-left: 1.5em; }
.btn-zhahu { display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 36px; padding: .2rem .95rem; margin-top: 1rem; font-size: .8rem; font-weight: 700; letter-spacing: .2em;
  color: var(--rose-deep); background: var(--rose-soft); border-radius: 10px; box-shadow: inset 0 0 0 1px #E8C2B9; width: auto; }
.btn-zhahu::before { content: "!"; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--rose); color: #fff; font-size: .7rem; letter-spacing: 0; }
.btn-zhahu:active { background: #EFD3CB; }

/* 台數滑桿 — 固定尺寸、不重排 */
.tai-unit { text-align: center; font-size: .78rem; color: var(--muted); letter-spacing: .14em; height: 1.4rem; line-height: 1.4rem; margin: .2rem 0 0; white-space: nowrap; }
.tai-wrap { position: relative; margin: .25rem -1.2rem .6rem; height: 84px; contain: layout paint; }
.tai-picker { display: flex; height: 84px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior-x: contain; position: relative; z-index: 1;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 26%, #000 74%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 26%, #000 74%, transparent 100%); }
.tai-picker::-webkit-scrollbar { display: none; }
.tai-item { flex: 0 0 4.4rem; width: 4.4rem; height: 84px; display: grid; place-items: center; scroll-snap-align: center; scroll-snap-stop: always;
  text-align: center; font-family: var(--serif); font-size: 1.9rem; line-height: 1; color: var(--muted); font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums; transform: scale(.6); opacity: .7;
  transition: transform .18s var(--ease), color .18s, opacity .18s; will-change: transform; }
.tai-item.on { transform: scale(1); color: var(--walnut); opacity: 1; }
.tai-pad { flex: 0 0 calc(50% - 2.2rem); pointer-events: none; }
.tai-mark { position: absolute; left: 50%; top: 8px; bottom: 8px; width: 4.6rem; margin-left: -2.3rem; border-radius: 18px; z-index: 0;
  background: var(--card); box-shadow: var(--shadow-sm), inset 0 0 0 1.5px var(--wood-hi); pointer-events: none; }
.tai-mark::after { content: "台"; position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; font-size: .62rem; letter-spacing: .1em; color: var(--muted); }
.tai-item { padding-bottom: 8px; }

/* ---------- settle ---------- */
.settle-hero { text-align: center; padding: .4rem 0 .2rem; }
.rank { display: flex; flex-direction: column; gap: .55rem; }
.rank-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .85rem 1rem;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(232, 220, 203, .7);
  animation: rise .4s var(--ease) both; }
.rank-row:nth-child(2) { animation-delay: .05s; } .rank-row:nth-child(3) { animation-delay: .1s; } .rank-row:nth-child(4) { animation-delay: .15s; }
.rank-row strong { font-family: var(--serif); letter-spacing: .06em; color: var(--ink); }
.rank-row:first-child { background: linear-gradient(180deg, #FFFBF1, #F8EDD8); box-shadow: 0 0 0 1.5px var(--honey), var(--shadow); }
.rank-row .big { font-family: var(--serif); font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; }
.pay-line { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px dashed var(--line-2);
  font-variant-numeric: tabular-nums; font-size: .92rem; color: var(--ink-soft); }
.pay-line strong { color: var(--walnut); font-family: var(--serif); }
.pay-line:last-child { border-bottom: 0; }

.menu-list { background: var(--card); border-radius: 18px; box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.menu-list button { display: block; width: 100%; text-align: left; min-height: 56px; padding: .4rem 1.1rem;
  border-bottom: 1px solid var(--line); font-weight: 600; letter-spacing: .08em; color: var(--ink); }
.menu-list button:active { background: var(--paper-2); }
.menu-list button:last-child { border-bottom: 0; }

@media (min-width: 640px) {
  body { background: var(--linen), #EADCC6; }
  #app { box-shadow: 0 0 0 1px rgba(74, 52, 30, .06), 0 24px 60px rgba(74, 52, 30, .14);
    background: var(--linen), var(--paper); }
}
@media (max-width: 360px) {
  .seat .score { font-size: 1.35rem; }
  .table-cross { grid-template-columns: minmax(0, 1fr) minmax(6.6rem, 1.1fr) minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
