*{box-sizing:border-box} :root{color-scheme:dark;--ink:#eff5e9;--muted:#abc6b8;--gold:#e5c987;--line:#ffffff24;--tile:clamp(31px,4.55vw,58px);font-family:"Noto Sans TC","PingFang TC","Microsoft JhengHei",sans-serif;color:var(--ink);background:#101f1d}body{margin:0;background:radial-gradient(ellipse at 50% 12%,#213932,transparent 69%),#101f1d;min-height:100svh}header,main{max-width:1340px;margin:auto}header{height:81px;padding:0 clamp(16px,4.5vw,74px);display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand,.roomhead,.trayhead,.actionbar,nav,#actions,#dlgButtons{display:flex;align-items:center;gap:12px}.mark{display:grid;place-items:center;width:39px;height:46px;border:1px solid #b99e63;border-radius:5px;box-shadow:3px 3px 0 #716545;color:var(--gold);font-family:serif;font-weight:bold;font-size:27px;transform:rotate(-5deg)}h1,h2{font-family:"Songti TC","Noto Serif TC",serif;margin:0}h1{font-size:22px;letter-spacing:.16em}.brand small,.smallcap,.session,.you{font-size:.81rem;letter-spacing:.13em;color:var(--muted)}.brand small{letter-spacing:.08em}button{font:inherit;cursor:pointer;color:var(--ink);background:#233a33;border:1px solid #76908370;border-radius:7px;padding:8px 14px}button:hover:enabled{filter:brightness(1.14)}button:focus-visible{outline:3px solid #ffcb65;outline-offset:2px}button:disabled{cursor:default}main{padding:24px clamp(12px,4.5vw,74px) 32px}.roomhead,.trayhead,.actionbar{justify-content:space-between}.roomhead{margin:0 3px 14px}.roomhead h2{font-size:clamp(26px,3vw,37px);letter-spacing:.12em}.smallcap{color:var(--gold)}.session{letter-spacing:.05em}.felt{position:relative;isolation:isolate;border:6px solid #413d2f;border-radius:25px;box-shadow:0 0 0 1px #807458,0 9px 27px #0004,inset 0 0 45px #061e1b80;background:radial-gradient(ellipse at center,#296358,#15483e 72%,#103c33);}.felt:before,.felt:after{position:absolute;content:"";inset:7px;border:1px solid #d2cb962e;border-radius:15px;pointer-events:none;z-index:-1}.felt:after{inset:12px;border-color:#d2cb9612}.seat,.you{text-align:center}.badge{display:inline-grid;place-items:center;width:27px;height:27px;border:1px solid #a6be9f82;border-radius:50%;font-family:serif;margin-right:6px;background:#103e33;color:#f5ead1}.seat.on .badge{border-color:#edcf83;background:#685835}.seatname{font-size:.88rem;color:#e0ebdd}.backs{display:flex;justify-content:center;margin:6px auto;gap:2px}.backs i{width:7px;height:13px;background:linear-gradient(#9abb9d,#709f87);border:1px solid #a1ba99;border-bottom:3px solid #e7dfbd;border-radius:2px}.wall{width:75px;height:75px;border-radius:18px;background:#173e35;box-shadow:0 0 0 1px #b7aa6f70,inset 0 0 0 5px #20493d,0 4px 10px #001c1755;display:grid;align-content:center;justify-items:center;color:var(--gold)}.wall span{font:600 31px Georgia,serif}.wall small{font-size:.72rem;letter-spacing:.1em}.you{color:#dedabd}.you i{display:inline-block;width:10px;border-top:1px solid #d7cc9770;vertical-align:middle}.mini{font-size:.78rem;font-weight:700;line-height:1.15;padding:3px 2px;background:#f3edd7;color:#274d41;border-radius:3px;white-space:nowrap;box-shadow:0 1px 0 #bba47d}.mini.last{outline:2px solid #f1b64c;outline-offset:-1px}.tray{margin-top:15px;background:#243930;border:1px solid #ffffff22;border-radius:14px;padding:17px clamp(12px,2vw,30px) 12px}.tray h2{font-size:23px;letter-spacing:.06em}.tray .smallcap{font-size:.75rem}.trayhead{margin-bottom:15px}#status{color:#e9cd84;font-size:.92rem;text-align:right}#hand{display:flex;justify-content:center;align-items:flex-end;gap:clamp(2px,.35vw,5px);padding:6px 0;flex-wrap:wrap}.face{flex:0 0 var(--tile);width:var(--tile);height:calc(var(--tile)*1.39);background:linear-gradient(145deg,#fffbea,#e7dfc5);color:#15392c;border:1px solid #eee9d2;border-radius:6px;box-shadow:0 4px 0 #b7ad90,0 6px 4px #0007;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:1px;position:relative}.face.selected{transform:translateY(-8px);outline:2px solid #ffc85f;outline-offset:1px}.face b{font:700 calc(var(--tile)*.48)/1.05 "Songti TC",serif}.face em{font:700 calc(var(--tile)*.43)/1.05 serif;color:#b53932}.face.honor b{font-size:calc(var(--tile)*.72)}.face.honor.jade{color:#267244}.face.honor.red{color:#af3933}.face.white b{width:57%;height:61%;border:3px double #48629a}.pattern{height:69%;width:68%;display:grid;gap:2px;place-items:center}.pip{width:100%;max-width:13px;aspect-ratio:1;border-radius:50%;background:#2e6452;box-shadow:inset 0 0 0 2px #2e6452,inset 0 0 0 3px #e3d9b0}.pip.red{background:#ac4237;box-shadow:inset 0 0 0 2px #ac4237,inset 0 0 0 3px #f3daba}.stick{height:100%;max-height:16px;width:60%;max-width:7px;background:linear-gradient(#2b7353 40%,#c5c48c 42% 54%,#2b7353 56%);border-radius:3px}.corner{font:700 .61rem/1 sans-serif;align-self:flex-start;margin-left:3px;color:#58664e}.actionbar{border-top:1px solid var(--line);margin-top:15px;padding-top:11px;min-height:48px}#hint{font-size:.88rem;color:#c7d5c7}#actions{flex-wrap:wrap;justify-content:flex-end}.primary{background:#e4c783;border-color:#e9d39f;color:#263127;font-weight:bold}.primary:disabled{opacity:.5}#myMelds,.exposed{display:flex;flex-wrap:wrap;gap:5px;justify-content:center}.meld{display:inline-flex;gap:1px}.exposed .mini{font-size:.65rem;padding:1px}.exposed{max-width:100px;margin:auto}dialog{color:var(--ink);background:#213a31;border:1px solid #888363;border-radius:13px;padding:25px;max-width:min(440px,90vw);box-shadow:0 20px 90px #0008}dialog::backdrop{background:#051510b8}dialog p{line-height:1.65}#dlgButtons{justify-content:flex-end}
@media(max-width:760px){:root{--tile:clamp(31px,5.7vw,41px)}header{height:69px}nav{gap:5px}nav button{padding:7px;font-size:.83rem}main{padding-top:16px}.tray{padding:12px}.seatname{font-size:.75rem}.badge{width:22px;height:22px;margin-right:3px}.backs i{width:4px;height:9px}.backs{gap:1px}.wall{width:61px;height:61px}.mini{font-size:.68rem}.actionbar{align-items:center}.session{font-size:.75rem}.trayhead{margin-bottom:8px}.pip{box-shadow:inset 0 0 0 1px #2e6452,inset 0 0 0 2px #e3d9b0}}@media(max-width:560px){#hand{max-width:calc(var(--tile)*9 + 20px);margin:auto;row-gap:8px}.trayhead{gap:4px}.actionbar{flex-wrap:wrap}#actions{margin-left:auto}.exposed{max-width:70px}}
.joinrow{display:flex;gap:8px;margin:6px 0 12px}.joinrow input{min-width:0;flex:1;padding:9px 12px;font:inherit;color:var(--ink);background:#152a23;border:1px solid #6e8b7d;border-radius:6px;text-transform:uppercase}.roomcode{display:block;font:700 34px Georgia,serif;color:var(--gold);letter-spacing:.14em}.error{color:var(--gold);font-size:.88rem;overflow-wrap:anywhere}#dlgButtons{flex-wrap:wrap}button[hidden]{display:none}@media(max-width:440px){header{padding:0 10px}.brand{gap:7px}.brand h1{font-size:18px}.mark{width:30px;height:38px;font-size:23px}nav{gap:3px}nav button{padding:6px 5px;font-size:.77rem}}
.tablemeta{display:flex;align-items:center;gap:10px}.tablemeta button{font-size:.85rem;padding:5px 10px}.round-choice{border:0;margin:15px 0;padding:0;display:flex;gap:8px}.round-choice legend{font-weight:600;margin-bottom:9px}.round-choice label{position:relative;flex:1}.round-choice input{position:absolute;opacity:0}.round-choice span{display:block;text-align:center;padding:8px;border:1px solid #688275;border-radius:6px;cursor:pointer}.round-choice input:checked+span{color:#172d25;background:var(--gold);border-color:var(--gold);font-weight:700}.round-choice input:focus-visible+span{outline:2px solid #fff;outline-offset:2px}.flower-group{display:inline-flex;gap:2px;flex-wrap:wrap;align-items:center}.flower{color:#fff1be;background:#6c5940;border:1px solid #a78a5b;padding:1px 4px;border-radius:4px;font-size:.77rem}.groupnote{color:var(--gold);font-size:.75rem}#myFlowers{display:flex;justify-content:center}#myFlowers:not(:empty){margin:4px 0}.scorelayout{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.8fr);gap:30px;margin-top:12px}.scorelayout h3,dialog h3{font-size:1rem;margin:10px 0 5px}.scoreline{display:flex;justify-content:space-between;border-bottom:1px solid var(--line);padding:5px 0}.scoretotal{font-weight:700;color:var(--gold)}.payline{font-size:.89rem;color:#d6e0d3}.totals{width:100%;align-self:start;border-collapse:collapse;text-align:right}.totals td,.totals th{padding:7px 8px;border-bottom:1px solid var(--line)}.totals th{font-size:.8rem;color:var(--muted)}.totals th:first-child,.totals td:first-child{text-align:left}dialog{width:min(480px,92vw);max-height:86svh}dialog .totals{margin:12px 0}details summary{cursor:pointer;color:var(--gold);padding:7px 0}#settlement[hidden]{display:none}@media(max-width:650px){.tablemeta{flex-direction:column-reverse;align-items:flex-end;gap:3px}.scorelayout{grid-template-columns:1fr;gap:10px}.exposed .flower{padding:0 2px;font-size:.65rem}}
.stake-choice{display:grid;grid-template-columns:repeat(2,1fr)}.stake-choice legend{float:left;width:100%}.stake-choice label:first-of-type{grid-column:1}.session{text-align:right;max-width:36ch;line-height:1.6}@media(max-width:650px){.session{max-width:24ch}}

/* Reserve separate spaces for seats, discard piles and the remaining-tile counter. */
.felt{
  --discard-width:clamp(1.66rem,3.1vw,2.25rem);
  --discard-height:clamp(1.34rem,2.35vw,1.75rem);
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1.35fr) minmax(0,1fr);
  min-height:clamp(320px,47vh,520px);
  grid-template-rows:auto auto auto auto auto;
  grid-template-areas:"north north north" "west top east" "left wall right" "left bottom right" ". you .";
  align-items:center;
  gap:5px clamp(4px,2vw,24px);
  padding:clamp(10px,1.6vw,20px);
}
.felt .seat,.felt .you,.felt .center{
  min-width:0;justify-self:center
}
.felt .north{grid-area:north}
.felt .west{grid-area:west;align-self:end}
.felt .east{grid-area:east;align-self:end}
.felt .center{grid-area:wall}
.felt .you{grid-area:you}
.felt .seat{width:100%;min-height:max-content}
.felt .exposed{max-width:100%;align-items:center;align-content:flex-start}
.felt .meld{max-width:100%;flex-wrap:wrap;justify-content:center}
.felt .backs{max-width:100%}
.river{
  display:flex;flex-wrap:wrap;justify-content:center;align-content:flex-start;
  align-self:start;min-width:0;gap:3px;padding:2px;
}
.river.top{grid-area:top}.river.bottom{grid-area:bottom}
.river.left{grid-area:left}.river.right{grid-area:right}
.river .mini{
  display:grid;place-items:center;flex:0 0 var(--discard-width);
  width:var(--discard-width);height:var(--discard-height);padding:0;
  font-size:clamp(.7rem,1.16vw,.89rem);line-height:1;letter-spacing:0
}
.river .mini.last{outline:2px solid #f1b64c;outline-offset:-2px}
.face{touch-action:manipulation;user-select:none;-webkit-user-select:none}
.face.selected{transform:none;outline:3px solid #ffc85f;outline-offset:0;box-shadow:0 4px 0 #ba8b37,0 6px 4px #0007}
@media(max-width:760px){
  .felt{min-height:300px;gap:6px;padding:10px;grid-template-columns:minmax(0,1fr) minmax(0,1.25fr) minmax(0,1fr)}
  .river{gap:2px}
}
.hand-outcome{font-size:1.12rem;font-weight:700;color:var(--gold)}
.totals th,.totals td{white-space:nowrap}
@media(max-width:440px){dialog .totals th,dialog .totals td{padding:7px 3px;font-size:.8rem}}

.call-strip{margin:10px 2px 0;border:1px solid #a58d514f;border-radius:10px;background:#203c31;padding:9px 14px}
.call-strip[hidden]{display:none}
.call-banner{display:flex;align-items:baseline;gap:12px}
.call-banner strong{color:var(--gold);font-size:.84rem;white-space:nowrap}
#callNotice p{margin:0;line-height:1.55}
#callDetails{margin-left:calc(3.36rem + 12px)}
#callSummary{width:fit-content;padding:3px 0;color:#d5ddc8;font-size:.82rem}
#callHistory{max-height:12rem;overflow:auto;margin:5px 0;padding-left:1.65rem}
#callHistory li{padding:3px 0;font-size:.9rem}
@media(max-width:550px){.call-strip{padding:8px 10px}.call-banner{gap:8px}.call-banner strong{font-size:.78rem}#callDetails{margin-left:0}#callNotice{font-size:.91rem}}
.meld .mini.claimed{background:#f1d999;box-shadow:inset 0 -2px #a87c28}
@media(max-width:760px){
  .actionbar{display:grid;grid-template-columns:minmax(0,1fr);gap:.4rem}
  #hint{min-height:2.8em;line-height:1.4}
  #actions{justify-self:end}
}

/* Keep the concealed hands against the outer edges and the discards inside. */
.felt{
  grid-template-columns:clamp(3.5rem,8vw,6rem) minmax(0,1fr) minmax(0,1.3fr) minmax(0,1fr) clamp(3.5rem,8vw,6rem);
  grid-template-areas:"north north north north north" "west top top top east" "west left wall right east" "west bottom bottom bottom east" ". you you you .";
}
.felt .west,.felt .east{align-self:center}
.felt :is(.west,.east) .backs{flex-direction:column;align-items:center;width:max-content}
.felt :is(.west,.east) .backs i{width:13px;height:7px;border-bottom-width:1px}
.felt .west .backs i{border-right:3px solid #e7dfbd}
.felt .east .backs i{border-left:3px solid #e7dfbd}
@media(max-width:760px){
  .felt{column-gap:3px;grid-template-columns:3.5rem minmax(0,1fr) minmax(61px,.8fr) minmax(0,1fr) 3.5rem}
  .felt :is(.west,.east) .backs i{width:10px;height:5px}
}
#hand .face.drawn{margin-inline-start:clamp(8px,1.1vw,16px)}

:root{--meld-width:clamp(1.25rem,2.2vw,1.6rem);--meld-height:clamp(1.1rem,1.8vw,1.35rem)}
.meld .mini{
  display:inline-grid;place-items:center;flex:0 0 var(--meld-width);
  width:var(--meld-width);height:var(--meld-height);padding:0;
  font-size:clamp(.60rem,.94vw,.72rem);line-height:1;
}
.felt{
  --side-width:max(calc(4 * var(--meld-width) + 3px),8%);
  grid-template-columns:var(--side-width) minmax(0,1fr) minmax(61px,1.3fr) minmax(0,1fr) var(--side-width);
}
.turn-ribbon{display:flex;align-items:baseline;gap:.65rem;flex-wrap:wrap;margin:-2px 0 13px;padding:0 0 9px;border-bottom:1px solid var(--line)}
.turn-ribbon strong{color:var(--muted);font-size:.82rem;font-weight:500}
#turnText{font-weight:700;color:#f5dca3}
#spokenText{margin-left:auto;color:#c1d1c4;font-size:.78rem}
.acting-seat .badge{box-shadow:0 0 0 2px #d7b771}
.you.acting-seat{color:#f7d88b}

.face.restricted{opacity:.55;filter:grayscale(.75)}
#discardRule{margin:10px 0 0;text-align:center;color:var(--gold);font-size:.9rem}
