.mobile-table,
.mobile-latest,
.mobile-header-actions,
.mobile-hand-tools,
.mobile-round {
  display: none;
}
.player-dock {
  display: contents;
}
.mobile-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 800px), (max-width: 1024px) and (max-height: 600px) and (pointer: coarse) {
  .app-shell {
    padding: max(4px, env(safe-area-inset-top)) 6px 0;
    max-width: none;
  }
  .topbar {
    height: 60px;
    gap: 8px;
    border: 0;
    padding: 0 4px;
  }
  .brand {
    gap: 0;
    min-width: 0;
  }
  .brand-mark,
  .nav,
  .desktop-brand-subtitle {
    display: none;
  }
  .brand h1 {
    font-size: 18px;
    letter-spacing: 0;
    white-space: nowrap;
  }
  .brand small {
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
    margin-top: 3px;
  }
  .mobile-round {
    display: inline;
    color: #bcd0bf;
  }
  .mobile-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }
  .mobile-header-actions button {
    background: #183d2d;
    border: 1px solid #adc1a72b;
    border-radius: 6px;
    padding: 6px 9px;
    min-height: 44px;
    font-size: 14px;
  }
  .workspace {
    display: block;
    padding: 0;
    height: calc(100dvh - 64px - env(safe-area-inset-top));
  }
  .play-area {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .table-toolbar,
  .sidebar,
  .footer,
  .hand-controls,
  .desktop-advice,
  .play-area > .win-announcement {
    display: none;
  }
  .board {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    border-width: 3px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 0 1px #806d493d;
  }
  .board:before,
  .board > .seat,
  .board > .table-center {
    display: none;
  }
  .mobile-table {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
  }
  .mobile-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 8px;
    border-bottom: 1px solid #d8d1ad24;
    background: #123d2e;
    flex-shrink: 0;
  }
  .mobile-view-nav {
    display: flex;
    gap: 3px;
    min-width: 0;
  }
  .mobile-view-nav button {
    font-size: 14px;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 6px;
    background: transparent;
    color: #bed0bc;
  }
  .mobile-view-nav button[aria-pressed='true'] {
    background: #e4d0a1;
    color: #173f2c;
    font-weight: 700;
  }
  .mobile-wall-count {
    display: flex;
    gap: 5px;
    align-items: center;
    background: none;
    padding: 4px 0 4px 6px;
    min-height: 44px;
    flex-shrink: 0;
    color: #ddd9bc;
  }
  .mobile-wall-count strong {
    font-size: 21px;
    font-variant-numeric: tabular-nums;
  }
  .mobile-wall-count span {
    font-size: 12px;
    max-width: 30px;
    line-height: 1.15;
    text-align: left;
  }
  .mobile-public-scroll {
    overflow: auto;
    overscroll-behavior: contain;
    min-height: 0;
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: #6d9478 #153e2e;
  }
  .mobile-opponent,
  .mobile-river {
    flex-shrink: 0;
    border: 1px solid #a8b99335;
    background: #123b2dc9;
    border-radius: 8px;
    padding: 8px;
    min-width: 0;
  }
  .mobile-opponent.active {
    border-color: #e5c784;
    box-shadow: inset 3px 0 #e5c784;
  }
  .mobile-opponent.winner {
    border-color: #f0cc78;
    background: #62532688;
  }
  .mobile-player-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }
  .mobile-player-name {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    gap: 3px;
    text-align: left;
  }
  .mobile-player-name strong {
    font-size: 14px;
    font-weight: 650;
    overflow-wrap: anywhere;
    line-height: 1.2;
  }
  .mobile-player-name > span {
    font-size: 12px;
    color: #b5cbb7;
  }
  .mobile-opponent .seat-markers {
    gap: 3px;
  }
  .mobile-opponent .avatar,
  .player-dock .wind-token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid #b5ad8c;
    border-radius: 4px;
    background: #fff5df;
    color: #214331;
    font-family: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    font-size: 23px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 2px 0 #aa9068;
  }
  .mobile-opponent .avatar.dealer-marker,
  .player-dock .wind-token.dealer-marker {
    color: #b52331;
    border-color: #cf5157;
  }
  .player-dock .you-label .dealer-marker {
    display: inline-flex;
    position: static;
  }
  .player-dock .own-tiles > .rack-dealer {
    display: none;
  }
  .mobile-opponent .tai-badge,
  .player-dock .tai-badge {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 65px;
    min-height: 38px;
    height: auto;
    padding: 5px 3px;
    flex-shrink: 0;
    border-radius: 6px;
  }
  .mobile-opponent .tai-count,
  .player-dock .tai-count {
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
  }
  .mobile-opponent .tai-count b,
  .player-dock .tai-count b {
    font-size: 19px;
  }
  .mobile-opponent .tai-count > span,
  .player-dock .tai-count > span {
    display: block;
    font-size: 12px;
  }
  .mobile-opponent .tai-meter,
  .mobile-opponent .tai-caption,
  .player-dock .tai-meter,
  .player-dock .tai-caption {
    display: none;
  }
  .mobile-tile-track {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    padding: 6px 1px 5px;
    margin-top: 4px;
    min-width: 0;
  }
  .mobile-melds {
    display: flex;
    gap: 10px;
    align-items: center;
  }
  .mobile-melds .meld {
    gap: 2px;
  }
  .mobile-melds .tile.tiny,
  .mobile-opponent .winning-concealed .tile.tiny {
    --tile-w: 30px;
    --tile-h: 41px;
  }
  .mobile-bonuses .bonus-row {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 5px;
    margin: 0;
    width: max-content;
  }
  .mobile-bonuses .tile.tiny {
    --tile-w: 28px;
    --tile-h: 38px;
  }
  .mobile-bonuses .bonus-piece {
    padding: 0;
    min-height: 44px;
  }
  .mobile-bonuses .bonus-value {
    font-size: 12px;
  }
  .mobile-opponent .winning-concealed {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 3px;
  }
  .mobile-opponent .winning-tile {
    margin-left: 4px;
  }
  .mobile-river-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 7px;
    font-size: 14px;
  }
  .mobile-river-heading strong {
    overflow-wrap: anywhere;
  }
  .mobile-river-heading span {
    font-size: 12px;
    white-space: nowrap;
    color: #b4c7ad;
  }
  .mobile-river-tiles {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px 2px;
  }
  .mobile-river-tiles > button {
    display: grid;
    place-items: center;
    background: transparent;
    min-height: 44px;
    padding: 1px;
    border-radius: 4px;
    min-width: 0;
  }
  .mobile-river-tiles .tile.small {
    --tile-w: clamp(23px, 7.5vw, 32px);
    --tile-h: clamp(32px, 10vw, 43px);
    max-width: 100%;
  }
  .mobile-river-tiles > .is-latest {
    background: #e5c17d40;
    outline: 1px solid #eed293;
  }
  .mobile-river-tiles > p {
    grid-column: 1/-1;
    font-size: 14px;
    color: #a8bea7;
    padding: 4px;
  }
  .player-dock {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    background: #12382a;
    border-top: 1px solid #dcca9566;
    padding-bottom: max(3px, env(safe-area-inset-bottom));
    min-width: 0;
    max-height: 78%;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 3;
  }
  .mobile-latest {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1f513c;
    padding: 5px 10px;
    border-bottom: 1px solid #acbd9233;
    min-height: 54px;
    text-align: left;
    flex-shrink: 0;
    width: 100%;
    border-radius: 0;
  }
  .mobile-latest .tile.small {
    --tile-w: 32px;
    --tile-h: 43px;
  }
  .mobile-latest > span:not(.tile) {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }
  .mobile-latest strong {
    font-size: 15px;
    line-height: 1.2;
  }
  .mobile-latest small {
    font-size: 12px;
    color: #c8d5bd;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .mobile-no-discard {
    min-height: 44px;
  }
  .mobile-win {
    background: #665325;
    border-color: #e5c88b;
  }
  .mobile-hu {
    font-size: 32px;
    color: #ffdd8e;
    font-weight: 800;
  }
  .mobile-win strong {
    color: #ffe7b7;
  }
  .hand-zone {
    position: static;
    inset: auto;
    padding: 7px 8px 4px;
    margin: 0;
    z-index: auto;
    min-width: 0;
  }
  .hand-topline {
    margin: 0 0 12px;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: space-between;
    min-height: 32px;
  }
  .hand-topline .you-label {
    font-size: 14px;
    gap: 5px;
    max-width: 42%;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .hand-topline .seat-markers {
    gap: 3px;
  }
  .hand-topline .rack-front {
    display: flex;
    flex: 1;
    flex-direction: row;
    flex-wrap: nowrap;
    min-width: 0;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    max-width: none;
  }
  .hand-topline .bonus-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow: auto;
    min-width: 0;
    max-width: none;
    gap: 3px;
    margin: 0;
    padding: 2px 1px 4px;
    scrollbar-width: thin;
  }
  .hand-topline .bonus-row .tile.tiny {
    --tile-w: 23px;
    --tile-h: 32px;
  }
  .hand-topline .bonus-piece {
    min-height: 36px;
    padding: 0;
    flex-shrink: 0;
  }
  .hand-topline .bonus-value {
    font-size: 12px;
  }
  .hand-topline .tai-anchor {
    position: static;
    flex: 0 0 60px;
    width: 60px;
    height: auto;
  }
  .hand-topline .tai-badge {
    width: 60px;
    min-height: 34px;
    padding: 2px;
  }
  .own-tiles {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 48px));
    justify-content: center;
    align-items: start;
    gap: 7px 3px;
    min-height: 0;
    padding: 0 0 5px;
    --claim-rise: -5px;
    --claim-focus-rise: -7px;
  }
  .own-tiles > .tile {
    --tile-w: 100%;
    --tile-h: clamp(48px, 14.4vw, 64px);
    width: 100%;
    height: var(--tile-h);
    margin: 0;
    padding: 1px;
    min-width: 0;
    border-radius: 4px;
  }
  .own-tiles > .tile.drawn {
    margin: 0;
    box-shadow:
      0 3px 0 #a1a795,
      0 0 0 2px #ddc78d;
  }
  .own-tiles > .tile.selected {
    transform: translateY(-6px);
    box-shadow:
      0 3px 0 #a1a795,
      0 0 0 2px #ffe2a0;
  }
  .own-tiles > .tile.group-start {
    margin-left: 0;
  }
  .own-tiles > .tile.playable:hover {
    transform: translateY(-3px);
  }
  .own-tiles > .tile.selected:hover {
    transform: translateY(-6px);
  }
  .own-melds {
    grid-column: 1/-1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0;
    padding: 0 1px 5px;
    overflow-x: auto;
    min-width: 0;
    max-width: 100%;
    scrollbar-width: thin;
  }
  .own-melds .tile {
    --tile-w: 29px;
    --tile-h: 40px;
  }
  .own-melds .meld {
    flex-shrink: 0;
  }
  .own-tiles > .back {
    width: 100%;
    height: 43px;
  }
  .own-tiles > .winning-concealed {
    grid-column: 1/-1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    min-width: 0;
  }
  .own-tiles > .winning-concealed .tile {
    --tile-w: 39px;
    --tile-h: 53px;
  }
  .table-turn-bar {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 5px 8px 3px;
    gap: 5px;
    background: none;
    border: 0;
    flex-shrink: 0;
  }
  .table-turn-bar .turn-status {
    flex: none;
    text-align: center;
    max-width: 100%;
    min-width: 0;
  }
  .table-turn-bar .turn-status strong {
    font-size: 14px;
    line-height: 1.25;
  }
  .table-turn-bar .turn-status p {
    display: none;
  }
  .table-turn-bar .move-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: none;
    width: 100%;
    gap: 5px;
    flex-shrink: 0;
  }
  .table-turn-bar .primary,
  .table-turn-bar .call-button,
  .table-turn-bar .ghost {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }
  .table-turn-bar [data-command='discard'] {
    flex: 1;
    max-width: 220px;
  }
  .mobile-hand-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px;
    min-height: 40px;
  }
  .mobile-hand-tools button {
    background: transparent;
    min-height: 40px;
    padding: 6px 2px;
    color: #d8cda9;
    font-size: 14px;
  }
  .mobile-hand-tools > span {
    font-size: 12px;
    color: #a3bca6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-public-scroll .coach-panel {
    margin: 0;
    padding: 10px;
    flex-shrink: 0;
  }
  .mobile-public-scroll .coach-heading {
    gap: 8px;
    flex-wrap: wrap;
  }
  .mobile-public-scroll .coach-heading h2 {
    font-size: 18px;
  }
  .mobile-public-scroll .hint-strip {
    margin: 0;
    flex-shrink: 0;
    font-size: 14px;
  }
  .mobile-public-scroll .coach-comparison table {
    min-width: 400px;
  }
  .mobile-public-scroll .coach-panel p {
    font-size: 14px;
  }
  .board > .privacy,
  .board > .pause-tag {
    position: absolute;
    inset: 0;
    z-index: 10;
  }
  dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 24px);
    border-radius: 12px;
  }
  .dialog-head {
    padding: 16px;
  }
  .dialog-content {
    padding: 16px;
  }
  .dialog-actions {
    padding: 12px 16px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .dialog-actions button {
    min-height: 44px;
  }
  .mobile-menu-grid button {
    font-size: 14px;
    min-height: 48px;
  }
  .meld-inspection .tile {
    --tile-w: 64px;
    --tile-h: 86px;
  }
}

