:root {
  color-scheme: dark;
  --bg: #101316;
  --surface: #181d22;
  --surface-2: #20262d;
  --line: #313943;
  --text: #f1f5f2;
  --muted: #9ca9a4;
  --accent: #e5b94e;
  --accent-2: #45b38b;
  --danger: #d95e57;
  --card-red: #e36161;
  --card-black: #1f252b;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(69, 179, 139, 0.16), transparent 28rem),
    linear-gradient(135deg, #101316 0%, #151819 48%, #11161a 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.is-hidden {
  display: none !important;
}

.topbar,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24, 29, 34, 0.86);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-2);
  color: #08110d;
  font-weight: 800;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #101418;
  outline: none;
}

.profile-pill input {
  width: 110px;
  border: 0;
  padding: 6px 10px;
  background: transparent;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 0.85fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(24, 29, 34, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.room-builder,
.rule-panel,
.game-picker {
  display: grid;
  align-content: start;
  gap: 18px;
}

.game-type-list {
  display: grid;
  gap: 10px;
}

.game-type-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #12171b;
  text-align: left;
}

.game-type-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(229, 185, 78, 0.25);
}

.game-type-card:disabled { opacity: .65; cursor: not-allowed; }

.room-audience { margin: 0; padding: 8px 20px; color: #ffe18a; background: #163e2f; font-size: 13px; }
.spectator-manager { border-top: 1px solid #ffffff25; margin-top: 16px; padding-top: 8px; }
.spectator-manager h3 { font-size: 14px; }
.spectator-member { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 10px 0; border-bottom: 1px solid #ffffff15; }
.spectator-member strong { flex-basis: 100%; overflow-wrap: anywhere; font-size: 13px; }
.spectator-member label { display: grid; gap: 5px; font-size: 12px; }
.spectator-member select, .builder-row select { padding: 8px; border: 1px solid #ffffff35; border-radius: 5px; color: inherit; background: #20282a; max-width: 100%; }
.spectator-member button, .seat-move-actions button { padding: 7px 8px; }
.seat-move-actions { flex-wrap: wrap; justify-content: flex-end; }
#roomControlStatus { color: #ffcd82; font-size: 12px; }

.game-type-card span {
  display: grid;
  gap: 4px;
}

.game-type-card small,
.game-type-card em,
.empty-room {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.game-type-card em {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

.builder-row {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101418;
}

.stepper button,
.icon-button {
  border: 0;
  color: var(--text);
  background: var(--surface-2);
}

.stepper button {
  height: 44px;
  font-size: 1.3rem;
}

.stepper strong {
  text-align: center;
}

.primary-action,
.ghost-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  color: #08110d;
  background: var(--accent);
  font-weight: 800;
}

.primary-action.compact {
  min-width: 120px;
  padding: 10px 14px;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.seat-manager {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(18, 23, 27, 0.88);
}

.seat-manager-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.seat-manager-head > div:first-child {
  display: grid;
  gap: 3px;
}

.seat-manager-head span,
.seat-manager-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.seat-manager-actions,
.seat-move-actions {
  display: flex;
  gap: 8px;
}

.seat-manager-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.seat-manager-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.seat-manager-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #08110d;
  background: var(--accent-2);
  font-weight: 900;
}

.seat-move-actions button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 900;
}

.seat-move-actions button[data-member-action] { width: auto; height: 32px; padding: 6px 9px; white-space: nowrap; font-size: 12px; }
.spectator-member button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--text); background: var(--surface-2); white-space: nowrap; font-size: 12px; }
@media (max-width: 520px) { .seat-manager-item .seat-move-actions { grid-column: 2 / -1; justify-content: flex-start; } }

.seat-manager button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.danger-action {
  border: 1px solid rgba(217, 94, 87, 0.52);
  border-radius: 8px;
  padding: 12px 18px;
  color: #fff8f7;
  background: rgba(217, 94, 87, 0.22);
  font-weight: 800;
}

.danger-action.compact {
  min-width: 112px;
  padding: 10px 14px;
}

.danger-action:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
}

.room-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.empty-room {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(18, 23, 27, 0.55);
}

.room-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #12171b;
}

.room-meta,
.seat-meta,
.round-stats,
.status-line,
.invite-box,
.score-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.room-card button {
  grid-row: span 2;
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  color: #07100d;
  background: var(--accent-2);
  font-weight: 800;
}

.room-layout {
  display: grid;
  gap: 16px;
}

.panel-title-row,
.hand-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-weight: 800;
}

.score-board {
  display: grid;
  gap: 10px;
}

.table-room {
  min-height: calc(100vh - 132px);
  grid-template-rows: auto minmax(520px, 1fr) auto;
}

.table-hud {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 12px;
  align-items: start;
}

.invite-strip {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(24, 29, 34, 0.86);
}

.invite-strip code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-hud .score-board {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.table-scene {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at center, rgba(229, 185, 78, 0.11), transparent 31rem),
    linear-gradient(135deg, rgba(24, 29, 34, 0.82), rgba(16, 20, 24, 0.94));
}

.table-seats {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.table-seat {
  position: absolute;
  z-index: 3;
  width: 238px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(18, 23, 27, 0.93);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.26);
}

.table-seat.is-active {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(229, 185, 78, 0.36),
    0 16px 34px rgba(0, 0, 0, 0.26);
}

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

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

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

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

.seat-face {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
}

.seat-face .avatar {
  width: 38px;
  height: 38px;
  background: #33404a;
  color: var(--text);
}

.table-seat.is-human .avatar {
  background: var(--accent-2);
  color: #08110d;
}

.ai-debug-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 76px;
  margin-top: 8px;
  overflow: auto;
}

.ai-debug-hand .mini-card {
  padding: 2px 4px;
  font-size: 0.68rem;
}

.card-back {
  width: 22px;
  height: 32px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    #b63b35;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.play-table {
  position: absolute;
  inset: 116px 246px;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 300px;
  border: 1px solid #405044;
  border-radius: 48px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #164231;
  background-size: 42px 42px;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.35);
}

.trick-area {
  display: grid;
  grid-template:
    ". top ." 104px
    "left . right" 104px
    ". bottom ." 104px / 90px 90px 90px;
  gap: 4px;
  place-items: center;
  min-height: 312px;
}

.played-slot {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.played-slot.top {
  grid-area: top;
}

.played-slot.right {
  grid-area: right;
}

.played-slot.bottom {
  grid-area: bottom;
}

.played-slot.left {
  grid-area: left;
}

.status-line {
  min-height: 24px;
  margin-top: 16px;
  color: #dce6dc;
  text-align: center;
}

.hand-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(24, 29, 34, 0.92);
}

.player-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 112px;
  margin-top: 12px;
  justify-content: center;
}

.card {
  position: relative;
  display: grid;
  width: 64px;
  height: 90px;
  align-content: space-between;
  border: 1px solid #d7dbe0;
  border-radius: 8px;
  padding: 8px;
  --ink: var(--card-black);
  color: var(--ink);
  background: #f8faf8;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

button.card {
  border: 1px solid #d7dbe0;
}

.card-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
  user-select: none;
}

.joker-index { position: absolute; z-index: 1; padding: 2px 1px; background: white; writing-mode: vertical-rl; font: 700 9px/1 Arial, sans-serif; border-radius: 2px; pointer-events: none; }
.joker-index.top { top: 3px; left: 3px; }
.joker-index.bottom { bottom: 3px; right: 3px; transform: rotate(180deg); }
.joker-large { color: #c62828; }
.joker-small { color: #181818; }

button.card:hover:not(:disabled) {
  transform: translateY(-8px);
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.28);
}

button.card:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.card.red {
  --ink: var(--card-red);
}

.card-rank {
  font-weight: 900;
}

.card-suit {
  justify-self: end;
  font-size: 1.6rem;
  line-height: 1;
}

.card-corner {
  position: absolute;
  display: grid;
  justify-items: center;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 0.9;
}

.card-corner small {
  font-size: 0.86rem;
  line-height: 1;
}

.card-corner.top {
  top: 6px;
  left: 6px;
}

.card-corner.bottom {
  right: 6px;
  bottom: 6px;
  transform: rotate(180deg);
}

.court-portrait {
  position: absolute;
  inset: 18px 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid currentColor;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 0 18%, currentColor 18% 21%, transparent 21% 79%, currentColor 79% 82%, transparent 82%),
    linear-gradient(180deg, rgba(229, 185, 78, 0.28), rgba(69, 179, 139, 0.18));
}

.court-portrait::before,
.court-portrait::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border: 1px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.2;
}

.court-portrait::before {
  top: -17px;
}

.court-portrait::after {
  bottom: -17px;
}

.court-band {
  position: absolute;
  top: 3px;
  font-size: 0.36rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.court-head {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #f8faf8;
  background: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow:
    0 -11px 0 -7px var(--ink),
    0 11px 0 -7px var(--ink);
}

.court-suit {
  position: absolute;
  bottom: 3px;
  font-size: 0.9rem;
  line-height: 1;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(18, 23, 27, 0.84);
}

.score-row strong:last-child {
  color: var(--accent);
}

.score-card-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
  padding-top: 4px;
}

.mini-card {
  border: 1px solid rgba(16, 20, 24, 0.18);
  border-radius: 4px;
  padding: 2px 5px;
  color: #101418;
  background: #f7faf8;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
}

.mini-card.red {
  color: var(--danger);
}

.empty-points {
  color: var(--muted);
  font-size: 0.76rem;
}

.taken-pile {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

#takenCards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#takenCards .mini-card {
  padding: 5px 7px;
  font-size: 0.82rem;
}

.xiangqi-room {
  display: none;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.xiangqi-room.is-active {
  display: grid;
}

.xiangqi-sidebar {
  display: grid;
  gap: 18px;
}

.xiangqi-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.xiangqi-players {
  display: grid;
  gap: 10px;
}

.xiangqi-player {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #12171b;
}

.red-side strong,
.captured-piece.red {
  color: var(--danger);
}

.black-side strong,
.captured-piece.black {
  color: #dbe3df;
}

.xiangqi-captured {
  display: grid;
  gap: 10px;
}

#xiangqiCaptured {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
}

.captured-piece {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #f3d8a9;
  font-weight: 900;
}

.xiangqi-board-wrap {
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #171b1d;
}

