/* 至尊麻將戰績本 —— 手機優先。配色沿用參考站（米白底、深棕字、莓粉重點色）。
   手寫字：芫荽 Iansui（SIL OFL），只收本站用到的字；數字一律用一般字體，對齊好讀。 */
@font-face {
  font-family: 'hand';
  src: url('/fonts/hand.woff2?v=2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #fafaf7;
  --card: #fff;
  --ink: #4a3f35;
  --mute: #8f857c;
  --line: #eaeae0;
  --hair: #f1efe9;
  --pink: #ffb6c1;
  --pink-ink: #c64d7d;
  --berry: #ad3f68;
  --soft: #fff1f4;
  --mint-ink: #3f8e6b;
  --mint-soft: #eef6f1;
  --orange: #c9741f;
  --gold-soft: #fff8dc;
  --gold-line: #f1dc95;
  --hand: 'hand', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --plain: ui-rounded, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  /* 手機的瀏海、圓角、底部橫條：加入主畫面當 APP 用時內容要避開 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--hand); letter-spacing: .04em; min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* 當 APP 用時：長按按鈕、圖片不要跳出「儲存圖片／拷貝」選單，也不要把字反白 */
button, a, img, .seg, .garden { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
img { -webkit-user-drag: none; }
body.locked { overflow: hidden; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
img { display: block; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.num { font-family: var(--plain); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.grow { flex: 1; }
.up { color: var(--pink-ink); }
.down { color: var(--mint-ink); }
.zero { color: var(--mute); }

/* ── 登入 ── */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(12vh + var(--safe-b)) calc(24px + var(--safe-l)); background: radial-gradient(circle at 50% 36%, var(--soft) 0, var(--bg) 58%); }
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; }
.login-box > img { height: auto; margin-bottom: 14px; }
.login-box h1 { font-size: 30px; font-weight: 400; letter-spacing: .12em; margin: 0 -.12em 24px 0; white-space: nowrap; }
.login-box input { width: 100%; height: 50px; border: 2px solid var(--line); border-radius: 25px; background: #fff; padding: 0 20px; font-size: 16px; margin-bottom: 12px; font-family: var(--plain); letter-spacing: .02em; }
.login-box input::placeholder { font-family: var(--hand); letter-spacing: .08em; color: #aaa198; }
.login-box input:focus { outline: 0; border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 182, 193, .28); }
.login-box button { width: 100%; height: 52px; border-radius: 26px; background: var(--pink-ink); color: #fff; font-size: 19px; letter-spacing: .2em; box-shadow: 0 4px 0 var(--berry); margin-top: 6px; }
.login-box button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--berry); }
.login-box button:disabled { opacity: .6; }
.login-error { width: 100%; text-align: center; color: var(--pink-ink); font-size: 15px; margin-bottom: 8px; }

/* ── 共用按鈕 ── */
.ghost { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 34px; font-size: 14px; border: 1.5px solid var(--line); border-radius: 17px; padding: 0 14px; background: #fff; white-space: nowrap; }
.ghost::after { content: ''; position: absolute; inset: -6px -4px; }
.ghost:hover { border-color: var(--pink); }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 24px; border-radius: 23px; background: var(--pink-ink); color: #fff; font-size: 17px; box-shadow: 0 4px 0 var(--berry); white-space: nowrap; }
.primary i { font-style: normal; font-size: 20px; line-height: 1; margin-top: -2px; }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--berry); }

/* ── 主畫面 ── */
.app { max-width: 1080px; margin: 0 auto; padding: 0 max(14px, var(--safe-r)) calc(120px + var(--safe-b)) max(14px, var(--safe-l)); }
/* 個人頁沒有底部的新增按鈕，底下不用留那麼多空白 */
.app:has(.player) { padding-bottom: calc(40px + var(--safe-b)); }
.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 2px 8px; position: sticky; top: 0; z-index: 10; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 9px; min-height: 40px; min-width: 0; font-size: 21px; letter-spacing: .1em; white-space: nowrap; }
.brand img { width: 26px; height: auto; transform: rotate(-6deg); }

.home { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'people' 'history' 'logs'; }
.people { grid-area: people; }
.history { grid-area: history; }
.logs { grid-area: logs; }

/* 頭像 */
.ava { position: relative; flex: none; width: var(--s, 52px); height: var(--s, 52px); }
.ava-img { width: 100%; height: 100%; border-radius: 34%; overflow: hidden; background: var(--tint, #f6f1ea); display: flex; align-items: flex-end; justify-content: center; }
.ava-img img { width: 90%; height: 90%; object-fit: contain; object-position: center bottom; }
.ava .win-badge { position: absolute; right: -15px; top: -11px; width: 37px; height: auto; transform: rotate(9deg); filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)); pointer-events: none; }
.ava .crown { position: absolute; left: 50%; top: -15px; width: 25px; height: auto; transform: translateX(-50%) rotate(-5deg); pointer-events: none; }
.ava.off .ava-img { opacity: .38; filter: grayscale(.7); }

/* 四個人的累計 */
.people-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 14px 6px 10px; }
.people-title { display: flex; align-items: baseline; padding: 0 10px 12px; font-size: 16px; }
.people-title small { margin-left: auto; font-size: 12.5px; color: var(--mute); }
.people-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.person { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 8px; border-radius: 16px; --s: 58px; --amt: 16.5px; min-width: 0; container-type: inline-size; }
.person:focus-visible { background: var(--soft); }
.person:active { transform: scale(.97); }
.person .nm { font-size: 15.5px; margin-top: 5px; }
/* 金額字級：平常用 --amt；位數很多（十萬、百萬）時依格子寬度自動縮小，任何寬度都不會擠出格子。
   --len 是金額的字數（JS 填的），一個數字大約 0.6 個字寬。不支援的舊瀏覽器就用固定字級。 */
.person b { font-size: var(--amt); font-size: min(var(--amt), calc(100cqi / (var(--len, 6) * .6))); font-weight: 700; white-space: nowrap; }
.person .go { display: none; }

/* 歷史戰績 */
.sec-head { display: flex; align-items: center; gap: 10px; padding: 0 4px; margin-bottom: 4px; min-height: 34px; }
.sec-head h2 { font-size: 19px; font-weight: 400; }
.sec-head .count { font-size: 13px; color: var(--mute); }
.sec-head .primary { display: none; }
.month { font-size: 13.5px; font-weight: 400; color: var(--mute); margin: 14px 6px 7px; }
.day { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 9px 8px 12px; margin-bottom: 10px; }
.day-head { display: flex; align-items: baseline; gap: 7px; padding: 0 2px 0 8px; }
.day-head b { font-size: 17px; font-weight: 700; }
.day-head span { font-size: 13.5px; color: var(--mute); }
.day-head .ghost { font-size: 13px; min-height: 30px; padding: 0 13px; align-self: center; color: var(--mute); }
.day-head .ghost::after { inset: -8px -6px; }
.day-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 11px; }
.col { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 0 2px; --s: 50px; --amt: 18px; container-type: inline-size; }
.col .nm { font-size: 14px; margin-top: 5px; color: #6f645a; }
.col .amt { font-size: var(--amt); font-size: min(var(--amt), calc(100cqi / (var(--len, 6) * .6))); font-weight: 700; line-height: 1.25; white-space: nowrap; }
.col .amt.none { font-weight: 400; color: #c5bdb4; }
.col.is-win .nm { color: var(--ink); }
.garden { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; line-height: 1; color: #b0527a; background: var(--soft); border-radius: 10px; padding: 3px 7px 3px 4px; margin-top: 3px; white-space: nowrap; letter-spacing: .02em; }
.garden img { width: 15px; height: auto; }

.empty { text-align: center; padding: 26px 16px 34px; background: var(--card); border: 1.5px dashed var(--line); border-radius: 20px; margin-top: 8px; }
.empty img { width: 170px; height: auto; margin: 0 auto 6px; }
.empty b { display: block; font-size: 19px; font-weight: 400; }
.empty p { font-size: 14.5px; color: var(--mute); margin-top: 4px; line-height: 1.6; }

/* 更動記錄 */
.panel { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 14px 16px 10px; }
.panel h3 { font-size: 16px; font-weight: 400; margin-bottom: 4px; display: flex; align-items: baseline; }
.panel h3 small { margin-left: auto; font-size: 12.5px; color: var(--mute); }
.log { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #efece6; font-size: 14px; line-height: 1.45; }
.log:last-of-type { border-bottom: 0; }
.log time { font-size: 12px; color: var(--mute); flex: none; width: 74px; padding-top: 2px; }
.log p { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.log p .num { font-size: 13.5px; }
.log p i { font-style: normal; color: var(--mute); }
.log-empty { font-size: 14px; color: var(--mute); padding: 12px 0 14px; text-align: center; }
.more { display: block; width: 100%; min-height: 44px; text-align: center; font-size: 13.5px; color: var(--mute); padding: 8px 0 2px; }
.more:hover { color: var(--pink-ink); }

/* 手機底部的新增按鈕 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; display: flex; justify-content: center; padding: 14px max(16px, var(--safe-r)) calc(14px + var(--safe-b)) max(16px, var(--safe-l)); background: linear-gradient(to top, var(--bg) 62%, rgba(250, 250, 247, 0)); pointer-events: none; }
.dock .primary { pointer-events: auto; width: 100%; max-width: 420px; height: 52px; border-radius: 26px; font-size: 18px; letter-spacing: .1em; }

/* ── 個人頁 ── */
.player { max-width: 720px; margin: 0 auto; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.player-nav { display: flex; align-items: center; gap: 8px; padding-top: 5px; }
.back-link { display: inline-flex; align-items: center; gap: .35em; min-height: 40px; font-size: 15px; padding: 0 12px 0 4px; border-radius: 14px; color: var(--mute); white-space: nowrap; }
.back-link:hover { color: var(--pink-ink); }
.switch { display: flex; gap: 8px; margin-left: auto; }
.switch a { --s: 40px; border-radius: 34%; opacity: .5; transition: opacity .15s; }
.switch a:hover { opacity: .85; }
.switch a[aria-current] { opacity: 1; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--pink); }

.me { background: var(--card); border: 1.5px solid var(--line); border-radius: 24px; padding: 20px 18px 18px; display: flex; align-items: center; gap: 18px; }
.me-ava { --s: 96px; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.me-ava .ghost { font-size: 13px; min-height: 32px; padding: 0 13px; }
.me-main { flex: 1; min-width: 0; }
.me-main h2 { font-size: 25px; font-weight: 400; line-height: 1.2; overflow-wrap: anywhere; }
.me-main .sub { font-size: 13.5px; color: var(--mute); margin-top: 3px; }
.me-total { margin-top: 10px; display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.me-total span { font-size: 14px; color: var(--mute); }
.me-total b { font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -.01em; white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 11px 14px 12px; position: relative; min-width: 0; }
.tile span { display: block; font-size: 13.5px; color: var(--mute); }
.tile b { display: block; font-size: 22px; font-weight: 700; line-height: 1.3; margin-top: 1px; }
.tile b small { font-family: var(--hand); font-size: 13.5px; font-weight: 400; margin-left: 3px; color: var(--mute); }
.tile em { display: block; font-style: normal; font-size: 12px; color: var(--mute); margin-top: 1px; }
.tile > img { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); width: 40px; height: auto; }
.tile.garden-tile { background: var(--soft); border-color: #f8d3db; }
.tile.win-tile { background: var(--gold-soft); border-color: var(--gold-line); }

.chart-wrap { position: relative; margin: 6px -4px 0; touch-action: pan-y; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-wrap text { font-family: var(--plain); font-size: 11.5px; fill: var(--mute); }
.chart-wrap .end-label { font-size: 13px; font-weight: 700; fill: var(--ink); }
.tip { position: absolute; z-index: 2; pointer-events: none; background: var(--ink); color: #fff; border-radius: 12px; padding: 7px 11px 8px; font-size: 12.5px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -100%); box-shadow: 0 6px 16px rgba(74, 63, 53, .22); }
.tip b { font-weight: 700; }
.tip i { font-style: normal; opacity: .72; margin-right: 6px; font-family: var(--hand); }
.chart-empty { font-size: 14px; color: var(--mute); text-align: center; padding: 26px 0 30px; }

.rec { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px dashed #efece6; }
.rec:last-child { border-bottom: 0; }
.rec .d { font-size: 14.5px; font-weight: 700; }
.rec .d small { display: block; font-family: var(--hand); font-weight: 400; font-size: 12px; color: var(--mute); }
.rec .tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.rec .tags .win-mini { width: 34px; height: auto; }
.rec .tags .garden { margin-top: 0; }
.rec .v { text-align: right; }
.rec .v b { display: block; font-size: 17px; font-weight: 700; }
.rec .v small { display: block; font-size: 12px; color: var(--mute); }
.rec .v small i { font-style: normal; font-family: var(--hand); margin-right: 3px; }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--hair) 0 calc(50% - 1px), #d9d3ca calc(50% - 1px) calc(50% + 1px), var(--hair) calc(50% + 1px)); position: relative; }
.bar i { position: absolute; top: 0; bottom: 0; }
.bar i.up { left: calc(50% + 1px); background: var(--pink-ink); border-radius: 0 3px 3px 0; }
.bar i.down { right: calc(50% + 1px); background: var(--mint-ink); border-radius: 3px 0 0 3px; }

/* ── 視窗 ── */
.modal, .confirm { position: fixed; inset: 0; background: rgba(60, 48, 40, .55); display: flex; justify-content: center; padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l)); overflow-y: auto; overscroll-behavior: contain; animation: fade .16s ease-out; }
.modal { z-index: 30; align-items: flex-start; }
.confirm { z-index: 35; align-items: center; }
.modal-box, .confirm-box { width: 100%; background: #fff; border-radius: 26px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal-box { max-width: 440px; padding: 16px 16px 18px; margin: auto 0; }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; padding-left: 6px; }
.modal-head h2 { font-size: 22px; font-weight: 400; }
.close { flex: none; margin-left: auto; width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--mute); background: var(--bg); }
.close:hover { color: var(--ink); background: var(--soft); }

.date-row { display: flex; align-items: center; gap: 7px; }
/* 日期：畫面上的字是自己排的（每台手機內建的日期欄位寬度都不一樣，窄螢幕會被截掉），
   真正的日期欄位透明地蓋在整顆上面，點哪裡都會跳出手機／電腦內建的月曆。 */
.date-pill { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 46px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 23px; padding: 0 12px 0 16px; cursor: pointer; }
.date-text { font-size: 17px; font-weight: 700; white-space: nowrap; }
.date-pill input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 23px; background: none; font-size: 16px; padding: 0; opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
.date-pill input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.date-pill input:focus { outline: 0; }
.date-pill:focus-within { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 182, 193, .28); }
.weekday { font-size: 14px; color: var(--mute); white-space: nowrap; }
.chip { flex: none; height: 46px; font-size: 14.5px; border: 1.5px solid var(--line); border-radius: 23px; padding: 0 13px; background: #fff; white-space: nowrap; }
.chip.on { border-color: var(--pink); color: var(--pink-ink); background: var(--soft); }
.entry-note { font-size: 13.5px; color: var(--orange); background: #fff7ea; border-radius: 12px; padding: 7px 12px; margin-top: 8px; line-height: 1.5; }

.rows { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 9px; padding: 8px 2px 8px 4px; border-bottom: 1px dashed var(--line); --s: 42px; }
.row:last-child { border-bottom: 0; }
.row .nm { width: 50px; flex: none; font-size: 16px; white-space: nowrap; }
.seg { display: flex; flex: none; border: 1.5px solid var(--line); border-radius: 24px; padding: 2px; background: var(--bg); }
.seg button { width: 44px; height: 40px; border-radius: 20px; font-size: 15px; color: var(--mute); }
.seg button[aria-pressed='true'].w { background: var(--pink-ink); color: #fff; }
.seg button[aria-pressed='true'].l { background: var(--mint-ink); color: #fff; }
.row.need .seg { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217, 130, 43, .18); }
.amount { flex: 1; min-width: 0; height: 47px; border: 2px solid var(--line); border-radius: 24px; background: #fff; padding: 0 15px; font-size: 19px; font-weight: 700; text-align: right; }
.amount::placeholder { font-family: var(--hand); font-weight: 400; font-size: 14.5px; color: #b9b0a6; letter-spacing: .04em; }
/* 量金額字寬用的隱形尺（跟金額欄同一種字），見 app.js 的 fitAmount */
.amount-probe { position: absolute; left: -9999px; top: 0; visibility: hidden; white-space: nowrap; font-weight: 700; pointer-events: none; }
.amount:focus { outline: 0; border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 182, 193, .28); }
.row.w .amount { color: var(--pink-ink); }
.row.l .amount { color: var(--mint-ink); }

.sum-line { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--mute); margin: 8px 0 12px; text-align: center; line-height: 1.5; }
.sum-line.ok { color: var(--mint-ink); }
.sum-line.warn { color: var(--orange); }
.sum-line .fill { min-height: 40px; font-size: 14px; border: 1.5px solid var(--pink); color: var(--pink-ink); background: var(--soft); border-radius: 20px; padding: 0 14px; }
.sum-line .fill:hover { background: #ffe6eb; }

.modal-actions, .confirm-actions { display: flex; gap: 12px; }
.modal-actions button, .confirm-actions button { flex: 1; height: 48px; border-radius: 24px; font-size: 17px; }
.back { border: 1.5px solid var(--line); background: #fff; }
.back:hover { border-color: var(--pink); }
.yes { flex: 1.5 !important; background: var(--pink-ink); color: #fff; box-shadow: 0 4px 0 var(--berry); }
.yes:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--berry); }
.yes:disabled { opacity: .55; }
.yes.danger { background: #c9552b; box-shadow: 0 4px 0 #a5411d; }
.danger-link { display: block; margin: 8px auto -6px; min-height: 40px; font-size: 14px; color: var(--mute); padding: 0 14px; }
.danger-link:hover { color: #c9552b; }

/* 換角色 */
.picker-box { max-width: 460px; }
.picker-tip { font-size: 14px; color: var(--mute); padding: 0 6px 10px; }
.picker-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 8px; padding: 4px 2px 6px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; --s: 100%; border-radius: 18px; padding: 4px; min-width: 0; }
.pick .ava { width: 100%; height: auto; aspect-ratio: 1; }
.pick small { font-size: 12px; color: var(--mute); height: 16px; white-space: nowrap; }
.pick:active:not(:disabled) { transform: scale(.95); }
.pick.mine .ava-img { box-shadow: 0 0 0 3px var(--pink-ink); }
.pick.mine small { color: var(--pink-ink); }
.pick:disabled .ava-img { opacity: .4; filter: grayscale(.6); }

/* 二次確認 */
.confirm-box { max-width: 420px; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; text-align: center; }
.confirm-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 2px; }
.confirm-scroll > img { margin: 0 auto 4px; height: auto; }
.confirm-box h2 { font-size: 22px; font-weight: 400; margin-bottom: 10px; }
.confirm-date { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.confirm-date span { font-family: var(--hand); font-weight: 400; color: var(--mute); margin-left: 4px; font-size: 14px; }
.confirm-list { list-style: none; background: var(--bg); border: 1.5px solid var(--line); border-radius: 18px; padding: 2px 14px; text-align: left; }
.confirm-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); --s: 36px; }
.confirm-list li:last-child { border-bottom: 0; }
.confirm-list .n { font-size: 16px; display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; min-width: 0; }
.confirm-list .n .win-mini { width: 30px; height: auto; }
.confirm-list .n .garden { margin-top: 0; }
.confirm-list b { font-size: 20px; font-weight: 700; white-space: nowrap; text-align: right; }
.confirm-list b.none { font-family: var(--hand); font-size: 15px; font-weight: 400; color: var(--mute); }
.confirm-list small { grid-column: 2 / -1; font-size: 12.5px; color: var(--orange); text-align: right; margin-top: -2px; }
.confirm-warn { font-size: 14px; color: var(--orange); background: #fff7ea; border-radius: 12px; padding: 7px 12px; margin-top: 10px; line-height: 1.5; }
.confirm-move { font-size: 14px; color: var(--orange); margin-bottom: 8px; }
.confirm-text { font-size: 15.5px; color: var(--mute); line-height: 1.6; }
.swap { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 0 2px; --s: 84px; }
.swap .arrow { font-size: 22px; color: var(--mute); }
.swap figure { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.swap figcaption { font-size: 12.5px; color: var(--mute); }
.confirm-ask { margin-top: 14px; font-size: 16.5px; }
.confirm-actions { flex: none; padding: 14px 20px 22px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 40; background: var(--ink); color: #fff; border-radius: 22px; padding: 10px 20px; font-size: 14.5px; box-shadow: 0 8px 22px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); text-align: center; animation: rise .2s ease-out; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── 小手機 ── */
/* ── 手機：視窗左右留白收一點，把寬度還給內容 ── */
@media (max-width: 479px) {
  .modal, .confirm { padding-left: max(12px, var(--safe-l)); padding-right: max(12px, var(--safe-r)); }
}

/* ── 小手機 ── */
@media (max-width: 379px) {
  .date-row { gap: 6px; }
  .date-pill { padding: 0 10px 0 14px; gap: 6px; }
  .date-text { font-size: 16px; }
  .weekday { font-size: 13px; }
  .chip { padding: 0 11px; font-size: 14px; }
  /* 金額欄要放得下 7 位數（上限 9,999,999）：頭像與間距收一點、欄內留白縮小，把寬度讓給數字 */
  .amount { padding: 0 10px; font-size: 18px; }
  .row { gap: 7px; --s: 38px; }
}

@media (max-width: 359px) {
  .app { padding-left: max(10px, var(--safe-l)); padding-right: max(10px, var(--safe-r)); }
  .brand { font-size: 19px; gap: 7px; letter-spacing: .08em; }
  .people-title small, .panel h3 small { font-size: 12px; }
  .col { --s: 44px; --amt: 16px; }
  .person { --s: 50px; --amt: 15.5px; }
  .modal, .confirm { padding-left: 10px; padding-right: 10px; }
  .modal-box { padding: 14px 12px 16px; }
  .date-pill { padding: 0 8px 0 12px; }
  .date-text { font-size: 15.5px; }
  .chip { padding: 0 9px; }
  .row { gap: 6px; padding-left: 0; padding-right: 0; --s: 32px; }
  .row .nm { width: 44px; font-size: 15px; }
  .seg button { width: 40px; }
  .amount { padding: 0 9px; font-size: 17px; }
  .me { gap: 12px; padding: 16px 12px; }
  .me-ava { --s: 80px; }
  .me-total b { font-size: 32px; }
  .tile { padding: 10px 11px 11px; }
  .tile > img { width: 34px; right: 9px; }
  .picker-grid { gap: 10px 4px; }
  .confirm-scroll { padding-left: 14px; padding-right: 14px; }
  .confirm-actions { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .confirm-list { padding: 2px 11px; }
  .confirm-list b { font-size: 18px; }
  .swap { --s: 76px; gap: 12px; }
}

/* ── 手機橫放／很矮的視窗：把直的空間省下來 ── */
@media (max-height: 480px) {
  .login { padding-top: calc(14px + var(--safe-t)); padding-bottom: calc(14px + var(--safe-b)); }
  .login-box > img { width: 116px; margin-bottom: 6px; }
  .login-box h1 { font-size: 24px; margin-bottom: 12px; }
  .login-box input { height: 46px; margin-bottom: 8px; }
  .login-box button { height: 48px; margin-top: 2px; }
  /* 換角色：橫放時排成兩列，15 個不用捲就全看得到 */
  .picker-box { max-width: 600px; }
  .picker-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px 10px; }
  .confirm-scroll > img { display: none; }
  .confirm-scroll { padding-top: 14px; }
  .confirm-actions { padding-top: 10px; padding-bottom: 16px; }
  .swap { --s: 64px; }
}

/* ── 平板以上 ── */
@media (min-width: 720px) {
  .app { padding: 0 24px 60px; }
  .top { padding: 18px 2px 14px; }
  .brand { font-size: 24px; }
  .brand img { width: 30px; }
  .dock { display: none !important; }
  .sec-head .primary { display: inline-flex; margin-left: auto; height: 42px; font-size: 16px; }
  .sec-head { margin-bottom: 8px; min-height: 46px; }
  .modal-box { padding: 20px 22px 22px; }
  .confirm-scroll { padding: 22px 26px 2px; }
  .confirm-actions { padding: 14px 26px 24px; }
  .toast { bottom: 32px; }

  .day { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; padding: 14px 16px 14px 18px; }
  .day-head { flex-direction: column; align-items: flex-start; gap: 2px; padding: 0; }
  .day-head b { font-size: 20px; }
  .day-head .grow { display: none; }
  .day-head .ghost { align-self: flex-start; margin-top: 8px; }
  .day-cols { margin-top: 0; }
  .col { --s: 56px; --amt: 20px; }
  .col .nm { font-size: 15px; }

  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .me { padding: 26px 28px; gap: 26px; }
  .me-ava { --s: 116px; }
  .me-total b { font-size: 44px; }
  .picker-grid { gap: 14px 12px; }
}

/* ── 桌機：左邊歷史戰績，右邊四個人的累計 ── */
@media (min-width: 1000px) {
  .home { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: 'history people' 'history logs'; grid-template-rows: auto 1fr; gap: 16px 24px; align-items: start; }
  .people-card { padding: 16px 10px 10px; }
  .people-list { grid-template-columns: 1fr; gap: 2px; }
  .person { flex-direction: row; gap: 12px; padding: 8px 10px; --s: 50px; --amt: 19px; text-align: left; container-type: normal; }
  .person .nm { margin-top: 0; font-size: 17px; }
  .person b { margin-left: auto; font-size: var(--amt); }
  .person .go { display: block; font-family: var(--plain); color: #cfc8bf; font-size: 18px; }
}

/* 滑鼠移上去的效果只給有滑鼠的裝置：手機點過之後「移上去」的樣子會黏著不放，
   看起來像選到了（例如點過「昨天」再改日期，「昨天」還是粉紅色）。 */
@media (hover: hover) {
  .person:hover { background: var(--soft); }
  .chip:hover { border-color: var(--pink); color: var(--pink-ink); background: var(--soft); }
  .pick:hover:not(:disabled):not(.mine) .ava-img { box-shadow: 0 0 0 3px var(--pink); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
