/* Mobile composition of the production board, not a second renderer. */
body.chokaigi-mobile #board > .board-stage {
  --tile-w: var(--mobile-hand-w);
  --tile-h: var(--mobile-hand-h);
  --tile-opponent-w: 18px;
  --tile-opponent-h: 25.2px;
  --tile-river-w: 20px;
  --tile-river-h: 28px;
  --tile-river-negative-h: -28px;
  --tile-river-rotated-w: 28px;
  --tile-river-riichi-grid-w: 128px;
  --river-grid-w: 120px;
  --river-grid-h: 84px;
  --river-box-h: 98px;
  --river-top-cell-w: var(--tile-river-w);
  --river-top-cell-h: var(--tile-river-h);
  --river-top-grid-w: var(--river-grid-w);
  --river-top-grid-h: var(--river-grid-h);
  --tile-dora-w: 16px;
  --tile-dora-h: 22.4px;
  --tile-meld-w: 16px;
  --tile-meld-h: 22.4px;
  --tile-meld-negative-h: -22.4px;
  --tile-small-face-inset-x: 1.5px;
  --tile-small-face-inset-y: 2.1px;
  --tile-opponent-face-inset-x: 1px;
  --tile-opponent-face-inset-y: 1.4px;
  --self-hand-height: var(--mobile-hand-h);
  --self-hud-height: 28px;
  --self-hud-gap: 34px;
  --self-hand-top: calc(100% - var(--mobile-hand-h) - 8px);
}
body.chokaigi-mobile #board > .board-stage .shoupai.main {
  left: 8px;
  top: auto;
  bottom: 8px;
  width: calc(100% - 16px);
  height: var(--mobile-hand-h);
}
body.chokaigi-mobile #board > .board-stage .shoupai.main .bingpai { left: 0; }
body.chokaigi-mobile #board > .board-stage .shoupai.main .bingpai .pai {
  --tile-face-inset-x: 2px;
  --tile-face-inset-y: 2.8px;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
body.chokaigi-mobile #board > .board-stage .shoupai.main .bingpai .zimo { margin-left: 8px; }
body.chokaigi-mobile #board > .board-stage .shoupai.main .fulou {
  bottom: calc(100% + 5px);
  max-width: 55%;
}
body.chokaigi-mobile #board > .board-stage .shoupai.main .chokaigi-nuki-board-area {
  top: auto !important;
  bottom: calc(100% + 5px) !important;
  left: 0 !important;
  right: auto !important;
  max-width: 43%;
  flex-wrap: wrap;
}
body.chokaigi-mobile #board > .board-stage > .player {
  width: min(145px, 43%);
  height: 38px;
  padding: 3px 6px;
  font-size: 14px;
  line-height: 17px;
}
body.chokaigi-mobile #board > .board-stage > .player.visual-seat-top { left: 8px; top: 8px; }
body.chokaigi-mobile #board > .board-stage > .player.visual-seat-right { left: auto; right: 8px; top: 8px; }
body.chokaigi-mobile #board > .board-stage > .player.visual-seat-self {
  left: 8px;
  top: auto;
  bottom: calc(var(--mobile-hand-h) + 40px);
  width: calc(100% - 84px);
  height: 24px;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}
body.chokaigi-mobile #board > .board-stage > .player.visual-seat-self .chokaigi-player-name { width: auto; max-width: 55%; }
body.chokaigi-mobile #board > .board-stage .shoupai.duimian.visual-seat-top {
  left: calc(50% - 117px); top: 54px; width: 240px;
}
body.chokaigi-mobile #board > .board-stage .shoupai.xiajia.visual-seat-right {
  left: calc(100% - 6px); top: 150px; width: 260px;
}
body.chokaigi-mobile #board > .board-stage .score {
  left: 8px; top: 106px; width: 138px; height: 132px; padding: 4px;
}
body.chokaigi-mobile #board > .board-stage .score .juchang { left: 4px; top: 3px; width: 128px; height: 24px; gap: 6px; }
body.chokaigi-mobile #board > .board-stage .score .juchang .jushu { font-size: 16px; line-height: 22px; }
body.chokaigi-mobile #board > .board-stage .score .juchang .jicun { font-size: 10px; line-height: 11px; }
body.chokaigi-mobile #board > .board-stage .score .jicun img.chouma { width: 26px; height: 4px; }
body.chokaigi-mobile #board > .board-stage .score .shan { left: 4px; top: 30px; width: 128px; height: 24px; }
body.chokaigi-mobile #board > .board-stage .score .shan .baopai { width: 84px; min-height: 22px; }
body.chokaigi-mobile #board > .board-stage .score .shan > div:last-child { width: 38px; font-size: 11px; line-height: 12px; }
body.chokaigi-mobile #board > .board-stage .score .defen { left: 4px; top: 58px; width: 128px; }
body.chokaigi-mobile #board > .board-stage .score .defen div { height: 23px; padding: 1px 4px; font-size: 14px; line-height: 20px; }
body.chokaigi-mobile #board > .board-stage .he.duimian.visual-seat-top { left: calc(50% - 4px); top: 116px; }
body.chokaigi-mobile #board > .board-stage .he.xiajia.visual-seat-right { left: calc(100% - 40px); top: max(44%, 230px); }
body.chokaigi-mobile #board > .board-stage .he.main.visual-seat-self {
  left: max(8px, calc(25% - 60px));
  top: min(61%, calc(100% - var(--mobile-hand-h) - 170px));
}
body.chokaigi-mobile #board > .board-stage .he div.lizhi img.chouma { width: 70px; height: 6px; }
body.chokaigi-mobile #board > .board-stage .chokaigi-nuki-img { width: 16px; height: 22.4px; }
body.chokaigi-mobile #board > .board-stage .shoupai.visual-seat-top .chokaigi-nuki-board-area,
body.chokaigi-mobile #board > .board-stage .shoupai.visual-seat-right .chokaigi-nuki-board-area { top: 29px !important; }
body.chokaigi-mobile #board > .board-stage > .player-button.chokaigi-action-layout {
  left: 8px !important; right: auto !important; top: auto !important;
  bottom: calc(var(--mobile-hand-h) + 76px) !important;
  width: calc(100% - 16px) !important; height: 48px !important;
  --naki-font: 16px; --naki-font-long: 13px;
  gap: 4px !important;
}
body.chokaigi-mobile #board > .board-stage > .player-button.chokaigi-action-layout.action-count-4 { height: 100px !important; }
body.chokaigi-mobile #board > .board-stage .timer { top: auto; bottom: calc(var(--mobile-hand-h) + 40px); left: auto; right: 10px; width: 60px; font-size: 16px; }
body.chokaigi-mobile #board > .board-stage .say { width: 120px; height: 44px; font-size: 26px; line-height: 44px; }
body.chokaigi-mobile #board > .board-stage .say.visual-seat-top { left: calc(50% - 60px); top: 86px; }
body.chokaigi-mobile #board > .board-stage .say.visual-seat-right { left: auto; right: 28px; top: 42%; }
body.chokaigi-mobile #board > .board-stage .say.visual-seat-self { left: 8px; top: auto; bottom: calc(var(--mobile-hand-h) + 70px); }
body.chokaigi-mobile #board > .board-stage > .player .open-riichi-reveal { min-height: 30px; }
body.chokaigi-mobile #board > .board-stage > .player .open-riichi-reveal .or-wait .pai { height: 30px; }

