:root {
  --green: #245e49;
  --green-deep: #153f34;
  --felt: #1d5340;
  --paper: #fbfaf4;
  --paper-2: #eef0e5;
  --paper-3: #e4e5d8;
  --ink: #263b32;
  --muted: #7a847b;
  --red: #a94434;
  --red-soft: #b34132;
  --gold: #d8bf79;
  --gold-soft: #e6d0a0;
  --line: #d9ddcf;
  --radius: 18px;
  --shadow: 0 18px 44px rgba(21, 63, 52, 0.16);
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", STSong, Georgia, serif;
}

* {
  box-sizing: border-box;
}

/* hidden 属性优先于各模块的 display 设定。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 8%, rgba(216, 191, 121, 0.28), transparent 34%),
    radial-gradient(circle at 88% 0%, rgba(36, 94, 73, 0.16), transparent 30%),
    linear-gradient(160deg, #fbfaf4 0%, #f4f2e8 52%, #eceee2 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
.piece:focus-visible,
.pile-stack:focus-visible,
.close-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 34px) 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 首页的大标题已经写着棋名，顶栏只留印章。 */
body.is-home .brand > div {
  display: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: var(--gold-soft);
  background: linear-gradient(150deg, var(--green), var(--green-deep));
  border: 1px solid rgba(216, 191, 121, 0.55);
  font-family: var(--font-serif);
  font-size: 24px;
  box-shadow: 0 8px 18px rgba(21, 63, 52, 0.22);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 26px;
  letter-spacing: 2px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 244, 0.8);
  color: var(--ink);
  font-size: 13px;
  transition: 0.16s ease;
}

.pill:hover {
  border-color: var(--gold);
  background: #fffdf3;
}

.pill[aria-pressed="false"] {
  color: var(--muted);
}

/* ---------- 首页 ---------- */

