:root {
  color-scheme: light;
  --felt: #3f7f61;
  --felt-edge: #2d604d;
  --surface: #f8f3e5;
  --panel-bg: rgba(250, 247, 237, 0.92);
  --panel-border: rgba(24, 48, 38, 0.16);
  --line: #2c443c;
  --paper: #f6f1e4;
  --ink: #22282b;
  --suit-red: #c0392b;
  --suit-black: #22282b;
  --us: #d14b33;
  --them: #5c8a96;
  --gate: #d9a441;
  --warn: #d9a441;
  --danger: #b3402e;
  --ok: #5f8a5e;
  --room: #e6eee6;
  --room-text: #183026;
  --muted: #5f756a;
  --shadow: rgba(25, 45, 36, 0.22);
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --visual-safe-top: var(--safe-top);
  --visual-safe-right: var(--safe-right);
  --visual-safe-bottom: var(--safe-bottom);
  --visual-safe-left: var(--safe-left);
}

body[data-theme="classic"] {
  color-scheme: dark;
  --felt: #152420;
  --felt-edge: #0e1916;
  --surface: #1e312b;
  --panel-bg: rgba(14, 25, 22, 0.82);
  --panel-border: rgba(255, 255, 255, 0.12);
  --room: #101815;
  --room-text: #e8e4d6;
  --muted: #93a69b;
  --shadow: rgba(0, 0, 0, 0.34);
}

body[data-theme="night"] {
  color-scheme: dark;
  --felt: #182b35;
  --felt-edge: #0d171d;
  --surface: #1b2730;
  --panel-bg: rgba(13, 23, 29, 0.86);
  --panel-border: rgba(255, 255, 255, 0.11);
  --room: #0a1014;
  --room-text: #edf2ed;
  --muted: #9baeb3;
  --shadow: rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--room);
  color: var(--room-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--room-text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
}

select {
  min-height: 38px;
  border: 1px solid rgba(24, 48, 38, 0.18);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--room-text);
  background: rgba(255, 255, 255, 0.58);
}

h1,
h2,
p {
  margin: 0;
}

.room-shell {
  width: min(1600px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  align-items: start;
  gap: 16px;
  padding:
    max(16px, var(--safe-top))
    max(16px, var(--safe-right))
    max(16px, var(--safe-bottom))
    max(16px, var(--safe-left));
}

.table {
  position: relative;
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  contain: layout paint style;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.05), transparent 28%),
    linear-gradient(135deg, var(--felt), var(--felt-edge));
  box-shadow: 0 18px 46px var(--shadow);
}

body:not(.table-mode) .table {
  display: none;
}

.hud {
  position: absolute;
  inset: 14px 14px auto 14px;
  z-index: 2;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.ladder-panel,
.trump-panel,
.score-band,
.side-panel section {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
}

.ladder-panel {
  width: min(520px, 62vw);
  padding: 10px;
}

.panel-title,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.panel-title strong,
.section-head span {
  color: var(--room-text);
  font-weight: 700;
}

.level-ladder {
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.level-step {
  position: relative;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: rgba(232, 228, 214, 0.78);
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.level-step.gate {
  border-color: var(--gate);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.24);
}

.level-step.active {
  color: #fff;
  background: rgba(209, 75, 51, 0.28);
  transform: translate3d(0, -1px, 0);
}

.team-token {
  position: absolute;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--felt-edge);
  border-radius: 50%;
}

.team-token.ns {
  left: 7px;
  background: var(--us);
}

.team-token.ew {
  right: 7px;
  background: var(--them);
}

.trump-panel {
  min-width: 190px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-card,
.playing-card {
  border: 1px solid #d8cfbd;
  border-radius: 6px;
  display: inline-block;
  position: relative;
  color: var(--suit-black);
  background: var(--paper);
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-weight: 800;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.mini-card {
  width: 34px;
  height: 46px;
  font-size: 13px;
}

.trump-panel strong,
.trump-panel span {
  display: block;
}

.trump-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.score-band {
  position: absolute;
  top: 116px;
  left: 14px;
  z-index: 2;
  width: 300px;
  padding: 10px;
}

.score-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.score-copy span {
  color: var(--muted);
  font-size: 12px;
}

.score-copy strong {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
}

.band-track {
  position: relative;
  height: 30px;
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  border-top: 4px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 11px;
}

.band-track span:nth-child(5) {
  color: var(--gate);
}

.band-cursor {
  position: absolute;
  top: -8px;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--us);
  transition: left 240ms cubic-bezier(.2, .8, .2, 1);
}

.felt {
  position: absolute;
  inset: 160px 18px 112px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(30, 49, 43, 0.58);
}

.seat-chip {
  position: absolute;
  min-width: 116px;
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(14, 25, 22, 0.72);
}

.seat-chip.us {
  border-color: rgba(209, 75, 51, 0.7);
}

.seat-chip.disconnected {
  filter: grayscale(1);
  opacity: 0.62;
}

.seat-chip .avatar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--them);
  font-weight: 800;
}

