/* 台灣麻將館：單一暗色調（像夜裡開燈打牌），不跟系統明暗切換 */
:root {
  color-scheme: dark;
  --bg: #1b100b;
  --surface: #2b1a12;
  --surface-2: #3a2418;
  --line: #6b4a2a;
  --ink: #f6ead2;
  --muted: #c9b28a;
  --jade: #3fb37c;
  --jade-soft: #1f4a35;
  --vermilion: #e2463a;
  --vermilion-soft: #4a1c17;
  --tile: #f7f1dc;
  --tile-edge: #d9cba4;
  --tile-back: #2a5ea8;
  --tile-back-dark: #1c4480;
  --tail: #f1c04d;
  --gold: #e8c063;
  --gold-deep: #a87b2c;
  --lacquer: #7d1717;
  --led: #ff4a36;
  --felt: #2a8a5a;
  --felt-2: #114b31;
  --rim: #6b3f1f;
  --on-felt: #f6ead2;
  --font-display: "LXGW WenKai TC", "Noto Serif TC", "Kaiti TC", "DFKai-SB", serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --radius-s: 6px;
  --radius-m: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  padding-inline: 16px;
  padding-block: 20px 48px;
}
.wrap { max-width: 980px; margin-inline: auto; display: grid; gap: 20px; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); line-height: 1.1; margin: 0; letter-spacing: 0.04em; text-wrap: balance; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.score { display: flex; gap: 8px; font-variant-numeric: tabular-nums; }
.score span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; color: var(--muted); }
.score b { color: var(--ink); font-weight: 700; }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); }
.tab {
  font: inherit; font-weight: 500; color: var(--muted);
  background: none; border: 0; padding: 10px 16px 12px; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
  transition: color 150ms var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--jade); font-weight: 700; }
.tab:focus-visible, .opt:focus-visible, .btn:focus-visible, input:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }

.panel { display: grid; gap: 20px; }
.panel h2 { font-family: var(--font-display); font-size: 1.35rem; margin: 0; letter-spacing: 0.02em; }
.lede { margin: 0; color: var(--muted); max-width: 62ch; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; display: grid; gap: 14px; align-content: start; }