.home {
  display: grid;
  gap: 18px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head scene"
    "foot scene";
  align-items: center;
  column-gap: clamp(18px, 4vw, 56px);
  row-gap: 8px;
  padding: clamp(26px, 4vw, 48px) clamp(20px, 4vw, 56px);
  border-radius: 30px;
  color: #f7f4e6;
  background:
    radial-gradient(ellipse at 76% 34%, rgba(96, 168, 132, 0.3), transparent 58%),
    radial-gradient(circle at 8% 0%, rgba(216, 191, 121, 0.16), transparent 46%),
    linear-gradient(155deg, #17493a 0%, #1d5641 55%, #0f2f27 100%);
  border: 1px solid rgba(216, 191, 121, 0.42);
  box-shadow: var(--shadow);
}

/* 桌沿：内凹的绿毯与一圈金线。 */
.hero::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 22px;
  border: 1px solid rgba(230, 208, 160, 0.18);
  box-shadow:
    inset 0 0 70px rgba(6, 24, 18, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.hero-glow {
  position: absolute;
  left: 24%;
  right: -10%;
  bottom: -46%;
  height: 90%;
  background: radial-gradient(ellipse at center, rgba(120, 200, 160, 0.16), transparent 68%);
  pointer-events: none;
}

.hero-head {
  grid-area: head;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  justify-items: start;
}

.hero-tag {
  margin: 0;
  color: var(--gold-soft);
  font-size: 12px;
  letter-spacing: 3px;
}

.hero-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 700;
  letter-spacing: 8px;
  line-height: 1.08;
  color: #f8f1da;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.12),
    0 16px 34px rgba(4, 18, 13, 0.5);
}

.hero-lead {
  margin: 0;
  max-width: 30ch;
  color: rgba(247, 244, 230, 0.76);
  font-size: 14px;
  line-height: 1.9;
}

.hero-foot {
  grid-area: foot;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  justify-items: start;
  margin-top: 14px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-cta {
  padding: 15px 40px;
  border-radius: 14px;
  font-size: 16px;
  letter-spacing: 6px;
  box-shadow: 0 16px 30px rgba(9, 32, 25, 0.35);
}

.hero-cta-2 {
  padding: 15px 26px;
  border-radius: 14px;
  font-size: 14px;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: rgba(247, 244, 230, 0.6);
  font-size: 12px;
  letter-spacing: 1px;
}

.hero-facts strong {
  margin-right: 4px;
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

/* 俯视的棋桌：三家围坐，中间摆着这一轮出的棋。 */
.hero-scene {
  grid-area: scene;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 26px);
}

.scene-table {
  position: relative;
  width: clamp(220px, 24vw, 280px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2f6f57, #14402f 74%);
  border: 1px solid rgba(216, 191, 121, 0.3);
  box-shadow:
    inset 0 20px 40px rgba(4, 18, 13, 0.55),
    inset 0 -12px 26px rgba(0, 0, 0, 0.35),
    0 26px 46px rgba(4, 18, 13, 0.45);
}

.scene-table::before {
  content: "";
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  border: 1px dashed rgba(230, 208, 160, 0.16);
}

.scene-seat {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.scene-seat .seat-avatar {
  width: 46px;
  height: 46px;
  box-shadow:
    0 8px 18px rgba(4, 18, 13, 0.45),
    inset 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.scene-name {
  color: rgba(247, 244, 230, 0.72);
  font-size: 11px;
  letter-spacing: 1px;
}

.scene-seat-nw {
  top: -12px;
  left: -6px;
}

.scene-seat-nw .seat-avatar {
  background: linear-gradient(160deg, #c45643, #9c3a2c);
}

.scene-seat-ne {
  top: -12px;
  right: -6px;
}

.scene-seat-ne .seat-avatar {
  background: linear-gradient(160deg, #4a7fb5, #2f5d8c);
}

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

#hero-fan {
  position: absolute;
  inset: 0;
}

#hero-fan .piece {
  position: absolute;
  left: 50%;
  top: 50%;
}

.primary-button,
.secondary-button,
.text-button {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 11px 20px;
  font-size: 14px;
  transition: transform 0.14s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-button {
  color: #1d3d31;
  background: linear-gradient(160deg, #f0dcae, var(--gold));
  box-shadow: 0 10px 22px rgba(21, 63, 52, 0.22);
  font-weight: 600;
}

.primary-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(21, 63, 52, 0.26);
}

.secondary-button {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}

.secondary-button:not(:disabled):hover {
  border-color: var(--gold);
  background: #fffdf3;
}

.text-button {
  color: var(--green);
  background: transparent;
  border-color: transparent;
  padding-inline: 12px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hero .secondary-button {
  color: #f3eeda;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(230, 208, 160, 0.42);
}

.hero .secondary-button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.16);
}

.room-panel {
  display: grid;
}

.room-card {
  padding: 24px;
  border-radius: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(38, 59, 50, 0.08);
}

.room-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 1px;
}

.room-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.room-join input {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.room-join input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 94, 73, 0.12);
}

.room-buttons,
.room-join {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.room-join {
  margin-top: 14px;
}

.room-join input {
  flex: 1 1 180px;
  letter-spacing: 2px;
}

.error-message {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

/* ---------- 棋桌 ---------- */

.table-section {
  display: grid;
  gap: 16px;
}

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.table-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(36, 94, 73, 0.22);
  background: rgba(36, 94, 73, 0.08);
  color: var(--green);
  font-size: 12px;
  letter-spacing: 1px;
}

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

.game-table {
  position: relative;
  /* 桌面高度跟着视口走：矮屏自动收矮，保证手棋和按钮一屏放得下。 */
  min-height: clamp(460px, calc(100dvh - 190px), 700px);
  padding: 20px;
  border-radius: 30px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(216, 191, 121, 0.1), transparent 46%),
    linear-gradient(180deg, #12362a 0%, #173f33 48%, #0f2f25 100%);
  border: 1px solid rgba(216, 191, 121, 0.5);
  box-shadow: inset 0 0 0 8px rgba(21, 63, 52, 0.35), 0 22px 50px rgba(21, 63, 52, 0.22);
}

.game-table::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(760px, 88%);
  height: 76%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 62%, #30765e 0%, #1d5340 52%, #113528 100%);
  border: 1px solid rgba(216, 191, 121, 0.7);
  box-shadow:
    inset 0 0 0 12px rgba(21, 63, 52, 0.35),
    inset 0 30px 60px rgba(0, 0, 0, 0.28),
    inset 0 -16px 34px rgba(0, 0, 0, 0.24),
    0 10px 0 #0a2418,
    0 32px 60px rgba(9, 32, 25, 0.5);
  pointer-events: none;
}

.game-table::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(660px, 78%);
  height: 64%;
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(230, 208, 160, 0.28);
  border-radius: 50%;
  pointer-events: none;
}

.seat {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  text-align: center;
  transition: 0.2s ease;
}

.seat-south {
  bottom: 12px;
  left: 18px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.seat-south .seat-avatar {
  width: 52px;
  height: 52px;
}

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

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

.seat-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(160deg, #2f745e, #1d5340);
  box-shadow: 0 6px 16px rgba(9, 32, 25, 0.4), inset 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.seat-northwest .seat-avatar {
  background: linear-gradient(160deg, #c45643, #9c3a2c);
}

.seat-northeast .seat-avatar {
  background: linear-gradient(160deg, #4a7fb5, #2f5d8c);
}

.seat-avatar svg {
  width: 72%;
  height: 72%;
  fill: #f6f1dd;
}

.seat-pile-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  color: #fff;
  background: rgba(21, 63, 52, 0.94);
  box-shadow: 0 2px 5px rgba(9, 32, 25, 0.3);
  white-space: nowrap;
}

.seat-pile-badge.enough {
  color: #4b3509;
  background: var(--gold-soft);
}

.seat-pile-badge.double {
  background: var(--red);
}

.seat.is-active .seat-avatar {
  box-shadow: 0 0 0 3px var(--gold), 0 6px 16px rgba(9, 32, 25, 0.4);
}

.seat.is-active .seat-name {
  color: var(--gold-soft);
}

.seat-hand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.seat-hand .piece + .piece {
  margin-left: -18px;
}

.seat-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 1px;
  color: #f4efdb;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}

.seat-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(9, 32, 25, 0.55);
  color: var(--gold-soft);
  font-size: 10px;
}

.seat-status {
  color: rgba(244, 239, 219, 0.8);
  font-size: 11px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.seat-timer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: fit-content;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, #2f745e, #1d5340);
  box-shadow: 0 2px 6px rgba(9, 32, 25, 0.25);
}

.seat-timer::before {
  content: "⏰";
  font-size: 11px;
}

/* 对手出棋时，倒计时贴在头像右下角，不占座位下方空间。 */
.seat-timer.is-badge {
  position: absolute;
  right: -10px;
  bottom: -6px;
  padding: 2px 7px;
  font-size: 11px;
  box-shadow: 0 3px 8px rgba(9, 32, 25, 0.45);
}

.seat-timer.is-urgent {
  background: linear-gradient(180deg, #e2574b, #b03a2e);
  animation: seat-timer-pulse 1s ease-in-out infinite;
}

@keyframes seat-timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.table-center {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100% - 420px));
  min-width: 260px;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.turn-banner {
  color: #f4efdb;
  font-family: var(--font-serif);
  font-size: clamp(15px, 2vw, 19px);
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

/* ---------- 每一手摆在自己面前 ---------- */

.play-zone {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  max-width: 240px;
}

/* 每一手按「自家 → 桌子中央」的顺序排：先赢棋摞，再是刚出的棋。 */
.play-zone-south {
  bottom: 38%;
  left: 50%;
  transform: translateX(-50%);
}

.play-zone-northwest {
  top: 38%;
  left: 26%;
  transform: translateX(-50%);
}

.play-zone-northeast {
  top: 38%;
  left: 74%;
  transform: translateX(-50%);
}

/* 收棋：三家出的棋一起飞向赢家的摞 */
.play-zone.is-collecting {
  z-index: 5;
}

.play-zone.is-collecting .piece {
  animation: collect-fly 0.7s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
}

@keyframes collect-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  45% {
    transform: translate(calc(var(--dx, 0px) * 0.2), calc(var(--dy, 0px) * 0.2)) scale(1.08);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(0.5);
    opacity: 0;
  }
}

/* ---------- 桌面上的赢棋摞 ---------- */

.pile-zone {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  max-width: 320px;
}

.pile-zone-south {
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  justify-content: center;
}

.pile-zone-northwest {
  top: 28%;
  left: 26%;
  transform: translateX(-50%);
}

.pile-zone-northeast {
  top: 28%;
  left: 74%;
  transform: translateX(-50%);
}

.pile-stack {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 6px 8px rgba(9, 32, 25, 0.32));
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* 单张一摞；对子/三卒并排多摞。每摞里三家的棋往上错开 5px，露出下层的边。 */
.pile-column {
  position: relative;
  width: 34px;
  height: calc(34px + (var(--layers, 1) - 1) * 5px);
}

.pile-column .stack-layer {
  position: absolute;
  left: 0;
  bottom: calc(var(--layer, 0) * 5px);
  z-index: calc(var(--layer, 0) + 1);
}

.pile-stack:hover {
  transform: translateY(-3px);
}

.pile-stack.is-open {
  filter: drop-shadow(0 0 6px rgba(216, 191, 121, 0.9));
}

/* 回看：在这摞棋原地直接铺开，不加任何框。 */
.pile-spread {
  position: absolute;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  max-width: min(360px, 78vw);
}

.pile-zone-south .pile-spread {
  bottom: calc(100% + 10px);
}

.pile-zone-northwest .pile-spread,
.pile-zone-northeast .pile-spread {
  top: calc(100% + 10px);
}

.game-table.is-spreading .table-center {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.pile-spread-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(9, 32, 25, 0.75);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.pile-spread-close:hover {
  background: var(--green);
}

.pile-spread-row {
  display: flex;
  align-items: center;
  gap: 5px;
  filter: drop-shadow(0 4px 6px rgba(9, 32, 25, 0.35));
}

/* ---------- 棋子 ---------- */

.piece {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #e0d5b0;
  background:
    radial-gradient(circle at 50% 120%, rgba(120, 100, 60, 0.3), transparent 58%),
    radial-gradient(circle at 32% 24%, #ffffff, #f4eedb 48%, #e0d2ac 88%, #cbb987 100%);
  box-shadow:
    0 2px 0 #d8cfae,
    0 4px 0 #bfae7c,
    0 6px 0 #a4905a,
    0 7px 0 #8a7544,
    0 13px 22px rgba(9, 32, 25, 0.5),
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -4px 8px rgba(120, 100, 60, 0.22);
  transition: transform 0.14s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.piece-glyph {
  font-family: var(--font-serif);
  font-size: 25px;
  line-height: 1;
  font-weight: 600;
}

.piece.red {
  color: #b3402f;
}

.piece.black {
  color: #22332b;
}

.piece.mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow:
    0 2px 0 #cdbf97,
    0 3px 5px rgba(9, 32, 25, 0.28),
    inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.piece.mini .piece-glyph {
  font-size: 17px;
}

/* 扣着的棋子：真实棋子背面，不露牌面 */
.piece.back {
  border-color: #cbbd8f;
  background: radial-gradient(circle at 34% 26%, #3a7a63, #245b49 52%, #17402f 90%);
  box-shadow:
    0 3px 0 #102f24,
    0 5px 0 #0c261d,
    0 8px 12px rgba(9, 32, 25, 0.34),
    inset 0 0 0 2px rgba(216, 191, 121, 0.32);
}

.piece.back::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px solid rgba(216, 191, 121, 0.42);
  background: radial-gradient(circle, rgba(216, 191, 121, 0.16), transparent 70%);
}

.piece.back .piece-glyph {
  display: none;
}

.piece.back.mini {
  width: 34px;
  height: 34px;
  box-shadow:
    0 2px 0 #102f24,
    0 3px 5px rgba(9, 32, 25, 0.3),
    inset 0 0 0 2px rgba(216, 191, 121, 0.3);
}

.piece.back.mini::after {
  inset: 6px;
}

.discard-note {
  margin-left: 6px;
  color: rgba(244, 239, 219, 0.7);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.hand-card {
  cursor: pointer;
}

/* 手棋重叠铺开：相邻棋子压住前一枚，像手里攥着一把棋 */
.table-hand .hand .hand-card + .hand-card {
  margin-left: -10px;
}

.hand-card:hover {
  transform: translateY(-6px);
  z-index: 3;
}

.hand-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 191, 121, 0.7), 0 14px 26px rgba(9, 32, 25, 0.4);
  transform: translateY(-14px) scale(1.06);
  z-index: 4;
}

.hand-card:disabled {
  cursor: default;
}

/* ---------- 桌面手棋区（斗地主式，铺在绿毯底部） ---------- */

.table-hand {
  position: absolute;
  z-index: 4;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 28px);
}

.action-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(9, 32, 25, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 20px rgba(9, 32, 25, 0.3);
}

.action-tab {
  min-width: 88px;
  padding: 8px 22px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 239, 219, 0.86);
  font-size: 14px;
  letter-spacing: 3px;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.action-tab:not(:disabled):hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.action-tab:disabled {
  opacity: 0.35;
}

.action-tab.is-active {
  color: #1d3d31;
  background: linear-gradient(160deg, #f0dcae, var(--gold));
  box-shadow: 0 4px 12px rgba(9, 32, 25, 0.35);
  font-weight: 600;
}

.table-extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.hand {
  order: 3;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 58px;
}

.hand-empty {
  color: rgba(244, 239, 219, 0.78);
  font-size: 13px;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

/* ---------- 面板 ---------- */

.panel {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(38, 59, 50, 0.07);
}

.panel h3 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 1px;
}

.vote-panel {
  border-color: rgba(216, 191, 121, 0.75);
  background: #fffbee;
}

.vote-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(217, 221, 207, 0.9);
}

.vote-row:last-child {
  border-bottom: none;
}

.vote-state {
  color: var(--muted);
}

.vote-state.agree {
  color: var(--green);
}

.vote-state.challenge {
  color: var(--red);
}

.result-panel h3 {
  margin-bottom: 6px;
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(217, 221, 207, 0.9);
}

.result-line:last-of-type {
  border-bottom: none;
}

.result-score {
  font-family: var(--font-serif);
  font-size: 16px;
}

.result-score.positive {
  color: var(--green);
}

.result-score.negative {
  color: var(--red);
}

.result-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 房间条 ---------- */

.room-strip {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(38, 59, 50, 0.07);
  display: grid;
  gap: 12px;
}

.room-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.room-code {
  font-family: var(--font-serif);
  letter-spacing: 4px;
  font-size: 18px;
}

.room-seats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.room-seat {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid transparent;
  font-size: 12px;
}

.room-seat.is-viewer {
  border-color: rgba(36, 94, 73, 0.35);
  background: #f4f8f1;
}

.room-seat strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
  font-family: var(--font-serif);
}

.room-seat span {
  color: var(--muted);
}

.room-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.room-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* 退房这类次要动作用描边按钮，靠右放，不和主操作抢注意力。 */
.ghost-button {
  margin-left: auto;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 13px;
  opacity: 0.62;
  transition: opacity 0.16s ease, background 0.16s ease;
}

.ghost-button:not(:disabled):hover {
  opacity: 1;
  background: rgba(127, 127, 127, 0.12);
}

/* ---------- 抽屉与提示 ---------- */

.drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  padding: 22px;
  overflow-y: auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(21, 63, 52, 0.18);
  animation: slide-in 0.24s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(28px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: 1px;
}

.close-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.drawer-body {
  padding-top: 16px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
}

.drawer-body h3 {
  margin: 18px 0 6px;
  font-family: var(--font-serif);
  font-size: 15px;
}

.drawer-body h3:first-child {
  margin-top: 0;
}

.drawer-body p {
  margin: 6px 0;
  color: var(--muted);
}

.history-trick {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.history-trick h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.history-move {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.history-move strong {
  color: var(--ink);
  font-weight: 500;
  min-width: 44px;
}

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

.shuffle-scene {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 26px;
  background: rgba(13, 42, 33, 0.86);
  backdrop-filter: blur(3px);
  color: #f6f1dd;
}

.shuffle-ring {
  position: absolute;
  width: min(420px, 76vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(230, 208, 160, 0.25);
  box-shadow: 0 0 0 26px rgba(230, 208, 160, 0.05), 0 0 0 70px rgba(230, 208, 160, 0.03);
}

.shuffle-pieces {
  position: relative;
  width: min(360px, 70vw);
  height: min(360px, 70vw);
  display: grid;
  place-items: center;
}

.shuffle-piece {
  position: absolute;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fffef7, #ece4cd 58%, #e0d6ba);
  color: var(--green-deep);
  font-family: var(--font-serif);
  font-size: 15px;
  box-shadow: 0 2px 0 #cdbf97, 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  animation: sweep 1.1s ease-in-out infinite alternate;
  animation-delay: var(--delay, 0ms);
}

@keyframes sweep {
  0% {
    transform: translate(var(--start-x, 0), var(--start-y, 0)) rotate(var(--tilt, 0deg));
  }
  100% {
    transform: translate(var(--sweep-x, 0), var(--sweep-y, 0)) rotate(calc(var(--tilt, 0deg) * -1));
  }
}

.shuffle-caption {
  position: relative;
  text-align: center;
  z-index: 1;
}

.shuffle-caption strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 4px;
}

.shuffle-caption span {
  display: block;
  margin-top: 8px;
  color: rgba(246, 241, 221, 0.66);
  font-size: 12px;
  letter-spacing: 2px;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(21, 63, 52, 0.95);
  color: #f6f1dd;
  font-size: 13px;
  box-shadow: 0 14px 32px rgba(9, 32, 25, 0.32);
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 4px 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.is-thinking {
  animation: pulse 1.6s ease-in-out infinite;
}

@media (max-width: 900px) {
  .table-center {
    width: calc(100% - 80px);
  }

  .seat-south {
    bottom: 12px;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 14px 12px 22px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "scene"
      "foot";
    justify-items: center;
    row-gap: 20px;
    padding: 26px 18px 30px;
    border-radius: 24px;
    text-align: center;
  }

  .hero-head,
  .hero-foot {
    justify-items: center;
  }

  .hero-foot {
    width: 100%;
    justify-items: stretch;
    margin-top: 0;
  }

  .hero-title {
    font-size: clamp(38px, 12vw, 46px);
    letter-spacing: 8px;
  }

  .hero-lead {
    max-width: none;
    font-size: 15px;
    line-height: 1.85;
  }

  /* 按钮改成单列网格，避免窄屏并排时被裁掉。 */
  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
  }

  .hero-cta,
  .hero-cta-2 {
    width: 100%;
    padding: 15px 20px;
    text-align: center;
  }

  .hero-facts {
    justify-content: center;
    gap: 14px;
  }

  .scene-table {
    width: min(260px, 66vw);
    margin-bottom: 20px;
  }

  .game-table {
    padding: 12px;
    border-radius: 22px;
  }

  .game-table::before {
    width: 96%;
    height: 70%;
  }

  .game-table::after {
    width: 84%;
    height: 58%;
  }

  .seat-avatar {
    width: 48px;
    height: 48px;
  }

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

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

  /* 手机上对手手棋压紧一点，免得顶出桌沿。 */
  .seat-hand .piece + .piece {
    margin-left: -22px;
  }

  .seat-south {
    bottom: 10px;
    left: 10px;
  }

  .seat-south .seat-avatar {
    width: 44px;
    height: 44px;
  }

  .table-center {
    top: 46%;
    width: calc(100% - 28px);
  }

  .seat-name {
    font-size: 12px;
  }

  .piece {
    width: 42px;
    height: 42px;
  }

  .piece-glyph {
    font-size: 21px;
  }

  .hand-card.selected {
    transform: translateY(-12px) scale(1.05);
  }

  .table-hand .hand .hand-card + .hand-card {
    margin-left: -8px;
  }

  .table-hand {
    bottom: 10px;
  }

  .action-tabs {
    width: 100%;
  }

  .action-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 6px;
    font-size: 13px;
    letter-spacing: 1px;
  }

  .room-buttons > button {
    flex: 1 1 auto;
  }

  .room-buttons .ghost-button {
    flex-basis: 100%;
    margin-left: 0;
  }

  .table-meta {
    flex-wrap: wrap;
    row-gap: 6px;
  }

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

  .page-footer {
    flex-direction: column;
    gap: 4px;
  }

  .pile-zone {
    max-width: 200px;
  }

  .play-zone {
    max-width: 160px;
    min-height: 30px;
  }
}

/* ---------- 处理中提示 ---------- */

.busy-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}

.busy-indicator::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(36, 94, 73, 0.3);
  border-top-color: var(--green);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 弹层（邀请、确认） ---------- */

.overlay-layer {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(13, 42, 33, 0.5);
  backdrop-filter: blur(2px);
}

.overlay-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid rgba(216, 191, 121, 0.75);
  box-shadow: 0 24px 60px rgba(9, 32, 25, 0.4);
}

.overlay-card h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 1px;
}

.overlay-hint,
.overlay-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.overlay-input {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.overlay-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 94, 73, 0.12);
}

.overlay-code {
  margin: 0;
  color: var(--green);
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 3px;
}

.overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* 小屏手机再收一档，按钮铺满一行更好点。 */
@media (max-width: 420px) {
  .hero {
    padding: 20px 16px 24px;
  }

  .hero h2,
  .hero-title {
    font-size: 40px;
    letter-spacing: 8px;
  }

  .hero-actions {
    width: 100%;
  }

  .piece {
    width: 38px;
    height: 38px;
  }

  .piece-glyph {
    font-size: 19px;
  }

  .room-strip {
    padding: 14px;
  }

  .room-buttons > button {
    flex-basis: 100%;
  }
}