@media (max-width: 800px) and (max-height: 600px) and (orientation: landscape),
  (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) and (pointer: coarse) {
  .app-shell {
    padding-top: 0;
  }
  .topbar {
    height: 46px;
  }
  .brand small {
    display: none;
  }
  .workspace {
    height: calc(100dvh - 46px);
  }
  .board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 46%);
  }
  .mobile-table {
    min-width: 0;
    min-height: 0;
  }
  .player-dock {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    border-top: 0;
    border-left: 1px solid #dcc69455;
  }
  .mobile-latest {
    min-height: 45px;
    padding: 3px 8px;
  }
  .mobile-latest .tile.small {
    --tile-w: 27px;
    --tile-h: 36px;
  }
  .hand-zone {
    padding: 6px;
  }
  .hand-topline {
    margin-bottom: 9px;
  }
  .own-tiles {
    grid-template-columns: repeat(7, minmax(0, 44px));
    gap: 6px 3px;
  }
  .own-tiles > .tile {
    --tile-h: 50px;
  }
  .table-turn-bar {
    padding: 3px 6px;
  }
  .mobile-hand-tools {
    min-height: 34px;
  }
  .mobile-hand-tools button {
    min-height: 34px;
  }
}

@media (max-width: 360px) {
  .brand h1 {
    font-size: 16px;
  }
  .mobile-view-nav button {
    padding: 8px;
  }
  .mobile-player-heading {
    gap: 5px;
  }
  .mobile-hand-tools > span {
    display: none;
  }
}