/* tiles */
.tile {
  display: inline-grid; place-items: center; position: relative;
  width: 2.6em; height: 3.4em; border-radius: var(--radius-s);
  background: var(--tile); color: #1a1a1a;
  border: 1px solid var(--tile-edge);
  box-shadow: 0 3px 0 var(--tile-back), 0 5px 10px rgb(0 0 0 / 0.15);
  font-family: var(--font-display); font-weight: 900; font-size: 1.3rem; line-height: 1;
}
.tile.lg { font-size: 2.2rem; }
.tile .num { position: absolute; top: 0.18em; left: 0.24em; font-family: var(--font-body); font-size: 0.38em; font-weight: 700; color: #6b5d3a; }
.tile.season { color: #b4342b; }
.tile.gentleman { color: #1d5a8a; }
.tile.zhong { color: #b4342b; }
.tile.fa { color: #1d6a50; }
.tile-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* dice game */
.hud { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 16px; }
/* 固定提示區高度，文字換行數改變時牌桌不會上下跳 */
.banner { display: grid; gap: 2px; min-height: 5.4em; align-content: start; flex: 1 1 18em; min-width: 0; }
.match-hud { flex: 0 1 auto; }
.banner .step { font-size: 0.78rem; letter-spacing: 0.14em; color: var(--muted); font-weight: 700; }
.banner .say { font-family: var(--font-display); font-size: clamp(1.1rem, 0.95rem + 0.9vw, 1.5rem); font-weight: 900; line-height: 1.35; text-wrap: balance; }
.banner .say em { font-style: normal; color: var(--vermilion); }
.game { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .game { grid-template-columns: minmax(0, 1fr); } }
.table-wrap { display: grid; gap: 10px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.mj-table {
  position: relative; width: 100%; max-width: 560px; aspect-ratio: 1 / 1.02; margin-inline: auto;
  /* clip 而不是 hidden：牌牆可被鍵盤選取，hidden 會讓瀏覽器為了露出焦點而偷捲牌桌 */
  border-radius: 18px; overflow: hidden; overflow: clip; user-select: none; -webkit-user-select: none;
  background: radial-gradient(120% 80% at 50% 0%, #2c4560 0%, #16222f 60%, #0e161f 100%);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.25);
  color: #f2f5f7;
  --hot: #f1c04d;
  --open: #ff5a4a;
}
.plane {
  position: absolute; left: 1%; width: 98%; aspect-ratio: 1; bottom: 15%;
  transform-origin: 50% 100%; transform: perspective(620px) rotateX(44deg);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 50%, #2f8a64 0%, #1f6a4c 70%, #185a40 100%);
  box-shadow: inset 0 0 0 10px #8c2a2a, inset 0 0 0 13px #5e1b1b, 0 30px 40px rgb(0 0 0 / 0.45);
}
.plane-center { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.wall { position: absolute; touch-action: none; }
.wall[data-w="0"], .wall[data-w="2"] { left: 18%; right: 18%; height: 11%; padding-block: 6px; }
.wall[data-w="1"], .wall[data-w="3"] { top: 18%; bottom: 18%; width: 11%; padding-inline: 6px; }
.wall[data-w="0"] { bottom: 6%; }
.wall[data-w="2"] { top: 6%; }
.wall[data-w="1"] { right: 6%; }
.wall[data-w="3"] { left: 6%; }
.stacks { display: flex; gap: 2px; width: 100%; height: 100%; border-radius: 3px; transition: outline-color 150ms var(--ease); outline: 2px solid transparent; outline-offset: 4px; }
.wall[data-w="2"] .stacks { flex-direction: row; }
.wall[data-w="1"] .stacks { flex-direction: column; }
.wall[data-w="0"] .stacks { flex-direction: row-reverse; }
.wall[data-w="3"] .stacks { flex-direction: column-reverse; }
.mj-table[data-phase="wall"] .wall { cursor: pointer; }
.mj-table[data-phase="wall"] .wall:hover .stacks { outline: 3px dashed #ffffff; }
.mj-table[data-phase="stack"] .wall { cursor: crosshair; }
.wall.hot .stacks { outline: 3px solid var(--hot); }
.wall.miss { animation: shake 320ms ease-in-out; }
@keyframes shake { 25% { transform: translate(-4px, 0); } 50% { transform: translate(4px, 0); } 75% { transform: translate(-2px, 0); } }
.stack {
  flex: 1; border-radius: 2px; background: #f7f2e2;
  box-shadow: inset 0 -4px 0 var(--tile-back);
  transition: opacity 220ms var(--ease), transform 120ms var(--ease), background-color 150ms var(--ease);
}
.stack.aim { background: #ffffff; transform: scale(1.4); box-shadow: 0 0 0 2px var(--open); position: relative; z-index: 2; }
.stack.tail { background: var(--hot); }
.stack.start { background: var(--open); box-shadow: 0 0 0 2px #ffffff, 0 0 12px var(--hot); }
.stack.wrong { background: transparent; box-shadow: inset 0 0 0 2px #ffb4ac; }
.stack.taken { opacity: 0.08; }

/* 玩家頭像：上家左上、對家正上、下家右上、你左下 */
.seat {
  position: absolute; z-index: 3; pointer-events: none;
  display: grid; justify-items: center; gap: 2px; text-align: center;
  font-size: 0.78rem; font-weight: 700; line-height: 1.15;
}
.seat .avatar {
  position: relative; width: clamp(40px, 12vw, 56px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; font-size: clamp(22px, 7vw, 32px); line-height: 1;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.85), 0 4px 10px rgb(0 0 0 / 0.45);
  transition: box-shadow 200ms var(--ease);
}
.seat .meta {
  display: grid; padding: 2px 10px; border-radius: 8px; min-width: 4.2em;
  background: linear-gradient(#24364a, #142030); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2);
}
.seat .rel { font-size: 0.82rem; }
.seat .wind { font-size: 0.68rem; color: #b9c7d3; font-weight: 500; }
.seat[data-s="0"] { bottom: 12%; left: 2%; grid-auto-flow: column; align-items: center; gap: 6px; }
.seat[data-s="0"] .avatar { width: 36px; font-size: 20px; }
/* 上家／對家／下家的位置由 JS 依牌牆實際位置擺在外側 */
.seat[data-s="1"], .seat[data-s="2"], .seat[data-s="3"] { left: 0; top: 0; }
.seat[data-s="1"] .avatar, .seat[data-s="3"] .avatar { width: clamp(36px, 10vw, 50px); font-size: clamp(20px, 6vw, 28px); }
.seat[data-s="1"] .meta, .seat[data-s="3"] .meta { min-width: 0; padding: 1px 6px; }
.seat.dealer .avatar::after {
  content: "莊"; position: absolute; right: -6px; bottom: -4px; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; background: #d9362b; color: #ffffff;
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 900; box-shadow: 0 0 0 2px #ffffff;
}
.seat.taking .avatar { box-shadow: 0 0 0 3px var(--hot), 0 0 16px var(--hot); }
.seat.shooter .avatar { box-shadow: 0 0 0 3px var(--open), 0 0 18px var(--open); }
.seat.winner .avatar { box-shadow: 0 0 0 3px var(--hot), 0 0 18px var(--hot); }
.bubble {
  position: absolute; z-index: 5; top: 30%; padding: 3px 10px; border-radius: 10px; white-space: nowrap;
  font-family: var(--font-display); font-weight: 900; font-size: 0.95rem;
  background: #ffffff; color: #111111; box-shadow: 0 3px 8px rgb(0 0 0 / 0.4);
  animation: bubble-in 360ms var(--ease) both;
}
.bubble.bad { background: var(--open); color: #ffffff; }
.seat[data-s="3"] .bubble { left: 100%; margin-left: 4px; }
.seat[data-s="1"] .bubble { right: 100%; margin-right: 4px; }
.seat[data-s="2"] .bubble { left: 100%; margin-left: 6px; }
.seat[data-s="0"] .bubble { left: 0; top: auto; bottom: 100%; margin-bottom: 4px; }
@keyframes bubble-in { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* 對手面前的牌背 */
.opp-hand { position: absolute; display: flex; gap: 1px; }
.opp-hand[data-s="2"] { top: 19%; left: 26%; right: 26%; height: 6%; }
.opp-hand[data-s="1"] { right: 19%; top: 26%; bottom: 26%; width: 6%; flex-direction: column; }
.opp-hand[data-s="3"] { left: 19%; top: 26%; bottom: 26%; width: 6%; flex-direction: column; }
.opp-hand i { flex: 1; border-radius: 2px; background: #2c8a67; box-shadow: inset 0 -3px 0 #f7f2e2; }

/* 桌子中央的羅盤面板 */
.centerbox {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none;
  width: clamp(96px, 27%, 150px); aspect-ratio: 1; padding: 16px 18px;
  display: grid; place-items: center; align-content: center; gap: 2px; text-align: center; border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, #1f3244, #0d1621); box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.18), 0 6px 16px rgb(0 0 0 / 0.45);
}
.centerbox.wide { width: clamp(124px, 38%, 180px); aspect-ratio: 1.6; padding-block: 14px; }
.centerbox .edge { position: absolute; font-size: 0.6rem; font-weight: 700; color: #9fb3c6; white-space: nowrap; }
.centerbox .edge[data-s="0"] { bottom: 3px; left: 50%; transform: translateX(-50%); color: var(--hot); }
.centerbox .edge[data-s="2"] { top: 3px; left: 50%; transform: translateX(-50%); }
.centerbox .edge[data-s="1"] { right: 3px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; }
.centerbox .edge[data-s="3"] { left: 3px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; }
.centerbox .edge b { color: #ffffff; }
.hide-winds .centerbox .edge b { display: none; }
.centerbox .roundline { font-size: 0.66rem; color: #d5dee6; font-weight: 700; }

/* 放槍那張牌：亮在羅盤旁邊、靠放槍的人那側 */
.discard { position: absolute; z-index: 4; pointer-events: none; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 2px; }
.discard .htile { width: clamp(24px, 7vw, 34px); flex: none; box-shadow: 0 3px 0 #2c8a67, 0 0 0 2px var(--open), 0 0 16px var(--open); animation: rise 500ms var(--ease) both; }
.discard span.cap { white-space: nowrap; font-size: 0.66rem; font-weight: 700; color: #ffffff; background: var(--open); padding: 0 6px; border-radius: 6px; }
.centerbox .dice-row { display: flex; gap: 4px; }
.centerbox small { font-size: 0.7rem; color: #b9c7d3; }
.die {
  width: 20px; height: 20px; border-radius: 4px; padding: 3px;
  background: #fbf8ee; border: 1px solid #d6cdb4; box-shadow: 0 3px 0 rgb(0 0 0 / 0.35);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
}
.die i { width: 4px; height: 4px; border-radius: 50%; place-self: center; background: #1a1a1a; visibility: hidden; }
.die i.on { visibility: visible; }
.die.red i { background: #c8322b; }
.die.one i.on { width: 7px; height: 7px; }
.die.rolling { animation: wobble 90ms linear infinite alternate; }
@keyframes wobble { from { transform: rotate(-10deg) translateY(-2px); } to { transform: rotate(10deg) translateY(2px); } }
.total { font-family: var(--font-display); font-size: 1rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; color: #ffffff; }

.my-hand { position: absolute; left: 2%; right: 2%; bottom: 2.5%; z-index: 3; pointer-events: none; display: flex; gap: 1px; justify-content: center; }
.htile {
  position: relative; min-width: 0;
  flex: 1; max-width: 32px; aspect-ratio: 3 / 4.2; border-radius: 3px;
  background: linear-gradient(#ffffff, #efe9d8); color: #1a1a1a;
  box-shadow: 0 3px 0 #2c8a67, 0 5px 6px rgb(0 0 0 / 0.45);
  display: grid; place-items: center; align-content: center; gap: 1px;
  font-family: var(--font-display); font-weight: 900; line-height: 1; font-size: clamp(8px, 2.5vw, 13px);
}
.htile .wan { color: #c8322b; }
.htile .tong { color: #1d5a8a; }
.htile .tiao { color: #1d6a50; }
.htile.honor { font-size: clamp(11px, 3.4vw, 18px); }

.hand { position: absolute; left: 0; top: 0; width: 44px; height: 44px; z-index: 5; pointer-events: none; transition: transform 650ms var(--ease); }
.hand-rot { width: 100%; height: 100%; display: grid; place-items: center; }
.hand-emoji { font-size: 34px; line-height: 1; filter: drop-shadow(0 3px 3px rgb(0 0 0 / 0.4)); animation: poke 600ms ease-in-out infinite alternate; }
@keyframes poke { from { transform: translateY(-4px); } to { transform: translateY(4px); } }

.pop {
  position: absolute; left: 50%; top: 50%; z-index: 6; pointer-events: none;
  font-family: var(--font-display); font-weight: 900; font-size: 1.8rem; color: var(--tail);
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.45); animation: pop 900ms var(--ease) forwards;
}
.pop.bad { color: #ffb4ac; }
.pop.time { top: 64%; font-size: 1.2rem; color: #ffffff; }
@keyframes pop {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  20% { transform: translate(-50%, -70%) scale(1.15); opacity: 1; }
  to { transform: translate(-50%, -160%) scale(1); opacity: 0; }
}
.over {
  position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; align-content: center; gap: 8px;
  background: rgb(8 18 14 / 0.86); color: #ffffff; text-align: center;
}
.over b { font-family: var(--font-display); font-size: 3rem; line-height: 1; }
.over .btn { justify-self: center; background: #ffffff; color: #111111; margin-top: 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.persp { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.persp td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.persp td:last-child { text-align: right; font-weight: 700; }

/* quiz */
.q { display: grid; gap: 10px; }
.q-title { font-weight: 700; margin: 0; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.opt {
  font: inherit; font-weight: 500; text-align: center; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  transition: transform 120ms var(--ease), border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.opt:hover:not(:disabled) { border-color: var(--jade); transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: translateY(1px); }
.opt:disabled { cursor: default; opacity: 0.6; }
.opt.is-right { border-color: var(--jade); background: var(--jade-soft); opacity: 1; font-weight: 700; }
.opt.is-wrong { border-color: var(--vermilion); background: var(--vermilion-soft); opacity: 1; }
.feedback { border-radius: 10px; padding: 12px 14px; background: var(--surface-2); font-size: 0.95rem; }
.feedback.good { border-left: 4px solid var(--jade); }
.feedback.bad { border-left: 4px solid var(--vermilion); }
.feedback p { margin: 0; }
.feedback p + p { margin-top: 6px; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; justify-self: start;
  background: var(--ink); color: var(--bg); border: 0; border-radius: 999px; padding: 10px 22px;
  transition: transform 120ms var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.mnemonic { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.9; margin: 0; }
.mnemonic em { font-style: normal; color: var(--vermilion); }

/* seat flower grid */
.seat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 480px) { .seat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.seat-cell { background: var(--surface-2); border-radius: 10px; padding: 10px; display: grid; gap: 6px; justify-items: center; font-size: 0.85rem; }
.seat-cell.hot { background: var(--jade-soft); box-shadow: inset 0 0 0 2px var(--jade); }
.seat-cell b { font-size: 0.95rem; }
.seat-cell .tile { font-size: 1rem; }

/* scenario */
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.facts li { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 0.9rem; }
.hand-flowers { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.breakdown td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.breakdown tr.zero td { color: var(--muted); font-weight: 400; }
.breakdown tr.sum td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 900; font-size: 1.05rem; }
.pay { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 0.9rem; color: var(--muted); }
.pay label { display: inline-flex; align-items: center; gap: 6px; }
.pay input { width: 4.5em; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-variant-numeric: tabular-nums; }
.pay output { color: var(--ink); font-weight: 700; }

/* cheat sheet */
.sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.sheet h3 { margin: 0; font-size: 0.8rem; letter-spacing: 0.12em; color: var(--muted); }
.sheet table { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.sheet td { padding: 6px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.sheet td:last-child { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 10px; }
.sheet td small { display: block; color: var(--muted); font-size: 0.8rem; }
.foot { color: var(--muted); font-size: 0.82rem; margin: 0; }

/* match timer */
.match-hud { display: flex; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; }
.match-hud b { color: var(--ink); }
.match-hud .clock { font-family: var(--font-display); font-weight: 900; font-size: 1.6rem; color: var(--ink); min-width: 4.4ch; text-align: right; }
.match-hud .pen b { color: var(--vermilion); }
.over h3 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; }
.over p { margin: 0; max-width: 30ch; font-size: 0.9rem; color: #d5dee6; }
.result { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 20px; font-variant-numeric: tabular-nums; }
.result span { display: grid; font-size: 0.75rem; color: #b9c7d3; }
.result span b { font-size: 1.3rem; color: #ffffff; }
.over .record { color: var(--hot); font-weight: 700; }

/* scene extras */
.round-tag { position: absolute; left: 2%; top: 2.5%; z-index: 3; padding: 4px 10px; border-radius: 8px; background: rgb(10 18 28 / 0.75); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18); font-size: 0.78rem; font-weight: 700; pointer-events: none; }
.seat .lian { font-size: 0.68rem; color: var(--hot); margin-left: 2px; }
.centerbox .big { font-family: var(--font-display); font-weight: 900; font-size: 1.1rem; line-height: 1.2; color: #ffffff; }
.centerbox .shout { color: var(--hot); }
.centerbox .tag { font-size: 0.64rem; color: #b9c7d3; }
.flower-row { position: absolute; left: 31%; bottom: 13%; z-index: 3; display: flex; gap: 3px; pointer-events: none; }
.flower-row .htile { flex: none; width: clamp(20px, 6vw, 30px); }
.hide-winds .seat .wind { visibility: hidden; }
.no-hand .flower-row { left: 50%; bottom: 3%; transform: translateX(-50%); gap: 6px; }
.no-hand .flower-row .htile { width: clamp(30px, 9vw, 44px); font-size: clamp(14px, 4.4vw, 22px); }
.no-hand .flower-row .htile .fnum { font-size: 9px; }
.htile .fnum { position: absolute; top: 2px; left: 3px; font-family: var(--font-body); font-size: 7px; color: #6b5d3a; }
.htile.season { color: #b4342b; }
.htile.gentleman { color: #1d5a8a; }
.htile.new { animation: rise 500ms var(--ease) both; box-shadow: 0 3px 0 #2c8a67, 0 0 0 2px var(--hot); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.htile.gap { margin-left: 4px; }
.htile.open { background: linear-gradient(#f1ece0, #ddd6c3); box-shadow: 0 2px 0 #8c2a2a, 0 3px 4px rgb(0 0 0 / 0.4); }
.htile.win { transform: translateY(-8px); box-shadow: 0 3px 0 #2c8a67, 0 0 0 2px var(--hot), 0 0 14px var(--hot); }
.htile[data-label]::before {
  content: attr(data-label); position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-body); font-size: 10px; font-weight: 700; color: #ffffff; white-space: nowrap;
}
.htile.win[data-label]::before { color: var(--hot); }

.pin {
  position: absolute; z-index: 4; pointer-events: none; transform: translate(-50%, -50%);
  padding: 2px 8px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; white-space: nowrap;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.45);
}
.pin.head { background: #ffffff; color: #111111; }
.pin.tail { background: var(--hot); color: #111111; }
.stack.is-head { box-shadow: 0 0 0 2px #ffffff, 0 0 10px #ffffff; }
.stack.is-tail-end { box-shadow: 0 0 0 2px var(--hot), 0 0 10px var(--hot); }

.btn.small { padding: 6px 16px; font-size: 0.85rem; }
.match-hud .btn { align-self: center; }
.panel.is-paused .game > .card { pointer-events: none; opacity: 0.4; }

button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.wall { -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 20; padding: 8px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 700; text-decoration: none; }
.skip:focus-visible { top: 12px; outline: 3px solid var(--jade); outline-offset: 2px; }
.wall:focus-visible { outline: none; }
.wall:focus-visible .stacks { outline: 3px solid #ffffff; }


/* ================= 麻將館外觀（覆蓋上面的通用樣式） ================= */
body {
  background:
    radial-gradient(90% 60% at 50% -8%, rgb(255 196 120 / 0.22), transparent 70%),
    radial-gradient(140% 100% at 50% 0%, #3a2214 0%, #1b100b 55%, #120a07 100%);
}

/* 標題：紅漆金字匾額 */
.top {
  padding: 14px 18px; border-radius: 14px;
  background: linear-gradient(180deg, #9a2219 0%, var(--lacquer) 55%, #5b0f0f 100%);
  box-shadow: inset 0 0 0 2px var(--gold-deep), inset 0 0 0 5px #5b0f0f, inset 0 0 0 6px rgb(232 192 99 / 0.5), 0 10px 24px rgb(0 0 0 / 0.45);
}
.brand h1 {
  font-family: "Noto Serif TC", var(--font-display); font-weight: 900; letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff3c4 0%, var(--gold) 45%, #b8862f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #3b0808);
}
.brand p { color: #f1d9a8; }
.score span { background: rgb(0 0 0 / 0.35); border-color: var(--gold-deep); color: #f1d9a8; }
.score b { color: var(--gold); }

/* 分頁：遊戲模式按鈕 */
.tabs { border-bottom: 0; gap: 8px; padding-bottom: 2px; }
.tab {
  border: 0; margin: 0; padding: 9px 18px; border-radius: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; color: #e9d3a6;
  background: linear-gradient(#3a2418, #24150e);
  box-shadow: inset 0 0 0 1.5px var(--gold-deep), 0 3px 0 #120a07;
}
.tab:hover { color: #fff3c4; }
.tab[aria-selected="true"] {
  color: #fff3c4; border: 0;
  background: linear-gradient(#b02a20, var(--lacquer));
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 3px 0 #3b0808, 0 0 14px rgb(232 192 99 / 0.25);
}

/* 木頭面板 */
.card {
  background: linear-gradient(180deg, #34200f 0%, #24160d 100%);
  border: 1px solid #5a3a1f;
  box-shadow: inset 0 1px 0 rgb(255 230 180 / 0.08), inset 0 0 0 4px rgb(0 0 0 / 0.18), 0 8px 18px rgb(0 0 0 / 0.35);
}
.q-title, .sheet h3 { color: var(--gold); }
.banner .step { color: var(--gold-deep); }
.banner .say { font-family: var(--font-display); font-weight: 700; }
.banner .say em { color: var(--gold); }
.feedback { background: rgb(0 0 0 / 0.28); }
.feedback.good { border-left-color: var(--jade); }
.facts li { background: rgb(0 0 0 / 0.3); box-shadow: inset 0 0 0 1px var(--gold-deep); color: #f1d9a8; }
.mnemonic em { color: var(--gold); }

/* 金色立體遊戲按鈕 */
.btn {
  font-family: var(--font-display); font-size: 1.05rem; letter-spacing: 0.06em;
  color: #3b1e06; border-radius: 12px; padding: 10px 26px;
  background: linear-gradient(180deg, #fff1b8 0%, var(--gold) 45%, #b8862f 100%);
  box-shadow: inset 0 1px 0 #fffbe6, 0 4px 0 #7a5418, 0 6px 12px rgb(0 0 0 / 0.4);
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 1px 0 #fffbe6, 0 1px 0 #7a5418; }
.btn.ghost { color: var(--gold); background: rgb(0 0 0 / 0.25); box-shadow: inset 0 0 0 1.5px var(--gold-deep), 0 3px 0 #120a07; }
.btn.small { padding: 5px 14px; font-size: 0.9rem; }

/* 答案選項：一張張站著的麻將牌 */
.opt {
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: #1a1a1a;
  border: 0; border-radius: 8px; padding: 12px 10px 10px;
  background: linear-gradient(180deg, #fffdf4 0%, #efe6cc 100%);
  box-shadow: 0 4px 0 var(--tile-back), 0 6px 0 var(--tile-back-dark), 0 8px 12px rgb(0 0 0 / 0.45);
}
.opt:hover:not(:disabled) { transform: translateY(-3px); border: 0; }
.opt:disabled { opacity: 0.45; }
.opt.is-right { opacity: 1; background: linear-gradient(#fff7d6, #f3dd92); box-shadow: 0 4px 0 var(--tile-back), 0 6px 0 var(--tile-back-dark), 0 0 0 3px var(--gold), 0 0 18px var(--gold); }
.opt.is-wrong { opacity: 1; background: linear-gradient(#f6d6cf, #e3a99f); box-shadow: 0 4px 0 var(--tile-back), 0 6px 0 var(--tile-back-dark), 0 0 0 3px var(--vermilion); }

/* 計時：紅色 LED */
.match-hud { color: var(--muted); }
.match-hud b { color: #f1d9a8; }
.match-hud .clock {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: 1.35rem; color: var(--led);
  background: #0a0605; padding: 2px 12px; border-radius: 8px;
  box-shadow: inset 0 0 0 1px #3a1a12, inset 0 2px 6px rgb(0 0 0 / 0.8);
  text-shadow: 0 0 8px rgb(255 74 54 / 0.7);
}

/* 牌桌：麻將館燈光、木頭桌邊、絨布 */
.mj-table {
  background: radial-gradient(120% 70% at 50% -10%, #7a4a22 0%, #3a2214 45%, #1a0f0a 100%);
  box-shadow: inset 0 0 0 1px #5a3a1f, 0 14px 30px rgb(0 0 0 / 0.5);
}
.plane {
  background:
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.025) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(-45deg, rgb(0 0 0 / 0.05) 0 2px, transparent 2px 5px),
    radial-gradient(circle at 50% 48%, #2f9a64 0%, #1d7048 60%, var(--felt-2) 100%);
  box-shadow: inset 0 0 0 11px #7a4a26, inset 0 0 0 13px #3d230f, inset 0 0 0 15px #a06a3a, inset 0 0 40px rgb(0 0 0 / 0.45), 0 30px 40px rgb(0 0 0 / 0.55);
}
/* 牌牆：藍色牌背朝上，看得到靠自己這側的象牙色牌身 */
.stack { background: linear-gradient(#3a72c0, var(--tile-back)); box-shadow: inset 0 -4px 0 #efe5c8; }
.opp-hand i { background: linear-gradient(#3a72c0, var(--tile-back)); box-shadow: inset 0 -3px 0 #efe5c8; }

/* 中央：電動麻將桌控制面板（黑玻璃＋紅 LED） */
.centerbox {
  background: radial-gradient(circle at 35% 25%, #2a2a2a 0%, #0c0c0c 60%, #050505 100%);
  box-shadow: inset 0 0 0 2px #2d2d2d, inset 0 0 0 3px var(--gold-deep), inset 0 10px 18px rgb(255 255 255 / 0.05), 0 8px 18px rgb(0 0 0 / 0.6);
}
.centerbox .edge { color: #8a5048; }
.centerbox .edge b, .centerbox .edge[data-s="0"] { color: var(--led); text-shadow: 0 0 6px rgb(255 74 54 / 0.8); }
.centerbox .total { color: var(--led); font-family: ui-monospace, "SF Mono", Menlo, monospace; text-shadow: 0 0 8px rgb(255 74 54 / 0.8); }
.centerbox .roundline { color: var(--gold); }
.centerbox .big { font-family: var(--font-display); }
.centerbox .shout { background: linear-gradient(180deg, #fff3c4, var(--gold) 50%, #b8862f); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* 頭像名牌 */
.seat .avatar { box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgb(0 0 0 / 0.5); }
.seat .meta { background: linear-gradient(#5b1712, #3a0d0b); box-shadow: inset 0 0 0 1px var(--gold-deep); color: #f6ead2; }
.seat .wind { color: var(--gold); }

/* 站著的牌：象牙色牌面＋藍色牌背 */
.htile {
  font-family: var(--font-display); font-weight: 700;
  background: linear-gradient(180deg, #fffdf4 0%, #efe6cc 100%);
  box-shadow: 0 3px 0 var(--tile-back), 0 5px 0 var(--tile-back-dark), 0 7px 8px rgb(0 0 0 / 0.45);
  border-radius: 4px;
}
.htile svg { position: absolute; left: 8%; top: 6%; width: 84%; height: 88%; display: block; }
.htile .baiban { position: absolute; left: 21%; right: 21%; top: 17%; bottom: 17%; border: 2px solid var(--tile-back); border-radius: 2px; box-shadow: inset 0 0 0 1.5px #fffdf4, inset 0 0 0 3px var(--tile-back); }
.tile {
  font-family: var(--font-display); font-weight: 700; border: 0;
  background: linear-gradient(180deg, #fffdf4 0%, #efe6cc 100%);
  box-shadow: 0 4px 0 var(--tile-back), 0 6px 0 var(--tile-back-dark), 0 8px 12px rgb(0 0 0 / 0.45);
}

/* 開始／暫停／結算畫面 */
.over { background: radial-gradient(circle at 50% 40%, rgb(60 20 12 / 0.92), rgb(14 8 5 / 0.95)); }
.over h3 { font-family: var(--font-display); color: var(--gold); font-size: 1.7rem; letter-spacing: 0.08em; }
.over .btn { background: linear-gradient(180deg, #fff1b8 0%, var(--gold) 45%, #b8862f 100%); color: #3b1e06; }

.top .tile.lg { font-size: 1.5rem; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 1 0; min-width: max-content; text-align: center; }
@media (max-width: 480px) {
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .tab { min-width: 0; padding: 8px 2px; font-size: 0.88rem; letter-spacing: 0; }
  .top { padding: 12px 14px; }
}

/* 算台模式：花牌＋吃碰的牌同一排，排得下就好，牌小一點 */
.has-melds .flower-row { left: 31%; right: 2%; gap: 2px; align-items: flex-end; }
.has-melds .flower-row .htile { width: clamp(14px, 4.2vw, 28px); }
.has-melds .flower-row .htile.gap { margin-left: 6px; }
.has-melds .flower-row { bottom: 14.5%; }
.has-melds .my-hand .htile { max-width: 27px; }
.has-melds .my-hand .htile.win { transform: none; }

/* 排行榜 */
.over { overflow-y: auto; padding-block: 12px; }
.board-result { display: grid; gap: 6px; justify-items: center; max-width: 30ch; }
.board-msg { margin: 0; color: #f1d9a8; font-size: 0.9rem; }
.board-rank { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--gold); }
.board-rank.podium { font-size: 1.35rem; animation: rank-pop 520ms var(--ease) both; text-shadow: 0 0 12px rgb(232 192 99 / 0.6); }
@keyframes rank-pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.name-form { display: grid; gap: 6px; justify-items: center; }
.name-label { font-weight: 700; color: var(--gold); }
.name-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.name-row input {
  width: 11em; font: inherit; color: #1a1a1a; background: #fffdf4; border: 0; border-radius: 8px; padding: 6px 10px;
  box-shadow: inset 0 0 0 2px var(--gold-deep);
}
.name-error { margin: 0; color: #ffb4ac; font-size: 0.82rem; }
.btn.share { text-decoration: none; display: inline-block; }
.board { gap: 10px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.board-head h3 { margin: 0; font-family: var(--font-display); color: var(--gold); font-size: 1.2rem; letter-spacing: 0.08em; }
.board-tabs { display: flex; gap: 4px; }
.board-tabs button {
  font: inherit; font-size: 0.85rem; padding: 4px 12px; border-radius: 8px; border: 0; cursor: pointer; color: #e9d3a6;
  background: rgb(0 0 0 / 0.3); box-shadow: inset 0 0 0 1px var(--gold-deep);
}
.board-tabs button[aria-pressed="true"] { color: #fff3c4; background: linear-gradient(#b02a20, var(--lacquer)); box-shadow: inset 0 0 0 1px var(--gold); }
.board-note { margin: 0; color: var(--muted); font-size: 0.8rem; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board-row {
  display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px; background: rgb(0 0 0 / 0.22); font-variant-numeric: tabular-nums;
}
.board-row .place { font-family: var(--font-display); font-weight: 700; color: var(--muted); text-align: center; }
.board-row.podium .place { color: #3b1e06; border-radius: 6px; background: linear-gradient(180deg, #fff1b8, var(--gold) 50%, #b8862f); }
.board-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .stat { color: #f1d9a8; font-size: 0.85rem; }
.board-row.me { box-shadow: inset 0 0 0 2px var(--jade); }
.board-empty { color: var(--muted); padding: 6px 2px; }
.board-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: #f1d9a8; font-size: 0.88rem; }
.board-mine { color: var(--gold); font-weight: 700; }
.linkish { font: inherit; color: var(--gold); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
@media (max-width: 480px) { .tab { white-space: normal; line-height: 1.2; } }

/* 分頁圖示：桌機只顯示文字，手機變成底部選單的小麻將牌 */
.tab-icon, .tab-short { display: none; }

/* ================= 手機版（以手機為主） ================= */
@media (max-width: 600px) {
  body { padding-inline: 10px; padding-block: 8px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .wrap { gap: 10px; }

  /* 頂部：細細一條匾額 */
  .top { padding: 8px 12px; gap: 6px 10px; align-items: center; border-radius: 10px; }
  .brand { gap: 8px; }
  .brand p, .top .tile.lg { display: none; }
  .brand h1 { font-size: 1.35rem; letter-spacing: 0.08em; }
  .score { gap: 4px; }
  .score span { padding: 2px 8px; font-size: 0.72rem; }

  /* 分頁放在上方：四個金框按鈕一行排開 */
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .tab, .tab[aria-selected="true"] { min-width: 0; padding: 8px 2px; font-size: 0.86rem; letter-spacing: 0; white-space: nowrap; }

  /* 提示＋計時：壓成兩行 */
  .hud { gap: 4px; }
  .banner { min-height: 0; }
  .banner .step { font-size: 0.7rem; }
  .banner .say { font-size: 1.02rem; min-height: 2.7em; }
  .match-hud { width: 100%; justify-content: space-between; gap: 6px; font-size: 0.8rem; }
  .match-hud .hud-extra { display: none; }
  .match-hud .clock { font-size: 1.15rem; min-width: 0; }

  /* 牌桌貼齊左右，下面直接接答案 */
  .game { gap: 10px; }
  .mj-table { border-radius: 14px; aspect-ratio: 1 / 0.86; }
  .legend, .table-wrap > .foot, .game > .card > .facts, .banner .step { display: none; }
  .seat[data-s="1"] .bubble, .seat[data-s="3"] .bubble { left: 50%; right: auto; top: auto; bottom: 100%; margin: 0 0 4px; transform: translateX(-50%); }
  .game > .card { background: none; border: 0; box-shadow: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
  .game > .card > .btn, .game > .card > .controls { order: 2; }
  .game > .card > .opts, .game > .card > .facts { order: 1; }
  .game > .card > .feedback, .game > .card > .breakdown, .game > .card > .pay, .game > .card > .lede { order: 3; }
  .game > .card > .btn, .controls .btn { width: 100%; padding-block: 12px; }
  .controls { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .opts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .opt { padding: 10px 2px 8px; font-size: 1.05rem; }
  .facts { gap: 4px; }
  .facts li { font-size: 0.78rem; padding: 2px 8px; }
  .feedback { font-size: 0.88rem; padding: 10px 12px; }
  .split { gap: 10px; }
  .card { padding: 14px; }
}

/* 答題印章：答對「胡」、答錯「詐胡」 */
.stamp {
  position: absolute; z-index: 6; left: 50%; top: 40%; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.4rem, 13vw, 4.2rem); line-height: 1.1;
  color: #d42a20; border: 5px double currentColor; border-radius: 12px; padding: 0.05em 0.3em;
  background: rgb(255 246 224 / 0.92); box-shadow: 0 8px 22px rgb(0 0 0 / 0.5);
  animation: stamp-in 380ms cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.stamp.bad { color: #3a3a3a; }
@keyframes stamp-in {
  from { transform: translate(-50%, -50%) rotate(-12deg) scale(2.2); opacity: 0; }
  to { transform: translate(-50%, -50%) rotate(-12deg) scale(1); opacity: 1; }
}

/* ===== Impeccable 審查＋Emil 動畫標準修正（2026-10-13） ===== */
:root { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); --press-ms: 120ms; }

/* 標題列的 3D 試玩入口：跟分數膠囊同排，但用金色表示可以點 */
.score-link { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color: #3b1e06; text-decoration: none; background: linear-gradient(180deg, #fff1b8, var(--gold) 50%, #b8862f); box-shadow: 0 2px 0 #7a5418; }
.score-link:active { transform: translateY(2px); box-shadow: none; }

/* 瀏覽器自帶的地方也套用麻將館配色 */
::selection { background: rgb(232 192 99 / 0.45); color: #fff8e6; }
html { scrollbar-color: var(--gold-deep) #120a07; accent-color: var(--gold); }
input { caret-color: var(--vermilion); }

/* 不要「提示上方的小標籤」：下面那句已經說清楚了 */
.banner .step { display: none; }

/* 解說框：拿掉左側粗色線，改成整框淡淡的底色 */
.feedback { border-left: 0; border-radius: 10px; box-shadow: inset 0 0 0 1px rgb(232 192 99 / 0.18); }
.feedback.good, .feedback.bad { border-left: 0; }
.feedback.good { background: rgb(63 179 124 / 0.14); box-shadow: inset 0 0 0 1px rgb(63 179 124 / 0.45); }
.feedback.bad { background: rgb(226 70 58 / 0.14); box-shadow: inset 0 0 0 1px rgb(226 70 58 / 0.45); }

/* 羅盤四邊的字提亮（原本對比不夠） */
.centerbox .edge { color: #c99a8f; }

/* 按下去縮一點點（Emil：0.97、120ms、ease-out）；麻將牌按鈕維持往下壓的手感 */
.opt, .tab, .board-tabs button, .linkish { transition: transform var(--press-ms) var(--ease-out), box-shadow 150ms ease, background-color 150ms ease, color 150ms ease; }
.opt:active:not(:disabled), .tab:active, .board-tabs button:active { transform: scale(0.97); }
.btn { transition: transform var(--press-ms) var(--ease-out), box-shadow var(--press-ms) var(--ease-out); }

/* 滑鼠移過去的浮起效果只給有滑鼠的裝置，手機點完不會卡住 */
@media (hover: none) {
  .opt:hover:not(:disabled), .btn:hover { transform: none; }
}

/* 動畫時間收斂到 0.3 秒內，不從很小的比例冒出來 */
.bubble { animation: bubble-in 220ms var(--ease-out) both; }
@keyframes bubble-in { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.htile.new { animation: rise 280ms var(--ease-out) both; }
.board-rank.podium { animation: rank-pop 420ms var(--ease-out) both; }
@keyframes rank-pop { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* 手機：手指好按（至少 44px）、輸入框 16px 免得 iPhone 自動放大、名牌別擋花牌 */
.name-row input, .pay input { font-size: 16px; }
@media (max-width: 600px) {
  .tab, .tab[aria-selected="true"] { min-height: 44px; }
  .match-hud .btn.small { min-height: 40px; min-width: 64px; }
  .board-tabs button { min-height: 40px; padding-inline: 14px; }
  .pay input { min-height: 40px; }
  .seat[data-s="0"] .meta { display: flex; gap: 4px; align-items: baseline; }
  .has-melds .flower-row { left: 37%; }
}

/* 減少動態效果：保留淡入淡出讓回饋還看得到，只拿掉位移、縮放和晃動 */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
/* 花牌號碼：黑底小圓章，一眼看得到 1、2、3、4 */
/* 花牌：號碼當主角（大字），國字縮小放左上角 */
.flower-tile { font-family: var(--font-body); font-weight: 800; color: #121212; }
.htile.flower-tile.season, .tile.flower-tile.season { color: #121212; }
.htile.flower-tile.gentleman, .tile.flower-tile.gentleman { color: #121212; }
.flower-tile .fchar { position: absolute; top: 2px; left: 3px; font-family: var(--font-display); font-size: 0.42em; font-weight: 700; line-height: 1; }
.season .fchar { color: #b4342b; }
.gentleman .fchar { color: #1d5a8a; }
.htile.flower-tile { font-size: clamp(14px, 4.4vw, 22px); }
/* 秒數越久越急：5 秒後橘、10 秒後紅並輕微跳動 */
.match-hud .clock { transition: color 200ms ease, box-shadow 200ms ease; }
.match-hud .clock[data-level="warn"] { color: #f08c1a; text-shadow: 0 0 8px rgb(240 140 26 / 0.5); }
.match-hud .clock[data-level="hot"] { color: #ff3b30; text-shadow: 0 0 10px rgb(255 59 48 / 0.7); animation: clock-pulse 900ms ease-in-out infinite; }
@keyframes clock-pulse { 50% { transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .hand-emoji, .die.rolling, .wall.miss { animation: none !important; }
  .stamp, .pop, .bubble, .htile.new, .board-rank.podium, .over { animation: fade-in 200ms ease both !important; }
  .hand { transition: none !important; }
}
.over .players-count { margin: 0; font-size: 0.82rem; opacity: 0.75; }
