.mahjong-page [hidden],.mahjong-table [hidden],.mj-actions[hidden],.mj-actions [hidden] { display: none!important }
.mahjong-page .poker-heading { margin-bottom: 16px }
.mahjong-page .poker-heading h2 { font-size: clamp(22px,2.6vw,28px) }
.mahjong-page .poker-table-settings input { font-variant-numeric: tabular-nums }
.mahjong-page .poker-wallet .balance { overflow-wrap: anywhere; white-space: normal }
.mahjong-page .poker-sidebar { overflow: visible }
.mahjong-page #mahjongSetup { scroll-margin-top: 16px }
.mahjong-page #mahjongChallenges { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px }
.mahjong-page #mahjongChallenges .bj-challenge { margin: 0 }
.mj-table-settings { margin: 0; font-size: .82rem }
.mj-table-settings div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 5px 0 }
.mj-table-settings dt { color: var(--muted) }
.mj-table-settings dd { margin: 0; text-align: right; font-weight: 750 }
.mahjong-page .mj-chip-terms { margin-top: 10px; padding-top: 7px; border-top: 1px solid var(--line) }
.mj-mobile-tools { display: none }
.mj-status { margin: 8px 0 0; overflow-wrap: anywhere }
.mj-status:empty { display: none }

.mahjong-table {
  container-type: inline-size;
  min-width: 0;
  --mj-safe-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  --mj-gold: #f5d878;
  --mj-felt-light: #498b9d;
  --mj-felt: #35788c;
  --mj-felt-deep: #236078;
  --mj-rail: #2a5a74;
  --mj-rail-deep: #153c54;
  --mj-ink: #f7fcff;
}
body.dark .mahjong-table {
  --mj-felt-light: #3c8296;
  --mj-felt: #286d81;
  --mj-felt-deep: #1a5369;
  --mj-rail: #245269;
  --mj-rail-deep: #102f46;
}
.mj-table {
  isolation: isolate; position: relative; display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,2.72fr) minmax(0,1fr);
  grid-template-rows: minmax(98px,auto) auto minmax(88px,auto);
  grid-template-areas: "die-left north die-north" "west board east" "die-south south die-east";
  align-items: center; justify-items: center;
  gap: clamp(12px,2.6cqi,24px) clamp(6px,1.25cqi,14px); padding: clamp(10px,2.1cqi,23px);
  border: clamp(5px,1.25cqi,14px) solid var(--mj-rail); border-radius: clamp(16px,4cqi,45px);
  outline: 1px solid #bc974d;
  color: var(--mj-ink);
  background:
    repeating-linear-gradient(44deg,#e1f7ff0b 0 1px,transparent 1px 4px),
    repeating-linear-gradient(136deg,#153b4c10 0 1px,transparent 1px 4px),
    radial-gradient(ellipse at 50% 28%,var(--mj-felt-light),var(--mj-felt) 61%,var(--mj-felt-deep));
  box-shadow: inset 0 0 0 2px #ddb65e,inset 0 0 26px #153e53ad,0 5px 0 var(--mj-rail-deep);
}
.mj-field {
  grid-area: board; position: relative; isolation: isolate; align-self: center;
  width: min(100%,575px); aspect-ratio: 1;
}
.mj-wall-ring {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  transform: rotate(-13deg);
  --wall-depth: clamp(17px,5.5cqi,42px);
  --wall-radius: clamp(2.5px,.55cqi,6px);
  /* Each long end projects past the neighboring wall, whose short end stops before the corner. */
  --wall-inset: 10.5%;
  --wall-tip: 4%;
  --wall-rise: clamp(2px,.53cqi,5px);
  --wall-gap: calc(var(--wall-rise) + 7px);
  --wall-inline-inset: var(--wall-inset);
  --wall-block-inset: var(--wall-inset);
  --wall-inline-tip: var(--wall-tip);
  --wall-block-tip: var(--wall-tip);
  --wall-inline-stop: calc(var(--wall-inline-inset) + var(--wall-depth) + var(--wall-gap));
  --wall-block-stop: calc(var(--wall-block-inset) + var(--wall-depth) + var(--wall-gap));
}
.mj-middle { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none }
.mj-emblem { width: 26%; max-width: 104px; aspect-ratio: 1; opacity: .28; mix-blend-mode: luminosity }
.mj-portrait,.mj-emblem { display: block; object-fit: contain; clip-path: var(--character-cutout,none) }

.mj-metrics,.mj-payments { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin: 0 0 13px; font-variant-numeric: tabular-nums }
.mj-metrics div,.mj-payments div { min-width: 0; padding: 7px 9px; background: var(--card); border: 1px solid var(--line); border-radius: 10px }
.mj-metrics dt,.mj-payments dt { font-size: .73rem; color: var(--muted); font-weight: 700 }
.mj-metrics dd,.mj-payments dd { margin: 2px 0 0; font-size: .86rem; line-height: 1.17; font-weight: 800; overflow-wrap: anywhere }
.mj-metrics { grid-template-columns: repeat(4,minmax(0,1fr)); text-align: center }
.mj-metrics > :first-child dd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.mj-flower-fan { margin-inline-start: .4em; color: #1b6b46; font-size: .86em; white-space: nowrap }
body.dark .mj-flower-fan { color: #a6eed0 }
.mj-seat { align-self: center; width: min(20.5cqi,228px); min-width: 0; display: grid; align-content: start; padding: clamp(5px,1cqi,10px); border: 1px solid #bde5f985; border-radius: 12px; background: linear-gradient(150deg,#124361,#0a304b); box-shadow: 0 3px 9px #102f4a55 }
.mj-seat-top { grid-area: north }
.mj-seat-bottom { grid-area: south }
.mj-seat-left { grid-area: west }
.mj-seat-right { grid-area: east }
.mj-seat[data-self] { border-color: #b7e7ff }
.mj-seat[data-turn] { border-color: var(--mj-gold); box-shadow: 0 0 0 1px var(--mj-gold),0 3px 10px #15394a80 }
.mj-player { display: flex; align-items: center; gap: clamp(4px,.8cqi,9px); min-width: 0 }
.mj-portrait { flex: none; width: clamp(33px,5.3cqi,66px); aspect-ratio: 1 }
.mj-name { min-width: 0; line-height: 1.16 }
.mj-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(.65rem,1.16cqi,.89rem) }
.mj-name small { display: block; color: #e1f3ff; font-size: clamp(.63rem,1.35cqi,.81rem); font-variant-numeric: tabular-nums }
.mj-wind { color: #ffdf83; font-size: .72rem; font-weight: 750 }
.mj-corner {
  display: grid; align-content: center; justify-items: start; gap: 7px;
  width: clamp(108px,19cqi,184px); max-width: 100%; min-width: 0;
}
.mj-corner-top { grid-area: die-north; justify-self: end }
.mj-corner-bottom { grid-area: die-south; justify-self: start }
.mj-corner-left { grid-area: die-left; justify-self: start; align-self: end }
.mj-corner-right { grid-area: die-east; justify-self: end; align-self: start }
.mj-corner:is(.mj-corner-top,.mj-corner-right) { justify-items: end }
.mj-corner:has(.mj-dice:not(:empty)) { align-self: stretch; align-content: start; gap: 3px }
.mj-corner:is(.mj-corner-bottom,.mj-corner-right):has(.mj-dice:not(:empty)) { align-content: end }
.mj-corner:is(.mj-corner-bottom,.mj-corner-right) .mj-dice { order: 1 }

.mj-dice:empty { display: none }
.mj-speech {
  grid-area: speech; justify-self: stretch;
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 4px 2px; font-size: clamp(.7rem,1.4cqi,.82rem);
}
.mj-speaker { flex: 0 0 auto; display: grid; justify-items: center; gap: 3px; width: clamp(48px,9cqi,86px); text-align: center; line-height: 1.15 }
.mj-speaker strong { max-width: 100%; overflow-wrap: anywhere }
.mj-speaker .mj-portrait,.mj-speaker-initial { width: clamp(28px,6cqi,45px) }
.mj-speaker-initial { display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; background: var(--panel); border: 1px solid var(--line) }
.mj-seat-line {
  position: relative; margin: 0; padding: 6px 9px; border-radius: 8px;
  background: #fff5d9; color: #234052; box-shadow: 0 2px 6px #15394a40;
  font-weight: 650; line-height: 1.3; overflow-wrap: anywhere;
}
.mj-seat-line::after {
  content: ""; position: absolute; width: 8px; height: 8px;
  inset-inline-start: -3px; top: calc(50% - 4px); background: inherit; rotate: 45deg;
}
.mj-exposed {
  --exposed-limit: 36px; --dense-limit: 23px;
  container-type: inline-size;
  display: flex; flex-wrap: wrap; align-items: start; gap: 5px 4px; min-width: 0;
  padding: 2px 1px 4px;
}
.mj-exposed:empty { display: none }
.mj-set { display: inline-flex; flex: none; align-items: center; gap: 1px }
.mj-exposed[data-compact] { --exposed-limit: var(--dense-limit) }
.mj-exposed .mj-tile { --tile-size: min(var(--exposed-limit), calc((100cqw - var(--set-gaps)) / var(--set-count))) }
.mj-exposed .mj-seat-flower { outline: 1px solid #ffdf83 }
.mj-seat .mj-exposed-link {
  min-width: 0; min-height: 26px; padding: 2px 4px;
  border: 1px solid #b7e7ff69; border-radius: 5px;
  background: #0b3048; color: #effaff; font: inherit; font-size: .65rem; font-weight: 750; line-height: 1.2;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.mj-exposed-link:hover { border-color: #ffdf83 }
.mj-exposed-tray {
  margin-top: 8px; padding: 8px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card);
}
.mj-exposed-tray h3 { margin: 0 0 6px; font-size: .9rem }
.mj-exposed-shelves { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,232px),1fr)); gap: 6px }
.mj-exposed-shelf { min-width: 0; padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel) }
.mj-exposed-shelf h4 { margin: 0 0 4px; font-size: .76rem; overflow-wrap: anywhere }
.mj-exposed-shelf .mj-exposed { --exposed-limit: 25px; --dense-limit: 23px; gap: 5px 9px }


.mj-wall { position: absolute }
.mj-wall i { position: absolute; width: 100%; height: 100% }
.mj-wall-tile {
  position: absolute; inset: 0;
  border: 1px solid #e1ffec70;
  border-radius: var(--wall-radius);
  background: var(--mj-jade);
  box-shadow: inset 0 1px 1px #bdf6d97d, inset 0 -1px 0 var(--mj-ivory-edge),
    inset 0 calc(-1 * var(--wall-rise)) 0 var(--mj-ivory);
}
/* The upper cap sits one tile height above the lower cap. */
.mj-wall-tile:last-child { transform: translateY(calc(-1 * var(--wall-rise))) }
.mj-wall i[data-height="1"] .mj-wall-tile:last-child { display: none }
.mj-wall-top,.mj-wall-bottom { height: var(--wall-depth) }
.mj-wall-top { top: var(--wall-block-inset); left: var(--wall-inline-stop); right: var(--wall-inline-tip) }
.mj-wall-bottom { bottom: var(--wall-block-inset); right: var(--wall-inline-stop); left: var(--wall-inline-tip) }
.mj-wall:is(.mj-wall-top,.mj-wall-bottom) i { left: var(--wall-position); width: calc(100% / 18 - .45px) }
.mj-wall-left,.mj-wall-right { width: var(--wall-depth) }
.mj-wall-left { left: var(--wall-inline-inset); top: var(--wall-block-tip); bottom: var(--wall-block-stop) }
.mj-wall-right { right: var(--wall-inline-inset); bottom: var(--wall-block-tip); top: var(--wall-block-stop) }
.mj-wall:is(.mj-wall-left,.mj-wall-right) i { top: var(--wall-position); height: calc(100% / 18 - .45px) }
.mj-wall:is(.mj-wall-left,.mj-wall-right) .mj-wall-tile {
  box-shadow: inset 1px 0 1px #bdf6d97d, inset -1px 0 0 var(--mj-ivory-edge),
    inset calc(-1 * var(--wall-rise)) 0 0 var(--mj-ivory);
}
.mj-wall:is(.mj-wall-left,.mj-wall-right) .mj-wall-tile:last-child { transform: translateX(calc(-1 * var(--wall-rise))) }
body:not([data-motion="off"]) .mj-wall i { transition: left .16s ease-out,top .16s ease-out }
.mj-discards {
  --discard-width: min(var(--discard-fit, 0px),clamp(31px,5.5cqi,54px));
  position: absolute; top: 50%; left: 50%; translate: -50% -50%; z-index: 0; display: grid;
  width: var(--discard-area-width,40%); height: var(--discard-area-height,40%);
  grid-template-columns: repeat(var(--discard-columns, 1),var(--discard-width));
  grid-auto-rows: calc(var(--discard-width) * var(--mj-tile-proportion));
  place-content: center; gap: clamp(1px,.38cqi,4px) clamp(1px,.33cqi,4px);
  padding: 3px 5px 6px;
}
.mj-field:has(.mj-discards:not(:empty)) .mj-emblem { visibility: hidden }
.mj-discards .mj-face { width: 92% }
.mj-discards .mj-tile { --tile-size: var(--discard-width); --tile-lift: min(3.5px,calc(var(--tile-size) * .1)); height: 100% }
.mj-wall i:is(.mj-end-draw,.mj-end-replacement) { z-index: 1 }
.mj-wall i.mj-end-draw .mj-wall-tile:last-child,.mj-wall i.mj-end-draw[data-height="1"] .mj-wall-tile:first-child { outline: 2px solid #ffdb70 }
.mj-wall i.mj-end-replacement .mj-wall-tile:last-child,.mj-wall i.mj-end-replacement[data-height="1"] .mj-wall-tile:first-child { outline: 2px solid #e3caff }
.mj-wall i.mj-end-draw.mj-end-replacement .mj-wall-tile { outline-color: #ffdb70; border-color: #e3caff }
.mj-wall-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 11px 0 0; padding: 0; color: var(--muted); font-size: .76rem }
.mj-wall-key span { display: inline-flex; align-items: center; gap: 5px }
.mj-wall-key span::before { content: ""; width: 8px; height: 8px; border-radius: 2px; border: 1px solid #775f23; background: #ffdb70 }
.mj-wall-key .mj-key-replacement::before { background: #e3caff; border-color: #795591 }

.mj-dice { display: flex; align-items: start; gap: clamp(2px,.5cqi,5px); padding-bottom: 2px; pointer-events: none }
.mj-die {
  --mj-die-size: clamp(17px,3.3cqi,32px);
  display: grid; grid-template: repeat(3,minmax(0,1fr)) / repeat(3,minmax(0,1fr));
  place-items: center; width: var(--mj-die-size); height: var(--mj-die-size); flex: none;
  padding: clamp(2px,.55cqi,5px); border: 1px solid #e7ddc3; border-radius: 5px;
  color: #1c293b; background: #fffaf0; box-shadow: 0 2px 0 #aa9678;
}
.mj-die i { width: 80%; aspect-ratio: 1; border-radius: 50%; background: currentColor }
.mj-die[data-face="1"] i,.mj-die[data-face="4"] i { color: #b62135 }
.mj-rolling { animation: mj-roll calc(.32s / var(--mj-speed,1)) ease-out both }
@keyframes mj-roll { from { transform: translateY(-8px) rotate(-28deg); opacity: .45 } 55% { transform: translateY(2px) rotate(13deg) } to { transform: none; opacity: 1 } }

.mj-rack-panel { display: grid; justify-items: center; gap: 8px; margin-top: 14px; padding: 11px 6px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--card) }
.mj-rack-heading { font-size: 1rem; margin: 0 }
.mj-rack-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: clamp(4px,1.2cqi,12px); width: 100% }
.mj-rack-row:has(.mj-discard-button[hidden]) { grid-template-columns: minmax(0,1fr) }
.mj-discard-button { min-height: 46px; min-width: 84px; padding: 7px clamp(8px,1.2cqi,15px); border: 1px solid #bc8e2d; border-radius: 9px; background: #ffdf78; color: #382b0f; font-size: .94rem; font-weight: 800 }
.mj-discard-button:disabled { background: var(--card); border-color: var(--line); color: var(--muted); opacity: .72 }
.mj-rack,.mj-rack .mj-tile:is(button) { touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none }
.mj-rack .mj-tile[aria-pressed="true"] { outline: 2px solid #e49b0a; outline-offset: 1px; transform: translateY(-3px) }
.mj-rack .mj-tile.mj-dragging { opacity: .38; cursor: grabbing }
.mj-rack .mj-tile.mj-drop-target { outline: 3px solid #1689ab; outline-offset: 2px }
.mj-rack .mj-tile[data-drop-edge]::after {
  content: ""; position: absolute; z-index: 1; inset-block: -2px;
  width: 3px; border-radius: 2px; background: #ffd45a; box-shadow: 0 0 0 1px #795427;
}
.mj-rack .mj-tile[data-drop-edge="before"]::after { inset-inline-start: -6px }
.mj-rack .mj-tile[data-drop-edge="after"]::after { inset-inline-end: -6px }
.mj-rack .mj-tile[data-drop-edge][aria-pressed="false"]:hover { outline: none }
.mj-rack-panel .mj-rack-hint { margin: 0; color: var(--muted); text-align: center; font-size: .84rem; min-height: 1.25em }
.mj-tile.mj-drag-ghost { position: fixed; inset: 0 auto auto 0; z-index: 50; pointer-events: none; margin: 0; will-change: transform }
.mj-rack { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: clamp(7px,.82cqi,9px); width: 100%; max-width: 100%; min-height: 64px; padding-bottom: 5px }
.mj-rack .mj-tile { --tile-size: clamp(34px,6.8cqi,67px); min-height: 44px }
.mj-rack .mj-tile:is(button) { cursor: pointer }
.mj-rack button:hover,.mj-rack button:focus-visible,.mj-rack .mj-drawn { outline: 2px solid #e8ac27; outline-offset: 1px }
.mj-rack .mj-drawn { margin-left: clamp(2px,.7cqi,8px) }
.mj-empty-rack { margin: 0; color: var(--muted); font-size: .85rem; text-align: center }
.mj-white-dragon { position: absolute; inset: 22% 21%; border: clamp(1px,.36cqi,4px) double #293d82; border-radius: 12%; box-shadow: inset 0 0 0 1px #abbded }
.mj-flower .mj-face { top: auto; bottom: 4%; width: var(--mj-flower-scale,75%); transform: translateX(-50%) }
.mj-flower-number {
  position: absolute; top: 5%; left: 10%; color: #a6192b;
  font-size: clamp(var(--mj-flower-label-min,10px),calc(var(--tile-size) * var(--mj-flower-label-scale,.36)),19px); font-weight: 800; line-height: 1;
}
.mj-tile.mj-latest { outline: 2px solid var(--mj-gold); outline-offset: -1px }

.mj-actions { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--card) }
.mj-table-note { min-height: 1.3em; margin: 0; text-align: center; font-size: .92rem; font-weight: 750; overflow-wrap: anywhere }
.mj-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px }
.mj-claim-timer { display: grid; gap: 4px; width: min(100%,320px); margin: 8px auto; text-align: center; color: var(--muted); font-size: .8rem; font-weight: 750 }
.mj-claim-meter { display: block; width: 100%; height: 9px; accent-color: #c58a12 }
.mj-claim-meter::-webkit-progress-value { transition: width .1s linear }
body[data-motion="off"] .mj-claim-meter::-webkit-progress-value { transition: none }
.mj-food-bonus { color: var(--text); font-weight: 750 }
.mj-guide-tiles { display: inline-flex; align-items: center; gap: 5px; margin: 5px 0 9px }
.mj-guide-tiles .mj-tile { --tile-size: 27px }
.mj-reset-controls { display: grid; gap: 8px }
.mj-controls:not(:empty) { margin-top: 8px }
.mj-controls button,.mj-skip { min-height: 44px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; font-weight: 750; cursor: pointer }
.mj-controls .mj-primary { background: #ffda57; border-color: #d9aa41; color: #413503 }
.mj-payout { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--panel) }
.mj-payout :is(h3,p,ul) { margin: 0 0 8px }
.mj-patterns { display: flex; flex-wrap: wrap; gap: 5px; padding: 0; list-style: none }
.mj-patterns li { border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; font-size: .8rem }
.mj-payments { grid-template-columns: repeat(4,minmax(0,1fr)); margin: 0 }
.mj-wash { position: absolute; inset: 10%; z-index: 2; pointer-events: none }
.mj-loose { position: absolute; inset: 48% auto auto 49%; width: clamp(11px,2.6cqi,27px); aspect-ratio: 3/4; border-radius: 4px; background: var(--mj-jade); box-shadow: 0 2px 0 var(--mj-ivory-edge); animation: mj-wash calc(.43s / var(--mj-speed,1)) var(--delay) ease-out both }
@keyframes mj-wash { from { transform: translate(0,22px) rotate(-20deg); opacity: 0 } 32% { opacity: 1 } to { transform: translate(var(--x),var(--y)) rotate(var(--spin)); opacity: 0 } }
.mj-building .mj-wall i { animation: mj-build calc(.30s / var(--mj-speed,1)) ease-out both }
.mj-building .mj-wall i:nth-child(3n) { animation-delay: calc(.07s / var(--mj-speed,1)) }
@keyframes mj-build { from { transform: translateY(-7px); opacity: .22 } to { transform: none; opacity: 1 } }
.mj-skip { position: absolute; z-index: 3; bottom: 2%; right: 2%; font-size: .72rem }

@media (max-width:850px), (orientation: landscape) and (max-width: 1100px) and (max-height: 600px) {
  .mj-mobile-tools,#mahjongMobileSetup { display: flex; align-items: center; justify-content: space-between; gap: 8px }
  .mj-mobile-tools { flex-wrap: wrap; margin: 0 0 12px; font-size: .83rem; font-weight: 750 }
  #mahjongMobileSetup { margin-left: auto }
  #mahjongQuickPlay { width: auto; min-height: 42px; margin: 0; padding: 8px 14px }
}
@container (max-width:610px) {
  .mj-play-area { scroll-margin-top: max(4px,env(safe-area-inset-top)) }
  .mj-metrics { margin-bottom: 5px }
  .mj-metrics div { padding: 3px 4px }
  .mj-metrics dt { font-size: .68rem }
  .mj-metrics dd { font-size: .77rem }
  .mj-table {
    --mj-side-seat: clamp(57px,17.5cqi,83px);
    grid-template-columns: var(--mj-side-seat) minmax(0,1fr) var(--mj-side-seat);
    grid-template-rows: auto auto auto;
    margin-inline: -8px; overflow: clip;
    gap: 3px 4px; padding: 5px 3px;
  }
  /* Let the walls use the full felt width while the side seats occupy their own columns. */
  .mj-field {
    grid-area: 2 / 1 / 3 / -1;
    width: min(100%,475px); height: min(100cqi,clamp(140px,calc(var(--mj-safe-height) - 382px),390px)); margin-block: 0;
  }
  .mj-wall-ring {
    transform: rotate(-7deg);
    --wall-depth: clamp(14px,5cqi,32px);
    --wall-inline-inset: calc(var(--mj-side-seat) + 14px);
    --wall-block-inset: clamp(11px,4cqi,23px);
    --wall-inline-tip: -2.5%;
    --wall-block-tip: 0%;
  }
  .mj-seat { width: 100%; min-width: 0; padding: 4px 3px; border-radius: 8px; z-index: 2 }
  .mj-seat:is(.mj-seat-top,.mj-seat-bottom) {
    width: min(100%,clamp(124px,45cqi,180px)); grid-template-columns: minmax(0,1fr) auto;
    align-items: center; gap: 3px;
  }
  .mj-seat:is(.mj-seat-top,.mj-seat-bottom) .mj-exposed {
    width: clamp(38px,14cqi,59px);
  }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-exposed { justify-content: center }
  .mj-seat .mj-player { gap: 4px }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-player { flex-direction: column; align-items: center; text-align: center }
  .mj-seat .mj-portrait { width: clamp(18px,5.5cqi,31px) }
  .mj-name { flex: 1 }
  .mj-name strong { text-overflow: clip }
  .mj-name strong > span { display: inline-block; transform: scaleX(var(--mj-name-scale,1)); transform-origin: left center }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-name strong { text-align: left }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-name { width: 100% }
  .mj-name strong,.mj-wind { font-size: clamp(.6rem,2.5cqi,.8rem) }
  .mj-name small { font-size: .59rem; overflow-wrap: anywhere }
  .mj-exposed {
    --exposed-limit: 21px; --dense-limit: 14px;
    --mj-flower-scale: 55%;
    --mj-flower-label-min: 6.25px;
    --mj-flower-label-scale: .325;
    gap: 3px; padding-block: 2px 4px;
  }
  .mj-corner { width: clamp(50px,19.5cqi,96px); max-width: none; z-index: 2 }
  .mj-corner:not(:has(.mj-dice:not(:empty))) { display: none }
  .mj-dice { gap: 2px }
  .mj-die { --mj-die-size: clamp(12px,4cqi,20px); padding: 2px }
  .mj-rack-panel {
    grid-template-columns: 1fr auto;
    grid-template-areas: "heading discard" "tiles tiles" "speech speech";
    gap: 3px; margin-top: 4px; padding: 4px 3px 6px;
  }
  .mj-rack-heading { grid-area: heading; justify-self: start; padding-left: 4px; font-size: .9rem }
  .mj-rack-row { display: contents }
  .mj-rack { grid-area: tiles; gap: 4px; min-height: 0; padding-bottom: 3px }
  .mj-rack-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
  .mj-discard-button { grid-area: discard; justify-self: end; min-height: 44px }
  .mj-rack .mj-tile { --tile-size: clamp(27px,calc((100cqi - 43px) / 7),53px); min-height: 0 }
  .mj-wall-key { margin-top: 4px; font-size: .66rem }
  .mj-discards { --discard-width: min(calc(var(--discard-fit, 0px) * .94),clamp(22px,7.5cqi,35px)) }
  .mj-payments { grid-template-columns: repeat(2,minmax(0,1fr)) }
}
@media (max-width:660px) {
  .mahjong-page #mahjongChallenges { grid-template-columns: 1fr }
}
@media (max-width:390px) {
  .mahjong-page .poker-heading .table-tools { gap: 4px }
  .mahjong-page .poker-heading .table-tools>button,.mahjong-page .poker-heading .audio-control>button { width: 38px; min-width: 38px }
}

@container (min-width:611px) {
  .mj-table {
    grid-template-rows: minmax(47px,1fr) auto minmax(47px,1fr);
    gap: 5px clamp(8px,1.4cqi,16px);
    padding: clamp(11px,1.55cqi,19px) clamp(13px,1.8cqi,22px);
    border-width: clamp(5px,.75cqi,10px);
  }
  .mj-field { width: min(100%,clamp(305px,calc(91svh - 430px),610px)); margin-block: -7px }
  .mj-wall-ring {
    --wall-depth: clamp(24px,calc(5.4svh - 12px),44px);
    --wall-inset: 11.5%;
    --wall-tip: -8.5%;
  }
  .mj-seat {
    padding: 6px 8px; gap: 3px 8px;
    grid-template: "portrait name" auto "portrait exposed" auto / auto minmax(0,1fr);
  }
  .mj-seat .mj-player { display: contents }
  .mj-seat .mj-name { grid-area: name }
  .mj-seat .mj-portrait { grid-area: portrait; align-self: center; width: clamp(30px,4.5cqi,49px) }
  .mj-seat .mj-exposed { grid-area: exposed; padding-block-start: 0 }
  .mj-seat:has(.mj-meld) {
    grid-template: "portrait name" auto "exposed exposed" auto / auto minmax(0,1fr);
  }
  .mj-seat:has(.mj-meld) .mj-portrait { width: clamp(30px,3.8cqi,42px) }
  .mj-metrics { margin-bottom: 6px }
  .mj-wall-key { margin-top: 4px }
  .mj-rack-panel {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "hint heading discard" "tiles tiles tiles" "speech speech speech";
    gap: 2px 8px; margin-top: 5px; padding: 4px 8px 6px;
  }
  .mj-rack-heading { grid-area: heading }
  .mj-rack-row { display: contents }
  .mj-rack { grid-area: tiles; --rack-gap: 6px; gap: var(--rack-gap); min-height: 42px }
  .mj-rack .mj-tile {
    --tile-size: min(75px,calc((100cqi - 13 * var(--rack-gap)) / 15));
    min-height: 0;
  }
  .mj-rack .mj-drawn { margin-left: 5px }
  .mj-discard-button { grid-area: discard; justify-self: end }
  .mj-rack-panel .mj-rack-hint { grid-area: hint; justify-self: start; text-align: start; padding-left: 3px }
}
@media (min-width:900px) {
  .mahjong-page { padding-block-start: 18px }
  .mahjong-page .casino-nav { margin-block: 14px }
  .mahjong-page .mj-game { padding-top: 12px }
  .mahjong-page .poker-heading { margin-bottom: 6px }
  .mahjong-page .poker-heading h2 { margin: 0 }
  .mahjong-page .poker-heading .eyebrow { display: none }
}
@container (min-width:611px) and (max-width:860px) {
  .mj-seat { grid-template: "name name" auto "portrait exposed" auto / auto minmax(0,1fr); gap: 3px 6px }
  .mj-name strong { font-size: clamp(.61rem,1.3cqi,.72rem) }
}
.mj-actions[data-prompt-open] { position: fixed; z-index: 20; bottom: max(10px,env(safe-area-inset-bottom)); left: 50%; translate: -50% 0; width: min(calc(100% - 28px),490px); margin: 0; box-shadow: 0 4px 18px #112b4a66 }


@media (orientation: landscape) and (max-width: 1100px) and (max-height: 600px) {
  .mahjong-page .poker-layout { grid-template-columns: minmax(0,1fr) }
  .mahjong-page { padding-inline: 5px }
  .mahjong-page .mj-game,.online-page #roomTable:has(#roomMahjong:not([hidden])) { padding-inline: 6px }
  .mahjong-page .poker-heading { margin-block-end: 5px }
  .mahjong-page .poker-heading h2 { margin-block: 0; font-size: 1.08rem }
  .mahjong-page .poker-heading :is(.eyebrow,.poker-subtitle) { display: none }
  .mj-play-area {
    /* The browser's bars can cover the edges without resizing the table. */
    --mj-safe-height: calc(100lvh - 8px);
    --mj-board-size: max(0px,calc(var(--mj-safe-height) - 2px));
    --mj-table-column: min(66%,var(--mj-board-size));
    --mj-hand-size: calc(var(--mj-board-size) * .94);
    display: grid;
    grid-template-columns: minmax(0,var(--mj-table-column)) minmax(0,min(var(--mj-hand-size),calc(100% - var(--mj-table-column) - 8px)));
    grid-template-areas: "table info" "table rack" "table key" "table controls";
    grid-template-rows: auto minmax(0,1fr) auto auto;
    column-gap: 8px; align-items: start; justify-content: center;
    scroll-margin-top: max(4px,env(safe-area-inset-top));
  }
  .mj-table {
    grid-area: table; --mj-side-seat: clamp(47px,14%,74px);
    width: 100%; aspect-ratio: 1;
    grid-template-columns: var(--mj-side-seat) minmax(0,1fr) var(--mj-side-seat);
    grid-template-rows: minmax(32px,auto) minmax(0,1fr) minmax(32px,auto);
    margin: 0; gap: 3px; padding: 4px; border-width: 5px;
  }
  .mj-field {
    position: absolute; inset: 50% auto auto 50%; translate: -50% -50%;
    grid-area: auto; width: calc(100% - 46px); height: auto; aspect-ratio: 1; margin: 0;
  }
  .mj-wall-ring {
    transform: rotate(-8deg);
    --wall-depth: clamp(14px,calc(var(--mj-safe-height) * .054),26px);
    --wall-radius: clamp(1.5px,calc(var(--mj-safe-height) * .0064),3.4px);
    --wall-rise: clamp(1.8px,calc(var(--mj-safe-height) * .0066),3.2px);
    --wall-inset: 16%;
    --wall-tip: -6%;
    --wall-inline-inset: var(--wall-inset);
    --wall-block-inset: var(--wall-inset);
    --wall-inline-tip: var(--wall-tip);
    --wall-block-tip: var(--wall-tip);
  }
  .mj-seat { display: grid; width: 100%; padding: 3px; gap: 2px; z-index: 2; border-radius: 8px }
  .mj-seat:is(.mj-seat-top,.mj-seat-bottom) {
    width: min(100%,152px); grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: none; align-items: center;
  }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) {
    grid-template-columns: minmax(0,1fr); grid-template-areas: none; text-align: center;
  }
  .mj-seat .mj-player { display: flex; align-items: center; gap: 3px }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-player { flex-direction: column }
  .mj-seat :is(.mj-name,.mj-portrait,.mj-exposed) { grid-area: auto }
  .mj-seat .mj-name { flex: 1; width: 100% }
  .mj-seat .mj-portrait { width: 18px }
  .mj-seat .mj-name strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: clip; font-size: .62rem }
  .mj-name strong > span { display: inline-block; transform: scaleX(var(--mj-name-scale,1)); transform-origin: left center }
  .mj-seat:is(.mj-seat-left,.mj-seat-right) .mj-name strong { text-align: left }
  .mj-seat .mj-name :is(small,.mj-wind) { font-size: .57rem; line-height: 1.1; overflow-wrap: anywhere }
  .mj-seat .mj-exposed {
    --exposed-limit: clamp(17.5px,calc(var(--mj-safe-height) * .051),24px); --dense-limit: 14px;
    --mj-flower-scale: 53%;
    --mj-flower-label-min: 6.25px;
    --mj-flower-label-scale: .325;
    gap: 3px; padding-block: 1px 4px;
  }
  .mj-seat:is(.mj-seat-top,.mj-seat-bottom) .mj-exposed { width: 42px }
  .mj-corner { width: min(100%,72px); z-index: 2; align-self: stretch; align-content: start }
  .mj-corner:is(.mj-corner-bottom,.mj-corner-right) { align-content: end }
  .mj-corner-left .mj-dice { translate: 11px 8px }
  .mj-corner-top .mj-dice { translate: -11px 8px }
  .mj-corner-bottom .mj-dice { translate: 11px -8px }
  .mj-corner-right .mj-dice { translate: -11px -8px }
  .mj-dice { gap: 2px }
  .mj-die { --mj-die-size: clamp(12px,calc(var(--mj-safe-height) * .04),20px); padding: 2px }
  .mj-metrics { grid-area: info; container-type: inline-size; gap: 3px; margin: 0 0 4px }
  .mj-metrics div { padding: 5px 3px }
  .mj-metrics dt { font-size: clamp(.59rem,4.5cqi,.8rem) }
  .mj-metrics dd { font-size: clamp(.67rem,4.6cqi,.87rem) }
  .mj-wall-key { grid-area: key; margin: 4px 2px 0; font-size: .62rem; gap: 3px 6px }
  .mj-action-home { grid-area: controls }
  .mj-actions { margin-top: 3px; padding: 5px }
  .mj-actions[data-prompt-open] {
    position: static; inset: auto; translate: none; width: auto;
    margin-top: 3px; padding: 4px 6px; box-shadow: none; font-size: .8rem;
  }
  .mj-actions[data-prompt-open] .mj-table-note { margin: 0; min-height: 0; font-size: .75rem; line-height: 1.18 }
  .mj-actions[data-prompt-open] .mj-claim-timer { margin: 3px auto; gap: 1px; font-size: .68rem; line-height: 1.15 }
  .mj-actions[data-prompt-open] .mj-claim-meter { height: 5px }
  .mj-actions[data-prompt-open] .mj-controls { margin-top: 2px; gap: 4px }
  .mj-rack-panel {
    grid-area: rack; grid-template-columns: 1fr auto;
    grid-template-areas: "heading discard" "tiles tiles" "speech speech";
    container-type: inline-size; align-content: start; align-self: stretch;
    gap: 5px; margin: 0; padding: 4px 5px 6px; min-width: 0;
  }
  .mj-rack-heading { grid-area: heading; justify-self: start; padding-left: 4px; font-size: .85rem }
  .mj-rack-row { display: contents }
  .mj-rack { grid-area: tiles; --rack-gap: 4px; gap: var(--rack-gap); min-height: 0; padding-bottom: 3px }
  .mj-rack .mj-tile { --tile-size: clamp(16px,calc((100cqi - 30px) / 7),50px); min-height: 0 }
  .mj-rack-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
  .mj-discard-button { grid-area: discard; justify-self: end; min-height: 44px }
  .mj-discards { --discard-width: min(var(--discard-fit, 0px),25px) }
  .mj-play-area:has(.mj-actions[data-prompt-open]) .mj-wall-key { display: none }
  .mj-speech-home:not(:has(.mj-speech:not([hidden]))) { display: none }
  .mj-speech-home { margin-top: 8px; padding-inline: 6px }

}


@media (orientation: portrait) {
  @container (max-width: 610px) {
    .mj-corner-left .mj-dice { translate: 4px 2px }
    .mj-corner-top .mj-dice { translate: -4px 2px }
    .mj-corner-bottom .mj-dice { translate: 4px -2px }
    .mj-corner-right .mj-dice { translate: -4px -2px }
  }
}
