:root {
  --felt: #15614d;
  --felt-dark: #0b3e34;
  --felt-light: #21846a;
  --ink: #17201d;
  --muted: #687671;
  --paper: #fbfcfb;
  --panel: #ffffff;
  --line: #dbe4df;
  --gold: #d7ad4f;
  --amber: #f0c05a;
  --red: #c7353e;
  --blue: #2d6ea6;
  --shadow: 0 18px 50px rgba(12, 45, 37, 0.18);
  --card-stack-offset: 24;
  --card-w: clamp(34px, 4.8vw, 62px);
  --card-h: calc(var(--card-w) * 1.42);
  --stack-gap: clamp(12px, 1.85vw, 24px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background: #edf4f0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.splash {
  min-height: 100vh;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  gap: 16px;
  color: white;
  background: linear-gradient(135deg, var(--felt), var(--felt-dark));
}

.splash h1,
.brand h1,
.panel h2,
.scoreboard h3 {
  margin: 0;
}

.splash p,
.brand p,
.empty,
.room span,
.seat span,
.seat em,
.hand-meta span,
.scoreboard p,
.user-row span {
  color: var(--muted);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  color: #251b05;
  background: linear-gradient(135deg, #ffe19a, var(--gold));
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, 0.12);
  font-size: 1.55rem;
  font-weight: 900;
}

.brand-mark.big {
  width: 64px;
  height: 64px;
  font-size: 2rem;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-shell {
  min-height: 100dvh;
  padding: 10px;
}

.topbar {
  width: min(1480px, 100%);
  margin: 0 auto 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 30px rgba(16, 55, 45, 0.1);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  font-size: 1.12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.82rem;
}

.top-actions,
.row-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
.icon-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--ink);
  background: #eef5f1;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(20, 55, 46, 0.08);
}

.btn.primary {
  color: #1f1604;
  background: linear-gradient(180deg, #ffe294, var(--amber));
}

.btn.subtle {
  color: var(--muted);
  background: transparent;
}

.btn.tiny {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

.icon-btn.active {
  background: var(--felt);
  color: white;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(310px, 430px) 1fr;
  background: #edf4f0;
}

.auth-panel {
  padding: clamp(28px, 6vw, 64px);
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  box-shadow: var(--shadow);
}

.auth-brand h1 {
  font-size: 2.2rem;
}

.auth-table {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--felt-dark);
}

.auth-table img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05) brightness(0.78);
}

.auth-table::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(11, 62, 52, 0.62), rgba(11, 62, 52, 0.12));
}

.floating-card {
  position: absolute;
  z-index: 1;
  width: 74px;
  height: 102px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: white;
  color: var(--red);
  font-size: 1.6rem;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
  animation: float-card 3s ease-in-out infinite;
}

.floating-card.c1 {
  left: 18%;
  top: 18%;
  transform: rotate(-12deg);
}

.floating-card.c2 {
  right: 18%;
  bottom: 18%;
  color: #111;
  transform: rotate(14deg);
  animation-delay: 0.5s;
}

.floating-card.c3 {
  left: 45%;
  bottom: 26%;
  color: var(--blue);
  animation-delay: 1s;
}

@keyframes float-card {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -14px;
  }
}

.segmented {
  width: fit-content;
  padding: 5px;
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8f6;
}

.segmented button {
  padding: 9px 16px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented .active {
  color: white;
  background: var(--felt);
}

.form,
.compact-form {
  display: grid;
  gap: 12px;
}

.form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.form input,
.form select,
.compact-form input,
.compact-form select,
.chat-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

.check-row {
  display: flex !important;
  align-items: center;
  grid-template-columns: none !important;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.game-layout {
  width: min(1480px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 10px;
  min-height: calc(100dvh - 20px);
}

.lobby,
.admin-grid {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 36px rgba(16, 55, 45, 0.1);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.compact-form {
  grid-template-columns: 1fr 96px auto;
}

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

.room,
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.room.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 173, 79, 0.18);
}

.room-main {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0;
  text-align: left;
  background: transparent;
}

.empty-table {
  min-height: 680px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  color: white;
  background: var(--felt-dark);
}

.empty-table img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.45;
}

.empty-table div {
  position: relative;
  width: min(520px, 90%);
  text-align: center;
}

.empty-table h2 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  margin: 0 0 10px;
}

