/* 香港麻雀：版面（直向手機 390×844 為主）＋三個主題（data-theme：ivory 寫實象牙、neon 茶餐廳霓虹、flat 極簡） */

:root {
  --tile-font: "Songti TC", "Noto Serif TC", "Noto Serif CJK TC", "PMingLiU", "STSong", "PingFang TC", serif;
  --ui-font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --maxw: 480px;
}

/* ---------- 主題 ---------- */
body[data-theme="ivory"] {
  --bg: #0a2619;
  --table: radial-gradient(ellipse 90% 70% at 50% 45%, #22844f 0%, #166640 50%, #0d4429 100%);
  --felt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --tile-face: linear-gradient(170deg, #fffef7 0%, #f6efda 70%, #eadfc2 100%);
  --tile-face-solid: #fbf6e6;
  --tile-side: #2f8f5c;
  --tile-side2: #1d6b41;
  --tile-edge: rgba(80, 60, 20, .25);
  --tile-back: linear-gradient(160deg, #46b37a, #237a4a);
  --ink-dark: #1a2747; --ink-red: #be2329; --ink-green: #17773b; --ink-blue: #1e4c9e; --ink-gold: #d08a10;
  --fg: #f6f1e2; --muted: #b9d3c3; --panel: rgba(4, 30, 18, .55); --panel-border: rgba(255, 255, 255, .1);
  --accent: #f2c14e; --accent-fg: #2b1d00; --danger: #e8554e; --good: #7ee0a1;
  --btn: rgba(255, 255, 255, .12); --sheet: #133e29; --sheet2: #1b4f35;
  --center: rgba(0, 0, 0, .28); --glow: 0 0 0 transparent;
}
body[data-theme="neon"] {
  --bg: #120a0e;
  --table:
    radial-gradient(ellipse 80% 65% at 50% 45%, rgba(255, 79, 163, .12), transparent 70%),
    repeating-conic-gradient(#2a1b23 0 25%, #20141a 0 50%) 0 0 / 22px 22px;
  --felt: linear-gradient(transparent, transparent);
  --tile-face: linear-gradient(170deg, #fffaf0 0%, #fbeed8 75%, #f0dcbb 100%);
  --tile-face-solid: #fff6e6;
  --tile-side: #d7263d;
  --tile-side2: #9b1328;
  --tile-edge: rgba(90, 20, 30, .3);
  --tile-back: linear-gradient(160deg, #ef4060, #a8162e);
  --ink-dark: #1f1f2b; --ink-red: #e0263a; --ink-green: #0d8a5d; --ink-blue: #1660c4; --ink-gold: #e09a00;
  --fg: #fff3f8; --muted: #e9a9c6; --panel: rgba(20, 8, 14, .78); --panel-border: rgba(255, 79, 163, .55);
  --accent: #ffd23f; --accent-fg: #2a1200; --danger: #ff4f6d; --good: #38f2ff;
  --btn: rgba(56, 242, 255, .1); --sheet: #1c0f16; --sheet2: #2a1520;
  --center: rgba(10, 4, 8, .82); --glow: 0 0 10px rgba(255, 79, 163, .65);
  --neon2: #38f2ff;
}
body[data-theme="flat"] {
  --bg: #f1eee8;
  --table: #e4dfd4;
  --felt: linear-gradient(transparent, transparent);
  --tile-face: #ffffff;
  --tile-face-solid: #ffffff;
  --tile-side: #cfc8b9;
  --tile-side2: #b9b2a3;
  --tile-edge: #d6d0c3;
  --tile-back: #7d9bb5;
  --ink-dark: #2a2a2a; --ink-red: #d24343; --ink-green: #2a8a57; --ink-blue: #3a6aa5; --ink-gold: #c98b16;
  --fg: #26231e; --muted: #7b756b; --panel: #faf8f4; --panel-border: #ddd7cb;
  --accent: #2f6fde; --accent-fg: #fff; --danger: #d24343; --good: #2a8a57;
  --btn: #ece8e0; --sheet: #faf8f4; --sheet2: #efebe3;
  --center: #f8f6f1; --glow: 0 0 0 transparent;
}

/* ---------- 基本 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--ui-font);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }

#app {
  position: fixed; inset: 0; margin: 0 auto; max-width: var(--maxw);
  display: flex; flex-direction: column;
  padding: var(--safe-t) 0 var(--safe-b);
  background: var(--table); background-color: var(--bg);
}
#app::before { content: ""; position: absolute; inset: 0; background: var(--felt); pointer-events: none; opacity: .9; }
#app > * { position: relative; }

/* 頁首：fixed 容器裡的 flex 項目，不會跟著捲動（iOS 26 PWA 整頁捲會糊） */
.topbar {
  flex: none; height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 8px;
  background: var(--panel); border-bottom: 1px solid var(--panel-border); z-index: 5;
}
.topbar .title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; overflow: hidden; }
.topbar .title b { font-size: 17px; letter-spacing: .06em; }
body[data-theme="neon"] .topbar .title b { color: #ff7ab8; text-shadow: 0 0 8px rgba(255, 79, 163, .9); font-style: italic; }
.topbar .title span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ibtn {
  flex: none; width: 38px; height: 34px; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--btn);
  font-size: 17px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.ibtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.ibtn:active { transform: scale(.94); }

/* ---------- 牌 ---------- */
.tile {
  --th: 3px;
  position: relative; display: inline-block; flex: none; width: var(--tw, 26px); aspect-ratio: 60 / 82;
  border-radius: 13% / 10%; background: var(--tile-face);
  box-shadow: inset 0 0 0 .6px var(--tile-edge), 0 var(--th) 0 var(--tile-side), 0 calc(var(--th) + 1px) 0 var(--tile-side2), 0 calc(var(--th) + 2px) 4px rgba(0, 0, 0, .3);
  margin-bottom: calc(var(--th) + 1px);
}
.tile svg { position: absolute; left: 6%; top: 5%; width: 88%; height: 90%; overflow: visible; }
.tile.back { background: var(--tile-back); box-shadow: inset 0 0 0 .6px rgba(0, 0, 0, .2), 0 var(--th) 0 var(--tile-face-solid), 0 calc(var(--th) + 2px) 4px rgba(0, 0, 0, .3); }
body[data-theme="flat"] .tile { box-shadow: inset 0 0 0 1px var(--tile-edge), 0 var(--th) 0 var(--tile-side); }
body[data-theme="flat"] .tile.back { box-shadow: 0 var(--th) 0 #5d7a93; }
.tile.dim { filter: brightness(.82) saturate(.8); }
.tile.hl { box-shadow: inset 0 0 0 2px var(--accent), 0 var(--th) 0 var(--tile-side), 0 0 10px var(--accent); }

/* ---------- 對家（上方一列）＋ 角落的上家／下家／自己 ---------- */
.opp-row { flex: none; height: 50px; display: flex; justify-content: center; padding: 4px 8px 0; }
.opp {
  display: flex; flex-direction: column; gap: 3px; border-radius: 12px; padding: 5px 7px; min-width: 0;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--glow);
  font-size: 12px; line-height: 1.15; transition: box-shadow .2s, border-color .2s;
}
.opp.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }
.opp .nm { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.opp .nm b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.opp .chips { margin-left: auto; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.opp .lv { color: var(--muted); font-size: 11px; }
.wind {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px;
  background: var(--btn); border: 1px solid var(--panel-border); font-size: 11px; font-weight: 800; flex: none;
}
.wind.dealer { background: var(--danger); color: #fff; border-color: transparent; }
.row-tiles { display: flex; align-items: flex-end; gap: 1px; flex-wrap: wrap; --tw: 13px; }
.row-tiles .tile { --th: 1.5px; }
.row-tiles .gap { width: 4px; }
.opp-row .opp { width: 100%; max-width: 300px; }
.opp-row .opp .line2 { display: flex; align-items: flex-end; gap: 6px; }
.opp-row .row-tiles { flex-wrap: nowrap; overflow: hidden; --tw: 14px; }
.opp .lv2 { color: var(--muted); font-size: 10px; }
.backs { display: flex; gap: 0; --tw: 7px; }
.backs .tile { --th: 1px; border-radius: 2px; margin-bottom: 1px; }

/* ---------- 牌桌：3×3 格，中間是牌桌中心，四邊是捨牌區（左右兩邊轉 90°） ---------- */
.board {
  flex: 1 1 auto; min-height: 0; margin: 4px 6px 0;
  display: grid; --c: 38%;
  grid-template-columns: 1fr var(--c) 1fr;
  grid-template-rows: 1fr minmax(0, auto) 1fr;
  gap: 3px;
}
.corner { min-width: 0; min-height: 0; display: flex; overflow: hidden; }
.corner.tl, .corner.bl { justify-content: flex-start; }
.corner.tr, .corner.br { justify-content: flex-end; }
.corner.tl, .corner.tr { align-items: flex-start; }
.corner.bl, .corner.br { align-items: flex-end; }
.corner .opp { width: 100%; max-height: 100%; }
.pond-cell { min-width: 0; min-height: 0; position: relative; container-type: size; }
.pond { position: absolute; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0; --cols: 6; }
.pond .tile { --th: 1.5px; width: calc(100% / var(--cols)); --tw: auto; border-radius: 10% / 8%; }
.pond-cell.bottom .pond { inset: 0; padding-top: 2px; }
.pond-cell.top .pond { inset: 0; padding-top: 2px; transform: rotate(180deg); }
.pond-cell.left .pond, .pond-cell.right .pond { left: 50%; top: 50%; width: 100cqh; height: 100cqw; padding-top: 2px; }
.pond-cell.left .pond { transform: translate(-50%, -50%) rotate(90deg); }
.pond-cell.right .pond { transform: translate(-50%, -50%) rotate(-90deg); }
.pond .tile.claimed { opacity: .35; }
.pond .tile.last { box-shadow: inset 0 0 0 2px var(--accent), 0 var(--th) 0 var(--tile-side), 0 0 8px var(--accent); }
.pond .tile.just { animation: drop .28s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes drop { from { transform: translateY(-14px) scale(1.5); opacity: 0; } to { transform: none; opacity: 1; } }

.center {
  aspect-ratio: 1; align-self: center; position: relative; border-radius: 14px;
  background: var(--center); border: 1px solid var(--panel-border); box-shadow: var(--glow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; text-align: center;
}
.center .rw { font-family: var(--tile-font); font-size: 30px; font-weight: 800; line-height: 1; }
body[data-theme="neon"] .center .rw { color: #ff7ab8; text-shadow: 0 0 6px #ff4fa3, 0 0 16px rgba(255, 79, 163, .8); }
body[data-theme="neon"] .center .left-n { color: var(--neon2); text-shadow: 0 0 6px rgba(56, 242, 255, .8); }
.center .sub { font-size: 11px; color: var(--muted); }
.center .left-n { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.center .sw {
  position: absolute; font-size: 11px; font-weight: 800; width: 20px; height: 20px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  background: var(--btn); color: var(--muted);
}
.center .sw.on { background: var(--accent); color: var(--accent-fg); box-shadow: 0 0 10px var(--accent); }
.center .s0 { bottom: 4px; left: 50%; transform: translateX(-50%); }
.center .s1 { right: 4px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.center .s2 { top: 4px; left: 50%; transform: translateX(-50%) rotate(180deg); }
.center .s3 { left: 4px; top: 50%; transform: translateY(-50%) rotate(90deg); }

.wallcard { font-size: 11px; color: var(--muted); text-align: right; padding: 4px 4px 2px; line-height: 1.35; }
.wallcard b { color: var(--fg); }

/* ---------- 自己 ---------- */
.me { flex: none; padding: 0 6px; }
.me-melds { height: 32px; display: flex; align-items: flex-end; gap: 6px; padding: 0 2px; overflow: hidden; --tw: 19px; }
.me-melds .meld { display: flex; gap: 1px; }
.me-melds .meld .tile { --th: 2px; }
.me-melds .flw { margin-left: auto; display: flex; gap: 1px; --tw: 15px; }
.me-melds .flw .tile { --th: 1.5px; }

.assist {
  margin: 4px 0 0; padding: 5px 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--panel-border);
  font-size: 12px; line-height: 1.4; min-height: 30px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px;
}
.assist[hidden] { display: none; }
.assist .row-tiles { --tw: 14px; display: inline-flex; gap: 1px; }
.assist .row-tiles .tile { --th: 1px; }
.assist .tag { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.assist .risk-低 { color: var(--good); font-weight: 800; }
.assist .risk-中 { color: var(--accent); font-weight: 800; }
.assist .risk-高 { color: var(--danger); font-weight: 800; }
.assist .cnt { font-size: 10px; color: var(--muted); margin-left: -1px; }

.hand {
  --tw: min(40px, calc((min(100vw, var(--maxw)) - 22px) / 14.4));
  height: calc(var(--tw) * 1.37 + 22px); display: flex; align-items: flex-end; justify-content: center; gap: 1px; padding-bottom: 6px;
  touch-action: none;
}
.hand .tile { --th: 4px; cursor: pointer; transition: transform .12s ease-out; }
.hand .tile.sel { transform: translateY(-12px); }
.hand .tile.best::after {
  content: ""; position: absolute; left: 50%; top: -7px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent);
}
.hand .tile.risk-高::before { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 2px; background: var(--danger); }
.hand .tile.risk-中::before { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 2px; background: var(--accent); }
.hand .drawn-gap { width: calc(var(--tw) * .35); flex: none; }
.hand .tile.new { animation: slidein .25s ease-out; }
.hand.wait .tile { filter: brightness(.94); }
@keyframes slidein { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

.actions { height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 2px 0 6px; }
.actions .hint { font-size: 13px; color: var(--muted); text-align: center; }
.abtn {
  min-width: 64px; height: 50px; padding: 0 16px; border-radius: 14px; border: 0; cursor: pointer;
  font-size: 22px; font-weight: 900; letter-spacing: .05em; position: relative; overflow: hidden;
  background: var(--btn); color: var(--fg); border: 1px solid var(--panel-border);
}
.abtn:active { transform: scale(.95); }
.abtn.win { background: linear-gradient(180deg, #ff5b4f, #c81e1e); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(200, 30, 30, .5); }
.abtn.meld { background: var(--accent); color: var(--accent-fg); border: 0; }
.abtn.pass { font-size: 18px; }
body[data-theme="neon"] .abtn { box-shadow: 0 0 8px rgba(56, 242, 255, .5); border-color: var(--neon2); }
body[data-theme="neon"] .abtn.meld { box-shadow: 0 0 12px rgba(255, 210, 63, .8); }
.abtn .timer { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .7); animation: shrink linear forwards; }
@keyframes shrink { from { width: 100%; } to { width: 0; } }
.chow-opt { display: flex; gap: 1px; padding: 6px 8px; border-radius: 12px; background: var(--accent); border: 0; cursor: pointer; --tw: 20px; }
.chow-opt .tile { --th: 2px; }

/* ---------- 喊牌（碰／上／槓／糊） ---------- */
#callouts { position: fixed; inset: 0; pointer-events: none; z-index: 20; max-width: var(--maxw); margin: 0 auto; }
.callout {
  position: absolute; transform: translate(-50%, -50%); font-family: var(--tile-font); font-weight: 900; font-size: 40px;
  color: #fff; padding: 2px 16px; border-radius: 16px; background: rgba(200, 30, 30, .92); box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  animation: pop 1s ease-out forwards; white-space: nowrap;
}
.callout.small { font-size: 18px; background: rgba(0, 0, 0, .6); padding: 2px 10px; }
.callout.big { font-size: 56px; background: linear-gradient(180deg, #ff6a3d, #d01c1c); }
body[data-theme="neon"] .callout { background: rgba(20, 6, 14, .9); color: #ffd23f; text-shadow: 0 0 10px #ff4fa3; border: 2px solid #ff4fa3; }
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

/* ---------- 疊層（選單、設定、結算） ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center;
  padding: calc(var(--safe-t) + 12px) 0 0;
}
.overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: var(--maxw); max-height: 100%; display: flex; flex-direction: column;
  background: var(--sheet); color: var(--fg); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  animation: up .22s ease-out;
}
body[data-theme="neon"] .sheet { border: 1px solid var(--panel-border); box-shadow: 0 0 24px rgba(255, 79, 163, .35); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 16px 12px; }
.sheet-foot { flex: none; display: flex; gap: 8px; padding: 10px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--panel-border); }
.btn {
  flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--btn); cursor: pointer;
  font-size: 16px; font-weight: 700; padding: 0 14px;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.small { flex: none; min-height: 34px; font-size: 14px; }
.btn:active { transform: scale(.97); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list .btn { text-align: left; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.menu-list .btn small { color: var(--muted); font-weight: 500; margin-left: auto; font-size: 12px; }

.sec { margin: 6px 0 16px; }
.sec h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-weight: 700; letter-spacing: .04em; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 64px; min-height: 40px; border-radius: 10px; border: 1px solid var(--panel-border); background: var(--btn); cursor: pointer; font-size: 14px; font-weight: 700; }
.seg button.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.tog { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--panel-border); font-size: 15px; }
.tog span { flex: 1; }
.tog small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.sw-i { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--btn); border: 1px solid var(--panel-border); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.sw-i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.sw-i:checked { background: var(--accent); }
.sw-i:checked::after { transform: translateX(18px); }
.num { width: 76px; min-height: 36px; border-radius: 10px; border: 1px solid var(--panel-border); background: var(--btn); color: var(--fg); font: inherit; font-size: 16px; text-align: center; }
select.num { width: auto; padding: 0 8px; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-card { border-radius: 12px; border: 2px solid transparent; padding: 0; overflow: hidden; cursor: pointer; background: none; }
.theme-card.on { border-color: var(--accent); }
.theme-card .pv { height: 64px; display: flex; align-items: center; justify-content: center; gap: 2px; --tw: 20px; }
.theme-card .pv .tile { --th: 2px; }
.theme-card .lb { display: block; padding: 5px 2px; font-size: 12px; font-weight: 700; background: var(--sheet2); }

.preset { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 6px; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--btn); cursor: pointer; text-align: left; }
.preset.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset b { font-size: 15px; }
.preset small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.preset .v { margin-left: auto; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.preset[disabled] { opacity: .45; cursor: default; }
.custom-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; font-size: 15px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 6px 4px; border-bottom: 1px solid var(--panel-border); text-align: left; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); font-weight: 800; }
.neg { color: var(--danger); font-weight: 800; }

/* 結算 */
.result-title { font-size: 28px; font-weight: 900; font-family: var(--tile-font); margin: 0 0 4px; }
.sheet-body > .result-title:first-child { margin-top: -4px; }
.win-hand { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1px; margin: 8px 0 4px; --tw: 22px; }
.win-hand .tile { --th: 2.5px; }
.win-hand .gap { width: 6px; }
.win-hand .tile.wt { box-shadow: inset 0 0 0 2px var(--danger), 0 var(--th) 0 var(--tile-side), 0 0 10px var(--danger); }
.fan-list { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 15px; margin: 8px 0; }
.fan-list .tot { font-weight: 900; font-size: 18px; border-top: 1px solid var(--panel-border); padding-top: 4px; }
.fan-list .tot.v { color: var(--accent); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px; background: var(--danger); color: #fff; font-weight: 800; vertical-align: middle; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-grid div { background: var(--btn); border-radius: 12px; padding: 8px; text-align: center; }
.stat-grid b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-grid small { color: var(--muted); font-size: 11px; }
.muted { color: var(--muted); }
.fan-ref { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.fan-ref .off { opacity: .4; text-decoration: line-through; }
details.hist { border-bottom: 1px solid var(--panel-border); padding: 6px 0; font-size: 14px; }
details.hist summary { cursor: pointer; }

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

