:root {
  color-scheme: light;
  --ink: #202c27;
  --muted: #666e62;
  --green: #164c42;
  --red: #963a32;
  --line: #d4c9b4;
  --paper: #f8f5ed;
  --serif: "Songti TC", "Noto Serif TC", "PMingLiU", "Hiragino Mincho ProN", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 15% 10%, #fcf9f2, transparent 58%), #f5f1e7;
  font: 15px/1.5 var(--sans);
}
body::before, .felt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("assets/grain.svg");
  opacity: .075;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, dialog :focus-visible { outline: 3px solid #bc7525; outline-offset: 4px; }
button, .tile-face { touch-action: manipulation; }
h1,h2,p,ol,ul { margin: 0; }
.symbols { position: absolute; height: 0; width: 0; overflow: hidden; }
.icon { width: 19px; height: 19px; display: inline-block; flex: none; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: min(1440px, 92%); margin-inline: auto; position: relative; }
.masthead { border-bottom: 1px solid #bba591; }
.mast-inner { min-height: 74px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; font: bold 35px/.96 Georgia, "Times New Roman", serif; letter-spacing: -1.7px; color: #212d24; }
.brand-name { font-family: var(--serif); letter-spacing: .055em; white-space: nowrap; }
.brand-mark { position: relative; width: 39px; height: 43px; display: inline-block; transform: rotate(-7deg); }
.brand-mark i, .brand-mark b { display: grid; place-items: center; position: absolute; width: 28px; height: 36px; border: 1.4px solid #594d39; border-radius: 5px; }
.brand-mark i { left: 0; top: 2px; transform: rotate(-7deg); background: #e9d9ab; box-shadow: -1px 2px #aa986a; }
.brand-mark b { bottom: 1px; right: 1px; color: #9b3227; background: #fff4d9; box-shadow: 0 2px #ad9564; font: 900 24px/1 var(--serif); }
.brand-subtitle { padding-left: 22px; border-left: 1px solid #baae9a; font-size: 13px; font-weight: 600; letter-spacing: .13em; color: #595e52; }
nav { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.nav-btn,.quiet-btn { border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 640; }
.nav-btn { min-height: 42px; padding: 6px 9px; font-size: 14px; }
a.nav-btn { color: inherit; text-decoration: none; }
@media (max-width:400px) { .masthead .brand-subtitle { display: none; } }
.nav-btn:hover,.quiet-btn:hover { color: var(--red); }
.nav-divider { height: 18px; width: 1px; background: var(--line); }
.sound { width: 38px; }
.sound .off,.sound.muted .on { display: none; }
.sound.muted .off { display: inline; }
.table-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 27px 0 25px; }
.heading-main { display: flex; align-items: center; gap: 15px; }
.heading-main > div { display: flex; align-items: center; gap: 18px; }
.east-seal { display: grid; place-items: center; width: 41px; height: 45px; background: var(--red); color: #fff3da; border-radius: 6px 4px 7px 4px; font: bold 31px/1 var(--serif); box-shadow: inset 0 0 0 2px #983a32, inset 0 0 0 3px #c28870; transform: rotate(-2deg); }
h1 { font: 800 clamp(32px, 3vw, 46px)/1.12 var(--serif); letter-spacing: .045em; color: #1d2c24; }
.heading-main p { padding-left: 18px; border-left: 1px solid #c9bca7; color: #696b60; font: 600 13px/1.3 var(--sans); letter-spacing: .09em; }
.heading-main p span { margin: 0 2px; color: #baafa0; }
.outline-btn,.primary-btn,.dialog-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 6px; padding: 8px 17px; min-height: 40px; border: 1px solid #436759; background: #faf8f0; color: #244b3c; font-weight: 700; font-size: 14px; letter-spacing: .045em; }
.outline-btn:hover:enabled,.dialog-actions button:hover { background: #ecebdd; }
.outline-btn:disabled { opacity: .57; }
.restart { color: var(--red); border-color: #ad7c69; min-height: 37px; font-size: 13px; }
.restart .icon { width: 16px; height: 16px; }
.layout { display: grid; grid-template-columns: minmax(0, 2.72fr) minmax(248px, 1fr); gap: 16px; align-items: stretch; }
.felt { position: relative; isolation: isolate; min-width: 0; min-height: 412px; display: flex; flex-direction: column; overflow: hidden; border-radius: 13px; border: 1px solid #193e33; background: radial-gradient(ellipse at 35% 18%, #205b4e, transparent 75%), #103f36; box-shadow: inset 0 0 24px #082a2866, 0 3px 8px #44371c1a; color: #f3e7c5; }
.felt::after { position: absolute; opacity: .17; mix-blend-mode: soft-light; z-index: -1; }
.landscape { position: absolute; z-index: -1; right: 0; bottom: 11%; width: 82%; aspect-ratio: 3; background: url("assets/table-landscape.webp") center / 100% auto no-repeat; opacity: .52; filter: grayscale(.7) contrast(2.1); mix-blend-mode: screen; mask-image: linear-gradient(0deg, transparent, #000 12%, #000 78%, transparent); }
.felt-border { position: absolute; inset: 9px; border: 1px solid #c0aa718c; outline: 1px solid #bba66966; outline-offset: 3px; border-radius: 5px; pointer-events: none; }
.corner { position: absolute; fill: none; stroke: #c8aa6d; stroke-width: 1.25px; width: 28px; height: 28px; }
.tl { top: -1px; left: -1px; } .tr { top: -1px; right: -1px; transform: rotate(90deg); }
.br { bottom: -1px; right: -1px; transform: rotate(180deg); } .bl { bottom: -1px; left: -1px; transform: rotate(270deg); }
.seats { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 27px 4.2% 0; }
.seat { display: flex; align-items: center; gap: 9px; min-width: 0; }
.wind { display: grid; place-items: center; width: 35px; height: 35px; flex: none; border-radius: 50%; border: 1px solid #c1b98c; color: #ede5bc; font: bold 22px/1 var(--serif); box-shadow: inset 0 0 0 3px #1d5247, inset 0 0 0 4px #9ca8785e; }
.seat.active .wind { background: #e5dab0; color: #204a3c; }
.seat-body { min-width: 0; }
.seat-title { color: #f2eacb; font-size: 12px; font-weight: 600; letter-spacing: .07em; margin-bottom: 3px; }
.seat-title small { font-size: 10px; font-weight: 450; letter-spacing: .04em; color: #b1c8b3; margin-left: 3px; }
.backs { display: flex; flex-wrap: nowrap; align-items: center; filter: drop-shadow(0 2px 1px #092c22); }
.backs i { width: clamp(5px, .62vw, 11px); height: 17px; background: linear-gradient(120deg,#6b9582,#3c7162 45%,#316153); border: 1px solid #bdbea2; border-top: 2px solid #e1d7ad; border-bottom: 2px solid #a3a782; border-radius: 2px; margin-left: -1px; }
.field { flex: 1; min-height: 230px; display: flex; flex-direction: column; justify-content: center; padding: 24px 4.5% 28px; }
.felt-heading { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 21px; color: #e7dbaf; }
.felt-heading h2 { font: 650 18px/1.3 var(--serif); letter-spacing: .2em; padding-left: .2em; }
.felt-heading i { display: block; width: 44px; height: 1px; background: #b7ad7e9c; }
.groups { display: flex; justify-content: center; align-items: center; align-content: center; flex-wrap: wrap; gap: 12px clamp(14px, 2.4vw, 37px); }
.meld { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 3px 1px; background: transparent; border: 1px solid transparent; border-radius: 7px; color: #e0d6b7; }
.meld:has(.tile:enabled:hover),.meld:has(.meld-label:enabled:hover) { background: #fff1c215; }
.meld.selected { background: #e7d3a824; border-color: #e5ce84; }
.meld-tiles { display: flex; align-items: center; gap: 2px; }
.tile { flex: none; position: relative; display: inline-grid; place-items: center; padding: 5px 5px 6px; width: clamp(37px, 3.68vw, 62px); aspect-ratio: .75; border: 1px solid #eee2be; border-radius: 5px; background: linear-gradient(112deg,#fffced 5%,#fdf6e2 70%,#f4e8ca); box-shadow: inset 0 1px 1px #fff, inset -1px -2px 1px #e7d3a6, 0 3px 0 #b7a270, 0 5px 0 #8a784f, 1px 7px 7px #082c2580; vertical-align: middle; }
.meld-label { font-size: 11px; font-weight: 600; letter-spacing: .105em; color: #eee2bd; }
.meld { max-width: 100%; }
.meld-tiles { max-width: 100%; }
.meld-tiles .tile { min-width: 0; flex-shrink: 1; }
.seat-meta { display: block; margin-top: 4px; color: #e3e6cc; font: 500 11px/1.4 var(--sans); background: transparent; padding: 2px 0; border: 0; text-align: left; }
.seat-meta:hover { text-decoration: underline; }
.player-extras { margin-top: 7px; font-size: 12px; color: #546251; }
.player-extras:empty { display: none; }
.settlement-items { margin: 10px 0; padding-left: 1.4em; }
.settlement-scores { width: 100%; text-align: left; border-collapse: collapse; margin-block: 12px; }
.settlement-scores td,.settlement-scores th { padding: 4px 7px; border-bottom: 1px solid var(--line); }
#feedback { min-width: 0; overflow-wrap: anywhere; }
@media(max-width:600px) {
  .hand-title-row { flex-wrap: wrap; }
  .seat-meta { font-size: 9px; }
}
.river-section { display: flex; align-items: center; gap: 17px; margin: 0 4% 20px; padding-top: 12px; padding-bottom: 4px; border-top: 1px solid #cfc19666; }
.river-section h2 { font: 620 15px/1.2 var(--serif); letter-spacing: .19em; white-space: nowrap; }
.river { display: flex; align-items: center; gap: 4px; padding: 1px 2px 7px; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #a4aa87 transparent; font-size: 12px; }
.river-tile { width: 26px; padding: 3px; border-radius: 3px; box-shadow: inset 0 1px 1px white,0 2px 0 #b3a27a,0 3px 0 #97865e,1px 4px 3px #0b3024; }
.sidebar { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.paper-panel,.hand { position: relative; background: #fcf9f0a6; border: 1px solid #ccbfa6; border-radius: 9px; }
.paper-panel { padding: 17px 20px 14px; }
.panel-title { display: flex; align-items: center; gap: 9px; padding-bottom: 11px; border-bottom: 1px solid #cbbeaa; }
.panel-title .icon { color: var(--green); width: 21px; height: 21px; }
.panel-title h2,.hand-title h2 { font: 750 22px/1.2 var(--serif); letter-spacing: .055em; }
.guide-steps,.history { list-style: none; padding: 0; }
.guide-steps li { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid #d9cebb9c; }
.guide-steps li:last-child { border: 0; padding-bottom: 0; }
.guide-steps li > span { align-self: flex-start; margin-top: 2px; flex: none; border-radius: 4px; background: #e3e8d7; color: #315e46; padding: 2px 6px; font: 600 13px/1.4 Georgia, serif; font-variant-numeric: tabular-nums; }
.guide-steps li b { font-size: 14px; color: #293e32; font-weight: 680; }
.guide-steps p { color: #64695e; font-size: 12px; line-height: 1.55; margin-top: 1px; }
.log { flex: 1; min-height: 140px; }
.history { height: 96px; overflow: auto; margin-top: 5px; scrollbar-width: thin; scrollbar-color: #c7bca4 transparent; }
.history li { display: flex; align-items: center; gap: 7px; min-height: 27px; padding-block: 4px; border-bottom: 1px solid #e2d9c8; font-size: 12px; }
.history li:last-child { border: 0; }
.history li div { flex: 1; min-width: 0; }
.history li b { margin-right: 5px; color: #35463a; font-size: 12px; }
.history li span { color: #525c51; overflow-wrap: anywhere; }
.history li small { color: #737464; font-size: 10px; white-space: nowrap; }
.log-dot,.status-dot { display: inline-block; width: 7px; height: 7px; background: #6c8d69; border-radius: 50%; flex: none; }
.dot-0 { background: #9b4539; } .dot-1 { background: #9a783f; } .dot-2 { background: #548081; } .dot-3 { background: #6a8255; }
.hand { grid-column: 1/-1; padding: 16px 23px 14px; box-shadow: 0 2px 4px #543e1710; }
.hand-title-row,.hand-title,.metadata,.controls,.actions { display: flex; align-items: center; }
.hand-title-row,.controls { justify-content: space-between; gap: 12px; }
.hand-title { gap: 10px; }
.hand-wind { display: grid; place-items: center; background: #f6ecdf; border: 1.5px solid #924139; color: #923c32; width: 32px; height: 32px; border-radius: 50%; font: 750 23px/1 var(--serif); }
.turn-badge { display: inline-flex; align-items: center; gap: 6px; color: #396249; background: #e4eada; border: 1px solid #ccd6bc; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.turn-badge::before { content: ''; width: 6px; height: 6px; background:#49724f; border-radius: 50%; }
.metadata { gap: 9px; color: #6e7466; font-size: 12px; }
.metadata b { color: #384b3c; font-variant-numeric: tabular-nums; }
.metadata i { width: 1px; height: 11px; background: var(--line); }
.rack-shell { position: relative; padding: 0 12px; width: fit-content; max-width: 100%; margin: 17px auto 12px; }
.rack { display: flex; flex-wrap: wrap; justify-content: center; align-items: end; gap: 3px; padding: 0 3px 5px; }
.hand-tile { width: clamp(38px, 4.08vw, 64px); transition: transform .14s ease; box-shadow: inset 0 1px 1px white,inset -1px -2px 1px #ddc999,0 3px 0 #b8a371,0 5px 0 #8a754e,1px 6px 4px #54462977; }
.hand-tile:enabled:hover { transform: translateY(-3px); }
.hand-tile.selected,.hand-tile.selected:enabled:hover { transform: translateY(-8px); border: 2px solid #9f4634; background: #fff2ce; box-shadow: 0 3px 0 #ba9367,0 5px 0 #8b6341,0 7px 8px #70472955; }
.rail { width: 100%; height: 12px; border: 1px solid #94714e; border-radius: 3px 3px 4px 4px; box-shadow: inset 0 -3px 1px #8b603c, 0 2px 3px #59482750; background: repeating-linear-gradient(2deg,transparent 0 6px,#98683850 7px 8px,transparent 9px 17px),linear-gradient(#c7a073,#b58656 45%,#a77444); }
.controls { border-top: 1px solid #ddd2bf; padding-top: 11px; }
.claim-offer { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 16px; background: #f7ecd9; border: 1px solid #bc9971; border-radius: 7px; }
.claim-offer:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.claim-offer > .tile { width: 34px; padding: 3px; }
.claim-actions { margin-left: auto; display: flex; gap: 8px; }
.claim-melds { display: contents; }
.claim-actions > [hidden] { display: none; }
@media(max-width:505px) {
  .claim-offer { flex-wrap: wrap; padding: 10px; gap: 8px; }
  .claim-offer strong { flex: 1; font-size: 14px; }
  .claim-actions { flex-basis: 100%; justify-content: flex-end; }
}
#feedback { font-size: 13px; color: #546354; }
.actions { gap: 8px; flex: none; }
.quiet-btn { padding: 8px 11px; min-height: 39px; font-size: 14px; color: #516348; }
.primary-btn { color: #fff6e3; background: var(--red); border-color: #85362e; min-width: 111px; box-shadow: 0 2px 0 #74352a; }
.primary-btn:hover:enabled { background: #82342d; }
.primary-btn:disabled { background: #a45b50; border-color: #995045; box-shadow: 0 1px 0 #865449; }
.quiet-btn:disabled { opacity: .5; }
dialog { position: fixed; max-width: min(480px, calc(100% - 32px)); width: 100%; max-height: 85dvh; border: 1px solid #b4a487; color: var(--ink); border-radius: 12px; padding: 28px 30px; box-shadow: 0 16px 70px #1b301e59; background: var(--paper); }
dialog::backdrop { background: #122b2499; }
dialog h2 { font: bold 28px/1.25 var(--serif); padding-right: 28px; margin-bottom: 14px; }
dialog p,dialog li { font-size: 14px; line-height: 1.75; margin-bottom: 8px; }
dialog ol { padding-left: 21px; }
dialog strong { color: #2a5644; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.dialog-actions button:first-child { background: var(--green); color: #fff9e8; }
.dialog-actions button:first-child:hover { background: #193d32; }
.dialog-close { position: absolute; top: 15px; right: 15px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; border-radius: 50%; }
.result-tiles { display: flex; flex-wrap: wrap; gap: 7px 3px; margin-block: 14px 4px; }
.result-tiles .tile { width: 33px; padding: 3px; }
.table-empty { color: #e4ddbc; font-size: 13px; }
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* The playing surface owns the viewport. Notes can open beside it without
   taking a row from the river or rack. */
body { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
.masthead, .table-heading { flex: none; }
.wrap { width: min(1560px, calc(100% - clamp(20px, 5vw, 88px))); }
.mast-inner { min-height: clamp(40px, 7.3dvh, 70px); }
.brand { font-size: clamp(26px, 4.2dvh, 35px); }
.main { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.table-heading { padding-block: clamp(6px, 2dvh, 21px); }
.table-tools { display: flex; align-items: center; gap: 7px; }
.panel-toggle,.panel-close,.sort-hand,.preview-detail { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 9px; border: 1px solid #bcaf98; border-radius: 5px; background: #faf7ed; color: #405344; font-size: 13px; font-weight: 650; }
.panel-toggle { min-height: 35px; }
.panel-toggle .icon { width: 16px; height: 16px; }
.panel-toggle[aria-expanded="true"] { background: #e3eadd; border-color: #668575; }
.panel-toggle:hover,.sort-hand:hover,.panel-close:hover { background: #e9e9db; }
.panel-close { padding: 3px; margin-left: auto; background: transparent; border-color: transparent; }
.panel-close .icon { width: 15px; height: 15px; }
.sort-hand { font-size: 12px; padding: 3px 8px; }
.preview-detail { padding: 1px 4px; font-size: inherit; line-height: 1.2; }
.layout { flex: 1; min-height: 0; grid-template: minmax(0, 1fr) auto / minmax(0, 1fr); gap: clamp(5px, 1.3dvh, 14px); }
.layout.with-panels { grid-template-columns: minmax(0, 1fr) clamp(232px, 23vw, 324px); }
.felt { grid-row: 1; grid-column: 1; min-height: 0; overflow: visible; }
.felt::after { border-radius: inherit; }
.hand { grid-row: 2; grid-column: 1/-1; min-width: 0; padding: clamp(6px, 1.55dvh, 16px) clamp(8px, 2vw, 25px); }
.sidebar { grid-column: 2; grid-row: 1; display: flex; min-height: 0; gap: 6px; }
.paper-panel { display: flex; flex-direction: column; min-height: 0; max-height: 100%; padding: 12px 15px; }
.panel-title { flex: none; padding-bottom: 6px; }
.guide-steps,.history { overflow: auto; overscroll-behavior: contain; }
.guide-steps li { padding-block: 7px; }
.log { min-height: 0; }
.history { height: auto; }
.seats { flex: none; margin: clamp(9px,2dvh,23px) 3.6% 0; }
.seat-body { flex: 1; }
.seat-meta { max-width: 100%; font-size: 11px; line-height: 1.12; margin: 2px 0 0; }
.seats .backs i { margin: 0; }
.field { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; padding: clamp(3px,1.1dvh,12px) clamp(9px,2.2vw,32px); }
.felt-heading { flex: none; margin-bottom: clamp(3px,.9dvh,9px); gap: clamp(4px,1vw,12px); }
.felt-heading i { flex-shrink: 1; width: clamp(13px,3vw,44px); }
.felt-heading h2 { font-size: clamp(13px,2.15dvh,18px); }
.groups { flex: none; width: 100%; overflow: visible; max-height: none; padding: 0; gap: 4px 6px; }
.meld { flex: none; max-width: 100%; padding: 2px 1px 1px; gap: 2px; }
.meld-tiles { display: grid; grid-template-columns: repeat(var(--meld-columns, 3),var(--public-size, 40px)); gap: 2px 1px; max-width: 100%; }
.meld-tiles .tile { flex: none; }
.meld-label { font-size: 10px; line-height: 12px; letter-spacing: .03em; white-space: nowrap; }
.meld-label { border: 0; padding: 0; background: transparent; font-family: var(--sans); }
.meld-label:enabled:hover { text-decoration: underline; }
.meld.narrow-row .meld-label { font-size: 0; }
.meld.narrow-row .meld-label::after { content: attr(data-seat-label); font: 650 10px/1 var(--sans); }
.meld.invalid-row { border: 1px dashed #f1a785; background: #783e332c; }
.meld .tile[aria-pressed="true"] { outline: 2px solid #ffd16e; outline-offset: -2px; background: #ffecb7; box-shadow: inset 0 0 0 3px #d59a51,0 2px #877243; }
.meld .tile:focus-visible { z-index: 1; outline: 2px solid #bd572f; outline-offset: -2px; }
.new-row { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-height: 29px; padding: 2px 8px; border: 1px dashed #c8b67f; border-radius: 5px; color: #f6eaca; background: #254f42; font: 650 12px/1.15 var(--sans); }
.new-row:enabled:hover,.editing-table .new-row,.table-drafting .new-row { background: #46674d; border-color: #f0ce85; }
.new-row:disabled { opacity: .5; }
.box-toggle { border-style: solid; }
.box-toggle .icon { width: 14px; height: 14px; }
.box-toggle[aria-pressed="true"]:enabled { color: #153d32; background: #f2df99; border-color: #f8e7af; }
.box-selecting :is(.field,section.hand),body:has(#box-select[aria-pressed="true"]) :is(.field,section.hand) { touch-action: none; user-select: none; -webkit-user-select: none; }
.box-selecting :is(.field,.rack-shell) .tile:enabled,.rj-boxing,.rj-boxing * { cursor: crosshair; }
.rj-boxing { user-select: none; -webkit-user-select: none; }
.selection-box { position: fixed; z-index: 9500; pointer-events: none; border: 1.5px solid #efd783; background: #fae7aa26; box-shadow: inset 0 0 0 1px #153e32a6; }
.selection-count,.drag-count { position: absolute; display: inline-flex; align-items: center; padding: 2px 5px; border: 1px solid #d0bd77; border-radius: 4px; white-space: nowrap; color: #fff3ca; background: #194a3e; font: 650 11px/1.2 var(--sans); pointer-events: none; }
.selection-count { left: 0; top: 0; }
.drag-count { right: -9px; top: -8px; z-index: 1; }
.rj-boxing .tile.box-preview { border-color: #a45a28; background: #ffe7a4; outline: 2px solid #dd822f; outline-offset: -2px; }
.new-row.drop-target,.meld.drop-target,.meld .tile.drop-target { outline: 2px solid #f8cf72; outline-offset: 0; }
.meld .tile { width: var(--public-size, 40px); height: calc(var(--public-size, 40px) * 1.32); padding: clamp(1px,calc(var(--public-size, 40px) * .065),4px); box-shadow: inset 0 1px 1px white, inset 0 -1px #d8c490, 0 2px #9d895d; }
.river-section { flex: none; gap: clamp(4px,1vw,13px); margin: 0 clamp(12px,2.6vw,38px) clamp(9px,1.7dvh,17px); padding: clamp(3px,.8dvh,8px) 0 1px; }
.river-section h2 { font-size: clamp(12px,1.9dvh,16px); }
.river { flex: 1; max-width: none; min-width: 0; flex-wrap: nowrap; justify-content: flex-start; align-items: center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 2px 2px 3px; gap: 2px; touch-action: pan-x; overscroll-behavior-x: contain; user-select: none; -webkit-user-select: none; }
.river::-webkit-scrollbar { display: none; }
.river:focus-visible { outline: 2px solid #e2c879; outline-offset: 1px; }
.river.can-pan { cursor: grab; }
.river.panning { cursor: grabbing; }
.river-nav { flex: none; display: grid; place-items: center; width: 24px; height: 28px; padding: 0; border: 1px solid #acaf7a8a; border-radius: 4px; background: #143c33; color: #f4ebc5; }
.river-nav .icon { width: 14px; height: 14px; }
#river-earlier .icon { transform: rotate(180deg); }
.river-nav:disabled { opacity: .4; }
.river-tile:last-child { border-color: #e5ab61; background: #ffedc4; }
.river-tile:last-child .river-owner::after { content: '・新'; }
@media (max-width:380px) { .groups { column-gap: 3px; } .river-nav { width: 18px; height: 25px; } }
.river-tile { display: flex; flex-direction: column; align-items: center; width: var(--river-size, 27px); height: calc(var(--river-size, 27px) * 1.27 + 7px); padding: 1px 2px; box-shadow: inset 0 -1px #d8c490, 0 1px #94815d; }
.river-tile .tile-face { min-height: 0; flex: 1; height: 0; width: 100%; }
.river-owner { flex: none; font: 550 8px/8px var(--sans); color: #67563b; }
.groups.compact-faces .tile .tile-face { display: none; }
.groups.compact-faces .tile::after { content: attr(data-face); color: #282a21; font: 750 11px/12px var(--sans); letter-spacing: -.06em; }
.groups.compact-faces .tile { padding: 0; border-radius: 3px; }

.groups.compact-faces .meld-label { font-size: 9px; line-height: 10px; letter-spacing: 0; }
.compact-faces .tile[data-face$="萬"]::before,.compact-faces .tile[data-face$="萬"]::after,.compact-faces .tile[data-face="中"]::before,.compact-faces .tile[data-face="中"]::after { color: #922e24; }
.compact-faces .tile[data-face$="索"]::before,.compact-faces .tile[data-face$="索"]::after,.compact-faces .tile[data-face="發"]::before,.compact-faces .tile[data-face="發"]::after { color: #18513e; }
.rack-shell { width: fit-content; max-width: 100%; padding-inline: 5px; margin: clamp(6px,1.25dvh,14px) auto clamp(4px,.95dvh,10px); }
:is(.editing-table,.table-drafting) .rack-shell { min-width: min(160px,100%); padding-inline: 5px; border-radius: 5px; outline: 1px dashed #a88b61; outline-offset: 1px; background: #f5edda; }
:is(.editing-table,.table-drafting) .rack-shell .rack { margin-inline: auto; }
:is(.editing-table,.table-drafting) .rack-shell:has(.drop-target),:is(.editing-table,.table-drafting) .rack-shell.drop-target { outline: 2px solid #a97e29; background: #fbefc8; }
.rack:has([data-return-rack]) { display: flex; }
[data-return-rack] { min-height: 28px; padding: 3px 12px; border: 1px dashed #8c764e; border-radius: 4px; background: #fcf6e4; color: #574932; font: 650 12px/1.2 var(--sans); }
.rack { display: grid; width: fit-content; max-width: 100%; grid-template-columns: repeat(var(--rack-cols, 9), var(--rack-size, 32px)); justify-content: center; align-items: end; padding: 0 1px 3px; gap: 4px 2px; overflow: visible; }
.hand-tile { width: var(--rack-size, 32px); height: calc(var(--rack-size, 32px) * 1.32); padding: clamp(1px,calc(var(--rack-size, 32px) * .075),5px); }
.hand-tile.selected,.hand-tile.selected:enabled:hover { transform: translateY(-6px); outline: 2px solid #913f28; outline-offset: -2px; background: #ffe6a3; }
.rail { height: clamp(5px,.95dvh,11px); }
.controls { padding-top: clamp(3px,.95dvh,10px); }
#feedback { line-height: 1.27; }
.player-extras { line-height: 1.25; margin-top: 3px; }
#rack [data-hand], #groups [data-table-tile] { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.drag-origin { opacity: .52; }
.drop-target { outline: 2px solid #ebc56c; outline-offset: 1px; }
.rj-dragging, .rj-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.drag-ghost { filter: drop-shadow(0 4px 8px #10271dcc); pointer-events: none; }
.drag-ghost.compact-ghost { display: grid; place-items: center; padding: 0; }
.drag-ghost.compact-ghost .tile-face { display: none; }
.drag-ghost.compact-ghost::after { content: attr(data-face); font: 750 13px/1 var(--sans); color: #283d2b; white-space: nowrap; }
@media (max-height:600px) { .new-row { min-height: 23px; padding: 2px 6px; font-size: 11px; } }

@media (max-width:820px), (max-height:520px) {
  .layout.with-panels { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; inset: auto auto auto 50%; top: 50%; transform: translate(-50%,-50%); z-index: 5; width: min(420px,calc(100vw - 32px)); max-height: calc(100dvh - 54px); background: var(--paper); box-shadow: 0 6px 40px #15291d70; border-radius: 9px; }
  .sidebar .paper-panel { overflow: auto; }
  .sidebar .log { flex: 1 1 auto; }
  .sidebar .history { max-height: 45dvh; }
  .heading-main { gap: 8px; }
  .heading-main > div { gap: 7px; }
  .heading-main p { font-size: 11px; letter-spacing: 0; }
  .seats { gap: 8px; }
  .backs i { height: 12px; width: clamp(3px,.9vw,7px); }
  .wind { width: 27px; height: 27px; font-size: 18px; }
  .seat { gap: 4px; }
  .seat-title { font-size: 11px; line-height: 1.1; margin-bottom: 2px; }
  .seat-meta { font-size: 10px; }
  .controls { gap: 5px; }
  .actions { gap: 4px; }
  .actions > button { padding-inline: 8px; min-width: 0; }
}
@media (max-width:620px) and (min-height:521px) {
  .mast-inner { gap: 9px; min-height: 41px; }
  .brand { font-size: 25px; gap: 6px; }
  .brand-mark { width: 30px; height: 32px; }
  .brand-mark i,.brand-mark b { width: 20px; height: 26px; border-radius: 3px; font-size: 18px; }
  .brand-subtitle { font-size: 10px; padding-left: 9px; }
  nav { gap: 2px; }
  .nav-btn { min-height: 34px; font-size: 12px; padding: 2px 4px; gap: 4px; }
  .sound { width: 29px; }
  .table-heading { padding-block: 6px; gap: 4px; }
  .east-seal { display: none; }
  h1 { font-size: clamp(18px,5.5vw,29px); }
  .heading-main > div { display: block; }
  .heading-main p { border: 0; padding: 0; font-size: 9px; }
  .table-tools { gap: 4px; }
  .panel-toggle,.restart { padding: 3px 6px; min-height: 30px; font-size: 12px; gap: 3px; }
  .panel-toggle .icon,.restart .icon { width: 13px; height: 13px; }
  .seats { margin-top: 12px; }
  .seat-meta { font-size: 9px; }
  .wind { width: 21px; height: 21px; font-size: 14px; }
  .seat-title small { font-size: 9px; margin: 0; }
  .felt-heading i { width: 25px; }
  .field { padding-inline: 8px; }
  .hand-title-row { gap: 4px; }
  .hand-title { gap: 4px; }
  .hand-title h2 { font-size: 17px; }
  .hand-wind { display: none; }
  .turn-badge { padding: 1px 4px; font-size: 10px; gap: 3px; }
  .metadata { font-size: 10px; gap: 4px; }
  .sort-hand { font-size: 11px; padding: 2px 4px; }
  .player-extras { font-size: 10px; }
  .controls { flex-direction: column; align-items: stretch; }
  #feedback { font-size: 11px; }
  .actions { justify-content: flex-end; flex-wrap: wrap; }
  .actions button { min-height: 31px; font-size: 12px; padding: 3px 8px; }
  .actions .icon { width: 14px; height: 14px; }
  .claim-offer { flex-wrap: nowrap; padding: 4px 6px; margin-top: 4px; gap: 4px; }
  .claim-actions { flex-basis: auto; gap: 3px; }
  .claim-actions > button { padding: 3px 7px; min-height: 30px; min-width: 0; }
}
@media (max-height:520px) {
  .wrap { width: calc(100% - 16px); }
  .mast-inner { min-height: 33px; gap: 4px; }
  .brand { font-size: 20px; gap: 3px; letter-spacing: 0; }
  .brand-mark { width: 24px; height: 26px; }
  .brand-mark i,.brand-mark b { width: 17px; height: 22px; border-radius: 2px; font-size: 14px; }
  .brand-subtitle { display: none; }
  nav { gap: 2px; }
  .nav-btn { min-height: 28px; font-size: 11px; padding: 2px 4px; gap: 3px; }
  .sound { width: 26px; }
  .nav-btn .icon { width: 15px; height: 15px; }
  .table-heading { position: absolute; left: 104px; right: 109px; top: -33px; height: 32px; padding: 0; gap: 2px; }
  .table-tools { gap: 3px; }
  h1 { font-size: 18px; letter-spacing: 0; }
  .heading-main p,.east-seal { display: none; }
  .panel-toggle,.restart { min-height: 25px; padding: 2px 5px; font-size: 11px; gap: 2px; }
  .panel-toggle .icon,.restart .icon { width: 12px; height: 12px; }
  .layout { padding-top: 3px; gap: 4px; }
  .seats { margin: 6px 17px 0; }
  .seat-title { margin: 0; font-size: 10px; }
  .seat-meta { margin: 0; padding: 0; font-size: 9px; }
  .wind { width: 20px; height: 20px; font-size: 13px; }
  .seat-body { display: grid; grid-template-columns: auto auto; gap: 1px 4px; align-items: center; }
  .seat-meta { grid-column: 1/-1; }
  .backs i { height: 8px; width: 4px; }
  .field { padding: 3px 10px; }
  .felt-heading { margin-bottom: 2px; }
  .felt-heading h2,.river-section h2 { font-size: 11px; }
  .felt-border { inset: 4px; outline-offset: 1px; }
  .corner { width: 14px; height: 14px; }
  .river-section { margin: 0 10px 6px; padding-top: 3px; }
  .hand { padding: 3px 8px; }
  .hand-title-row { flex-wrap: nowrap; gap: 5px; }
  .hand-title { gap: 5px; }
  .hand-title h2 { font-size: 15px; }
  .hand-wind { display: none; }
  .turn-badge,.metadata,.player-extras { font-size: 9px; }
  .metadata { gap: 4px; }
  .sort-hand { font-size: 10px; padding: 0 4px; }
  .player-extras { margin-top: 0; }
  .rack-shell { margin: 4px auto 2px; }
  .rail { height: 4px; }
  .actions { gap: 4px; }
  .actions button,.claim-actions button { min-height: 23px; font-size: 11px; padding: 2px 6px; min-width: 0; }
  .actions .icon { width: 12px; height: 12px; }
  .controls { padding-top: 2px; gap: 6px; }
  #feedback { font-size: 10px; }
  .claim-offer { padding: 2px 6px; margin: 2px 0; gap: 4px; flex-wrap: nowrap; }
  .claim-offer > .tile { width: 18px; }
  .claim-offer strong { font-size: 11px; }
  .claim-actions { flex-basis: auto; }
}
.groups.compact-faces .meld { flex-direction: row; gap: 1px; }
.groups.compact-faces .meld-label { order: -1; flex: none; width: 9px; font-size: 0; line-height: 0; letter-spacing: 0; }
.groups.compact-faces .meld-label::before { content: attr(data-wind); display: block; font: 650 9px/9px var(--sans); }
.groups.compact-faces .meld-label::after { content: attr(data-count); font: 650 8px/9px var(--sans); letter-spacing: -1px; }
.groups.compact-faces [data-sealed="true"] .meld-label::before { content: attr(data-wind) '封'; font-size: 7px; }
.groups.compact-faces .meld-label.preview-label::before { content: none; }
.groups.dense-draft { gap: 2px; }
.groups.dense-draft.compact-faces .short-row { flex-direction: row; padding: 0; gap: 0; }
.groups.dense-draft.compact-faces .short-row .meld-label { order: -1; width: 7px; }
.groups.dense-draft.compact-faces .short-row .meld-label::before { font-size: 7px; }
.groups.dense-draft.compact-faces .short-row .meld-label::after { content: none; }

.panel-pages { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.panel-pages span { font-size: 11px; color: #5c665b; font-variant-numeric: tabular-nums; }
.panel-pages button { padding: 2px 6px; border: 1px solid #bcaf98; border-radius: 4px; background: #faf7ed; color: #405344; font-size: 11px; }
.panel-pages button:disabled { opacity: .45; }
.guide-steps,.history,.sidebar .paper-panel { overflow: visible; }
.sidebar .history { max-height: none; }
.sidebar > section { flex: 0 1 auto; }

.dialog-tabs { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; margin: 0 0 10px; gap: 4px; }
.dialog-tabs button { min-height: 28px; padding: 3px 8px; color: #35513f; background: transparent; border: 1px solid #bfb9a4; border-radius: 4px; font-size: 12px; }
.dialog-tabs [aria-current="page"] { color: #fff9e8; background: #315a44; border-color: #315a44; }
@media (max-height:520px) {
  #modal[data-view="rules"],dialog[data-view="result"] { width: min(560px,95vw); max-height: 97dvh; padding: 10px 15px; }
  :is(#modal, dialog[data-view="result"]) h2 { font-size: 20px; margin-bottom: 5px; }
  :is(#modal, dialog[data-view="result"]) h3 { font-size: 15px; margin-block: 4px; }
  :is(#modal, dialog[data-view="result"]) p,:is(#modal, dialog[data-view="result"]) li { font-size: 12px; line-height: 1.35; margin-bottom: 4px; }
  :is(#modal, dialog[data-view="result"]) .dialog-tabs { margin-bottom: 5px; }
  :is(#modal, dialog[data-view="result"]) .dialog-tabs button { min-height: 23px; font-size: 11px; }
  :is(#modal, dialog[data-view="result"]) .dialog-actions { margin-top: 6px; }
  :is(#modal, dialog[data-view="result"]) .dialog-actions > button { padding: 3px 8px; min-height: 26px; font-size: 12px; }
  :is(#modal, dialog[data-view="result"]) .settlement-scores td,:is(#modal, dialog[data-view="result"]) .settlement-scores th { padding-block: 2px; font-size: 11px; }
  :is(#modal, dialog[data-view="result"]) .result-tiles { margin: 4px 0; gap: 3px 2px; }
  :is(#modal, dialog[data-view="result"]) .result-tiles .tile { width: 23px; }
}
.groups.compact-faces .tile::after { writing-mode: horizontal-tb; white-space: nowrap; font-size: clamp(8px, calc(var(--public-size) * .55), 11px); }
@media (max-width:410px) and (min-height:521px) and (max-height:710px) {
  .mast-inner { min-height: 34px; }
  .mast-inner .nav-btn { min-height: 28px; }
  .table-heading { padding-block: 3px; }
  .field { padding-block: 2px; }
  .hand { padding: 4px 6px; }
  .hand-title-row { gap: 3px; }
  .rack-shell { margin-block: 4px; }
  .hand-title h2 { font-size: 15px; }
  .metadata { gap: 3px; font-size: 9px; }
  .actions button { min-height: 27px; font-size: 11px; padding-inline: 6px; }
  .claim-offer > .tile { width: 22px; }
  .claim-offer strong { font-size: 11px; }
}

.tile.newly-played { border-color: #ac661d; box-shadow: inset 0 0 0 2px #eac16c, 0 2px #886f40; }
.tile-mark { position: absolute; z-index: 1; top: -3px; right: -2px; padding: 1px 2px; border-radius: 3px; color: #fff8dc; background: #764619; font: 700 clamp(8px, .75vw, 11px)/1.1 var(--sans); pointer-events: none; }
.hand-tile.just-drawn { border-color: #267267; box-shadow: inset 0 0 0 2px #4a9f89, 0 3px #8a784f; }
.just-drawn .tile-mark { background: #205e52; }
.empty-row { width: calc(3 * var(--public-size, 40px)); min-height: calc(var(--public-size, 40px) * 1.32); padding: 2px; border: 1px dashed #e8d590; border-radius: 5px; background: #254f42; color: #fff2c7; font: 600 clamp(9px,1vw,13px)/1.25 var(--sans); }
.empty-row.drop-target,.empty-row:hover { outline: 2px solid #f8cf72; background: #41674e; }

/* Animation copies travel above the playing surface. Each live tile keeps its
   final hit area, including when its visible copy is still flying into place. */
.motion-copy { position: fixed; z-index: 9300; pointer-events: none; transform-origin: 0 0; transition: none; }
.motion-hidden-draw, .motion-draw-back {
  border: 1px solid #d0c499; border-radius: 4px;
  background: repeating-linear-gradient(40deg, transparent 0 4px, #97b59355 5px 6px),
    linear-gradient(140deg, #6d9782, #245347);
  box-shadow: inset 0 0 0 2px #e8dbb6, inset 0 0 0 4px #356151, 0 3px 7px #142c2850;
}
.motion-draw-back { pointer-events:none; position:absolute; inset:0; animation: motion-turn-face 350ms ease-out both; }
.motion-hidden-draw[data-flight="deal"] {
  box-shadow: inset 0 0 0 2px #e7dcb9, inset 0 0 0 3px #335949,
    1px 2px #c6b58e, 2px 3px #466151, 3px 4px #ddceaa, 3px 5px 4px #142c284d;
}
@keyframes motion-turn-face {
  0%, 32% { opacity:1; transform:scaleX(1); }
  64%, 100% { opacity:0; transform:scaleX(.08); }
}
.motion-thrown { filter: drop-shadow(0 5px 3px #402b1460); }
.motion-contact {
  pointer-events:none; position:absolute; z-index:3; inset:-3px;
  border:2px solid #fff1a5; border-radius:inherit;
  box-shadow:0 0 6px #e3b952; animation:motion-touch 310ms 320ms ease-out both;
}
.motion-contact-discard { border-color:#a4432d; box-shadow:0 0 0 1px #ffe9af; animation-delay:240ms; }
@keyframes motion-touch {
  0% { opacity:0; transform:scale(.92); }
  18% { opacity:1; }
  100% { opacity:0; transform:scale(1.36); }
}
.motion-covered { opacity: 0 !important; }
.motion-arrived { outline: 2px solid #e19e3a; outline-offset: -2px; }
.motion-compact .tile-face { display: none; }
.motion-compact::after { content: attr(data-face); color: #283d2b; font: 750 clamp(8px,calc(var(--public-size) * .55),11px)/1 var(--sans); white-space: nowrap; }
.motion-river-clip { position: fixed; inset: 0; z-index: 9300; pointer-events: none; }

/* Keep hit testing on the resting grid while its tile faces preview an insertion. */
.rj-dragging :is(#groups,#rack) .tile,
.rj-dragging .meld-label {
  transition: transform 160ms ease-out, opacity 140ms ease-out;
}
.rj-dragging :is(#groups,#rack) .tile { pointer-events: none; }
.rj-dragging .drag-origin { opacity: 0; }
.drag-ghost { filter: drop-shadow(0 7px 8px #10271dbd); }
.tile.drop-rejected { outline: 2px solid #bf583b; outline-offset: -2px; }
.box-selecting #rack .hand-tile:not(.selected):enabled:hover { transform: none; }

@media (max-width:620px) {
  .sidebar {
    position: relative;
    grid-area: 1 / 1;
    align-self: start;
    justify-self: center;
    inset: auto;
    transform: none;
    width: calc(100% - 12px);
    max-height: min(45dvh, 100%);
    box-shadow: 0 4px 14px #15291d55;
  }
  .sidebar .paper-panel { overflow: hidden; }
  .sidebar :is(.history,.guide-steps) { min-height: 0; overflow-y: auto; }
}

.river-section { position: relative; }
.river-section[data-discard] {
  border-radius: 5px;
  outline: 2px dashed #f4d58a;
  outline-offset: 2px;
  background: #eee0a719;
}
.river-section[data-discard="release"] {
  outline: 3px solid #ffdf78;
  background: #f6ca5742;
}
#river-drop-hint {
  position: absolute;
  z-index: 3;
  inset-inline-start: 0;
  bottom: 100%;
  pointer-events: none;
  font: 650 clamp(12px, 2dvh, 16px)/1.35 var(--sans);
}
#river-drop-hint:not(:empty) {
  /* Keep the entire visible label droppable when its text changes on entry. */
  pointer-events: auto;
  min-inline-size: calc(9em + 20px);
  text-align: center;
  padding: 3px 9px;
  border: 1px solid #efce7b;
  border-radius: 4px;
  background: #184339;
  color: #fff1c4;
}
[data-discard="release"] #river-drop-hint {
  background: #ffdf78;
  color: #302815;
}

.seat-control { display: block; margin-top: 2px; white-space: nowrap; }
.meld-label { color: var(--control-color, #f2e9ce); }
[data-controller="0"] { --control-color: #ffdf8e; }
[data-controller="1"] { --control-color: #ffc9ad; }
[data-controller="2"] { --control-color: #c0e3ff; }
[data-controller="3"] { --control-color: #e9d4ff; }
.meld[data-sealed="true"] { border: 1px solid #e5d28f; background: #e7cc8e12; }
.tile.own-tile { background: linear-gradient(125deg, #ebf5db, #cfebc3); }
.tile-wind { position: absolute; left: 1px; bottom: 1px; padding: 0 1px; border-radius: 2px;
  background: #fffcf0; color: #33443a; font: 750 clamp(10px, calc(var(--public-size, 40px) * .29), 13px)/1.1 var(--sans);
  pointer-events: none; }
.own-tile .tile-wind { background: #d6ebce; color: #174f38; }
.meld .tile:has(.tile-wind) { padding-bottom: max(6px, calc(var(--public-size, 40px) * .2)); }
.groups.compact-faces .tile::after { align-self: start; margin-top: 1px; }
.groups.compact-faces .tile-wind { font-size: 8px; line-height: 1; bottom: 0; left: 0; }
.meld .meld-label.preview-label { position: relative; z-index: 2; font-size: 11px; line-height: 14px;
  background: #184439; box-shadow: 0 0 0 2px #184439; border-radius: 2px; text-align: center; }
.meld .meld-label.preview-label::after { content: none; }