body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage {
  --tile-opponent-w: 10px; --tile-opponent-h: 14px;
  --tile-river-w: 16px; --tile-river-h: 22.4px;
  --tile-river-negative-h: -22.4px; --tile-river-rotated-w: 22.4px;
  --tile-river-riichi-grid-w: 102.4px;
  --river-grid-w: 96px; --river-grid-h: 67.2px; --river-box-h: 81.2px;
}
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage > .player { top: 4px; height: 30px; font-size: 12px; line-height: 14px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage > .player.visual-seat-self { top: auto; height: 22px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .shoupai.duimian.visual-seat-top { left: calc(50% - 65px); top: 8px; width: 140px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .shoupai.xiajia.visual-seat-right { top: 38px; width: 150px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score { top: 36px; height: 100px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score .juchang { top: 1px; height: 20px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score .jushu { font-size: 14px; line-height: 18px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score .shan { top: 21px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score .defen { top: 45px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .score .defen div { height: 17px; padding-top: 0; padding-bottom: 0; line-height: 16px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .he.duimian.visual-seat-top { left: 50%; top: 48px; }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .he.xiajia.visual-seat-right { top: 48px; left: calc(100% - 24px); }
body.chokaigi-mobile #board[data-layout="landscape"] > .board-stage .he.main.visual-seat-self { left: 28%; top: 48px; }
body.chokaigi-mobile #board > .board-stage > .player.main .open-riichi-reveal {
  left: auto; right: 0; top: auto; bottom: calc(100% + 4px); transform: none;
}
body.chokaigi-mobile #board > .board-stage > .player.duimian .open-riichi-reveal,
body.chokaigi-mobile #board > .board-stage > .player.xiajia .open-riichi-reveal {
  left: 0; top: calc(100% + 4px); bottom: auto; transform: none;
}
body.chokaigi-mobile #board > .board-stage > .player.xiajia .open-riichi-reveal { left: auto; right: 0; }
body.chokaigi-mobile #board > .board-stage .select-mianzi {
  left: 8px; top: auto; bottom: calc(var(--mobile-hand-h) + 76px); width: calc(100% - 16px);
}

@media (orientation: landscape) and (min-width: 560px) and (max-height: 600px) {
  /* All eight 44px targets fit in one row. Give the saved height to the table. */
  body.chokaigi-mobile #chokaigi-action-toggles.chokaigi-player-controls {
    --chokaigi-controls-height: 56px;
    height: 56px;
    min-height: 56px;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 3px;
  }
  body.chokaigi-mobile #chokaigi-action-toggles.chokaigi-player-controls #chokaigi-auto-nuki-controls {
    flex: 0 0 auto;
    width: auto;
    height: 44px;
    order: 1;
    margin: 0;
    gap: 3px;
  }
  body.chokaigi-mobile #chokaigi-action-toggles.chokaigi-player-controls > .chokaigi-toggle-btn { padding: 2px 6px; }
  body.chokaigi-mobile #chokaigi-action-toggles .chokaigi-auto-nuki-label { font-size: 12px; }
}

/* Selection is local; tapping the same tile again uses the normal controller. */
body.chokaigi-mobile #board .bingpai .touch-selected { outline: 2px solid #f0cb67; outline-offset: -2px; filter: brightness(1.12); }