.xiangqi-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 54px);
  grid-template-rows: repeat(10, 54px);
  padding: 18px;
  border: 3px solid #111;
  background:
    repeating-linear-gradient(90deg, transparent 0 26px, #111 26px 27px, transparent 27px 54px),
    repeating-linear-gradient(180deg, transparent 0 26px, #111 26px 27px, transparent 27px 54px),
    #f8f8f3;
  background-position: 18px 18px;
  background-size: 54px 54px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.xiangqi-board::before {
  content: "楚河        汉界";
  position: absolute;
  top: calc(50% - 18px);
  left: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  height: 36px;
  border-top: 1px solid #111;
  border-bottom: 1px solid #111;
  color: #111;
  background: #f8f8f3;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.4em;
  pointer-events: none;
}

.xiangqi-board::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid #111;
  background:
    linear-gradient(45deg, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 162px 0 / 108px 108px no-repeat,
    linear-gradient(-45deg, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 162px 0 / 108px 108px no-repeat,
    linear-gradient(45deg, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 162px 378px / 108px 108px no-repeat,
    linear-gradient(-45deg, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)) 162px 378px / 108px 108px no-repeat;
  pointer-events: none;
}

.xiangqi-point {
  position: relative;
  z-index: 1;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #27160a;
  background: transparent;
}

.xiangqi-point::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.34);
}

.xiangqi-point span {
  position: absolute;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.36), transparent 28%),
    #fffdf2;
  font-size: 1.28rem;
  font-weight: 900;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
}

.xiangqi-point.red {
  color: #b4312f;
}

.xiangqi-point.black {
  color: #20262d;
}

.xiangqi-point.is-selected span {
  box-shadow:
    0 0 0 4px rgba(229, 185, 78, 0.42),
    0 5px 12px rgba(0, 0, 0, 0.24);
}

.xiangqi-point.is-last-move span {
  background: #def3e6;
  outline: 2px solid #008b68;
  outline-offset: 2px;
}

.xiangqi-point.is-legal::after {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent-2);
  background: rgba(69, 179, 139, 0.28);
}

.xiangqi-point.is-legal.has-piece span {
  box-shadow:
    0 0 0 4px rgba(69, 179, 139, 0.34),
    0 5px 12px rgba(0, 0, 0, 0.24);
}

.doudizhu-room {
  display: none;
  gap: 16px;
}

.doudizhu-room.is-active {
  display: grid;
}

.majiang-room {
  display: none;
  gap: 16px;
}

.majiang-room.is-active {
  display: grid;
}

.freeplay-room {
  display: none;
  gap: 16px;
}

