/* 四人扑克界面 */

:root {
  --felt: #1a5c3a;
  --felt-deep: #0f3d28;
  --wood: #2c1810;
  --cream: #f3efe6;
  --ink: #1a1510;
  --gold: #e8b84a;
  --gold-hot: #f0a020;
  --danger: #b33a3a;
  --muted: #6b6458;
  --panel: rgba(18, 22, 30, 0.72);
  --panel-soft: rgba(22, 28, 38, 0.55);
  --line: rgba(255, 255, 255, 0.14);
  --card-w: 54px;
  --card-h: 78px;
  --radius: 12px;
  --font-display: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-card: "Georgia", "Times New Roman", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-display);
  color: var(--cream);
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(ellipse at 30% 20%, #245a38 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, #0a2e1c 0%, transparent 45%),
    linear-gradient(160deg, var(--felt) 0%, var(--felt-deep) 100%);
}

body {
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top top"
    "table log";
  min-height: 100vh;
}

.screen-game {
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.screen-game.theme-medieval {
  /* 主题伪元素相对对局屏定位 */
}

/* 牌桌+记录铺满；顶栏浮层；底栏小贴士 */
.screen-game .app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 236px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "table log"
    "tip log";
}

.screen-game .game-toolbar-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 248px;
  z-index: 30;
  grid-area: unset;
  width: auto;
  padding: 0;
  margin: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.screen-game .game-toolbar-bar > * {
  pointer-events: auto;
}

.screen-game .game-back {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(12, 16, 24, 0.55);
  border: 1px solid var(--line);
  font-size: 1.1rem;
  text-decoration: none;
}

.screen-game .game-toolbar {
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(12, 16, 24, 0.55);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.screen-game .game-toolbar .btn {
  padding: 7px 14px;
  font-size: 0.88rem;
  border-radius: 10px;
}

.screen-game .game-toolbar #btn-gallery {
  position: static;
  right: auto;
  bottom: auto;
  box-shadow: none;
  border-radius: 10px;
}

.game-tip-bar {
  grid-area: tip;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 16px;
  background: rgba(8, 12, 18, 0.72);
  border-top: 1px solid var(--line);
}

.game-tip-bar .hint {
  margin: 0;
  color: #c8c2b4;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.btn,
.card.playable,
.gallery-fab,
.gallery-item,
.draw-target {
  touch-action: manipulation;
}

.topbar {
  grid-area: top;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f7f1e4;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: #d9d0c0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #d9d0c0;
  cursor: pointer;
  user-select: none;
}

.scoreboard {
  display: none;
}

.table {
  grid-area: table;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  grid-template-rows: max-content minmax(0, 1fr) max-content;
  grid-template-areas:
    "top top top"
    "left center right"
    "bottom bottom bottom";
  /* 半透明遮罩，让背景图更透出来 */
  background:
    radial-gradient(ellipse at 50% 42%, rgba(232, 184, 74, 0.05) 0%, transparent 42%),
    radial-gradient(ellipse at 50% 50%, rgba(30, 48, 64, 0.18) 0%, transparent 70%),
    linear-gradient(180deg, rgba(6, 10, 16, 0.28) 0%, rgba(8, 14, 22, 0.38) 100%);
  border: none;
  border-radius: 0;
  padding: 44px 10px 8px 8px;
  min-height: 0;
  height: 100%;
  overflow: visible;
}

.seat {
  display: flex;
  min-width: 0;
  min-height: 0;
}

.seat.current .seat-info {
  outline: 2px solid var(--gold);
  background: rgba(232, 184, 74, 0.16);
  box-shadow: 0 0 0 1px rgba(232, 184, 74, 0.35);
}

.seat.finished {
  opacity: 0.55;
}

.seat-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.62);
  border: 1px solid var(--line);
  overflow: visible;
  backdrop-filter: blur(6px);
}

.seat-info .pname {
  font-weight: 700;
  white-space: nowrap;
}