.table-board {
  height: calc(100dvh - 20px);
  min-height: 640px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(12, 68, 56, 0.88), rgba(12, 68, 56, 0.9)),
    url("/resource/desk.jpg") center / cover;
  box-shadow: var(--shadow);
}

.table-board::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 17%;
  bottom: 20%;
  border: 16px solid rgba(215, 173, 79, 0.38);
  border-radius: 48%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.11), rgba(12, 74, 61, 0.62));
}

.table-board.my-turn {
  box-shadow: 0 0 0 4px rgba(240, 192, 90, 0.72), var(--shadow);
}

.table-topline {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 2;
}

.badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  color: white;
  background: rgba(7, 39, 33, 0.58);
  font-weight: 800;
}

.badge.heart {
  color: #ffe7e8;
}

.seat {
  position: absolute;
  z-index: 3;
  width: 190px;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  color: white;
  background: rgba(5, 38, 32, 0.72);
  backdrop-filter: blur(12px);
}

.seat.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 192, 90, 0.22);
}

.seat.team-0 .avatar {
  background: linear-gradient(135deg, #86e0c2, #1f9c79);
}

.seat.team-1 .avatar {
  background: linear-gradient(135deg, #9fc7ff, #2d6ea6);
}

.seat .avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 900;
}

.seat strong,
.seat span,
.seat em {
  display: block;
}

.seat span,
.seat em {
  color: rgba(255, 255, 255, 0.76);
  font-style: normal;
  font-size: 0.82rem;
}

.bottom-seat {
  left: 20px;
  bottom: 230px;
}

.top-seat {
  left: 50%;
  top: 62px;
  translate: -50% 0;
}

.left-seat {
  left: 20px;
  top: 42%;
}

.right-seat {
  right: 20px;
  top: 16%;
}

.center-play {
  position: absolute;
  z-index: 2;
  left: 230px;
  right: 230px;
  top: 170px;
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: white;
}

.turn-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 8px;
  color: #1f1604;
  background: linear-gradient(180deg, #ffe294, var(--amber));
  font-weight: 900;
}

.played-lane {
  width: 100%;
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-hint {
  opacity: 0.8;
  font-weight: 800;
}

.play-stack {
  min-width: 132px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  animation: play-pop 260ms ease-out;
}

@keyframes play-pop {
  from {
    transform: translateY(12px) scale(0.96);
    opacity: 0;
  }
}

.play-stack span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.78);
}

.mini-cards {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.small-card {
  min-width: 32px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: white;
  color: #111;
  font-size: 0.78rem;
  font-weight: 900;
}

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

.last-play {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  color: rgba(255, 255, 255, 0.84);
}

.hand-zone {
  position: absolute;
  z-index: 4;
  left: 16px;
  right: 16px;
  bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(245, 249, 246, 0.94);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.2);
}

.hand-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.hand {
  min-height: 122px;
  display: flex;
  align-items: end;
  overflow-x: auto;
  padding: 18px 4px 8px;
}

