.mahjong {max-width:960px;margin:1rem auto;padding:0 1rem;color:#203a34}
.mahjong-setup,.mahjong-board {display:grid;gap:.8rem;margin-block:1rem}
.mahjong-board:empty,.mahjong-status:empty,.mahjong-print:empty {display:none}
.mahjong-setup[hidden] {display:none}
.mahjong-setup label {display:grid;gap:.4rem}
:is(.mahjong,.mahjong-setup) :is(textarea,select,input) {border:1px solid #b7cbc6;background:#fff;color:inherit;border-radius:6px;padding:.65rem;font:inherit;min-width:0}
.mahjong textarea {resize:vertical}
.mahjong select {width:fit-content;max-width:100%}
.mahjong-actions,.mahjong-hand {display:flex;align-items:center;flex-wrap:wrap;gap:.65rem}
.mahjong .button {white-space:normal;text-align:center}
.mahjong-board h2,.mahjong-board h3,.mahjong-board p {margin:0}
.mahjong-seats {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr));gap:.6rem}
.mahjong-seats section {border-top:2px solid #93b2a8;padding:.6rem;background:#edf5f1}
.mahjong-seats h3 {font-size:1rem}
.mahjong-tile {display:grid;place-items:center;border:1px solid #739288;border-bottom:4px solid #477969;border-radius:6px;background:#fffdf4;color:#183b32;font:1.65rem/1 serif;width:2.65rem;height:3.4rem}
.mahjong-tile[aria-pressed=true] {outline:2px solid #b65a2c;background:#fff0ce}
.mahjong-setup .game-thumb {width:min(100%,300px);height:auto;aspect-ratio:3/2}
.mahjong-word {padding:.32rem}
.mahjong-word img {display:block;width:80px;height:64px;object-fit:contain}
.mahjong-status {color:#8c3825}
.mahjong-sheet {padding:12px;background:white;margin-block:12px;color:#141414}
.mahjong-print-grid {display:grid;grid-template-columns:repeat(6,minmax(0,1fr));border-top:1px solid;border-left:1px solid}
.mahjong-print-grid div {display:grid;place-items:center;aspect-ratio:1;border-right:1px solid;border-bottom:1px solid;font:1.6rem serif}
.mahjong-print-page {background:#edf3f1}
.mahjong-print-page header {padding:1rem;border-bottom:1px solid #b7cbc6;background:white}
[data-game="word-mahjong"] .mahjong {max-width:1400px}
[data-game="word-mahjong"] .mahjong-board:not(:empty) {
  display:grid;grid-template-columns:minmax(72px,1fr) minmax(0,4fr) minmax(72px,1fr);
  grid-template-rows:auto minmax(240px,1fr) auto auto;gap:.55rem;
  min-height:min(70vh,690px);padding:clamp(6px,2vw,24px);
  border:clamp(6px,1.35vw,20px) solid #6e3b27;border-radius:8px;
  background:repeating-linear-gradient(110deg,#ffffff06 0 1px,transparent 1px 4px),radial-gradient(ellipse at 50% 43%,#237568,#0e483f 80%);
  box-shadow:inset 0 0 0 3px #271b15,inset 0 0 28px #061f1dbb,0 6px 15px #233d3540;
  color:#fffaf0;
}
.mahjong-seats {display:contents}
.mahjong-seats section {border:0;padding:.25rem;background:none;min-width:0;text-align:center;align-self:center}
.mahjong-seats h3 {font:600 .85rem/1.4 system-ui,sans-serif;color:#f4e9c7}
.mahjong-seats [data-position=self] {grid-area:3/1/4/4}
.mahjong-seats [data-position=across] {grid-area:1/2}
.mahjong-seats [data-position=left] {grid-area:2/1}
.mahjong-seats [data-position=right] {grid-area:2/3}
.mahjong-center {grid-area:2/2;align-self:center;text-align:center;display:grid;justify-items:center;gap:.65rem;min-width:0}
.mahjong-center h2 {font-size:1.45rem}
.mahjong-center p {color:#def0e6}
.mahjong-center .mahjong-actions {justify-content:center}
.mahjong-table-zones {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.6fr);gap:.45rem;width:min(100%,420px)}
.mahjong-zone {display:grid;align-content:start;justify-items:center;gap:.45rem;min-width:0;padding:.5rem;border:1px solid #9cc6aa;border-radius:6px;background:#123f38}
.mahjong-zone h3 {font-size:.85rem}
.mahjong-zone p {font-size:.78rem}
.mahjong-board .mahjong-draw-stack {background:#d6ead6;box-shadow:0 3px 0 #558768;max-width:100%}
@media (max-width:480px) {
  .mahjong-table-zones {grid-template-columns:1fr}
  .mahjong-zone {padding:.3rem}
}
.mahjong-board .button {background:#f5e3ad;color:#2a3026;border:1px solid #987d48;border-radius:6px}
.mahjong-board .button:disabled {opacity:.55}
.mahjong-placement {grid-area:4/1/5/4;text-align:center;padding:.4rem;min-width:0}
.mahjong-placement-groups {display:flex;flex-wrap:wrap;justify-content:center;gap:.35rem;margin-top:.3rem}
.mahjong-placement-pair {display:grid;grid-template-columns:repeat(2,auto);gap:3px;padding:4px;border:1px solid #a1c6ad;border-radius:5px;background:#123f38}
.mahjong-placement-pair>span {grid-column:1/-1;font:600 .72rem/1.4 system-ui,sans-serif;color:#e0f1e8}
.mahjong-placement-pair[data-match=true] {border-color:#f5d37c;background:#285947}
.mahjong-placement-pair .button {width:clamp(25px,4.5vw,42px);height:clamp(32px,5vw,53px);min-height:0;padding:0;font:1.15rem/1 serif}
.mahjong-placement-pair .button[data-filled=false] {background:#174a41;color:#e0f1e8;border:1px dashed #a1c6ad}
.mahjong-placement-pair .button[data-filled=true]:disabled {opacity:1}
.mahjong-board>.mahjong-hand {grid-area:5/1/6/4;justify-content:center;gap:.32rem}
.mahjong-board .mahjong-tile {width:clamp(32px,6vw,68px);height:clamp(48px,8vw,92px);font-size:clamp(21px,4vw,42px);border:1px solid #d5d1b7;border-bottom:7px solid #55a17c;background:linear-gradient(#fffef8,#e9e3d3);box-shadow:0 3px 4px #142b24;color:#172a23}
.mahjong-board .mahjong-tile[aria-pressed=true] {transform:translateY(-5px);outline-color:#f6ce68}
.mahjong-board .mahjong-tile:disabled {opacity:1}
.mahjong .mahjong-tile[data-placed=true] {background:#b5bfbb;color:#55645d;border-color:#819089;box-shadow:none;opacity:.72}
.mahjong-names {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,125px),1fr));gap:.6rem}
.mahjong-setup label[hidden] {display:none}
.mahjong-online-view {grid-area:1/1/-1/-1;display:grid;gap:.65rem;min-width:0}
[data-game="word-mahjong"] .mahjong-board:has(.mahjong-online-view) {display:block;min-height:0}
.mahjong-online-error {grid-area:5/1/6/4}
.mahjong-online-error:empty {display:none}
.mahjong-online-table {background:#174f45;color:#fff8de;padding:1rem;border:4px solid #6e3b27;border-radius:6px}
.mahjong-online-table .mahjong-names div {background:#103b34;padding:.5rem;border-radius:4px;overflow-wrap:anywhere}
.mahjong-online-view .mahjong-placement-groups {justify-content:flex-start}
.mahjong-invite {display:flex;align-items:center;flex-wrap:wrap;gap:1rem}
.mahjong-invite a {color:inherit}
.mahjong-backs,.mahjong-discards {display:flex;flex-wrap:wrap;justify-content:center;gap:2px}
.mahjong-backs {margin:.35rem auto}
[data-position=left] .mahjong-backs,[data-position=right] .mahjong-backs {display:grid;grid-template-columns:repeat(2,auto);justify-content:center}
.mahjong-backs span {width:clamp(8px,2vw,25px);height:clamp(14px,3vw,35px);border:1px solid #26765c;border-top:4px solid #c8e3ca;border-radius:3px;background:linear-gradient(#64ab85,#20764f);box-shadow:0 2px 2px #0b3028}
.mahjong-discards {max-width:260px}
.mahjong-discards span {display:grid;place-items:center;width:26px;height:32px;background:#e4dfc8;color:#173d34;border-radius:3px;border-bottom:3px solid #8caf91}
.mahjong-discards .mahjong-offer {outline:2px solid #f7d785;background:#fff2ca}
.mahjong-board .mahjong-word {display:inline-block;color:#193a30;background:#f8f2db;border-radius:4px;margin:2px;max-width:100%;overflow-wrap:anywhere}
.mahjong-board .mahjong-word img {max-width:100%}
@media screen and (min-width:900px) {
  .mahjong-print-page .mahjong {max-width:1440px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:1.2rem;align-items:start}
  .mahjong-print-page h1 {grid-column:1/-1}
  .mahjong-print-page .mahjong-setup {grid-column:1;grid-row:2}
  .mahjong-print-page .mahjong-board {grid-column:1;grid-row:3;margin-top:0}
  .mahjong-print-page .mahjong-print {grid-column:2;grid-row:2/span 3}
}
@media print {
  @page mahjong-sheet {size:A4 portrait;margin:10mm}
  body.mahjong-print-page {page:mahjong-sheet;margin:0;background:white}
  .mahjong-print-page header,.mahjong-print-page h1,.mahjong-print-page .mahjong-setup,.mahjong-print-page .mahjong-board {display:none!important}
  .mahjong-print-page .mahjong {max-width:none;margin:0;padding:0}
  .mahjong-print-page .mahjong-sheet {margin:0;padding:0;break-inside:avoid-page}
  .mahjong-print-page .mahjong-sheet + .mahjong-sheet {break-before:page}
  .mahjong-print-page .mahjong-print-grid {width:180mm}
  .mahjong-print-page .mahjong-print-grid div {height:29mm;aspect-ratio:auto;font-size:20pt}
}