.seat-info .meta {
  font-size: 0.78rem;
  color: #b8ae9c;
  white-space: nowrap;
}

.seat-info .avatar-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.avatar-box {
  position: relative;
  flex-shrink: 0;
  line-height: 0;
  overflow: visible;
}

/* 思考气泡：头像右上角外侧，三角指向头像 */
.think-bubble {
  position: absolute;
  z-index: 9;
  left: calc(100% + 6px);
  bottom: calc(100% + 6px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 9px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  white-space: nowrap;
}

.think-bubble span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8a9199;
  animation: think-dot 0.9s infinite ease-in-out;
}

.think-bubble span:nth-child(2) {
  animation-delay: 0.3s;
}

.think-bubble span:nth-child(3) {
  animation-delay: 0.6s;
}

.think-bubble::after {
  content: '';
  position: absolute;
  left: 8px;
  bottom: -5px;
  width: 11px;
  height: 11px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 1px;
}

@keyframes think-dot {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  35% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.goods-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.goods-tag.has {
  background: #c9a227;
  color: #1a1510;
}

.goods-tag.solo {
  background: #b33a3a;
  color: #fff8ee;
}

.goods-tag.none {
  background: #5c5348;
  color: #f0e8dc;
}

.seat-info .pts {
  color: var(--gold);
  font-weight: 700;
}

.seat-top {
  grid-area: top;
  /* 头像在左、手牌在右，整体贴顶 */
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding: 0 12px 4px;
  margin: 0;
  width: 100%;
}

.seat-top .seat-info {
  flex-shrink: 0;
  /* 下移一点，给头像右上角思考气泡留出空间 */
  margin: 22px 0 0;
  padding: 4px 10px 4px 4px;
}

.seat-top .hand {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  /* 参考图：对手手牌玻璃牌槽 */
  padding: 10px 14px 8px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.seat-left {
  grid-area: left;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding-left: 4px;
}

.seat-right {
  grid-area: right;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding-right: 6px;
}

.seat-left .hand.vertical,
.seat-right .hand.vertical {
  padding: 8px 8px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  max-height: min(360px, 48vh);
  overflow: hidden;
}

.table-bottom {
  grid-area: bottom;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}

.seat-bottom {
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  width: 100%;
  gap: 10px;
}

.seat-bottom .hand {
  flex: 1;
  min-width: 0;
}

.seat-bottom .seat-info {
  flex-shrink: 0;
  margin: 0 4px 8px 0;
}

.hand {
  display: flex;
  position: relative;
}

.hand.horizontal {
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  max-width: 100%;
  overflow: hidden;
  padding: 12px 8px 4px;
}

.seat-top .hand.horizontal {
  padding: 8px 18px 6px;
  align-items: center;
}

.hand.horizontal .card {
  margin-left: -18px;
  flex-shrink: 0;
}

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

.hand.vertical {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 10px;
}

.hand.vertical .card {
  margin-top: -24px;
  flex-shrink: 0;
}

.hand.vertical .card:first-child {
  margin-top: 0;
}

.seat-top .card,
.seat-left .card,
.seat-right .card {
  width: 66px;
  height: 93px;
}

.seat-bottom .card {
  width: 72px;
  height: 104px;
}

.seat-top .hand.horizontal .card {
  margin-left: -24px;
}

.seat-bottom .hand.horizontal .card {
  margin-left: -8px;
}

.seat-bottom .hand.horizontal {
  padding-top: 18px;
}

.seat-bottom .hand.horizontal .card:first-child {
  margin-left: 0;
}

.center-info {
  grid-area: center;
  text-align: center;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  justify-items: stretch;
  padding: 14px 16px;
  margin: 4px 14px;
  background:
    radial-gradient(circle at 50% 48%, rgba(232, 184, 74, 0.1) 0%, transparent 38%),
    rgba(12, 16, 24, 0.42);
  border-radius: 18px;
  border: 1px solid rgba(232, 184, 74, 0.28);
  min-width: 0;
  min-height: 0;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.28),
    0 10px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.center-mid {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) minmax(0, 1.4fr) minmax(70px, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 0;
  width: 100%;
}

.center-core {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.center-play {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  min-width: 0;
}

.center-play-left,
.center-play-right {
  min-height: 72px;
}

.center-play-left .seat-play-cards,
.center-play-right .seat-play-cards {
  flex-direction: column;
}

.center-play-left .seat-play-cards .card.tiny,
.center-play-right .seat-play-cards .card.tiny {
  margin-left: 0;
  /* 竖排重叠：与横排 -40px 接近的可见条比例 */
  margin-top: -58px;
}

.center-play-left .seat-play-cards .card.tiny:first-child,
.center-play-right .seat-play-cards .card.tiny:first-child {
  margin-top: 0;
}

.center-play-left .seat-play--fresh .seat-play-cards .card.tiny,
.center-play-right .seat-play--fresh .seat-play-cards .card.tiny {
  margin-top: -72px;
}

.center-play-left .seat-play--fresh .seat-play-cards .card.tiny:first-child,
.center-play-right .seat-play--fresh .seat-play-cards .card.tiny:first-child {
  margin-top: 0;
}

.seat-play {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.seat-play-cards {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 24px;
}

/* 旧出牌略小，最新一手略大，对比清晰即可 */
.seat-play-cards .card.tiny {
  width: 69px;
  height: 99px;
  margin-left: -12px;
  flex-shrink: 0;
  transition: width 0.18s ease, height 0.18s ease, margin-left 0.18s ease;
  opacity: 0.60;
}

.seat-play-cards .card.tiny:first-child {
  margin-left: 0;
}

.seat-play--fresh .seat-play-cards .card.tiny {
  width: 84px;
  height: 120px;
  margin-left: -12px;
  opacity: 1;
}

.seat-play--fresh .seat-play-cards .card.tiny:first-child {
  margin-left: 0;
}

.seat-pass {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(18, 22, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #f3efe6;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.turn-info {
  font-size: 1.08rem;
  font-weight: 700;
  color: #f7f1e4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.last-play {
  margin-top: 10px;
  color: #e8dfcf;
  min-height: 1.4em;
  text-align: left;
}

.last-play-empty {
  text-align: center;
  color: #cfc5b4;
}

.last-play-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.last-play-who {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

.last-play-who .play-label {
  color: var(--gold);
  font-weight: 700;
}

.last-play-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 2px 8px;
}

.last-play-cards .card.tiny {
  margin: 0;
}

.hand.vertical::-webkit-scrollbar,
.hand.horizontal::-webkit-scrollbar,
.last-play-cards::-webkit-scrollbar,
.log::-webkit-scrollbar,
.log-cards::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.hand.vertical::-webkit-scrollbar-thumb,
.hand.horizontal::-webkit-scrollbar-thumb,
.last-play-cards::-webkit-scrollbar-thumb,
.log::-webkit-scrollbar-thumb,
.log-cards::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 8px;
}

.team-info {
  margin-top: 0;
  font-size: 0.9rem;
  color: #b8ae9c;
}

.players {
  display: none;
}

.player-row {
  display: none;
}

.card {
  appearance: none;
  -webkit-appearance: none;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: #fff;
  border: none;
  display: block;
  overflow: hidden;
  cursor: default;
  user-select: none;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
  transition: transform 0.12s, box-shadow 0.12s;
  padding: 0;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.card.tiny {
  width: 48px;
  height: 68px;
}

.card.back {
  background-color: #101d38;
  background-image: none;
  padding: 0;
}

.card.back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.seat.current .card.playable {
  cursor: pointer;
}

.seat-bottom .card.playable:hover {
  transform: translateY(-12px);
  z-index: 8;
}

.seat-left .card.playable:hover {
  transform: translateX(10px);
  z-index: 8;
}

.seat-right .card.playable:hover {
  transform: translateX(-10px);
  z-index: 8;
}

.seat-top .card.playable:hover {
  transform: translateY(8px);
  z-index: 8;
}

.seat-info .avatar,
.seat-info .avatar-letter {
  width: 44px;
  height: 44px;
}

.seat-info .avatar-letter {
  font-size: 1.15rem;
  border-radius: 50%;
  border: 2px solid rgba(232, 184, 74, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.card.selected {
  z-index: 6;
  transform: translateY(-10px);
  box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(0, 0, 0, 0.35);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 10px 2px;
  width: 100%;
}

.hint {
  color: #e2d8c6;
  font-size: 0.95rem;
}

.control-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(18, 22, 30, 0.72);
  color: var(--cream);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.btn:hover:not(:disabled) {
  background: rgba(36, 44, 58, 0.88);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 出牌：参考图金色主按钮 */
.btn-primary {
  background: linear-gradient(180deg, #f6c24a 0%, #e09018 100%);
  border-color: rgba(255, 220, 140, 0.55);
  color: #2a1a08;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffd060 0%, #ee9e22 100%);
}

.btn-accent {
  background: linear-gradient(180deg, #4aa3e8 0%, #2a6fbf 100%);
  border-color: rgba(160, 210, 255, 0.45);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(180deg, #5bb0f0 0%, #347fd0 100%);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.log-panel {
  grid-area: log;
  background: rgba(10, 14, 22, 0.72);
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--line);
  padding: 48px 12px 10px;
  max-height: none;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.log-panel h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e8dfcf;
  letter-spacing: 0.04em;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  font-size: 0.82rem;
  color: #cfc5b4;
}

.log li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.log-item.system {
  opacity: 0.9;
}

.log-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.log-item-head .avatar {
  width: 28px;
  height: 28px;
}

.log-item-name {
  font-weight: 700;
  color: #f3efe6;
}

.log-item-tag {
  color: var(--gold);
  font-size: 0.78rem;
}

.log-item-text {
  line-height: 1.4;
}

.log-panel .log-cards {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
  overflow-x: hidden;
  padding-bottom: 2px;
  max-width: 100%;
}

.log-panel .log-cards .card.tiny {
  width: 54px;
  height: 78px;
  flex-shrink: 0;
  margin: 0 0 0 -18px;
}

.log-panel .log-cards .card.tiny:first-child {
  margin-left: 0;
}

.draw-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.draw-overlay[hidden] {
  display: none !important;
}

.draw-panel {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(14, 18, 28, 0.55);
  border: 1px solid rgba(212, 168, 75, 0.4);
  border-radius: 14px;
  padding: 22px 24px 20px;
  color: #f0e6d2;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 18px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 230, 180, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.draw-panel h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  color: #e8d7b0;
  letter-spacing: 0.06em;
}

.draw-desc {
  margin: 0 0 16px;
  color: rgba(232, 215, 176, 0.85);
  line-height: 1.5;
}

.draw-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.draw-target {
  appearance: none;
  min-width: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(212, 168, 75, 0.35);
  background: rgba(10, 14, 24, 0.45);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.draw-target:hover:not(:disabled) {
  border-color: rgba(212, 168, 75, 0.85);
  background: rgba(212, 168, 75, 0.14);
  box-shadow: 0 0 16px rgba(212, 168, 75, 0.18);
}

.draw-target:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.draw-target .meta {
  font-size: 0.78rem;
  color: rgba(200, 188, 160, 0.85);
}

.draw-card-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.draw-card-group .group-title {
  margin-bottom: 10px;
  font-size: 0.95rem;
  color: #e8dfcf;
}

.draw-card-group .log-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* 抽牌/还牌公示：卡牌放大，便于辨认 */
.draw-card-group .log-cards .card.tiny {
  width: 96px;
  height: 136px;
  margin: 0;
  flex-shrink: 0;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(212, 168, 75, 0.3);
}

.draw-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  gap: 10px;
}

.draw-actions .btn[hidden] {
  display: none !important;
}

.draw-timer {
  margin-top: 16px;
  text-align: center;
  font-size: 1.1rem;
  color: #d4a84b;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.settle-banner {
  margin-top: 8px;
  padding: 8px;
  background: rgba(201, 162, 39, 0.15);
  border-radius: 8px;
  color: #f0e2b8;
}

@media (max-width: 900px) and (orientation: portrait) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "table"
      "log";
    height: auto;
    min-height: 100vh;
  }

  .screen-game .app {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "table"
      "log"
      "tip";
  }

  .table {
    grid-template-columns: 88px minmax(0, 1fr) 88px;
    grid-template-rows: auto minmax(140px, 1fr) auto;
  }

  .log-panel {
    max-height: 240px;
    min-height: 160px;
  }

  .screen-game .log-panel {
    max-height: none;
    min-height: 0;
    height: 100%;
  }

  :root {
    --card-w: 46px;
    --card-h: 66px;
  }

  .seat-bottom .card {
    width: 48px;
    height: 70px;
  }
}

/* 竖屏手机：提示转到横屏 */
.rotate-hint {
  display: none;
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    background: #0f3d28;
    color: #f3efe6;
  }

  .rotate-hint-box p {
    margin: 12px 0 0;
    font-size: 1.15rem;
    font-weight: 700;
  }

  .rotate-icon {
    font-size: 3rem;
    line-height: 1;
    animation: rotate-phone 1.6s ease-in-out infinite;
    display: inline-block;
  }
}

@keyframes rotate-phone {
  0%,
  20% {
    transform: rotate(0deg);
  }
  50%,
  80% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

/* 手机横屏：压低高度，保留桌面+右侧记录 */
@media (orientation: landscape) and (max-height: 560px) {
  html,
  body,
  .screen-game,
  .screen-game .app {
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .app {
    max-width: none;
    padding: 4px 8px 6px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) 168px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "table log";
    min-height: 0;
  }

  /* 对局屏：顶栏浮层 + 底栏贴士 */
  .screen-game .app {
    padding: 0;
    gap: 0;
    grid-template-columns: minmax(0, 1fr) 168px;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "table log"
      "tip log";
  }

  .screen-game .game-toolbar-bar {
    top: 4px;
    left: 8px;
    right: 176px;
    padding: 0;
  }

  .topbar {
    padding: 0 2px;
    gap: 6px;
  }

  .topbar h1 {
    font-size: 0.95rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar .btn {
    padding: 5px 10px;
    font-size: 0.82rem;
  }

  .meta-chip {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .table {
    padding: 4px 6px;
    border-radius: 10px;
    grid-template-columns: 70px minmax(0, 1fr) 70px;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .screen-game .table {
    padding: 36px 4px 4px 2px;
    border-radius: 0;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    grid-template-areas:
      "top top top"
      "left center right"
      "bottom bottom bottom";
  }

  .screen-game .seat-top {
    padding: 0 6px;
  }

  .screen-game .log-panel {
    padding-top: 40px;
  }

  .seat-info {
    padding: 2px 6px;
    gap: 4px;
  }

  .seat-info .pname {
    font-size: 0.78rem;
  }

  .seat-info .meta {
    font-size: 0.68rem;
  }

  .seat-info .avatar,
  .seat-info .avatar-wrap .avatar {
    width: 24px;
    height: 24px;
  }

  .goods-tag {
    font-size: 0.62rem;
    padding: 0 4px;
  }

  .seat-top,
  .seat-left,
  .seat-right,
  .seat-bottom,
  .table-bottom {
    gap: 2px;
  }

  .center-info {
    padding: 4px 8px;
    margin: 0 4px;
  }

  .turn-info {
    font-size: 0.82rem;
  }

  .last-play {
    margin-top: 4px;
  }

  .last-play-cards .card.tiny,
  .card.tiny {
    width: 32px;
    height: 46px;
  }

  .seat-top .card,
  .seat-left .card,
  .seat-right .card {
    width: 32px;
    height: 46px;
  }

  .seat-bottom .card {
    width: 44px;
    height: 64px;
  }

  .hand.horizontal {
    padding: 6px 4px 2px;
  }

  .hand.vertical {
    max-height: 160px;
    padding: 2px 4px;
  }

  .hand.vertical .card {
    margin-top: -18px;
  }

  .seat-top .hand.horizontal .card {
    margin-left: -14px;
  }

  .seat-bottom .hand.horizontal .card {
    margin-left: -10px;
  }

  .controls {
    padding: 2px 6px;
    gap: 6px;
  }

  .hint {
    font-size: 0.78rem;
  }

  .control-btns {
    gap: 6px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .log-panel {
    padding: 6px 8px;
    border-radius: 10px;
  }

  .log-panel h2 {
    font-size: 0.82rem;
    margin-bottom: 4px;
  }

  .log {
    font-size: 0.72rem;
  }

  .log li {
    padding: 4px 0;
  }

  .log-item-head .avatar {
    width: 20px;
    height: 20px;
  }

  .draw-overlay,
  .gallery-overlay {
    padding: 8px;
  }

  .draw-panel,
  .gallery-panel {
    max-height: calc(100dvh - 16px);
    padding: 10px 12px;
  }

  .draw-card-group .log-cards .card.tiny {
    width: 72px;
    height: 102px;
  }

  .gallery-fab {
    left: max(8px, env(safe-area-inset-left));
    right: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }

  .gallery-item img {
    height: 64px;
  }
}

body.has-bg-image {
  /* 页面背景图全局遮罩：0=完全透出背景图，越大越暗。对局页建议 0。 */
  --background-image-overlay-opacity: 0;
  background-color: #0a121c;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

/* 有背景图时再压一层，牌桌信息优先 */
body.has-bg-image::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--background-image-overlay-opacity);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(8, 12, 20, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, rgba(4, 8, 14, 0.18) 0%, rgba(4, 8, 14, 0.32) 100%);
}

body.has-bg-image .screen-game,
body.has-bg-image .app {
  position: relative;
  z-index: 1;
}

.gallery-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(18, 48, 32, 0.88);
  color: var(--cream);
  padding: 8px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.gallery-fab:hover {
  background: rgba(47, 125, 78, 0.95);
}

.gallery-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gallery-overlay[hidden] {
  display: none !important;
}

.gallery-panel {
  width: min(880px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #163326;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 16px 18px 18px;
  color: #f3efe6;
}

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

.gallery-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.gallery-item {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: inherit;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
}

.gallery-item span {
  display: block;
  padding: 8px 8px 10px;
  font-size: 0.82rem;
  line-height: 1.3;
}

.gallery-item:hover,
.gallery-item.active {
  border-color: var(--gold);
}

.gallery-empty {
  margin: 8px 0;
  color: #d9d0c0;
}

/* 过牌只更新状态，不应让上一手牌重新播放落牌动画。 */
.seat-play--stable,
.seat-play--stable.seat-play--fresh {
  animation: none !important;
  transform: none !important;
}

.gallery-item-wrap {
  min-width: 0;
}

.gallery-dialog {
  z-index: 90;
}

.gallery-dialog-panel {
  width: min(420px, 100%);
  padding: 18px;
  background: #163326;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #f3efe6;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.gallery-dialog-panel h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.gallery-action-preview {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

.gallery-action-title {
  margin-top: 12px !important;
  overflow-wrap: anywhere;
}

.gallery-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: #d9d0c0;
}

.gallery-field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font: inherit;
}

.gallery-dialog-actions,
.gallery-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-danger {
  background: #8f3030;
  border-color: #bd5656;
}
