/* The container follows the selected orientation, including when the phone is held upright. */
#game-viewport { display: none; container: game / size; transform-origin: top left; }
#game-viewport.active { display: block; position: fixed; inset: 0 auto auto 0; overflow: hidden; z-index: 1; }
#game-viewport[data-rotation="clockwise"] { transform: rotate(90deg) translateY(-100%); }
#game-viewport[data-rotation="counterclockwise"] { transform: rotate(-90deg) translateX(-100%); }
#game-viewport #view-game.active { width: 100%; height: 100%; }
#view-game .topbar { flex-wrap: nowrap; }
#view-game .info-line { order: 0; width: auto; }
.orientation-settings { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.orientation-settings legend { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.orientation-options { display: flex; gap: 10px; }
.orientation-options label { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; padding: 12px; color: #d3e6da; border: 1px solid #679087; border-radius: 8px; cursor: pointer; }
.orientation-options label:has(input:checked) { background: #245f53; border-color: #e1c879; color: #fff0b6; }
.orientation-options input { accent-color: #dec879; margin: 0; }
.orientation-settings p { color: #a6c5b7; font-size: 11px; line-height: 1.6; margin: 8px 0 0; }

/* Reference-style full-bleed table. All dimensions track the available viewport. */
#view-game {
  --hand-w: min(6.55cqw, 10.8cqh, 116px);
  --river-w: clamp(19px, 2.65cqw, 44px);
  --river-h: calc(var(--river-w) * 1.38);
  --portrait: clamp(48px, 7cqw, 112px);
  position: relative; isolation: isolate; color: #e4f3e9;
  background: radial-gradient(ellipse at 50% 48%, #328c82 0%, #1c6a65 35%, #104342 65%, #052c31 100%);
}
#view-game::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .18; z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23ffffff' filter='url(%23n)' opacity='.3' d='M0 0h150v150H0z'/%3E%3C/svg%3E");
}
#view-game .topbar {
  position: absolute; top: 0; inset-inline: 0; height: 80px; padding: 18px 24px;
  background: transparent; border: 0; z-index: 8; gap: 18px;
}
#view-game .logo { color: #f3e4b5; font-family: 'Kaiti SC', STKaiti, serif; font-size: 32px; text-shadow: 0 2px 3px #002e30; }
#view-game .info-line { margin-right: auto; flex-direction: column; align-items: flex-start; gap: 5px; color: #a1c9c2; font-size: 11px; }
#view-game #g-wall { display: none; }
#view-game #g-turn { padding: 0; background: none; border: 0; color: #dfd7a5; font-weight: 400; font-size: 11px; }
.table-tool {
  display: grid; place-items: center; width: 52px; height: 52px; padding: 0;
  border: 1px solid #86ada7; border-radius: 50%; color: #fff0bc; cursor: pointer; font-size: 35px;
  background: radial-gradient(circle at 40% 0, #9bb6ad 0, #315951 35%, #103734 65%);
  box-shadow: inset 0 2px 2px #d0dfcc80, inset 0 -3px 5px #001d25, 0 3px 6px #00272780;
}
.table-tool:hover { filter: brightness(1.2); }
#btn-back-room { transform: rotate(180deg); }
#view-game .table-wrap { display: block; position: absolute; inset: 0; max-width: none; width: 100%; padding: 0; margin: 0; overflow: hidden; }
#view-game .table { position: absolute; inset: 0; min-height: 0; padding: 0; display: block; border-radius: 0; background: none; box-shadow: none; }
#view-game .table-mid { display: contents; }
#view-game .center-area { position: absolute; inset: 0; display: block; }
.table-seal {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); width: min(43cqw, 60cqh); aspect-ratio: 1;
  display: grid; place-items: center; border: 9px double #7bb68e; border-radius: 50%; opacity: .065;
  font: min(32cqw, 43cqh) 'Kaiti SC', STKaiti, serif; box-shadow: 0 0 0 15px #7bb68e33, inset 0 0 0 15px #7bb68e33;
}
.compass-wrap { position: absolute; left: 50%; top: 43%; transform: translate(-50%, -50%); text-align: center; }
.table-caption { font: 26px 'Kaiti SC', STKaiti, serif; color: #8dc7bc; text-shadow: 0 2px 3px #033d40; margin-bottom: 8px; letter-spacing: 5px; }
.wind-compass {
  position: relative; width: clamp(88px, 9cqw, 145px); aspect-ratio: 1; border: 3px solid #126361; border-radius: 28%;
  background: conic-gradient(from 45deg, #064e51 0deg 90deg, #126c6a 90deg 180deg, #064e51 180deg 270deg, #126c6a 270deg);
  box-shadow: 0 3px 4px #002f35, inset 0 0 0 2px #71bdb52b;
}
.compass-wind { position: absolute; display: grid; place-items: center; color: #d6ce8d; font: clamp(19px, 2.2cqw, 32px) 'Kaiti SC', STKaiti, serif; border-radius: 8px; }
.compass-0, .compass-2 { width: 44%; height: 24%; left: 28%; }
.compass-0 { bottom: 0; } .compass-2 { top: 0; }
.compass-1, .compass-3 { width: 24%; height: 44%; top: 28%; }
.compass-1 { right: 0; } .compass-3 { left: 0; }
.compass-wind.current { background: #40c9bd; color: #064442; box-shadow: 0 0 16px #54eee464; }
.compass-core { position: absolute; inset: 32%; display: grid; place-items: center; border: 2px solid #51b8b0; border-radius: 25%; color: #71b7a3; background: #104944; font-family: serif; }
/* 罗盘中心放百搭牌：金色描边，抬头就能看到本局百搭是哪张 */
.compass-core.has-wild {
  inset: 26%; padding: 2px; border-color: #f0d477; background: #0b3d3a; overflow: hidden;
  box-shadow: 0 0 14px #f5d77559, inset 0 0 0 2px #f5d7753d;
}
.compass-core.has-wild .tile { width: 100%; height: 100%; font-size: clamp(10px, 1.5cqw, 17px); }
.wind-compass.has-wild { box-shadow: 0 3px 4px #002f35, inset 0 0 0 2px #f5d77545; }
#view-game .wall-count { position: absolute; top: 55%; left: 50%; transform: translateX(-50%); color: #bedbcc; font-size: 16px; white-space: nowrap; letter-spacing: 2px; }
.wall-count strong { font-size: 24px; color: #e1d797; font-weight: 500; }
#view-game .seat-slot { position: absolute; padding: 0; background: none; border-radius: 0; transition: none; animation: none; box-shadow: none; }
#view-game .seat-slot.active { background: none; animation: none; }
#view-game .seat-top { inset: 0; pointer-events: none; }
#view-game .seat-left, #view-game .seat-right, #view-game .seat-bottom { inset: 0; pointer-events: none; }
#view-game .player-head { position: absolute; display: flex; gap: 10px; margin: 0; align-items: center; max-width: 27%; }
.seat-top .player-head { top: 14px; right: 19%; }
.seat-left .player-head { left: 18px; top: 25%; flex-direction: column; align-items: flex-start !important; }
.seat-right .player-head { right: 18px; top: 25%; flex-direction: column; align-items: flex-start !important; }
.seat-bottom .player-head { left: 18px; bottom: calc(var(--hand-w) * 1.48 + 25px); }
.player-avatar {
  position: relative; flex-shrink: 0; width: var(--portrait); height: var(--portrait); display: grid; place-items: center;
  border: 3px solid #a66b31; border-radius: 16%; background: radial-gradient(circle at 40% 25%, #b49376, #56423b 65%, #202e32);
  box-shadow: inset 0 0 0 2px #f1c26b55, 0 4px 10px #001b2866; overflow: hidden;
}
.player-avatar::before { content: ''; position: absolute; width: 75%; height: 75%; border: 1px solid #e8dabf40; transform: rotate(45deg); border-radius: 12%; }
.player-avatar > span { font: calc(var(--portrait) * .52) 'Kaiti SC', STKaiti, serif; color: #ffedd5; text-shadow: 0 3px 5px #241d1d80; }
.avatar-1 { background: radial-gradient(circle at 40% 20%, #c99555, #684930 65%, #352b27); }
.avatar-2 { background: radial-gradient(circle at 40% 20%, #bc7e98, #643951 65%, #352e42); }
.avatar-3 { background: radial-gradient(circle at 40% 20%, #86a8a2, #36585c 65%, #213a46); }
.dealer-mark { position: absolute; bottom: 0; right: 0; background: linear-gradient(#f9cc69, #ad5b15); color: #fff8dc; border-radius: 5px 0 0; padding: 2px 5px; font-size: 18px; }
.player-name { display: flex; align-items: center; gap: 8px; }
#view-game .player-head .pname { font-size: clamp(15px, 1.8cqw, 26px); font-weight: 400; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-game .player-head .wind { background: none; border: 1px solid #b7cba544; color: #d5ce96; padding: 1px 4px; }
#view-game .player-head .pscore { background: #002a2ea1; display: flex; align-items: center; gap: 8px; margin-top: 5px; border-radius: 20px; padding: 3px 15px 3px 3px; font-size: clamp(16px, 1.9cqw, 28px); min-width: 96px; }
.score-coin { display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid #ffe789; border-radius: 50%; background: linear-gradient(135deg, #ffdb57, #dc8309); color: #fff4b4; font-size: 14px; box-shadow: 0 1px 3px #0008; }
.player-kind { margin-top: 6px; color: #92bdb4; font-size: 11px; letter-spacing: 1px; }
#view-game .turn-badge { position: absolute; top: -9px; left: 8px; white-space: nowrap; animation: none; font-size: 10px; }
#view-game .turn-badge.youjin { top: auto; bottom: -20px; }
#view-game .player-head.active .player-avatar { border-color: #e5d382; box-shadow: 0 0 0 2px #e5d38244, 0 0 20px #e7c86b40; }
#view-game .seat-slot > .tile-row { position: absolute; flex-wrap: nowrap; gap: 2px; }
.seat-top > .tile-row { top: 15%; left: 50%; transform: translateX(-50%) rotate(180deg); }
.seat-left > .tile-row { left: 15%; top: 43%; transform: translate(-50%, -50%) rotate(90deg); }
.seat-right > .tile-row { right: 15%; top: 43%; transform: translate(50%, -50%) rotate(-90deg); }
#view-game .tile.back { width: clamp(15px, 2.45cqw, 42px); height: clamp(24px, 3.3cqw, 57px); border: 1px solid #52791f; border-top: 5px solid #9aba6c; background: linear-gradient(90deg, #446c09, #548810 25%, #4b7b09 80%, #386006); box-shadow: inset 0 0 0 2px #94ac352e, 0 4px 0 #254b19; }
#view-game .seat-left .tile.back, #view-game .seat-right .tile.back { height: clamp(17px, 2cqw, 34px); background: linear-gradient(#ebeee7, #c4cdc0); border-top: 4px solid #638a26; border-color: #b5c0a4; }
#view-game .melds { position: absolute; margin: 0; gap: 8px; }
.seat-top .melds { top: 15%; left: 22%; transform: rotate(180deg); }
.seat-left .melds { left: 20%; top: 24%; transform-origin: left top; transform: rotate(90deg); }
.seat-right .melds { right: 20%; top: 62%; transform-origin: right top; transform: rotate(-90deg); }
.seat-bottom .melds { bottom: calc(var(--hand-w) * 1.48 + 32px); right: 19%; }
#view-game .meld-group { background: none; }

/* ------------------------------------------------------------------ 牌河
   四家牌河全部正向摆放（不旋转），分布在桌面四个象限，读牌方向与玩家一致。 */
#view-game .discard-area { position: absolute; inset: 0; display: block; min-height: 0; pointer-events: none; }
.river {
  position: absolute; display: grid; grid-template-columns: repeat(6, var(--river-w));
  grid-auto-rows: var(--river-h); gap: 3px; max-height: calc(var(--river-h) * 3 + 14px);
  overflow-y: auto; pointer-events: auto; padding: 4px; scrollbar-width: thin;
  background: rgba(0, 38, 40, .30); border: 1px solid rgba(140, 200, 170, .14); border-radius: 10px;
}
.river-2 { top: 19%; left: 50%; transform: translateX(-50%); }
.river-0 { bottom: 24%; left: 50%; transform: translateX(-50%); }
.river-3 { left: 26%; top: 50%; transform: translate(-50%, -50%); }
.river-1 { left: 74%; top: 50%; transform: translate(-50%, -50%); }
#view-game .river .tile { width: var(--river-w); height: var(--river-h); font-size: calc(var(--river-w) * .48); }

/* Ivory faces, green resin bases and traditional engraved suit markings. */
.tile { padding: 3px; flex-shrink: 0; border: 1px solid #bcc1b1 !important; border-top: 1px solid #dce0d5 !important; border-radius: 5px; background: linear-gradient(145deg, #fffffc 0%, #f1f1eb 55%, #dddfd5 100%) !important; box-shadow: inset 0 2px 2px #fff, 0 3px 0 #a9b09e, 0 6px 0 #3f671e, 0 7px 4px #002d2b70; font-family: 'Kaiti SC', STKaiti, KaiTi, serif; }
.tile .num { font-weight: 700; color: #162c26 !important; line-height: 1.05; }
.tile.m .suit { color: #bb211b; font-size: 1.05em; margin: 0; line-height: 1.05; }
.tile.z5 .num { color: #b4221d !important; }
.tile.z6 .num { color: #257330 !important; }
.tile.z .num { font-size: 1.45em; }
.tile-art { width: 100%; height: 100%; display: block; }
.white-dragon { width: 65%; height: 72%; border: 3px double #376e9b; border-radius: 3px; }
#view-game .tile.back { background: linear-gradient(90deg, #446c09, #548810 25%, #4b7b09 80%, #386006) !important; }
#view-game .seat-left .tile.back, #view-game .seat-right .tile.back { background: linear-gradient(#ebeee7, #c4cdc0) !important; }
#view-game .tile.discard-new { outline: 2px solid #f5d375; transform: none; box-shadow: 0 3px 0 #81975d, 0 0 10px #f5d37580; }

#view-game .last-discard { position: absolute; left: 50%; top: 59%; transform: translateX(-50%); min-height: 0; z-index: 2; }
#view-game .ld-card { padding: 5px 10px; gap: 9px; border: 0; background: #043f3dc9; border-radius: 6px; box-shadow: none; }
#view-game .ld-card .tile { width: 25px; height: 34px; font-size: 16px; transform: none; }
#view-game .ld-who, #view-game .ld-what { font-size: 10px; }
#view-game .ld-empty { display: none; }
#view-game .hand-bar { position: absolute; bottom: 8px; inset-inline: 0; max-width: none; padding: 0 10px; margin: 0; display: block; border: 0; background: none; box-shadow: none; pointer-events: none; z-index: 5; }
#view-game .hand-main { padding: 0; min-width: 0; }
#view-game .my-hand { width: 100%; display: flex; flex-wrap: nowrap; align-items: flex-end; justify-content: center; gap: 3px; padding: 10px 0 0; min-height: 0; border: 0; border-radius: 0; background: none; animation: none; box-shadow: none; pointer-events: auto; }
#view-game .my-hand .tile { width: var(--hand-w); height: calc(var(--hand-w) * 1.43); font-size: calc(var(--hand-w) * .44); border-radius: 9% 9% 6% 6%; border-top: 7px solid #679735 !important; box-shadow: inset 0 3px 3px white, 0 3px 0 #b5bfab, 0 6px 0 #365a1a, 0 8px 8px #00252580; }
#view-game .my-hand .tile:hover { background: #fffdf0 !important; }
#view-game .tile.selected { outline-color: #f5d785; transform: translateY(-15px); box-shadow: 0 0 18px #dccc7370; }
#view-game .tile.drawn { transform: none; outline: none; }
#view-game .tile.drawn.selected { transform: translateY(-15px); outline: 3px solid #f5d785; }
#view-game .tile.wild-tile { outline: 2px solid #e6c968; }
#view-game .draw-split { width: clamp(8px, 2cqw, 35px); margin: 0; flex-shrink: 0; }
#view-game .draw-split span { display: none; }
#view-game .turn-tip { top: auto; bottom: calc(var(--hand-w) * 1.43 + 16px); left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: 65cqw; white-space: normal; border-radius: 24px; padding: 6px 16px; color: #b2d4ca; font-size: 12px; background: #043e3b8c; animation: none; box-shadow: none; }
#view-game .turn-tip.me { color: #ffedbc; background: #073c35e0; border: 1px solid #d1bc5c66; }
#view-game .turn-tip.me .dot { width: 6px; height: 6px; background: #efda8b; }
#view-game .action-bar { position: absolute; bottom: calc(var(--hand-w) * 1.43 + 66px); right: 24px; width: auto; max-width: 65%; justify-content: flex-end; pointer-events: auto; gap: 8px; }
#view-game .prompt-box { width: auto; justify-content: flex-end; gap: 8px; }
#view-game .prompt-box > .chip { display: none; }
#view-game .act-btn { border: 1px solid #ecd38f; background: linear-gradient(#ffedb8, #d6b569); color: #513b18; border-radius: 25px; box-shadow: 0 3px 0 #745b2c; min-height: 40px; }
#view-game .act-btn.hu, #view-game .act-btn.youjin { background: linear-gradient(#e9ae5c, #b94e25); color: #fff6dc; }
#view-game .host-btn, #view-game .act-btn.pass { background: #073b39c9; color: #c3dacf; border: 1px solid #7ca69c; border-radius: 24px; min-height: 38px; }
#view-game .countdown { color: #ffe3a0; border-color: #bca761; background: #063d37; white-space: nowrap; }
#view-game .host-banner { position: absolute; top: 88px; left: 50%; transform: translateX(-50%); bottom: auto; background: #583c18ed; color: #ffe1a7; width: max-content; max-width: 65cqw; font-size: 12px; z-index: 6; }
#view-game .side-panel { position: absolute; right: 18px; top: 82px; width: min(340px, calc(100cqw - 36px)); max-height: calc(100cqh - 110px); overflow: auto; z-index: 20; padding: 20px; background: #073c3bf5; color: #e4eee2; border-color: #679087; box-shadow: 0 16px 50px #001c2bb3; }
.settings-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.settings-heading h2 { font-size: 18px; margin: 0; }
#view-game .log-box { height: 220px; background: #062f2f; color: #c0d3c6; border-color: #35605a; margin-bottom: 20px; }
#view-game .log-box div { border-color: #28544b; padding: 5px 0; }
#view-game button:focus-visible { outline: 3px solid #f2d984; outline-offset: 4px; }

/* ------------------------------------------------- 横屏矮窗（手机横持 / 旋转化竖屏） */
@container game (max-height: 600px) and (min-aspect-ratio: 1/1) {
  #view-game { --portrait: 52px; --river-w: 18px; }
  #view-game .topbar { height: 56px; padding: 8px 16px; }
  .table-tool { width: 40px; height: 40px; font-size: 27px; }
  .seat-top .player-head { top: 8px; }
  .seat-left .player-head, .seat-right .player-head { top: 26%; }
  .table-caption { display: none; }
  .compass-wrap { top: 45%; }
  .wind-compass { width: 64px; }
  .compass-wind { font-size: 17px; }
  #view-game .wall-count { top: calc(45% + 40px); font-size: 11px; letter-spacing: 0; }
  .wall-count strong { font-size: 16px; }
  #view-game .last-discard { display: none; }
  .river { max-height: calc(var(--river-h) * 2 + 12px); }
  .river-2 { top: 92px; }
  .river-0 { top: calc(45% + 58px); bottom: auto; }
  .river-3 { left: 26%; top: 54%; }
  .river-1 { left: 74%; top: 54%; }
  .seat-left .player-head, .seat-right .player-head { max-width: 150px; }
  .seat-left .player-head .pname, .seat-right .player-head .pname { max-width: 82px; }
  .player-kind { display: none; }
  #view-game .melds .tile { width: 17px; height: 24px; font-size: 11px; }
  #view-game .turn-tip { bottom: calc(var(--hand-w) * 1.43 + 12px); font-size: 11px; padding: 5px 14px; }
  #view-game .action-bar { bottom: calc(var(--hand-w) * 1.43 + 52px); right: 12px; }
  #view-game .host-banner { top: 60px; }
}

/* ------------------------------------------------- 竖屏窄窗（手机竖持容器） */
@container game (max-width: 699px) and (max-aspect-ratio: 1/1) {
  #view-game { --hand-w: 6.35cqw; --river-w: 4cqw; --portrait: 46px; }
  #view-game .topbar { height: 66px; padding: 10px 12px; flex-wrap: nowrap; gap: 12px; }
  #view-game .logo { font-size: 24px; }
  #view-game .info-line { width: auto; order: 0; font-size: 10px; }
  #g-room { max-width: 135px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #view-game .user-box { gap: 6px; }
  .table-tool { width: 36px; height: 36px; font-size: 26px; }
  #view-game .player-head { gap: 5px; max-width: 34%; }
  .seat-top .player-head { top: 80px; right: 12%; }
  .seat-left .player-head { left: 8px; top: 26%; }
  .seat-right .player-head { right: 8px; top: 26%; }
  .seat-bottom .player-head { left: 10px; bottom: 19%; }
  #view-game .player-head .pname { font-size: 14px; max-width: 68px; }
  #view-game .player-head .pscore { font-size: 15px; min-width: 64px; padding: 2px 8px 2px 2px; }
  .score-coin { width: 19px; height: 19px; font-size: 10px; }
  .player-kind { font-size: 9px; letter-spacing: 0; }
  .player-name { gap: 3px; }
  .seat-top > .tile-row { top: 22%; }
  .seat-left > .tile-row { left: 10%; top: 50%; }
  .seat-right > .tile-row { right: 10%; top: 50%; }
  #view-game .tile.back { width: 4cqw; height: 6cqw; }
  #view-game .seat-left .tile.back, #view-game .seat-right .tile.back { width: 3.5cqw; height: 3cqw; }
  .table-caption { display: none; }
  .compass-wrap { top: 45%; }
  .wind-compass { width: 82px; }
  .compass-wind { font-size: 18px; }
  #view-game .wall-count { top: calc(45% + 50px); font-size: 12px; letter-spacing: 0; }
  .wall-count strong { font-size: 18px; }
  #view-game .last-discard { display: none; }
  .river { grid-template-columns: repeat(5, var(--river-w)); max-height: calc(var(--river-h) * 3 + 12px); }
  .river-2 { top: calc(45% - 120px); }
  .river-0 { top: calc(45% + 68px); bottom: auto; }
  .river-3 { left: 27%; top: 50%; }
  .river-1 { left: 73%; top: 50%; }
  .seat-left .melds, .seat-right .melds { transform: none; left: auto; right: auto; }
  .seat-left .melds { left: 8px; top: 40%; }
  .seat-right .melds { right: 8px; top: 40%; }
  #view-game .hand-bar { padding: 0 4px; bottom: max(12px, env(safe-area-inset-bottom)); }
  #view-game .my-hand { gap: 2px; }
  #view-game .my-hand .tile { border-top-width: 4px !important; padding: 1px; }
  #view-game .action-bar { right: 10px; bottom: calc(var(--hand-w) * 1.43 + 66px); max-width: 75%; flex-wrap: wrap; }
  #view-game .act-btn { padding: 8px 12px; font-size: 13px; }
  #view-game .turn-tip { bottom: calc(var(--hand-w) * 1.43 + 24px); max-width: 90cqw; font-size: 11px; }
  #view-game .host-banner { top: 74px; max-width: 90cqw; font-size: 10px; }
  #view-game .melds .tile { width: 17px; height: 24px; font-size: 11px; }
  .seat-top .melds { top: 17%; left: 43%; }
  .seat-left .melds { left: 17%; top: 40%; }
  .seat-right .melds { right: 17%; top: 60%; }
  .seat-bottom .melds { bottom: 17%; right: 12%; }
}
@media (prefers-reduced-motion: reduce) {
  #view-game *, #view-game *::before, #view-game *::after { animation: none !important; transition: none !important; }
}
#view-game .river:focus-visible { outline: 1px solid #c7d8a3; border-radius: 4px; }

/* Separate player information, decorative hands and the central playing area. */
#view-game { --portrait: clamp(44px, 5cqh, 68px); --opponent-w: clamp(9px, 1.5cqw, 25px); }
#view-game .player-head { z-index: 3; flex-wrap: nowrap; gap: 8px; max-width: none; }
#view-game .player-details { min-width: 0; }
#view-game .player-name { gap: 5px; }
#view-game .player-head .pname { font-size: clamp(13px, 1.25cqw, 19px); max-width: 110px; }
#view-game .player-head .wind { font-size: 10px; padding: 1px 3px; flex-shrink: 0; }
#view-game .player-head .pscore { margin: 5px 0 0; padding: 0; min-width: 0; background: none; border-radius: 0; gap: 7px; font-size: clamp(13px, 1.2cqw, 18px); line-height: 1.2; color: #eee3ba; }
.score-label { color: #98bcb0; font-size: 10px; }
.player-status { display: inline-block; margin-top: 3px; color: #dfcf97; font-size: 10px; }
#view-game .dealer-mark { font-size: 12px; padding: 1px 4px; }
#view-game .seat-top .player-head { top: 12px; left: 50%; right: auto; transform: translateX(-50%); }
#view-game .seat-bottom .player-head { left: 16px; bottom: calc(var(--hand-w) * 1.48 + 25px); }
#view-game .seat-left .player-head { left: 12px; top: 32%; width: 11%; flex-direction: column; align-items: center !important; }
#view-game .seat-right .player-head { right: 12px; top: 32%; width: 11%; flex-direction: column; align-items: center !important; }
#view-game .seat-left .player-head .pname, #view-game .seat-right .player-head .pname { max-width: 8cqw; }
#view-game .seat-slot > .tile-row { gap: 1px; }
#view-game .seat-top > .tile-row { top: 14%; left: 50%; transform: translateX(-50%) rotate(180deg); }
#view-game .seat-top .tile.back { width: var(--opponent-w); height: calc(var(--opponent-w) * 1.35); }
#view-game .seat-left > .tile-row { left: 16%; top: 46%; }
#view-game .seat-right > .tile-row { right: 16%; top: 46%; }
#view-game .seat-left .tile.back, #view-game .seat-right .tile.back { width: clamp(7px, 1.8cqh, 17px); height: clamp(12px, 1.3cqw, 22px); padding: 0; }
#view-game .seat-top .melds { top: 14%; left: 67%; }
#view-game .seat-left .melds { left: 20%; top: 32%; }
#view-game .seat-right .melds { right: 20%; top: 60%; }
#view-game .river { background: none; border-color: transparent; border-radius: 4px; }
#view-game .river-2 { top: 22%; max-height: calc(var(--river-h) * 2 + 14px); }
#view-game .compass-wrap { top: 45%; }
#view-game .table-caption { display: none; }
#view-game .wind-compass { width: clamp(96px, 11cqw, 142px); }
#view-game .compass-core.has-wild { inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 36%; height: 51%; padding: 0; border: 0; border-radius: 4px; overflow: visible; box-shadow: none; background: none; }
#view-game .compass-core.has-wild .tile { width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 3px; font-size: clamp(16px, 1.8cqw, 24px); border-radius: 4px; outline: 1px solid #e6c968; }
#view-game .compass-core.has-wild .tile::after { content: none; }
#view-game .compass-wind { font-size: clamp(16px, 1.8cqw, 26px); }
#view-game .wall-count { top: calc(45% + clamp(48px, 5.5cqw, 71px) + 10px); font-size: 12px; letter-spacing: 0; }
#view-game .wall-count strong { font-size: 18px; }
#view-game .last-discard { display: none; }
@container game (max-height: 600px) and (min-aspect-ratio: 1/1) {
  #view-game { --portrait: 42px; --opponent-w: 13px; }
  #view-game .seat-top .player-head { top: 8px; }
  #view-game .seat-top > .tile-row { top: 65px; }
  #view-game .seat-top .melds { top: 65px; }
  #view-game .river-2 { top: 96px; max-height: calc(var(--river-h) + 12px); }
  #view-game .wind-compass { width: 92px; }
  #view-game .compass-core.has-wild .tile { font-size: 16px; }
  #view-game .wall-count { top: calc(45% + 52px); font-size: 10px; }
  #view-game .wall-count strong { font-size: 14px; }
  #view-game .river-0 { top: calc(45% + 75px); max-height: calc(var(--river-h) + 12px); }
  #view-game .player-head .pname { font-size: 13px; }
  #view-game .player-head .pscore { font-size: 13px; }
  #view-game .seat-left .melds { left: 19%; top: 30%; }
  #view-game .seat-right .melds { right: 19%; top: 62%; }
  #view-game .action-bar { bottom: calc(var(--hand-w) * 1.43 + 43px); }
}
@container game (max-width: 699px) and (max-aspect-ratio: 1/1) {
  #view-game { --portrait: 40px; --opponent-w: 12px; }
  #view-game .seat-top .player-head { top: 76px; }
  #view-game .seat-top > .tile-row { top: 22%; }
  #view-game .seat-left .player-head, #view-game .seat-right .player-head { top: 28%; width: 70px; }
  #view-game .seat-left .player-head { left: 3px; }
  #view-game .seat-right .player-head { right: 3px; }
  #view-game .seat-left .player-head .pname, #view-game .seat-right .player-head .pname { max-width: 48px; }
  #view-game .seat-left > .tile-row { left: 8%; top: 53%; }
  #view-game .seat-right > .tile-row { right: 8%; top: 53%; }
  #view-game .seat-left .tile.back, #view-game .seat-right .tile.back { width: 10px; height: 12px; }
  #view-game .seat-bottom .player-head { bottom: 20%; left: 12px; }
  #view-game .seat-top .melds { top: 17%; left: 43%; }
  #view-game .wind-compass { width: 96px; }
  #view-game .wall-count { top: calc(45% + 58px); }
  #view-game .river-2 { top: calc(45% - 113px); max-height: calc(var(--river-h) * 2 + 12px); }
  #view-game .river-0 { top: calc(45% + 83px); }
}
/* The compass and hand prompt already identify the active player. */
#view-game #g-turn { display: none; }
#view-game #g-room { display: block; max-width: 20cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