#tractorRoom { display: grid; gap: 16px; }
.tractor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.tractor-toolbar label { display: flex; align-items: center; gap: 8px; }
.tractor-toolbar select { background: var(--surface-2); color: var(--text); padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.tractor-toolbar > span { color: var(--muted); font-size: .85rem; }
.tractor-scene { display: grid; grid-template-columns: minmax(170px,22%) minmax(0,1fr) minmax(170px,22%); grid-template-rows: auto minmax(360px,auto) auto; gap: 18px; padding: 20px; background: #101c21; border: 1px solid var(--line); }
.tractor-opponents { display: contents; }
.tractor-opponent { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #18262b; align-self: center; }
.tractor-opponent > strong, .tractor-opponent > span { display: block; overflow-wrap: anywhere; }
.tractor-opponent > span { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.tractor-seat-top { grid-column: 2; grid-row: 1; }
.tractor-seat-left { grid-column: 1; grid-row: 2; }
.tractor-seat-right { grid-column: 3; grid-row: 2; }
.tractor-seat-bottom { grid-column: 2; grid-row: 3; text-align: center; }
.tractor-seat-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tractor-open-hand { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tractor-mini { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 3px; border: 1px solid #d7dbe0; border-radius: 4px; color: #20252a; background: #fff; font-weight: 700; }
.tractor-mini.red { color: #c62828; }
.tractor-trump { outline: 2px solid #e5b94e; outline-offset: -2px; }
.tractor-table { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: minmax(0,1fr) 80px minmax(0,1fr); grid-template-areas: 'top top top' 'left score right' 'bottom bottom bottom'; gap: 18px; min-height: 360px; padding: 20px; background: #164231; border: 3px solid #405044; border-radius: 36px; box-shadow: inset 0 0 30px #0c2c20; }
.tractor-center-score { grid-area: score; align-self: center; display: grid; justify-items: center; gap: 6px; text-align: center; color: #e3efe6; }
.tractor-center-score span { font-size: .8rem; }
.tractor-center-score strong { font-size: 2rem; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.tractor-center-score small { font-size: .7rem; color: #bbd3c3; }
.tractor-play { display: grid; align-content: center; justify-items: center; gap: 8px; min-width: 0; text-align: center; font-size: .85rem; }
.tractor-play-top { grid-area: top; }
.tractor-play-left { grid-area: left; }
.tractor-play-right { grid-area: right; }
.tractor-play-bottom { grid-area: bottom; }
.tractor-play > div { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.tractor-play .card { width: 62px; height: 88px; }
.tractor-play small { color: #d7e9dc; }
.tractor-hand { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; }
.tractor-selected { transform: translateY(-8px); box-shadow: 0 0 0 3px #45b38b; }
.tractor-bid { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tractor-callable { box-shadow: 0 0 0 3px #45b38b; opacity: 1 !important; }
.tractor-last-draw { border: 3px solid #e5b94e; }
.tractor-previous-plays { display: grid; gap: 16px; }
.tractor-previous-play { min-width: 0; border-top: 1px solid var(--line); padding-top: 12px; }
.tractor-previous-play.is-winner > strong { color: var(--accent); }
.tractor-previous-cards { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tractor-previous-cards .card { flex-shrink: 0; width: 64px; height: 90px; }
@media (max-width: 720px) {
  .tractor-scene { grid-template-columns: minmax(70px,21%) minmax(0,1fr) minmax(70px,21%); gap: 8px; padding: 8px; }
  .tractor-seat-top { grid-column: 1 / -1; justify-self: center; width: min(100%,320px); }
  .tractor-seat-bottom { grid-column: 1 / -1; }
  .tractor-opponent { padding: 6px; font-size: .8rem; }
  .tractor-open-hand { gap: 3px; max-height: 360px; overflow-y: auto; }
  .tractor-mini { min-width: 28px; height: 30px; font-size: .7rem; }
  .tractor-table { grid-template-columns: minmax(0,1fr) 60px minmax(0,1fr); padding: 8px; gap: 6px; border-radius: 18px; }
  .tractor-play .card { width: 42px; height: 62px; padding: 4px; }
  .tractor-play .card-rank { font-size: .85rem; }
  .tractor-play .card-suit { font-size: 1.3rem; }
  .tractor-play small { font-size: .7rem; overflow-wrap: anywhere; }
  #tractorRoom .hand-toolbar { flex-wrap: wrap; }
}

.room-dialog {
  width: min(660px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  border: 1px solid #53615c;
  border-radius: 8px;
  padding: 24px;
  color: var(--text);
  background: #181f22;
  box-shadow: 0 24px 80px #0008;
}
.room-dialog::backdrop { background: #06130dcc; }
.room-dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.room-dialog > header button { width: 36px; height: 36px; padding: 0; font-size: 24px; background: transparent; color: white; border: 1px solid var(--line); border-radius: 6px; }
.room-name-field { display: grid; gap: 8px; margin-bottom: 24px; }
.room-dialog .seat-manager { margin: 0; padding: 16px 0; border: 0; background: transparent; }
.room-dialog .seat-manager-list { grid-template-columns: 1fr; }
.room-dialog h3 { margin-top: 24px; }
.tractor-active { background: #206c4b; }
.tractor-active .app-shell { width: 100%; max-width: none; padding: 0; }
.tractor-active #roomView { position: relative; display: flex; flex-direction: column; min-height: 100dvh; background: #206c4b; }
.tractor-active .game-header { flex-direction: row; align-items: center; height: 64px; margin: 0; padding: 8px 20px; gap: 12px; background: #154b36; }
.tractor-active .game-header h1 { font-size: 18px; line-height: 1.2; }
.tractor-active .game-header .eyebrow { font-size: 11px; margin: 0 0 3px; }
.tractor-active .game-header .room-actions { margin-left: auto; flex-wrap: nowrap; }
.tractor-active button.ghost-button { background: #ffffff0b; border-color: #ffffff30; color: #e2eee6; }
.tractor-active #tractorRoom { position: relative; display: flex; flex: 1; flex-direction: column; gap: 0; min-height: 0; }
.tractor-tools { display: flex; align-items: center; flex-shrink: 0; gap: 6px; }
.tractor-active .tractor-tools button { padding: 7px 10px; min-height: 34px; white-space: nowrap; font-size: 12px; border-radius: 4px; }
.tractor-active #tractorScoreHud { position: absolute; top: calc(50% + 45px); left: 50%; width: 100px; transform: translate(-50%, -50%); pointer-events: none; }
.tractor-center-info { display: grid; justify-items: center; gap: 4px; width: 100%; margin-top: 3px; padding-top: 8px; border-top: 1px solid #ffffff20; }
#tractorScoreHud .tractor-center-info strong { font-size: 13px; line-height: 1.3; color: #ffe18a; }
.tractor-active .tractor-center-info span { font-size: 11px; white-space: nowrap; color: #d2e4d8; }
.tractor-active .tractor-toolbar { padding: 10px 24px; gap: 16px; border: 0; background: #194f39; min-height: 48px; }
.tractor-active .tractor-toolbar > span { color: #d2e4d8; flex: 1; }
.tractor-active #tractorTrump { color: #ffe18a; white-space: nowrap; }
.tractor-active #tractorStatus { text-align: center; padding: 8px 20px; margin: 0; color: #d4e9db; font-size: 13px; min-height: 34px; }
.tractor-active .tractor-bid { justify-content: center; padding: 0 16px; }
.tractor-active .tractor-bid:not(:empty) { padding-block: 8px; }
.tractor-active .tractor-scene { position: relative; display: block; flex: 1; min-height: 390px; padding: 0; background: transparent; border: 0; }
.tractor-active .tractor-opponent { position: absolute; z-index: 2; width: 150px; padding: 8px; background: transparent; border: 0; text-align: center; }
.tractor-active .tractor-seat-top { top: 0; left: 50%; transform: translateX(-50%); }
.tractor-active .tractor-seat-left { top: 46%; left: 16px; transform: translateY(-50%); }
.tractor-active .tractor-seat-right { top: 46%; right: 16px; transform: translateY(-50%); }
.tractor-active .tractor-seat-bottom { display: none; }
.tractor-active .tractor-opponent > span { color: #cae0d1; font-size: 12px; }
.tractor-avatar { position: relative; width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 8px; border-radius: 50%; border: 2px solid #9bc8af; background: #1a3639; color: #e8eee9; font-size: 22px; font-weight: 700; }
.tractor-bid-badge { position: absolute; left: calc(100% - 5px); bottom: 0; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; padding: 3px 5px; border: 1px solid #e5b94e; border-radius: 4px; background: #fff9df; color: #20252a; font-size: 12px; line-height: 1.2; box-shadow: 0 2px 5px #0003; }
.tractor-bid-badge.red { color: #bd2929; }
.tractor-bid-badge small { font-size: 9px; }
.tractor-active .tractor-seat-active { box-shadow: none; }
.tractor-seat-active .tractor-avatar { border-color: #ffdc68; box-shadow: 0 0 0 4px #ffdc6830; }
.tractor-active .tractor-table { position: absolute; inset: 110px 172px 20px; min-height: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; grid-template-columns: minmax(0,1fr) 100px minmax(0,1fr); grid-template-rows: repeat(3,minmax(0,1fr)); gap: 10px; }
.tractor-active .tractor-play .card { width: 78px; height: 110px; flex-shrink: 0; }
.tractor-active .tractor-play > div { flex-wrap: nowrap; max-width: 100%; min-height: 118px; overflow-x: auto; padding: 4px; }
.tractor-active .tractor-center-score strong { font-size: 36px; }
.tractor-active .hand-panel { padding: 12px 24px 20px; background: transparent; border: 0; border-radius: 0; }
.tractor-active .hand-toolbar { justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.tractor-active #tractorPlay { min-width: 100px; background: #d54436; color: white; }
.tractor-active #tractorSelection { color: #cce4d4; font-size: 13px; }
.tractor-self-profile { display: flex; align-items: center; gap: 8px; padding: 4px; border: 1px solid transparent; border-radius: 6px; min-width: 0; }
.tractor-self-profile.is-active { border-color: #ffdc68; background: #ffdc681a; box-shadow: 0 0 0 2px #ffdc6830; }
.tractor-self-profile.is-active > span { color: #ffe18a; font-weight: 700; }
.tractor-self-profile input { width: 144px; min-width: 0; padding: 8px 10px; font-size: 14px; border: 1px solid #ffffff30; border-radius: 4px; background: #ffffff0b; color: white; }
.tractor-self-profile input:focus { outline: 2px solid #e5b94e; outline-offset: 1px; }
.tractor-self-profile > span { color: #cae0d1; font-size: 12px; white-space: nowrap; }
.tractor-active .tractor-hand { display: grid; grid-template-columns: repeat(var(--hand-count, 1), minmax(0, 1fr)); width: min(100%, calc(var(--hand-count, 1) * 44px + 42px)); max-width: 1050px; margin: auto; gap: 0; padding: 16px 42px 0 0; min-height: 128px; }
.tractor-active .tractor-hand:empty { min-height: 30px; }
.tractor-active .tractor-hand .card { width: 86px; height: 118px; padding: 6px; border-radius: 6px; }
.tractor-active .tractor-hand .card:disabled { opacity: 1; cursor: default; }
.tractor-active .tractor-hand .card:hover:not(:disabled), .tractor-active .tractor-selected { z-index: 3; transform: translateY(-12px); }
.tractor-active .tractor-hand .card-corner { font-size: 16px; }
.tractor-active .tractor-hand .card-rank { position: absolute; top: 6px; left: 6px; font-size: 20px; line-height: 1; }
.tractor-active .tractor-hand .card-suit { position: absolute; top: 32px; left: 6px; font-size: 20px; }
@media (max-width: 760px) {
  .tractor-active .game-header { height: auto; min-height: 60px; padding: 8px; flex-wrap: wrap; }
  .tractor-active .game-header h1 { font-size: 14px; }
  .tractor-active .game-header .room-actions { gap: 5px; }
  .tractor-active .game-header button { padding: 8px; font-size: 12px; }
  .tractor-active .tractor-toolbar { padding: 8px; gap: 8px; flex-wrap: wrap; font-size: 12px; }
  .tractor-active .tractor-toolbar > span { font-size: 11px; }
  .tractor-active .tractor-scene { min-height: 260px; }
  .tractor-active .tractor-opponent { width: 84px; padding: 4px; font-size: 12px; }
  .tractor-active .tractor-seat-left { left: 0; }
  .tractor-active .tractor-seat-right { right: 0; }
  .tractor-active .tractor-seat-bottom { left: 0; }
  .tractor-avatar { width: 36px; height: 36px; font-size: 16px; margin-bottom: 4px; }
  .tractor-bid-badge { left: calc(100% - 12px); bottom: -2px; font-size: 10px; padding: 2px 3px; }
  .tractor-active .tractor-opponent > span { font-size: 10px; }
  .tractor-active .tractor-table { inset: 84px 86px 8px; grid-template-columns: minmax(0,1fr) 46px minmax(0,1fr); gap: 4px; }
  .tractor-active .tractor-play .card { width: 44px; height: 64px; padding: 4px; }
  .tractor-active .tractor-play > div { min-height: 72px; }
  .tractor-active .tractor-center-score strong { font-size: 26px; }
  .tractor-active .tractor-center-score span, .tractor-active .tractor-center-score small { font-size: 10px; }
  .tractor-active #tractorScoreHud { width: 86px; gap: 4px; }
  .tractor-active .tractor-table { grid-template-columns: minmax(0,1fr) 100px minmax(0,1fr); grid-template-rows: repeat(3,minmax(0,1fr)); }
  .tractor-active .tractor-play-left > div, .tractor-active .tractor-play-right > div { flex-direction: column; max-height: 142px; }
  .tractor-active .hand-panel { padding: 8px 12px 16px; }
  .tractor-active .hand-toolbar { flex-wrap: wrap; }
  .tractor-active .tractor-tools { flex-basis: 100%; justify-content: center; }
  .tractor-self-profile input { width: 118px; }
  .tractor-self-profile { flex-direction: column; align-items: flex-start; gap: 3px; }
  .tractor-self-profile > span { font-size: 10px; }
  .tractor-active .tractor-hand { grid-template-columns: repeat(var(--compact-count, 1), minmax(0, 1fr)); width: min(100%, calc(var(--compact-count, 1) * 30px + 30px)); row-gap: 16px; padding-right: 30px; min-height: 104px; }
  .tractor-active .tractor-hand .card { width: 60px; height: 86px; }
  .tractor-active .tractor-hand .card-corner { font-size: 12px; }
  .tractor-active .tractor-hand .card-rank { font-size: 16px; }
  .tractor-active .tractor-hand .card-suit { top: 26px; font-size: 16px; }
  .room-dialog { padding: 16px; }
  .room-dialog .seat-manager-head { flex-wrap: wrap; }
}
@media (max-width: 440px) {
  .tractor-active .tractor-bid { gap: 5px; font-size: 11px; }
  .tractor-active .tractor-bid > span { width: 100%; text-align: center; }
  .tractor-active .tractor-bid button { padding: 8px; font-size: 12px; }
  .tractor-active .tractor-bid > strong { width: 100%; text-align: center; }
}

.tractor-bury-selection { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; max-width: 1050px; min-height: 46px; margin: 0 auto 8px; padding: 5px 0; border-bottom: 1px solid #ffffff26; }
.tractor-bury-selection .tractor-mini { cursor: pointer; min-width: 54px; font-size: 14px; }
.tractor-active #tractorRoom.is-burying .tractor-scene { min-height: 190px; }
.tractor-active #tractorRoom.is-burying .tractor-seat-bottom { display: none; }
.tractor-active #tractorRoom.is-burying .tractor-table { inset-block: 80px 0; }
.tractor-active #tractorRoom.is-burying .tractor-center-score { display: none; }
.tractor-bottom-reveal { grid-column: 1 / -1; grid-row: 1 / -1; align-self: center; display: grid; justify-items: center; gap: 16px; min-width: 0; text-align: center; }
.tractor-bottom-reveal h2 { font-size: 20px; margin: 0; }
.tractor-revealed-cards { display: grid; grid-template-columns: repeat(8, minmax(0, 78px)); gap: 8px; max-width: 100%; }
.tractor-active .tractor-revealed-cards .card { width: 100%; height: 110px; }
.tractor-bottom-reveal p { margin: 0; color: #d5e9dc; font-size: 14px; }
.tractor-bottom-reveal > strong { color: #ffdf7b; font-size: 22px; }
.tractor-active #tractorRoom.is-round-over .hand-panel { display: block; }
.tractor-active #tractorRoom.is-round-over #tractorHand,
.tractor-active #tractorRoom.is-round-over #tractorSelection,
.tractor-active #tractorRoom.is-round-over #tractorPlay { display: none; }
@media (max-width: 760px) {
  .tractor-revealed-cards { grid-template-columns: repeat(4, minmax(0, 60px)); gap: 6px; width: 100%; }
  .tractor-active .tractor-revealed-cards .card { height: 82px; padding: 5px; }
  .tractor-bottom-reveal h2 { font-size: 16px; }
  .tractor-bottom-reveal p { font-size: 12px; }
}
.tractor-active #tractorRoom.is-burying .tractor-hand { width: 100%; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; padding: 8px; max-height: min(430px, 52dvh); min-height: 0; overflow-y: auto; scrollbar-gutter: stable; align-content: start; }
.tractor-active #tractorRoom.is-burying .tractor-hand .card { width: 100%; height: 106px; margin: 0; transform: none; box-shadow: 0 2px 5px #0003; }
.tractor-active #tractorRoom.is-burying .tractor-hand .card:hover:not(:disabled) { transform: none; box-shadow: 0 0 0 2px #ffffff90; }
.tractor-active #tractorRoom.is-burying .tractor-hand .tractor-selected { border: 3px solid #f5ce64; box-shadow: 0 0 0 2px #f5ce6450; background: #fff5cf; }
.tractor-active #tractorRoom.is-burying .tractor-hand .tractor-selected::after { content: '✓'; position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: #176840; color: white; font-size: 13px; }
@media (max-width: 760px) {
  .tractor-active #tractorRoom.is-burying .tractor-hand { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 7px; max-height: 46dvh; }
  .tractor-active #tractorRoom.is-burying .tractor-hand .card { height: 86px; }
  .tractor-active #tractorRoom.is-burying .tractor-scene { min-height: 145px; }
  .tractor-active #tractorRoom.is-burying .tractor-seat-left, .tractor-active #tractorRoom.is-burying .tractor-seat-right { top: 42%; }
  .tractor-active #tractorRoom.is-burying .tractor-center-score { align-self: end; }
  .tractor-bury-selection { gap: 4px; }
  .tractor-bury-selection .tractor-mini { min-width: 45px; height: 30px; font-size: 12px; }
}

.freeplay-room.is-active {
  display: grid;
}

.mj-table {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(ellipse at center, rgba(241, 232, 198, 0.22), transparent 26rem),
    linear-gradient(135deg, #0f513f, #143a32);
  box-shadow: inset 0 0 76px rgba(0, 0, 0, 0.32);
}

.mj-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.mj-status {
  margin-top: 8px;
  color: #e2ece6;
  font-size: 0.9rem;
}

.mj-wall-count {
  display: grid;
  min-width: 92px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 10px;
  color: #e7efe9;
  background: rgba(0, 0, 0, 0.18);
}

.mj-wall-count span {
  color: rgba(231, 239, 233, 0.72);
  font-size: 0.76rem;
}

.mj-wall-count strong {
  color: var(--accent);
  font-size: 1.45rem;
  line-height: 1;
}

.mj-seat {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(18, 23, 27, 0.92);
}

.mj-seat.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(229, 185, 78, 0.36);
}

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

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

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

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

.mj-center {
  position: absolute;
  inset: 142px 262px 138px;
  display: grid;
  grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
  gap: 10px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(8, 16, 15, 0.2);
}

.mj-center-label {
  display: grid;
  grid-area: 2 / 2;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.16);
  font-weight: 900;
}

.mj-discard {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  min-width: 0;
  min-height: 64px;
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.mj-discard-top {
  grid-area: 1 / 2;
}

.mj-discard-left {
  grid-area: 2 / 1;
}

.mj-discard-right {
  grid-area: 2 / 3;
}

.mj-discard-bottom {
  grid-area: 3 / 2;
}

.mj-empty {
  color: rgba(231, 239, 233, 0.62);
  font-size: 0.78rem;
}

.mj-actions {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
}

.mj-player-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 78px;
}

.mj-tile {
  display: grid;
  grid-template-rows: 1fr;
  width: 46px;
  height: 64px;
  place-items: center;
  border: 1px solid #d4dcd2;
  border-radius: 7px;
  color: #101418;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(238, 244, 235, 0.96) 62%, rgba(212, 225, 205, 0.96)),
    #f8faf6;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset -4px -5px 0 rgba(83, 117, 89, 0.12),
    0 6px 0 #b7c6b3,
    0 8px 12px rgba(0, 0, 0, 0.18);
  font-weight: 900;
}

.mj-tile:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.mj-tile.wan,
.mj-tile.tong {
  color: var(--danger);
}

.mj-tile.tiao {
  color: #16744d;
}

.mj-tile.honor {
  color: #1c2420;
}

.mj-tile.is-small {
  width: 30px;
  height: 42px;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset -2px -3px 0 rgba(83, 117, 89, 0.12),
    0 3px 0 #b7c6b3;
}

.mj-rank {
  color: #c83f3a;
  font-size: 1.15rem;
  line-height: 1;
}

.mj-char {
  color: #26312b;
  font-size: 0.8rem;
  line-height: 1;
}

.mj-tile.wan {
  grid-template-rows: minmax(0, 1fr);
}

.mj-dots,
.mj-bamboos {
  display: grid;
  gap: 2px;
  width: 30px;
  justify-content: center;
}

.mj-dots {
  grid-template-columns: repeat(3, 9px);
  grid-auto-rows: 9px;
  align-content: center;
  justify-items: center;
}

.mj-dots i {
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, currentColor 0 18%, transparent 20% 38%, currentColor 40% 54%, transparent 56%),
    #fdfdfb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.mj-dots i.red {
  color: #c83f3a;
}

.mj-dots i.blue {
  color: #236a9c;
}

.mj-dots.count-1 {
  grid-template-columns: 1fr;
}

.mj-dots.count-2 {
  grid-template-columns: repeat(2, 9px);
}

.mj-dots.count-4,
.mj-dots.count-5 {
  grid-template-columns: repeat(2, 9px);
}

.mj-dots.count-7,
.mj-dots.count-8 {
  grid-template-columns: repeat(2, 9px);
}

.mj-bamboos {
  grid-template-columns: repeat(3, 5px);
}

.mj-bamboos i {
  width: 5px;
  height: 15px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, transparent 0 18%, #16744d 18% 30%, transparent 30% 42%, #16744d 42% 58%, transparent 58% 70%, #16744d 70% 82%, transparent 82%),
    #49a16f;
}

.mj-honor {
  color: #1b2420;
  font-size: 1.25rem;
  line-height: 1;
}

.mj-honor.red-dragon {
  color: #c83f3a;
}

.mj-honor.green-dragon {
  color: #168152;
}

.mj-honor.white-dragon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid #2f7dba;
  color: #2f7dba;
  font-size: 0.82rem;
}

.mj-tile.is-small .mj-rank,
.mj-tile.is-small .mj-honor {
  font-size: 0.86rem;
}

.mj-tile.is-small .mj-char {
  font-size: 0.58rem;
}

.mj-tile.is-small .mj-dots {
  grid-template-columns: repeat(3, 5px);
  grid-auto-rows: 5px;
  gap: 1px;
  width: 18px;
}

.mj-tile.is-small .mj-dots i {
  width: 5px;
  height: 5px;
}

.mj-tile.is-small .mj-dots.count-1 {
  grid-template-columns: 1fr;
}

.mj-tile.is-small .mj-dots.count-2,
.mj-tile.is-small .mj-dots.count-4,
.mj-tile.is-small .mj-dots.count-5,
.mj-tile.is-small .mj-dots.count-7,
.mj-tile.is-small .mj-dots.count-8 {
  grid-template-columns: repeat(2, 5px);
}

.mj-tile.is-small .mj-bamboos {
  grid-template-columns: repeat(3, 3px);
  gap: 1px;
  width: 14px;
}

.mj-tile.is-small .mj-bamboos i {
  width: 3px;
  height: 9px;
}

.ddz-table {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(ellipse at center, rgba(229, 185, 78, 0.16), transparent 28rem),
    #143c2d;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.34);
}

.ddz-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.ddz-status {
  margin-top: 8px;
  color: #dce6dc;
  font-size: 0.9rem;
}

.ddz-bottom-cards {
  display: flex;
  gap: 8px;
  min-width: 160px;
  justify-content: flex-end;
}

.ddz-bottom-card {
  display: grid;
  width: 44px;
  height: 62px;
  place-items: center;
  border: 1px solid #d7dbe0;
  border-radius: 7px;
  color: var(--card-black);
  background: #f8faf8;
  font-size: 0.78rem;
  font-weight: 900;
}

.ddz-bottom-card.is-back {
  border-color: rgba(255, 255, 255, 0.24);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    #b63b35;
}

.ddz-seat {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(18, 23, 27, 0.9);
}

.ddz-seat.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(229, 185, 78, 0.34);
}

.ddz-seat strong,
.ddz-seat span {
  display: block;
}

.ddz-seat span {
  color: var(--muted);
  font-size: 0.86rem;
}

.ddz-card-count {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.ddz-card-count strong {
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
}

.ddz-card-count span {
  font-size: 0.74rem;
}

.ddz-seat-left {
  top: 44%;
  left: 24px;
  transform: translateY(-50%);
}

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

.ddz-seat-bottom {
  right: 24px;
  bottom: 24px;
}

.ddz-seat-right {
  top: 44%;
  right: 24px;
  transform: translateY(-50%);
}

.freeplay-table {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(ellipse at center, rgba(69, 179, 139, 0.16), transparent 29rem),
    linear-gradient(135deg, rgba(20, 60, 45, 0.96), rgba(19, 33, 38, 0.96));
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.34);
}

.freeplay-topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.freeplay-status {
  margin-top: 8px;
  color: #dce6dc;
  font-size: 0.9rem;
}

.freeplay-config {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.freeplay-config label {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.16);
  font-size: 0.86rem;
}

.freeplay-config input[type="number"] {
  width: 56px;
  padding: 6px 8px;
}

.freeplay-center {
  position: absolute;
  inset: 142px 248px 128px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.14);
}

.freeplay-stock {
  display: inline-grid;
  justify-self: center;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #f7f2df;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent),
    #b63b35;
}

.freeplay-stock strong {
  color: #fff;
  font-size: 1.8rem;
}

.freeplay-revealed {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
}

.freeplay-reveal-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  color: #dce6dc;
}

.freeplay-reveal-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.freeplay-actions {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.freeplay-hand-panel {
  min-height: 150px;
}

.ddz-play-area {
  position: absolute;
  inset: 160px 230px 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.12);
}

.ddz-round-play,
.ddz-round-empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: #dce6dc;
}

.ddz-round-play div {
  display: flex;
  gap: 14px;
  min-height: 108px;
}

.ddz-round-play.is-pass {
  align-self: end;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.14);
}

.ddz-round-play.is-pass div {
  display: none;
  min-height: 0;
}

.table-play-card {
  position: relative;
  display: grid;
  width: 76px;
  height: 108px;
  align-content: space-between;
  place-items: center;
  border: 1px solid #d7dbe0;
  border-radius: 9px;
  padding: 10px;
  --ink: var(--card-black);
  color: var(--ink);
  background: #f8faf8;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.28);
}

.table-play-card.red {
  --ink: var(--card-red);
}

.table-play-card .card-rank {
  font-size: 1.05rem;
}

.table-play-card .card-suit {
  font-size: 2rem;
}

.table-play-card .court-portrait {
  inset: 22px 15px;
}

.ddz-actions {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.ghost-button.compact {
  min-width: 86px;
  padding: 10px 14px;
}

.ddz-hand-panel {
  min-height: 150px;
}

.ddz-card.is-selected {
  transform: translateY(-12px);
  box-shadow:
    0 0 0 3px rgba(229, 185, 78, 0.34),
    0 16px 24px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1320px) {
  .play-table {
    inset: 116px 220px;
  }
}

@media (max-width: 1100px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .xiangqi-room {
    grid-template-columns: 1fr;
  }

  .ddz-play-area {
    inset: 180px 190px 140px;
  }

  .freeplay-center {
    inset: 166px 210px 128px;
  }

  .table-hud,
  .table-hud .score-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .seat-manager-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-seat {
    width: 178px;
  }

  .play-table {
    inset: 112px 192px;
    border-radius: 34px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-hud,
  .table-hud .score-board {
    grid-template-columns: 1fr;
  }

  .seat-manager-head {
    align-items: stretch;
    flex-direction: column;
  }

  .seat-manager-list {
    grid-template-columns: 1fr;
  }

  .table-scene {
    min-height: 640px;
  }

  .table-seat {
    width: 152px;
    padding: 8px;
  }

  .seat-top {
    top: 10px;
  }

  .seat-right {
    right: 8px;
  }

  .seat-left {
    left: 8px;
  }

  .seat-bottom {
    bottom: 10px;
  }

  .seat-face {
    grid-template-columns: 32px 1fr;
  }

  .seat-face .avatar {
    width: 32px;
    height: 32px;
  }

  .play-table {
    inset: 122px 28px 120px;
    border-radius: 24px;
  }

  .ddz-table {
    min-height: 620px;
  }

  .ddz-seat {
    min-width: 150px;
  }

  .ddz-seat-left {
    left: 8px;
  }

  .ddz-seat-bottom {
    right: 8px;
  }

  .ddz-seat-right {
    right: 8px;
  }

  .ddz-play-area {
    inset: 210px 18px 150px;
  }

  .freeplay-table {
    min-height: 700px;
  }

  .freeplay-topbar {
    flex-direction: column;
  }

  .freeplay-center {
    inset: 236px 18px 150px;
  }

  .trick-area {
    grid-template:
      ". top ." 92px
      "left . right" 92px
      ". bottom ." 92px / 74px 74px 74px;
    min-height: 276px;
  }

  .card {
    width: 58px;
    height: 82px;
  }

  .xiangqi-board {
    grid-template-columns: repeat(9, 42px);
    grid-template-rows: repeat(10, 42px);
  }

  .xiangqi-point {
    width: 42px;
    height: 42px;
  }

  .xiangqi-point span {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
}

/* Keep all four plays around a reserved central score area. */
.gongzhu-active { background: #206c4b; }
.gongzhu-active .app-shell { width: 100%; max-width: none; padding: 0; }
.gongzhu-active #roomView { display: flex; flex-direction: column; min-height: 100dvh; background: #206c4b; }
.gongzhu-active .game-header { flex-direction: row; align-items: center; min-height: 64px; margin: 0; padding: 8px 20px; gap: 12px; background: #154b36; }
.gongzhu-active .game-header h1 { font-size: 18px; line-height: 1.2; }
.gongzhu-active .game-header .eyebrow { font-size: 11px; margin: 0 0 3px; }
.gongzhu-active .room-actions { margin-left: auto; }
.gongzhu-active button.ghost-button { background: #ffffff0b; border-color: #ffffff30; color: #e2eee6; }
.gongzhu-active .table-room { display: flex; flex: 1; flex-direction: column; min-height: 0; gap: 0; }
.gongzhu-active .status-line { min-height: 34px; padding: 8px 20px; margin: 0; font-size: 13px; color: #d4e9db; }
.gongzhu-active .table-scene { flex: 1; min-height: 550px; border: 0; border-radius: 0; background: transparent; }
.gongzhu-active .table-seat { width: 150px; padding: 8px; border: 0; background: transparent; box-shadow: none; text-align: center; }
.gongzhu-active .seat-top { top: 0; }
.gongzhu-active .seat-left { left: 16px; top: 46%; }
.gongzhu-active .seat-right { right: 16px; top: 46%; }
.gongzhu-active .seat-bottom { display: none; }
.gongzhu-active .seat-face { display: flex; flex-direction: column; gap: 6px; }
.gongzhu-active .seat-top .seat-face { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 8px; text-align: left; }
.gongzhu-active .seat-face .avatar { width: 52px; height: 52px; border: 2px solid #ffffff50; background: #173e30; color: #eef5f0; font-size: 22px; }
.gongzhu-active .table-seat.is-active .avatar { border: 3px solid #ffdc68; box-shadow: 0 0 0 5px #ffdc6840; }
.gongzhu-active .seat-face strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.gongzhu-active .seat-meta { color: #d2e4d8; font-size: 11px; }
.gongzhu-seat-points { display: flex; justify-content: center; flex-wrap: wrap; gap: 3px; margin-top: 6px; max-height: 32px; overflow-y: auto; }
.gongzhu-seat-points .mini-card { padding: 2px 3px; font-size: 10px; }
.gongzhu-active .empty-points { color: #bed7c7; font-size: 11px; }
.gongzhu-active .play-table { display: block; top: 150px; bottom: 12px; left: 50%; right: auto; transform: translateX(-50%); width: calc(100% - 352px); max-width: 860px; min-height: 0; border: 4px solid #739681; border-radius: 42px; background: #185c40; box-shadow: inset 0 0 0 3px #102f25, 0 8px 24px #0002; }
.gongzhu-active .trick-area { position: absolute; inset: 12px; min-height: 0; grid-template: '. top .' minmax(0,1fr) 'left . right' 120px '. bottom .' minmax(0,1fr) / minmax(0,1fr) 128px minmax(0,1fr); gap: 6px; }
.gongzhu-active .played-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; width: 100%; }
.gongzhu-active .played-slot .seat-meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gongzhu-active .played-slot.is-turn .seat-meta { color: #ffe18a; }
.gongzhu-active .played-slot .card { width: 68px; height: 96px; flex-shrink: 0; }
.gongzhu-empty-play { width: 68px; height: 96px; }
.gongzhu-center-score { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 164px; pointer-events: none; }
.gongzhu-center-score > span { display: block; text-align: center; color: #bed7c7; font-size: 11px; margin-bottom: 4px; }
.gongzhu-active .score-board { gap: 2px; }
.gongzhu-score-heading, .gongzhu-active .score-row { display: grid; grid-template-columns: minmax(0,1fr) 40px 40px; gap: 4px; padding: 2px 4px; }
.gongzhu-score-heading { color: #bed7c7; font-size: 10px; margin-bottom: 3px; }
.gongzhu-score-heading span:not(:first-child), .gongzhu-active .score-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.gongzhu-active .score-row { border: 0; border-radius: 0; background: transparent; font-size: 11px; }
.gongzhu-active .score-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gongzhu-active .score-row strong { color: #ffe18a; font-size: 13px; }
.gongzhu-active .score-row .gongzhu-total-score { color: #e6f2e9; }
.gongzhu-active .hand-panel { padding: 12px 24px 20px; border: 0; border-radius: 0; background: transparent; }
.gongzhu-active .hand-toolbar { justify-content: center; flex-wrap: wrap; gap: 20px; }
.gongzhu-active .tractor-self-profile.is-turn { border-color: #ffdc68; background: #ffdc6812; }
.gongzhu-active .tractor-self-profile.is-turn .round-stats { color: #ffe18a; }
.gongzhu-active .taken-pile { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; max-width: 440px; }
.gongzhu-active .taken-pile h3 { margin: 0; color: #cce4d4; font-size: 12px; }
.gongzhu-active #takenCards { display: flex; flex-wrap: wrap; gap: 3px; }
.gongzhu-active #takenCards .mini-card { padding: 3px 5px; font-size: 11px; }
.gongzhu-active .player-hand { display: grid; grid-template-columns: repeat(var(--hand-count,1),minmax(0,1fr)); width: min(100%,calc(var(--hand-count,1) * 44px + 42px)); margin: 12px auto 0; gap: 0; padding: 16px 42px 0 0; min-height: 134px; }
.gongzhu-active .player-hand .card { width: 86px; height: 118px; border-radius: 6px; }
.gongzhu-active .player-hand .card:disabled { opacity: 1; cursor: default; }
.gongzhu-active .player-hand .card:hover:not(:disabled) { z-index: 3; transform: translateY(-12px); }
.gongzhu-shown-points { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 5px; max-height: 32px; overflow-y: auto; }
.gongzhu-shown-points:empty { display: none; }
.gongzhu-shown-points .mini-card { font-size: 10px; padding: 2px 4px; border: 1px solid #ffdc68; }
.gongzhu-active .player-hand .gongzhu-revealable { box-shadow: 0 0 0 2px #ffdc68; }
.gongzhu-active .player-hand .gongzhu-selected { z-index: 2; transform: translateY(-12px); box-shadow: 0 0 0 3px #ffdc68; }
.gongzhu-card-badge { position: absolute; bottom: 5px; left: 3px; right: 3px; padding: 2px; border-radius: 3px; background: #165435; color: #ffe18a; font-size: 11px; text-align: center; pointer-events: none; }
.gongzhu-phase { max-width: 300px; font-size: 12px; color: #ffe18a; overflow-wrap: anywhere; }
.gongzhu-last-drawn { animation: gongzhu-draw-in .3s ease-out; }
@keyframes gongzhu-draw-in { from { transform: translateY(-16px); opacity: .3; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .gongzhu-last-drawn { animation: none; } }
@media (max-width: 760px) {
  .gongzhu-active .game-header { padding: 8px; gap: 8px; flex-wrap: wrap; }
  .gongzhu-active .game-header h1 { font-size: 14px; }
  .gongzhu-active .game-header button { padding: 8px; font-size: 12px; }
  .gongzhu-active .room-actions { gap: 5px; }
  .gongzhu-active .table-scene { min-height: 535px; }
  .gongzhu-active .table-seat { width: 100px; padding: 4px; }
  .gongzhu-active .seat-left, .gongzhu-active .seat-right { top: 0; transform: none; }
  .gongzhu-active .seat-left { left: 0; }
  .gongzhu-active .seat-right { right: 0; }
  .gongzhu-active .seat-face .avatar { width: 40px; height: 40px; font-size: 18px; }
  .gongzhu-active .seat-top .seat-face { display: flex; text-align: center; }
  .gongzhu-active .seat-face strong { font-size: 12px; }
  .gongzhu-active .seat-meta { font-size: 10px; }
  .gongzhu-active .gongzhu-seat-points { max-height: 20px; overflow-y: auto; }
  .gongzhu-active .gongzhu-shown-points { max-height: 24px; }
  .gongzhu-active .play-table { top: 175px; bottom: 8px; width: calc(100% - 16px); border-width: 3px; border-radius: 28px; }
  .gongzhu-active .trick-area { inset: 8px; grid-template: '. top .' minmax(0,1fr) 'left . right' 106px '. bottom .' minmax(0,1fr) / minmax(0,1fr) 94px minmax(0,1fr); gap: 4px; }
  .gongzhu-center-score { width: 140px; }
  .gongzhu-score-heading, .gongzhu-active .score-row { grid-template-columns: minmax(0,1fr) 35px 35px; gap: 3px; }
  .gongzhu-active .score-row { font-size: 10px; padding-inline: 0; }
  .gongzhu-active .score-row strong { font-size: 12px; }
  .gongzhu-active .played-slot .card, .gongzhu-empty-play { width: 48px; height: 68px; }
  .gongzhu-active .hand-panel { padding: 8px 12px 16px; }
  .gongzhu-active .hand-toolbar { gap: 8px; }
  .gongzhu-active .taken-pile { justify-content: center; }
  .gongzhu-active .player-hand { width: 100%; padding-right: 36px; min-height: 104px; }
  .gongzhu-active .player-hand .card { width: 60px; height: 86px; }
}
.tractor-active .tractor-scene { min-height: 510px; }
.tractor-table-stage { position: absolute; top: 114px; bottom: 12px; left: 50%; transform: translateX(-50%); width: calc(100% - 352px); max-width: 860px; min-width: 0; border: 4px solid #739681; border-radius: 42px; background: #185c40; box-shadow: inset 0 0 0 3px #102f25, 0 8px 24px #0002; }
.tractor-active .tractor-table { inset: 12px; grid-template-columns: minmax(0,1fr) 128px minmax(0,1fr); grid-template-rows: minmax(0,1fr) 120px minmax(0,1fr); gap: 6px; }
.tractor-active #tractorScoreHud { top: 50%; width: 128px; gap: 3px; }
.tractor-active #tractorScoreHud > strong { font-size: 30px; }
.tractor-active #tractorScoreHud > span { font-size: 12px; }
.tractor-active #tractorScoreHud > small { font-size: 11px; }
.tractor-active .tractor-center-info { margin-top: 0; padding-top: 5px; }
.tractor-active .tractor-play { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 0; }
.tractor-play header { flex-shrink: 0; max-width: 100%; padding: 2px 6px; font-size: 12px; line-height: 16px; color: #e0ece4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tractor-active .tractor-play > div { flex-shrink: 0; min-height: 0; height: 100px; width: max-content; max-width: 100%; justify-content: flex-start; align-items: center; gap: 0; padding: 2px; }
.tractor-active .tractor-play .card { width: 68px; height: 96px; }
.tractor-active .tractor-play .card + .card { margin-left: -30px; }
.tractor-play.is-turn header, .tractor-play.is-winner header { color: #ffe18a; }
.tractor-play-pending { display: grid; place-items: center; min-width: 88px; min-height: 58px; border: 2px dashed #ffdc68; border-radius: 6px; background: #ffdc6812; color: #ffe18a; font-size: 13px; font-weight: 700; }
.tractor-turn-label { display: block; width: max-content; max-width: 100%; margin: 6px auto 0; padding: 3px 8px; border-radius: 4px; background: #ffdc68; color: #173b2c; font-size: 12px; line-height: 18px; }
.tractor-active .tractor-seat-active .tractor-avatar { border-width: 3px; border-color: #ffdc68; box-shadow: 0 0 0 5px #ffdc6840; }
.tractor-active #tractorRoom.is-burying .tractor-table-stage { display: none; }
.tractor-active #tractorRoom.is-round-over .tractor-table { grid-template-rows: repeat(3,minmax(0,1fr)); }
@media (max-width: 760px) {
  .tractor-active .tractor-scene { min-height: 470px; }
  .tractor-active .tractor-seat-left, .tractor-active .tractor-seat-right { top: 0; transform: none; }
  .tractor-table-stage { top: 110px; bottom: 8px; width: calc(100% - 16px); border-width: 3px; border-radius: 28px; }
  .tractor-active .tractor-table { inset: 8px; grid-template-columns: minmax(0,1fr) 94px minmax(0,1fr); grid-template-rows: minmax(0,1fr) 106px minmax(0,1fr); gap: 4px; }
  .tractor-active #tractorScoreHud { width: 94px; }
  .tractor-active #tractorScoreHud > strong { font-size: 28px; }
  .tractor-active #tractorScoreHud > span, .tractor-active #tractorScoreHud > small { font-size: 10px; }
  .tractor-active .tractor-play .card { width: 48px; height: 68px; }
  .tractor-active .tractor-play > div { height: 72px; }
  .tractor-active .tractor-play .card + .card { margin-left: -26px; }
  .tractor-active .tractor-play-left > div, .tractor-active .tractor-play-right > div { flex-direction: row; max-height: none; }
  .tractor-play header { font-size: 10px; padding-inline: 2px; }
  .tractor-play-pending { min-width: 68px; min-height: 48px; font-size: 11px; }
  .tractor-turn-label { font-size: 10px; padding: 2px 5px; margin-top: 3px; }
}

body:has(#lobbyView.is-active) { background: #f7f8fa; }
.app-shell:has(#lobbyView.is-active) { width: 100%; padding: 0; }
#lobbyView { color: #22272c; color-scheme: light; }
#lobbyView .topbar { background: #2c3239; color: #fff; padding: 18px max(24px, calc((100% - 1320px) / 2)); margin: 0; min-height: 92px; }
.lobby-brand { display: flex; align-items: center; gap: 16px; }
#lobbyTitle { font-size: 32px; line-height: 1.2; margin: 0; }
.brand-cards { display: grid; place-items: center; width: 40px; height: 50px; border-radius: 5px; background: #fff; color: #20262d; font-size: 32px; transform: rotate(-10deg); }
#lobbyView .profile-pill { border: 0; border-radius: 0; background: transparent; padding: 0; }
#lobbyView .profile-pill input { color: #fff; width: 120px; }
#lobbyView .avatar { background: #6d99b8; color: #fff; }
#lobbyView .lobby-grid { max-width: 1320px; margin: 0 auto; padding: 36px 24px; grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); gap: 36px; }
#lobbyView h2 { font-size: 25px; line-height: 1.3; }
#lobbyView .game-picker { gap: 18px; }
#lobbyView .game-type-list { display: block; border-top: 1px solid #dce0e4; }
.lobby-game-row { display: grid; grid-template-columns: 178px minmax(90px,1fr) auto; align-items: center; gap: 24px; min-height: 124px; padding: 16px 0; border-bottom: 1px solid #dce0e4; }
.lobby-game-art { width: 100%; aspect-ratio: 9 / 4; border-radius: 6px; background-image: url('assets/lobby-games.png'); background-size: 200% 300%; background-repeat: no-repeat; }
.art-gongzhu { background-position: 0 0; }
.admin-entry { background: transparent; color: #ced4d9; border: 1px solid #ffffff30; border-radius: 5px; padding: 7px 10px; font-size: 13px; }
.admin-dialog { width: min(1100px,calc(100% - 24px)); max-height: 90vh; padding: 24px; color: #22272c; background: #f7f8fa; border: 1px solid #cbd0d6; border-radius: 8px; color-scheme: light; }
.admin-dialog::backdrop { background: #0009; }
.admin-dialog header, .admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-dialog button { border: 1px solid #cbd0d6; border-radius: 5px; padding: 9px 12px; background: #fff; color: #303940; }
.admin-dialog button:disabled { opacity: .5; cursor: wait; }
.admin-dialog h2 { font-size: 22px; }
#adminLogin { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; }
#adminLogin[hidden], #adminContent[hidden] { display: none; }
#adminPassword { background: #fff; color: #22272c; border-color: #cbd0d6; }
#adminStatus { margin: 16px 0; color: #a23e34; font-size: 14px; }
.admin-table-wrap { overflow-x: auto; }
.admin-dialog table { width: 100%; border-collapse: collapse; min-width: 700px; font-size: 14px; }
.admin-dialog th, .admin-dialog td { text-align: left; padding: 14px 10px; border-bottom: 1px solid #dce0e4; max-width: 280px; overflow-wrap: anywhere; }
.admin-dialog th { color: #56616b; font-size: 13px; background: #edf0f3; }
.admin-close-room { color: #a23e34 !important; white-space: nowrap; }
.admin-games { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #dce0e4; }
.admin-service { padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid #dce0e4; }
.admin-service h3 { color: #303940; font-size: 16px; margin-bottom: 12px; }
.admin-service p { margin: 8px 0 0; font-size: 13px; color: #58636b; }
.admin-room-limit { display: grid; gap: 10px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid #dce0e4; }
.admin-room-limit > label { color: #303940; font-size: 16px; font-weight: 650; }
.admin-room-limit > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-room-limit input { width: 90px; min-height: 38px; padding: 6px 10px; border: 1px solid #cbd0d6; border-radius: 6px; background: #fff; color: #22272c; }
.admin-room-limit button { min-height: 38px; padding: 6px 16px; border: 0; border-radius: 6px; background: #008b68; color: #fff; }
#adminRoomUsage,.room-capacity-status { font-size: 13px; color: #6d747c; }
.room-capacity-status { margin: 12px 0 0; }
.xiangqi-engine-controls { padding: 12px 0; border-top: 1px solid #dce0e4; border-bottom: 1px solid #dce0e4; }
.xiangqi-engine-controls[hidden] { display: none; }
.xiangqi-engine-controls label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.xiangqi-engine-controls select { width: 94px; padding: 6px 8px; }
.xiangqi-engine-controls p { margin: 10px 0; font-size: 13px; overflow-wrap: anywhere; }
.xiangqi-engine-controls a { font-size: 12px; color: inherit; }
.xiangqi-board {
  --xq-cell: 54px;
  --xq-pad: 18px;
  grid-template-columns: repeat(9,var(--xq-cell));
  grid-template-rows: repeat(10,var(--xq-cell));
  padding: var(--xq-pad);
  background: repeating-linear-gradient(90deg,transparent 0 calc(var(--xq-cell) / 2 - .5px),#111 calc(var(--xq-cell) / 2 - .5px) calc(var(--xq-cell) / 2 + .5px),transparent calc(var(--xq-cell) / 2 + .5px) var(--xq-cell)),repeating-linear-gradient(180deg,transparent 0 calc(var(--xq-cell) / 2 - .5px),#111 calc(var(--xq-cell) / 2 - .5px) calc(var(--xq-cell) / 2 + .5px),transparent calc(var(--xq-cell) / 2 + .5px) var(--xq-cell)),#f8f8f3;
  background-position: var(--xq-pad) var(--xq-pad);
  background-size: var(--xq-cell) var(--xq-cell);
}
.xiangqi-point { width: var(--xq-cell); height: var(--xq-cell); }
.xiangqi-point span { width: calc(var(--xq-cell) * .82); height: calc(var(--xq-cell) * .82); }
.xiangqi-board::before { left: var(--xq-pad); right: var(--xq-pad); height: calc(var(--xq-cell) * .66); top: calc(50% - var(--xq-cell) * .33); letter-spacing: 0; }
.xiangqi-board::after {
  inset: calc(var(--xq-pad) + var(--xq-cell) / 2);
  background: linear-gradient(45deg,transparent calc(50% - .5px),#111 calc(50% - .5px) calc(50% + .5px),transparent calc(50% + .5px)) calc(var(--xq-cell) * 3) 0 / calc(var(--xq-cell) * 2) calc(var(--xq-cell) * 2) no-repeat,linear-gradient(-45deg,transparent calc(50% - .5px),#111 calc(50% - .5px) calc(50% + .5px),transparent calc(50% + .5px)) calc(var(--xq-cell) * 3) 0 / calc(var(--xq-cell) * 2) calc(var(--xq-cell) * 2) no-repeat,linear-gradient(45deg,transparent calc(50% - .5px),#111 calc(50% - .5px) calc(50% + .5px),transparent calc(50% + .5px)) calc(var(--xq-cell) * 3) calc(var(--xq-cell) * 7) / calc(var(--xq-cell) * 2) calc(var(--xq-cell) * 2) no-repeat,linear-gradient(-45deg,transparent calc(50% - .5px),#111 calc(50% - .5px) calc(50% + .5px),transparent calc(50% + .5px)) calc(var(--xq-cell) * 3) calc(var(--xq-cell) * 7) / calc(var(--xq-cell) * 2) calc(var(--xq-cell) * 2) no-repeat;
}
@media(max-width: 680px) {
  .xiangqi-board-wrap { order: -1; container-type: inline-size; padding: 8px; overflow: hidden; min-width: 0; }
  .xiangqi-board { --xq-cell: calc((100cqw - 22px) / 9); --xq-pad: 8px; box-shadow: none; }
  .xiangqi-point span { font-size: 16px; }
  .xiangqi-board::before { font-size: 14px; }
  .xiangqi-sidebar { gap: 12px; padding: 14px; }
}
.service-notice { margin: 0 0 20px; padding: 12px 16px; border-left: 3px solid #bd2929; color: #9e2525; background: #fff0f0; }
.service-notice[hidden] { display: none; }
.admin-games h3 { color: #303940; font-size: 16px; margin-bottom: 14px; }
#adminGames { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px 24px; }
.admin-game-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; font-size: 14px; cursor: pointer; min-height: 36px; }
.admin-game-switch input { position: absolute; right: 0; width: 42px; height: 24px; opacity: 0; margin: 0; cursor: pointer; }
.admin-switch-track { pointer-events: none; flex-shrink: 0; width: 42px; height: 24px; padding: 3px; border-radius: 12px; background: #a9b0b8; transition: background .15s; }
.admin-switch-track::before { content: ''; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.admin-game-switch input:checked + .admin-switch-track { background: #008b68; }
.admin-game-switch input:checked + .admin-switch-track::before { transform: translateX(18px); }
.admin-game-switch input:focus-visible + .admin-switch-track { outline: 2px solid #008b68; outline-offset: 3px; }
.admin-game-switch input:disabled + .admin-switch-track { opacity: .5; }
@media(max-width:600px) { #adminGames { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:760px) {
  .admin-dialog { padding: 16px; }
  #adminLogin { grid-template-columns: minmax(0,1fr) auto; }
  #adminLogin label { grid-column: 1 / -1; }
  #lobbyView .admin-entry { padding: 7px; font-size: 12px; }
  #lobbyView .profile-pill { gap: 6px; }
  #lobbyView .profile-pill input { width: 68px; }
  .admin-toolbar { align-items: flex-start; flex-wrap: wrap; }
}
.art-tractor { background-position: 100% 0; }
.art-doudizhu { background-size: 200% 320%; background-position: 0 48.6%; }
.art-majiang { background-size: 200% 320%; background-position: 100% 48.6%; }
.art-xiangqi { background-position: 0 100%; }
.art-freeplay { background-position: 100% 100%; }
.active-rooms { max-width: 1320px; margin: 0 auto; padding: 28px 24px 0; }
.active-rooms > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.active-rooms h2 { margin: 0; }
#activeRoomCount { font-size: 14px; font-weight: 400; color: #6d747c; margin-left: 12px; white-space: nowrap; }
#refreshLobbyRooms { width: 36px; height: 36px; padding: 0; border: 1px solid #cbd0d6; border-radius: 6px; background: #fff; color: #434b53; font-size: 24px; }
.active-room-list { display: grid; gap: 8px; }
.active-room-row { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) 180px 112px; align-items: center; gap: 20px; padding: 14px 18px; border: 1px solid #dce0e4; border-radius: 6px; background: #fff; color: #22272c; text-align: left; }
.active-room-row:hover:not(:disabled), .active-room-row:focus-visible { border-color: #008b68; background: #f1faf6; }
.active-room-row:disabled { opacity: .6; cursor: not-allowed; }
.active-room-game { display: flex; align-items: center; gap: 16px; min-width: 0; }
.active-room-game .lobby-game-art { width: 82px; flex: 0 0 82px; }
.active-room-game > span:last-child { min-width: 0; display: grid; gap: 6px; }
.active-room-game strong { font-size: 18px; overflow-wrap: anywhere; }
.active-room-game small { font-size: 14px; font-weight: 400; color: #6d747c; }
.active-room-names { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #6d747c; font-size: 13px; }
.active-room-occupancy { display: grid; gap: 6px; font-size: 13px; color: #6d747c; }
.active-room-occupancy strong { color: #008b68; font-size: 20px; }
.active-room-occupancy small { color: #6d747c; font-size: 13px; font-weight: 400; }
.active-room-join { color: #008b68; font-size: 15px; font-weight: 650; white-space: nowrap; text-align: right; }
#activeRoomStatus { margin: 0; padding: 20px 0; color: #6d747c; font-size: 14px; border-bottom: 1px solid #dce0e4; }
@media(max-width: 620px) {
  .active-rooms { padding: 24px 16px 0; }
  .active-room-row { grid-template-columns: minmax(0,1fr) auto; gap: 10px 12px; padding: 12px; }
  .active-room-game .lobby-game-art { width: 54px; flex-basis: 54px; }
  .active-room-game { gap: 10px; }
  .active-room-game strong { font-size: 16px; }
  .active-room-game small { font-size: 12px; }
  .active-room-occupancy { grid-column: 1; grid-row: 2; display: flex; align-items: center; gap: 12px; }
  .active-room-occupancy strong { font-size: 16px; }
  .active-room-join { grid-column: 2; grid-row: 1 / 3; font-size: 13px; }
}
.lobby-game-info { display: grid; gap: 8px; }
.lobby-game-info strong { font-size: 23px; }
.lobby-game-info small { font-size: 15px; color: #747b83; }
.lobby-game-action { display: flex; align-items: center; gap: 12px; }
.lobby-game-action button, #lobbyView .primary-action { border: 0; border-radius: 6px; background: #008b68; color: #fff; font-weight: 650; padding: 14px 20px; font-size: 17px; white-space: nowrap; min-height: 50px; }
.lobby-game-action button:hover, #lobbyView .primary-action:hover { background: #00795b; }
.lobby-game-action button:disabled { background: #dfe1e4; color: #999fa6; cursor: not-allowed; }
.lobby-game-action small { color: #9b782f; font-size: 13px; white-space: nowrap; }
#lobbyView .room-builder { border-left: 1px solid #dce0e4; padding: 0 0 0 32px; gap: 28px; }
#lobbyView .builder-row { display: grid; gap: 14px; }
#lobbyView .builder-row label { font-size: 18px; color: #434b53; }
#lobbyView #roomName { background: #fff; border: 1px solid #cbd0d6; border-radius: 6px; color: #22272c; font-size: 22px; padding: 18px; width: 100%; }
#lobbyView #roomName:focus { border-color: #008b68; box-shadow: 0 0 0 3px #008b6815; }
#lobbyView #createRoom { width: 100%; display: flex; justify-content: center; gap: 18px; }
@media(max-width:1100px) {
  .lobby-game-row { grid-template-columns: 132px minmax(90px,1fr) auto; gap: 16px; }
  .lobby-game-action { flex-direction: column; gap: 5px; }
}
@media(max-width:760px) {
  #lobbyView .topbar { padding: 16px; gap: 12px; flex-direction: row; }
  #lobbyTitle { font-size: 24px; }
  .lobby-brand { gap: 10px; }
  .brand-cards { width: 28px; height: 36px; font-size: 25px; }
  #lobbyView .profile-pill input { width: 88px; padding: 4px; font-size: 14px; }
  #lobbyView .avatar { display: none; }
  #lobbyView .lobby-grid { display: flex; flex-direction: column; padding: 24px 16px; gap: 28px; }
  #lobbyView .room-builder { order: -1; border-left: 0; border-bottom: 1px solid #dce0e4; padding: 0 0 24px; gap: 16px; }
  #lobbyView h2 { font-size: 21px; }
  #lobbyView .builder-row { gap: 8px; }
  #lobbyView #roomName { padding: 12px; font-size: 18px; }
  .lobby-game-row { grid-template-columns: 90px minmax(0,1fr) 112px; gap: 12px; min-height: 94px; padding: 14px 0; }
  .lobby-game-info strong { font-size: 18px; }
  .lobby-game-info small { font-size: 13px; }
  .lobby-game-action button { padding: 10px 12px; min-height: 40px; font-size: 14px; width: 112px; }
  .lobby-game-action small { font-size: 12px; }
}

.mahjong-active { background: #206c4b; }
.mahjong-active .app-shell { width: 100%; max-width: none; padding: 0; }
.mahjong-active #roomView { display: flex; flex-direction: column; min-height: 100dvh; background: #206c4b; }
.mahjong-active .game-header { min-height: 64px; flex-direction: row; margin: 0; padding: 8px 20px; background: #154b36; gap: 12px; }
.mahjong-active .game-header h1 { font-size: 18px; line-height: 1.2; }
.mahjong-active .game-header .eyebrow { font-size: 11px; }
.mahjong-active .room-actions { margin-left: auto; }
.mahjong-active .majiang-room.is-active { display: flex; flex-direction: column; flex: 1; gap: 0; }
.mahjong-active .mj-table { flex: 1; min-height: 550px; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.mahjong-active .mj-seat { min-width: 0; width: 136px; border: 0; padding: 8px; background: transparent; grid-template-columns: 1fr; text-align: center; gap: 7px; box-shadow: none; }
.mahjong-active .mj-seat .avatar { width: 50px; height: 50px; margin: auto; border: 2px solid #ffffff60; background: #173e30; color: #fff; font-size: 22px; }
.mahjong-active .mj-seat strong { font-size: 14px; overflow-wrap: anywhere; }
.mahjong-active .mj-seat .seat-meta { font-size: 11px; color: #d2e4d8; margin-top: 5px; }
.mahjong-active .mj-seat.is-active .avatar { border: 3px solid #ffdc68; box-shadow: 0 0 0 5px #ffdc6833; }
.mahjong-active .mj-seat-top { top: 8px; width: 210px; grid-template-columns: 50px 1fr; text-align: left; }
.mahjong-active .mj-seat-left { left: 14px; top: 48%; }
.mahjong-active .mj-seat-right { right: 14px; top: 48%; }
.mahjong-active .mj-seat-bottom { display: none; }
.mj-turn-tag { display: block; color: #ffe18a; font-size: 11px; margin-top: 6px; }
.mahjong-active .mj-center { inset: 105px max(160px,calc((100% - 980px)/2)) 24px; grid-template-columns: minmax(0,1fr) 140px minmax(0,1fr); grid-template-rows: minmax(0,1fr) 135px minmax(0,1fr); gap: 12px; padding: 18px; border: 4px solid #739681; border-radius: 34px; background: #185c40; box-shadow: inset 0 0 0 3px #102f25; }
.mahjong-active .mj-center-label { padding: 10px 4px; border: 0; background: #104832; border-radius: 6px; display: flex; flex-direction: column; gap: 8px; justify-content: center; font-size: 14px; }
.mahjong-active .mj-center-label > span { color: #cfe3d6; font-size: 12px; }
.mahjong-active .mj-center-label b { color: #ffdc68; font-size: 22px; }
.mahjong-active .mj-status { margin: 0; font-size: 12px; color: #f3e4a6; }
#mjLastDiscard:empty { display: none; }
#mjLastDiscard .mj-tile { width: 27px; height: 37px; }
.mahjong-active .mj-discard { min-height: 0; gap: 5px; padding: 5px; background: transparent; border-radius: 0; overflow: auto; scrollbar-width: thin; justify-content: center; }
.mahjong-active .mj-discard-top { grid-area: 1 / 1 / 2 / 4; padding-inline: 18%; }
.mahjong-active .mj-discard-bottom { grid-area: 3 / 1 / 4 / 4; padding-inline: 18%; }
.mahjong-active .mj-discard .mj-tile { flex-shrink: 0; width: 29px; height: 40px; }
.mahjong-active .mj-empty { align-self: center; font-size: 12px; color: #b6d0c0; }
.mahjong-active .mj-hand-panel { border: 0; border-radius: 0; margin: 0; padding: 14px 24px 24px; background: #174f38; box-shadow: none; }
.mahjong-active .mj-hand-panel .hand-toolbar { max-width: 1000px; margin: 0 auto 18px; justify-content: space-between; }
.mj-self-profile { display: flex; align-items: center; gap: 14px; }
#mjPlayerName { width: 120px; border: 1px solid #ffffff25; background: #ffffff0a; color: #fff; font-size: 16px; padding: 8px 10px; }
.mahjong-active .mj-player-hand { justify-content: center; flex-wrap: nowrap; padding-top: 14px; padding-bottom: 10px; overflow-x: auto; gap: 5px; min-height: 96px; }
.mahjong-active .mj-player-hand .mj-tile { width: 56px; height: 78px; flex-shrink: 0; padding: 3px; transition: transform .15s; }
.mahjong-active .mj-player-hand .mj-tile:disabled { opacity: 1; cursor: default; }
.mahjong-active .mj-player-hand .mj-tile.is-new-draw { margin-left: 14px; visibility: hidden; }
.mj-draw-reveal { position: fixed; z-index: 30; width: 112px; pointer-events: none; transform-origin: 50% 78px; text-align: center; }
.mj-draw-reveal[hidden] { display: none; }
.public-card-reveal { position: fixed; z-index: 30; display: grid; justify-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; text-align: center; }
.public-card-reveal > strong { max-width: 100%; padding: 5px 10px; border-radius: 4px; background: #104832; color: #ffdc68; font-size: 15px; overflow-wrap: anywhere; }
.public-reveal-cards { display: flex; gap: 8px; }
.public-card-reveal .card { position: relative; flex-shrink: 0; width: var(--reveal-card-width); height: calc(var(--reveal-card-width) * 1.4); padding: 0; margin: 0; outline: 3px solid #ffdc68; outline-offset: 3px; box-shadow: 0 8px 24px #0006; transform: none; }
.mj-draw-reveal .mj-tile { width: 112px; height: 156px; padding: 8px; pointer-events: auto; outline: 3px solid #ffdc68; outline-offset: 3px; box-shadow: 0 8px 24px #0006; }
.mj-draw-reveal .mj-tile:disabled { opacity: 1; }
.mj-draw-reveal > span { display: inline-block; margin-top: 14px; padding: 4px 9px; border-radius: 4px; background: #104832; color: #ffdc68; font-size: 13px; font-weight: 700; }
.mj-tile > img.mj-face { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; pointer-events: none; user-select: none; transform: none; }
.mahjong-active .mj-player-hand button { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.mahjong-active .mj-player-hand[data-arrange="true"] button { cursor: grab; }
.mahjong-active .mj-player-hand .is-dragging { opacity: .3; }
.mahjong-active .mj-player-hand .is-drop-target { outline: 2px solid #ffdc68; outline-offset: 1px; }
.mj-drag-ghost { position: fixed; z-index: 40; pointer-events: none; transform: translate(-50%,-65%); opacity: .95; }
.mahjong-active .mj-sort-hand { width: 36px; min-width: 36px; height: 36px; display: grid; place-items: center; padding: 7px; flex-shrink: 0; }
.mj-sort-hand[hidden] { display: none; }
.mj-sort-hand img { filter: invert(1); }
.mj-hand-tools { display: flex; gap: 6px; align-items: center; }
#mjSound[aria-pressed="true"] { border-color: #ffdc68; background: #ffdc6820; }
.mj-turn-hint { max-width: 100%; padding: 6px 10px; color: #d2e4d8; font-size: 13px; overflow-wrap: anywhere; }
.mj-turn-hint.is-your-turn { color: #173e30; background: #ffdc68; border-radius: 4px; font-weight: 700; }
.mahjong-active .mj-self-profile.is-active input { border-color: #ffdc68; }
.mahjong-active .mj-turn-tag { display: inline-block; margin-top: 5px; padding: 3px 7px; border-radius: 4px; background: #ffdc68; color: #173e30; font-weight: 700; }
.mj-option-buttons, .mj-self-melds { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 1000px; margin: 8px auto; }
.mj-option-buttons:empty, .mj-self-melds:empty { display: none; }
.mj-option-buttons button { white-space: normal; overflow-wrap: anywhere; max-width: 100%; font-size: 14px; }
.mj-seat-melds { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; grid-column: 1 / -1; }
.mj-meld { display: flex; gap: 2px; padding: 3px; border-bottom: 2px solid #d6bd75; }
.mj-seat-melds .mj-tile { width: 20px; height: 29px; }
.mj-tile.tile-back { background: #cee3d3; box-shadow: inset 0 0 0 3px #548771,0 3px 0 #94bba2; }
.mj-round-result { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px; color: #ffe18a; }
.mj-round-result[hidden] { display: none; }
.mj-result-dialog { width: min(900px,calc(100% - 24px)); max-height: 90dvh; overflow: auto; }
.mj-settlement-scores { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; padding: 18px 0; }
.mj-settlement-scores > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.mj-settlement-scores strong { color: #ffe18a; font-size: 24px; }
.mj-winning-hand { margin: 20px 0; }
.mj-winning-hand > div { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.mj-winning-hand h3 { color: #fff; line-height: 1.7; }
.mj-payment-list { border-top: 1px solid #ffffff25; padding-top: 12px; font-size: 13px; line-height: 1.9; color: #bed7c7; }
.mahjong-rules { margin-top: 20px; padding-top: 18px; border-top: 1px solid #ffffff25; font-size: 13px; line-height: 1.8; color: #c6d6cc; }
.mahjong-rules h3 { color: #fff; margin-bottom: 10px; font-size: 15px; }
.mahjong-rules p + p { margin-top: 8px; }
@media(max-width:760px) {
  .mahjong-active .game-header { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .mahjong-active .game-header h1 { font-size: 15px; }
  .mahjong-active .game-header button { font-size: 12px; padding: 7px 9px; }
  .mahjong-active .mj-table { min-height: 460px; }
  .mahjong-active .mj-seat { width: 70px; padding: 4px; }
  .mahjong-active .mj-seat .avatar { width: 36px; height: 36px; font-size: 17px; }
  .mahjong-active .mj-seat strong { font-size: 11px; }
  .mahjong-active .mj-seat .seat-meta { font-size: 10px; }
  .mj-seat-melds .mj-tile { width: 12px; height: 19px; box-shadow: 0 2px 0 #94bba2; }
  .mj-seat-melds .mj-meld { gap: 1px; padding: 1px; }
  .mj-seat-melds .mj-tile > * { transform: scale(.55); }
  .mj-self-melds .mj-tile { width: 22px; height: 32px; }
  .mj-option-buttons { gap: 5px; }
  .mj-option-buttons button { padding: 8px; font-size: 12px; }
  .mj-settlement-scores { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mahjong-active .mj-seat-top { width: 165px; grid-template-columns: 36px 1fr; }
  .mahjong-active .mj-seat-left { left: 0; top: 50%; }
  .mahjong-active .mj-seat-right { right: 0; top: 50%; }
  .mahjong-active .mj-center { inset: 100px 72px 20px; padding: 8px; border-width: 2px; border-radius: 20px; grid-template-columns: minmax(0,1fr) 76px minmax(0,1fr); grid-template-rows: minmax(0,1fr) 146px minmax(0,1fr); gap: 4px; }
  .mahjong-active .mj-discard { padding: 2px; gap: 3px; }
  .mahjong-active .mj-discard .mj-tile { width: 19px; height: 27px; padding: 1px; box-shadow: 0 2px 0 #b7c6b3; }
  .mahjong-active .mj-discard-top, .mahjong-active .mj-discard-bottom { padding-inline: 5%; }
  .mahjong-active .mj-center-label { padding: 6px 2px; font-size: 12px; gap: 7px; }
  .mahjong-active .mj-status { font-size: 10px; }
  .mahjong-active .mj-hand-panel { padding: 12px 8px 18px; }
  .mj-self-profile { flex-direction: column; align-items: flex-start; gap: 5px; }
  #mjPlayerName { width: 110px; font-size: 14px; padding: 5px 8px; }
  .mahjong-active .mj-player-hand { gap: 2px; min-height: 68px; justify-content: flex-start; }
  .mahjong-active .mj-player-hand .mj-tile { width: 24px; height: 38px; border-radius: 4px; padding: 1px; box-shadow: inset 0 -2px 0 #cadbc9,0 3px 0 #b7c6b3; }
  .mahjong-active .mj-player-hand .mj-tile.is-new-draw { margin-left: 5px; }
  .mahjong-active .mj-turn-hint { font-size: 11px; padding: 5px 7px; }
  .mahjong-active .mj-player-hand .mj-rank { font-size: 12px; }
  .mahjong-active .mj-player-hand .mj-char { font-size: 15px; }
  .mahjong-active .mj-player-hand .mj-honor { font-size: 19px; }
  .mahjong-active .mj-player-hand .mj-dots { width: 18px; grid-template-columns: repeat(3,5px); grid-auto-rows: 5px; gap: 1px; }
  .mahjong-active .mj-player-hand .mj-dots i { width: 5px; height: 5px; }
  .mahjong-active .mj-player-hand .mj-dots.count-1 { grid-template-columns: 1fr; }
  .mahjong-active .mj-player-hand .mj-dots:is(.count-2,.count-4,.count-5,.count-7,.count-8) { grid-template-columns: repeat(2,5px); }
  .mahjong-active .mj-player-hand .mj-bamboos { width: 15px; grid-template-columns: repeat(3,3px); gap: 1px; }
  .mahjong-active .mj-player-hand .mj-bamboos i { width: 3px; height: 7px; }
  .mahjong-active .mj-tile .white-dragon { width: 14px; height: 18px; font-size: 10px; }
  .mahjong-active .mj-discard .mj-bamboos i { width: 2px; height: 6px; }
  .mahjong-active .mj-discard .mj-bamboos { grid-template-columns: repeat(3,2px); width: 12px; }
}