.seat-chip.us .avatar {
  background: var(--us);
}

.seat-name {
  display: grid;
  gap: 2px;
}

.seat-name strong {
  font-size: 13px;
}

.seat-name span {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--felt-edge);
  background: var(--gate);
  font-size: 12px;
  font-weight: 800;
}

.seat-n {
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
}

.seat-w {
  top: 50%;
  left: -8px;
  transform: translateY(-50%);
}

.seat-e {
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
}

.seat-s {
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
}

.center-play {
  position: absolute;
  inset: 50px 150px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
}

.center-status {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.center-status span {
  color: var(--muted);
  font-size: 12px;
}

.center-status strong {
  font-size: 18px;
}

.last-trick {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 8px;
  width: min(420px, 100%);
}

.trick-cell {
  min-height: 66px;
  border-radius: 6px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.trick-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.trick-cell.winner {
  box-shadow: inset 0 0 0 1px var(--gate);
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.playing-card {
  width: 46px;
  height: 64px;
  padding: 0;
  vertical-align: bottom;
  overflow: hidden;
}

.mini-card.red,
.playing-card.red {
  color: var(--suit-red);
}

.mini-card.joker,
.playing-card.joker {
  color: var(--us);
}

.playing-card .rank {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.playing-card .suit {
  position: absolute;
  top: 18px;
  left: 5px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 11px;
  line-height: 1;
}

.playing-card .corner {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 19px;
  line-height: 1;
}

.playing-card .trump-stars {
  position: absolute;
  left: 5px;
  bottom: 5px;
  color: var(--gate);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.24);
}

.playing-card.true-trump {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(217, 164, 65, 0.5);
}

.playing-card.joker .rank {
  top: 5px;
  left: 6px;
  font-size: 10px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  writing-mode: vertical-rl;
}

.playing-card.back {
  border-color: rgba(217, 164, 65, 0.52);
  background:
    linear-gradient(135deg, rgba(217, 164, 65, 0.18) 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(315deg, rgba(217, 164, 65, 0.12) 25%, transparent 25%) 0 0 / 10px 10px,
    var(--surface);
  color: transparent;
}

.team-chat,
.action-bar,
.hand-fan {
  position: absolute;
  z-index: 2;
}

.team-chat {
  left: 14px;
  bottom: calc(max(14px, var(--visual-safe-bottom)) + 112px);
  display: grid;
  gap: 7px;
  z-index: 4;
}

.phrase-row,
.quick-chat-form,
.chat-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.phrase-row {
  flex-wrap: wrap;
}

.team-chat button {
  border-color: rgba(209, 75, 51, 0.38);
}

.team-chat span {
  color: var(--muted);
  font-size: 12px;
}

.quick-chat-form input,
.chat-form input {
  min-width: 0;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--room-text);
  background: rgba(255, 255, 255, 0.07);
  font-size: 16px;
  line-height: 1.2;
}

.quick-chat-form input {
  width: 172px;
}

button.recording {
  border-color: var(--danger);
  color: #fff;
  background: rgba(179, 64, 46, 0.48);
}

.action-bar {
  left: 50%;
  bottom: calc(max(14px, var(--visual-safe-bottom)) + 112px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
}

.selected-pattern {
  display: grid;
  gap: 2px;
  min-width: 140px;
  text-align: center;
}

.selected-pattern span {
  color: var(--muted);
  font-size: 11px;
}

.primary-action {
  min-width: 104px;
  border-color: transparent;
  background: var(--us);
  color: #fff;
  font-weight: 800;
}

.secondary-action {
  min-width: 92px;
  border-color: rgba(217, 164, 65, 0.42);
  color: #f4d08a;
  font-weight: 800;
}

.hand-fan {
  left: 14px;
  right: 14px;
  bottom: max(6px, var(--visual-safe-bottom));
  height: 112px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.hand-placeholder {
  position: absolute;
  left: 50%;
  top: 58px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.hand-gesture {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: pointer;
}

.hand-cards {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: min(660px, 96%);
  height: 90px;
  transform: translateX(-50%);
  will-change: transform;
}

.hand-card {
  position: absolute;
  bottom: 0;
  width: 58px;
  height: 82px;
  transform: translate3d(var(--x), var(--y, 0), 0);
  transition: transform 140ms cubic-bezier(.2, .8, .2, 1), opacity 140ms linear;
  pointer-events: none;
}

.hand-card.selected {
  --y: -14px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--us);
}

.hand-card.dimmed {
  opacity: 0.48;
}

.hand-card .rank {
  font-size: 16px;
}

.hand-card .suit {
  top: 21px;
  font-size: 12px;
}

.hand-card .corner {
  font-size: 22px;
}

.hand-card.joker .rank {
  font-size: 11px;
}

.hand-hit-band {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(660px, 96%);
  height: 100%;
  transform: translateX(-50%);
  border-radius: 8px;
}

.hand-hit-band.active {
  background: linear-gradient(90deg, transparent, rgba(209, 75, 51, 0.14), transparent);
}

.hand-preview {
  position: absolute;
  bottom: 92px;
  width: 72px;
  height: 102px;
  transform: translateX(-50%) scale(1.6);
  transform-origin: bottom center;
  pointer-events: none;
  z-index: 5;
}

.hand-preview .playing-card {
  width: 100%;
  height: 100%;
  font-size: 16px;
}

.table.syncing .action-bar,
.table.syncing .hand-fan {
  pointer-events: none;
  opacity: 0.62;
}

.side-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 12px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding-right: 2px;
}

.side-panel section {
  padding: 14px;
}

.join-card h1 {
  font-size: 24px;
  line-height: 1.15;
}

.join-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.invite-box {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.invite-box > span {
  color: var(--muted);
  font-size: 12px;
}

.invite-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.join-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.join-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.join-form input {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--room-text);
  background: rgba(255, 255, 255, 0.07);
}

.invite-row input {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(217, 164, 65, 0.34);
  border-radius: 6px;
  padding: 0 10px;
  color: #f4d08a;
  background: rgba(217, 164, 65, 0.08);
  font-size: 12px;
}

.seat-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.auto-seat-button {
  width: 100%;
  margin-top: 12px;
  border-color: transparent;
  background: var(--us);
  color: #fff;
  font-weight: 800;
}

.seat-buttons button.owned {
  border-color: var(--us);
  background: rgba(209, 75, 51, 0.22);
}

.seat-buttons button.selected {
  border-color: var(--gate);
  background: rgba(217, 164, 65, 0.22);
}

.seat-buttons button.occupied:not(.owned) {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.seat-manage-hint {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.partner-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.partner-actions button {
  min-height: 34px;
  font-size: 12px;
}

.partner-actions button.danger-action {
  border-color: rgba(179, 64, 46, 0.58);
  color: #ffd8d1;
  background: rgba(179, 64, 46, 0.22);
}

.chat-card {
  min-height: 260px;
}

.chat-log {
  height: 186px;
  margin-top: 12px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 2px;
}

.chat-message {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.chat-message.mine {
  background: rgba(209, 75, 51, 0.18);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.chat-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--room-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message p {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.chat-message audio {
  width: 100%;
  height: 34px;
}

.voice-meta {
  color: var(--muted);
  font-size: 12px;
}

.chat-form {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.summary-grid div {
  display: grid;
  gap: 4px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 11px;
}

.summary-grid strong {
  min-height: 18px;
  font-size: 13px;
}

@media (max-width: 1200px) {
  .room-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 940px) {
  .room-shell {
    grid-template-columns: 1fr;
  }

  .table {
    height: calc(100dvh - 32px);
    min-height: 520px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 940px) {
  body:not(.table-mode) {
    overflow: auto;
  }

  body:not(.table-mode) .room-shell {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100dvh;
    padding:
      max(12px, var(--safe-top))
      max(12px, var(--safe-right))
      calc(max(12px, var(--safe-bottom)) + 74px)
      max(12px, var(--safe-left));
    overflow: visible;
  }

  body:not(.table-mode) .table {
    display: none;
  }

  body:not(.table-mode) .side-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.table-mode {
    overflow: hidden;
  }

  body.table-mode .room-shell {
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    overflow: hidden;
  }

  body.table-mode .table {
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
  }

  body.table-mode .side-panel {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 940px),
  (orientation: portrait) and (max-width: 700px) {
  body:not(.table-mode) #auto-seat-button {
    position: fixed;
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    bottom: max(12px, var(--safe-bottom));
    z-index: 20;
    width: auto;
    height: 54px;
    margin: 0;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 940px),
  (orientation: portrait) and (max-width: 700px) {
  body.table-mode .hud {
    inset: 8px 8px auto 8px;
  }

  body.table-mode .ladder-panel {
    width: min(430px, 58vw);
    padding: 6px;
  }

  body.table-mode .panel-title,
  body.table-mode .trump-panel span,
  body.table-mode .score-copy span,
  body.table-mode .selected-pattern span {
    font-size: 10px;
  }

  body.table-mode .level-ladder {
    gap: 3px;
    margin-top: 5px;
  }

  body.table-mode .level-step {
    height: 28px;
    font-size: 11px;
  }

  body.table-mode .trump-panel {
    min-width: 142px;
    padding: 6px;
    gap: 7px;
  }

  body.table-mode .mini-card {
    width: 31px;
    height: 42px;
  }

  body.table-mode .score-band {
    top: 86px;
    left: 8px;
    width: 198px;
    padding: 0;
    border-color: transparent;
    background: transparent;
  }

  body.table-mode .score-copy strong {
    font-size: 28px;
  }

  body.table-mode .band-track {
    height: 24px;
    margin-top: 4px;
    font-size: 10px;
  }

  body.table-mode .felt {
    inset: 116px 8px 96px;
  }

  body.table-mode .seat-chip {
    min-width: 96px;
    min-height: 46px;
    padding: 6px 8px;
  }

  body.table-mode .seat-s {
    bottom: 10px;
  }

  body.table-mode .seat-name strong {
    font-size: 12px;
  }

  body.table-mode .seat-name span {
    font-size: 10px;
  }

  body.table-mode .avatar {
    width: 28px;
    height: 28px;
  }

  body.table-mode .center-play {
    inset: 30px 116px;
  }

  body.table-mode .center-status strong {
    font-size: 17px;
  }

  body.table-mode .team-chat {
    left: max(8px, var(--visual-safe-left));
    bottom: calc(max(8px, var(--visual-safe-bottom)) + 96px);
    gap: 6px;
  }

  body.table-mode .phrase-row,
  body.table-mode .quick-chat-form {
    gap: 6px;
  }

  body.table-mode .team-chat button {
    min-height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }

  body.table-mode .quick-chat-form input {
    width: 148px;
    height: 36px;
  }

  body.table-mode .team-chat span {
    display: none;
  }

  body.table-mode .action-bar {
    left: 50%;
    right: auto;
    bottom: calc(max(8px, var(--visual-safe-bottom)) + 96px);
    transform: translateX(-50%);
    gap: 8px;
  }

  body.table-mode .primary-action,
  body.table-mode .secondary-action {
    min-height: 38px;
    min-width: 88px;
    padding: 0 10px;
  }

  body.table-mode .hand-fan {
    left: max(8px, var(--visual-safe-left));
    right: max(8px, var(--visual-safe-right));
    height: 96px;
  }

  body.table-mode .hand-cards {
    bottom: 6px;
    height: 84px;
  }

  body.table-mode .hand-hit-band {
    height: 96px;
  }

  body.table-mode .hand-placeholder {
    top: 42px;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  :root {
    --visual-safe-top: var(--safe-right);
    --visual-safe-right: var(--safe-bottom);
    --visual-safe-bottom: var(--safe-left);
    --visual-safe-left: var(--safe-top);
  }

  body:not(.table-mode) {
    overflow: auto;
  }

  body:not(.table-mode) .room-shell {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    padding:
      max(12px, var(--safe-top))
      max(12px, var(--safe-right))
      calc(max(12px, var(--safe-bottom)) + 74px)
      max(12px, var(--safe-left));
    overflow: visible;
  }

  body:not(.table-mode) .table {
    display: none;
  }

  body:not(.table-mode) .side-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  body.table-mode {
    overflow: hidden;
  }

  body.table-mode .room-shell {
    display: block;
    width: 100dvw;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    overflow: hidden;
  }

  body.table-mode .side-panel {
    display: none;
  }

  body.table-mode .table {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100dvh;
    height: 100dvw;
    min-height: 0;
    border-radius: 0;
    transform: translate3d(-50%, -50%, 0) rotate(90deg);
    transform-origin: center center;
  }
}