.card {
  width: 58px;
  height: 86px;
  flex: 0 0 58px;
  margin-left: -18px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto 1fr;
  column-gap: 3px;
  align-items: start;
  justify-items: start;
  padding: 7px;
  border: 1px solid #d9dddc;
  border-radius: 7px;
  color: #111;
  background: linear-gradient(180deg, #fff, #edf1ef);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.card:first-child {
  margin-left: 0;
}

.card span {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.card b {
  align-self: start;
  font-size: 0.95rem;
  line-height: 1;
}

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

.card.selected {
  transform: translateY(-22px);
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.24);
}

.card.wild {
  outline: 3px solid rgba(240, 192, 90, 0.72);
}

.side-panel {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: auto;
  top: 82px;
  width: 210px;
  display: grid;
  gap: 10px;
}

.scoreboard,
.chat {
  padding: 12px;
  border-radius: 8px;
  color: white;
  background: rgba(5, 38, 32, 0.7);
  backdrop-filter: blur(12px);
}

.scoreboard p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.chat-log {
  min-height: 72px;
  max-height: min(26dvh, 180px);
  overflow: auto;
}

.chat-log p {
  margin: 0 0 6px;
  font-size: 0.84rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.admin-grid {
  width: min(1180px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.admin-grid .wide {
  grid-column: 1 / -1;
}

.admin-logo {
  display: flex;
  align-items: center;
}

.user-table {
  display: grid;
  gap: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  background: rgba(11, 39, 34, 0.92);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .lobby {
    grid-template-columns: 1fr 1fr;
  }

  .table-board {
    min-height: 760px;
  }

  .center-play {
    left: 24px;
    right: 24px;
    top: 200px;
  }

  .side-panel {
    right: 16px;
    bottom: 156px;
  }
}

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

  .auth-page,
  .admin-grid,
  .lobby {
    grid-template-columns: 1fr;
  }

  .auth-table {
    display: none;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand p {
    display: none;
  }

  .compact-form {
    grid-template-columns: 1fr;
  }

  .table-board {
    min-height: 820px;
  }

  .table-board::before {
    left: 3%;
    right: 3%;
    top: 18%;
    bottom: 25%;
  }

  .table-topline {
    top: 10px;
  }

  .seat {
    width: 150px;
    min-height: 62px;
    padding: 8px;
  }

  .seat .avatar {
    width: 36px;
    height: 36px;
  }

  .top-seat {
    top: 92px;
  }

  .left-seat {
    top: 35%;
  }

  .right-seat {
    top: 22%;
  }

  .bottom-seat {
    bottom: 238px;
  }

  .center-play {
    top: 225px;
    min-height: 220px;
  }

  .side-panel {
    left: 16px;
    right: 16px;
    bottom: 218px;
    width: auto;
    grid-template-columns: 1fr 1fr;
  }

  .card {
    width: 50px;
    height: 76px;
    flex-basis: 50px;
    margin-left: -20px;
  }

  .hand-zone {
    bottom: 8px;
  }
}

@media (max-width: 520px) {
  .side-panel {
    display: none;
  }

  .center-play {
    left: 10px;
    right: 10px;
  }

  .table-actions {
    justify-content: center;
  }

  .seat {
    width: 136px;
  }

  .left-seat,
  .right-seat {
    top: 26%;
  }

  .right-seat {
    right: 8px;
  }

  .left-seat,
  .bottom-seat {
    left: 8px;
  }
}

.create-head,
.admin-head .create-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.create-head .brand h1 {
  margin: 0;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-button::after {
  content: "⌄";
  margin-left: 8px;
  font-size: 0.8rem;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 126px;
  padding: 6px;
  border-radius: 8px;
  background: white;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.user-menu-panel button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.user-menu-panel button:hover {
  background: #eef5f1;
}

.counter-line {
  align-items: stretch;
}

.level-cell {
  min-width: 84px;
  display: grid;
  place-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  color: white;
  background: rgba(7, 39, 33, 0.66);
  font-weight: 900;
}

.rank-counter {
  display: grid;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 8px;
  color: #1d261f;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.rank-counter div {
  display: grid;
  grid-template-columns: repeat(15, minmax(24px, 1fr));
  gap: 2px;
  align-items: center;
  text-align: center;
}

.rank-counter span,
.rank-counter b {
  min-width: 24px;
  font-size: 0.78rem;
  line-height: 1.15;
}

.rank-counter span {
  font-weight: 900;
}

.rank-counter b {
  color: var(--red);
}

.seat-wrap {
  position: absolute;
  z-index: 5;
  width: 190px;
}

.seat-wrap .seat {
  position: relative;
  width: 100%;
}

.seat-wrap.top-seat {
  left: 50%;
  top: 92px;
  translate: -50% 0;
}

.seat-wrap.left-seat {
  left: 20px;
  top: 41%;
}

.seat-wrap.right-seat {
  right: 20px;
  top: 335px;
}

.seat-play {
  min-height: 52px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.top-side {
  top: 80px;
  bottom: auto;
  right: 16px;
}

.voice-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 8px;
}

.voice-tools.active {
  padding: 5px;
  border-radius: 8px;
  background: rgba(240, 192, 90, 0.14);
}

.center-play {
  top: 270px;
  left: 245px;
  right: 245px;
  min-height: 180px;
}

.waiting-actions-panel {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100% - 32px));
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(5, 38, 32, 0.68);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
}

.waiting-actions-panel .table-actions {
  justify-content: center;
}

.waiting-actions-panel .seat-order-panel {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  justify-self: center;
  width: min(360px, 100%);
  margin: 0;
  transform: none;
  translate: 0 0;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
}

.tribute-panel {
  max-width: min(560px, 100%);
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(5, 38, 32, 0.66);
  text-align: center;
  font-weight: 800;
  line-height: 1.45;
}

.tribute-record-panel {
  position: absolute;
  z-index: 4;
  left: 16px;
  top: 70px;
  max-width: 255px;
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 8px;
  color: white;
  background: rgba(5, 38, 32, 0.68);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(12px);
}

.tribute-record-panel strong {
  font-size: 0.78rem;
}

.tribute-record-panel p {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.72rem;
}

.my-play {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.center-play .turn-chip {
  margin-top: 2px;
}

.hand-player {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hand-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.avatar.small {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--felt);
  font-weight: 900;
}

.flush-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.selected-card-zone {
  min-width: 128px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px dashed rgba(21, 97, 77, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.selected-card-zone.has-selection {
  background: rgba(240, 192, 90, 0.14);
  border-style: solid;
}

.selected-card-zone em {
  width: 100%;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.selected-card {
  width: 32px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: start;
  justify-items: start;
  padding: 4px;
  border: 1px solid #d9dddc;
  border-radius: 6px;
  color: #111;
  background: linear-gradient(180deg, #fff, #edf1ef);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.14);
}

.selected-card span,
.selected-card b {
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.selected-card b {
  align-self: end;
}

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

.flush-tools > span {
  font-weight: 900;
  color: var(--muted);
}

.suit-pick {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.45);
  background: #7b8883;
  font-size: 1.18rem;
  font-weight: 900;
}

.suit-pick.available {
  color: white;
  background: var(--felt);
  box-shadow: 0 0 0 3px rgba(240, 192, 90, 0.35);
}

.suit-pick[data-flush="hearts"],
.suit-pick[data-flush="diamonds"] {
  color: rgba(255, 225, 225, 0.58);
}

.suit-pick.available[data-flush="hearts"],
.suit-pick.available[data-flush="diamonds"] {
  color: #ffe6e7;
}

.stacked-hand {
  min-height: 150px;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(2px, 0.55vw, 8px);
  overflow: visible;
  padding: 8px 4px 6px;
}

.hand {
  overflow-x: hidden;
}

.card-stack {
  position: relative;
  flex: 1 1 var(--card-w);
  max-width: var(--card-w);
  width: var(--card-w);
  height: calc(var(--card-h) + (var(--stack-count) - 1) * var(--stack-gap));
  min-height: var(--card-h);
  cursor: pointer;
}

.card-stack .card {
  position: absolute;
  left: 0;
  top: calc(var(--stack-index) * var(--stack-gap));
  width: var(--card-w);
  height: var(--card-h);
  margin-left: 0;
  flex-basis: auto;
  pointer-events: none;
  z-index: var(--stack-index);
}

.card-stack .card.selected {
  transform: translateY(-12px);
}

.card.wild span {
  color: var(--red);
}

.hand-zone.readonly {
  opacity: 0.94;
}

.hand-zone.readonly .card {
  cursor: default;
}

.report-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 35, 30, 0.52);
  backdrop-filter: blur(3px);
}

.report-card {
  width: min(520px, 96%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  color: white;
  background: rgba(9, 52, 43, 0.92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.report-card h2 {
  margin: 0 0 12px;
}

.report-card p {
  margin: 8px 0;
  color: rgba(255, 255, 255, 0.84);
}

.report-list {
  max-height: 220px;
  overflow: auto;
  margin: 10px 0;
}

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

.seat-order-panel {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 92px;
  translate: -50% 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  gap: 6px;
  width: min(430px, calc(100% - 460px));
}

.seat-order-chip {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  color: white;
  background: rgba(5, 38, 32, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  cursor: grab;
}

.seat-order-chip:active {
  cursor: grabbing;
}

.seat-order-chip.selected-seat-order {
  box-shadow: 0 0 0 3px rgba(240, 192, 90, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.seat-order-chip b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.seat-order-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-head {
  grid-column: 1 / -1;
}

@media (max-width: 1080px) {
  .rank-counter div {
    grid-template-columns: repeat(8, minmax(24px, 1fr));
  }

  .center-play {
    left: 180px;
    right: 180px;
  }

  .top-side {
    top: 188px;
  }

  .seat-wrap.right-seat {
    top: 315px;
  }
}

@media (max-width: 760px) {
  .create-head {
    align-items: flex-start;
  }

  .rank-counter {
    width: 100%;
  }

  .seat-wrap {
    width: 150px;
  }

  .seat-wrap.top-seat {
    top: 132px;
  }

  .seat-wrap.right-seat {
    right: 8px;
    top: 216px;
  }

  .seat-wrap.left-seat {
    left: 8px;
    top: 40%;
  }

  .top-side {
    display: none;
  }

  .center-play {
    left: 12px;
    right: 12px;
    top: 335px;
  }

  .hand-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .flush-tools {
    justify-content: flex-start;
  }

  .card-stack {
    flex-basis: 54px;
    width: 54px;
  }

  .card-stack .card {
    width: 54px;
    height: 80px;
  }
}

/* Final responsive overrides for the game table. */
@media (max-width: 1080px) {
  .rank-counter div {
    grid-template-columns: repeat(15, minmax(18px, 1fr));
    gap: 1px;
  }

  .rank-counter span,
  .rank-counter b {
    min-width: 18px;
    font-size: 0.68rem;
  }

  .top-side {
    display: grid;
    top: 80px;
    right: 16px;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  :root {
    --card-w: clamp(28px, 6vw, 44px);
    --stack-gap: clamp(9px, 2.2vw, 16px);
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    padding: 6px;
  }

  .game-layout {
    height: calc(100dvh - 12px);
    min-height: calc(100dvh - 12px);
    gap: 6px;
    overflow: hidden;
  }

  .game-layout.has-game .lobby {
    display: none;
  }

  .table-board {
    height: calc(100dvh - 12px);
    min-height: 0;
  }

  .table-topline {
    left: 6px;
    right: 6px;
    top: 6px;
    gap: 3px;
  }

  .level-cell {
    min-width: 58px;
    padding: 3px 5px;
    font-size: 0.68rem;
  }

  .rank-counter {
    width: 100%;
    padding: 2px 3px;
  }

  .rank-counter div {
    grid-template-columns: repeat(15, minmax(13px, 1fr));
    gap: 0;
  }

  .rank-counter span,
  .rank-counter b {
    min-width: 13px;
    font-size: 0.52rem;
  }

  .seat-order-panel {
    top: 72px;
    width: calc(100% - 12px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .seat-order-chip {
    min-height: 32px;
    padding: 3px;
    gap: 2px;
  }

  .seat-order-chip b {
    width: 20px;
    height: 20px;
  }

  .seat-order-chip span {
    font-size: 0.62rem;
  }

  .seat-wrap {
    width: 138px;
  }

  .seat {
    min-height: 56px;
    padding: 6px;
    gap: 6px;
  }

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

  .seat strong {
    font-size: 0.78rem;
  }

  .seat span,
  .seat em {
    font-size: 0.66rem;
  }

  .seat-wrap.top-seat {
    top: 118px;
  }

  .seat-wrap.left-seat,
  .seat-wrap.right-seat {
    top: 270px;
  }

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

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

  .top-side {
    display: block;
    top: 172px;
    right: 8px;
    width: 176px;
  }

  .chat {
    padding: 8px;
  }

  .chat-log {
    min-height: 34px;
    max-height: 68px;
  }

  .chat-form {
    grid-template-columns: 1fr auto;
  }

  .center-play {
    top: 405px;
    left: 10px;
    right: 10px;
    min-height: 104px;
    gap: 6px;
  }

  .table-actions {
    justify-content: center;
    gap: 5px;
  }

  .btn {
    min-height: 30px;
    padding: 0 9px;
    font-size: 0.74rem;
  }

  .turn-chip {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .my-play {
    min-height: 32px;
  }

  .hand-zone {
    left: 6px;
    right: 6px;
    bottom: 6px;
    padding: 7px;
  }

  .hand-meta {
    margin-bottom: 3px;
  }

  .stacked-hand {
    min-height: 88px;
  }

  .card-stack {
    flex-basis: var(--card-w);
    width: var(--card-w);
  }

  .card-stack .card {
    width: var(--card-w);
    height: var(--card-h);
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  :root {
    --card-w: clamp(25px, 4.1vw, 42px);
    --stack-gap: clamp(8px, 1.55vw, 14px);
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    padding: 4px;
  }

  .game-layout {
    grid-template-columns: 205px minmax(0, 1fr);
    height: calc(100dvh - 8px);
    min-height: calc(100dvh - 8px);
    gap: 6px;
    overflow: hidden;
  }

  .game-layout.has-game {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-layout.has-game .lobby {
    display: none;
  }

  .panel {
    padding: 8px;
  }

  .compact-form {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .table-board {
    height: calc(100dvh - 8px);
    min-height: 0;
  }

  .table-topline {
    left: 8px;
    right: 8px;
    top: 6px;
    gap: 4px;
  }

  .level-cell {
    min-width: 58px;
    padding: 3px 5px;
    font-size: 0.66rem;
  }

  .rank-counter {
    padding: 2px 4px;
  }

  .rank-counter div {
    grid-template-columns: repeat(15, minmax(13px, 1fr));
    gap: 0;
  }

  .rank-counter span,
  .rank-counter b {
    min-width: 13px;
    font-size: 0.54rem;
  }

  .seat-order-panel {
    top: 54px;
    width: min(360px, calc(100% - 390px));
  }

  .seat-wrap {
    width: 128px;
  }

  .seat {
    min-height: 54px;
    padding: 6px;
    gap: 6px;
  }

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

  .seat span,
  .seat em {
    font-size: 0.66rem;
  }

  .seat-wrap.top-seat {
    top: 82px;
  }

  .seat-wrap.left-seat,
  .seat-wrap.right-seat {
    top: 182px;
  }

  .top-side {
    display: block;
    top: 66px;
    right: 8px;
    width: 166px;
  }

  .chat {
    padding: 8px;
  }

  .chat-log {
    min-height: 30px;
    max-height: 62px;
  }

  .center-play {
    top: 194px;
    left: 142px;
    right: 142px;
    min-height: 112px;
    gap: 5px;
  }

  .table-actions {
    justify-content: center;
    gap: 5px;
  }

  .btn {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .turn-chip {
    min-height: 28px;
    padding: 0 9px;
    font-size: 0.74rem;
  }

  .hand-zone {
    left: 8px;
    right: 8px;
    bottom: 5px;
    padding: 6px;
  }

  .hand-meta {
    margin-bottom: 3px;
  }

  .stacked-hand {
    min-height: 80px;
  }

  .card-stack {
    flex-basis: var(--card-w);
    width: var(--card-w);
  }

  .card-stack .card {
    width: var(--card-w);
    height: var(--card-h);
  }
}

@media (min-width: 921px) {
  .center-play {
    top: auto;
    bottom: clamp(238px, 33dvh, 285px);
    min-height: 132px;
    gap: 8px;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  .center-play {
    top: auto;
    bottom: clamp(104px, 27dvh, 132px);
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .center-play {
    top: auto;
    bottom: clamp(116px, 20dvh, 154px);
  }
}

@media (max-width: 760px) {
  .selected-card-zone {
    min-width: 98px;
    min-height: 38px;
    gap: 3px;
    padding: 3px;
  }

  .selected-card {
    width: 28px;
    height: 37px;
    padding: 3px;
  }

  .selected-card span,
  .selected-card b {
    font-size: 0.6rem;
  }
}

/* Mobile table fit refinements. */
@media (max-width: 760px) and (orientation: portrait) {
  :root {
    --card-w: clamp(30px, 6.8vw, 42px);
    --stack-gap: clamp(20px, 4.6vw, 24px);
  }

  html,
  body,
  #app,
  .app-shell,
  .game-layout,
  .table-wrap,
  .table-board {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden !important;
  }

  .app-shell {
    padding: 4px;
  }

  .table-board {
    height: calc(100dvh - 8px);
  }

  .top-side {
    display: block;
    top: 160px;
    left: auto !important;
    right: 6px;
    width: min(124px, 32vw);
    z-index: 4;
  }

  .chat {
    padding: 5px;
  }

  .voice-tools {
    margin-bottom: 4px;
  }

  .chat-log {
    min-height: 0;
    max-height: 28px;
    font-size: 0.58rem;
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px;
  }

  .chat-form input {
    min-width: 0;
    height: 26px;
    font-size: 0.66rem;
  }

  .seat-wrap {
    width: 124px;
  }

  .seat-wrap.left-seat,
  .seat-wrap.right-seat {
    top: 246px;
  }

  .seat-wrap.top-seat {
    top: 104px;
  }

  .center-play {
    top: auto;
    bottom: clamp(220px, 29dvh, 248px);
    left: 8px;
    right: 8px;
    min-height: 58px;
    gap: 4px;
  }

  .my-play {
    min-height: 24px;
  }

  .hand-zone {
    left: 4px;
    right: 4px;
    bottom: 4px;
    max-height: 214px;
    padding: 5px;
    overflow: hidden;
  }

  .hand-meta {
    gap: 4px;
    margin-bottom: 2px;
  }

  .hand-player {
    gap: 5px;
  }

  .avatar.small {
    width: 28px;
    height: 28px;
  }

  .hand-status .btn,
  .flush-tools .btn {
    min-height: 26px;
    padding: 0 7px;
  }

  .flush-tools {
    gap: 4px;
  }

  .suit-pick {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }

  .selected-card-zone {
    min-width: 86px;
  }

  .stacked-hand {
    min-height: 132px;
    padding: 3px 2px 2px;
  }

  .card span {
    font-size: 0.82rem;
  }

  .card b {
    font-size: 0.78rem;
  }

  .tribute-record-panel {
    left: 6px;
    top: 52px;
    max-width: 160px;
    padding: 6px;
  }

  .tribute-record-panel p {
    font-size: 0.6rem;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  :root {
    --card-w: clamp(22px, 3.45vw, 34px);
    --stack-gap: clamp(13px, 2vw, 16px);
  }

  html,
  body,
  #app,
  .app-shell,
  .game-layout,
  .table-wrap,
  .table-board {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden !important;
  }

  .table-board {
    height: calc(100dvh - 6px);
  }

  .table-topline {
    top: 4px;
  }

  .seat-wrap {
    width: 112px;
  }

  .seat-wrap.top-seat {
    top: 58px;
  }

  .seat-wrap.left-seat,
  .seat-wrap.right-seat {
    top: 138px;
  }

  .top-side {
    top: 44px;
    left: auto !important;
    right: 6px;
    width: 132px;
  }

  .chat {
    padding: 5px;
  }

  .chat-log {
    min-height: 0;
    max-height: 22px;
    font-size: 0.58rem;
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px;
  }

  .chat-form input {
    min-width: 0;
    height: 25px;
    font-size: 0.64rem;
  }

  .center-play {
    top: auto;
    bottom: clamp(98px, 28dvh, 118px);
    left: 120px;
    right: 140px;
    min-height: 58px;
    gap: 3px;
  }

  .my-play {
    min-height: 22px;
  }

  .hand-zone {
    left: 6px;
    right: 6px;
    bottom: 3px;
    max-height: 106px;
    padding: 4px;
    overflow: hidden;
  }

  .hand-meta {
    align-items: center;
    gap: 5px;
    margin-bottom: 1px;
  }

  .avatar.small {
    width: 26px;
    height: 26px;
  }

  .flush-tools {
    gap: 4px;
  }

  .suit-pick {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .selected-card-zone {
    min-width: 78px;
    min-height: 32px;
  }

  .stacked-hand {
    min-height: 58px;
    padding: 2px 2px 1px;
  }
}
