:root {
  --wood: #6b3f24;
  --wood-deep: #3d2314;
  --wood-hi: #a56a3d;
  --felt: #1b7a45;
  --felt-dark: #0f5a30;
  --felt-light: #249553;
  --ink: #1c140f;
  --paper: #f3ead7;
  --mute: #8a7460;
  --chip: #f0b429;
  --danger: #c62828;
  --raise: #e65100;
  --compare: #1565c0;
  --call: #2e7d32;
  --card-w: 70px;
  --card-h: 98px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "ZCOOL QingKe HuangYou", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--paper);
  font-family: var(--font);
  background-color: #24160f;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(165, 106, 61, .35), transparent 55%),
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,.015) 0 1px,
      transparent 1px 7px
    ),
    linear-gradient(180deg, #2c1b12 0%, #1a100b 100%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow-x: hidden;
}

#app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  gap: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.room-tag {
  justify-self: start;
  font-size: 11px;
  color: #d7b48a;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(165,106,61,.45);
  padding: 4px 8px;
  border-radius: 4px;
}
.brand {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 2px;
  color: #ffe08a;
  text-align: center;
  text-shadow: 0 2px 0 #5a320f;
}
.scoreboard {
  justify-self: end;
  display: flex;
  gap: 6px;
  font-size: 11px;
}
.scoreboard span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(0,0,0,.35);
  border-radius: 4px;
  padding: 3px 6px;
  color: #cbb79a;
}
.scoreboard i {
  font-style: normal;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  background: #5a3a22;
  color: #f6d9a6;
  font-size: 10px;
}
.scoreboard b {
  color: #ffd15a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.table-wrap { min-height: 0; }
.table-rail {
  height: 100%;
  min-height: 440px;
  padding: 10px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, #b07a45, #7a4a28 40%, #5a3218 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,220,170,.35),
    inset 0 -2px 0 rgba(0,0,0,.25),
    0 10px 24px rgba(0,0,0,.4);
}

.felt {
  position: relative;
  height: 100%;
  min-height: 420px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,.07), transparent 42%),
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,.03) 0 2px,
      transparent 2px 4px
    ),
    linear-gradient(160deg, var(--felt-light), var(--felt) 45%, var(--felt-dark));
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18), inset 0 0 40px rgba(0,0,0,.22);
}

.felt-mark {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: 64px;
  color: rgba(0,0,0,.08);
  letter-spacing: 12px;
  pointer-events: none;
}

.pot {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  padding: 6px 12px 8px;
  background: rgba(12, 40, 24, .72);
  border: 1px solid rgba(255, 210, 120, .35);
  border-radius: 6px;
}
.pot-label {
  font-size: 11px;
  color: #cfe8d6;
  letter-spacing: 2px;
}
.pot strong {
  font-size: 20px;
  color: #ffe082;
  font-variant-numeric: tabular-nums;
}

.seat {
  position: absolute;
  z-index: 3;
  width: 132px;
}
.seat-bot0 { left: 8px; top: 12px; }
.seat-bot1 { right: 8px; top: 12px; }
.seat-you {
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.plate {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 2px;
  align-items: center;
  background: rgba(18, 12, 8, .55);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: 5px 7px;
  margin-bottom: 6px;
}
.plate.self {
  margin: 0;
  width: 150px;
}
.seat-bot1 .plate { direction: rtl; }
.seat-bot1 .plate .meta,
.seat-bot1 .plate .status { direction: ltr; text-align: right; }

.face {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  grid-row: 1 / span 2;
  background:
    linear-gradient(135deg, #4e342e, #3e2723);
  position: relative;
  overflow: hidden;
}
.face::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #ffe0b2;
}
.face-a::after { content: "强"; }
.face-b::after { content: "王"; background: #37474f; }
.face-b { background: linear-gradient(135deg, #455a64, #263238); }
.face-you { background: linear-gradient(135deg, #bf360c, #870000); }
.face-you::after { content: "我"; }

.meta .name { font-size: 13px; font-weight: 700; color: #fff3e0; }
.meta .chips {
  font-size: 12px;
  color: #ffd54f;
  font-variant-numeric: tabular-nums;
}
.status {
  grid-column: 2;
  font-size: 11px;
  color: #9ccc65;
  min-height: 14px;
}

.hand {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: calc(var(--card-h) * 0.75);
  perspective: 700px;
}
.seat-you .hand {
  gap: 6px;
  min-height: var(--card-h);
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 5px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .28s ease;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.card.small {
  --card-w: 48px;
  --card-h: 68px;
  width: var(--card-w);
  height: var(--card-h);
}
.card .face, .card .back {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  backface-visibility: hidden;
  overflow: hidden;
}
.card .back {
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.18), transparent 40%),
    repeating-linear-gradient(45deg, #1a237e 0 6px, #283593 6px 12px);
  border: 1.5px solid #c9a227;
}
.card .back::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 213, 79, .45);
  border-radius: 3px;
}
.card .face {
  background: #fffaf0;
  color: #212121;
  transform: rotateY(180deg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 5px 6px;
  border: 1px solid #d7cbb5;
}
.card.red .face { color: #c62828; }
.card.black .face { color: #212121; }
.card .corner {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.05;
}
.card .corner .suit { display: block; font-size: 12px; }
.card .center-suit {
  display: grid;
  place-items: center;
  font-size: 24px;
}
.card .corner.br {
  justify-self: end;
  align-self: end;
  transform: rotate(180deg);
}
.card.flipped { transform: rotateY(180deg); }
.card.folded { filter: grayscale(.8) brightness(.75); opacity: .6; }
.card.winner-glow {
  outline: 2px solid #ffeb3b;
  outline-offset: 1px;
}

.bet-chip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: 40px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #b71c1c;
  border: 1px solid #ffcc80;
  color: #fff8e1;
  font-size: 11px;
  text-align: center;
  font-weight: 700;
}
.seat-bot0 .bet-chip,
.seat-bot1 .bet-chip { top: calc(100% + 2px); }
.seat-you .bet-chip { bottom: 52px; }

.deck-pile {
  position: absolute;
  left: 50%;
  top: 16%;
  width: 42px;
  height: 60px;
  transform: translateX(-50%);
  border-radius: 4px;
  background:
    repeating-linear-gradient(45deg, #1a237e 0 6px, #283593 6px 12px);
  border: 1.5px solid #c9a227;
  box-shadow: 3px 3px 0 rgba(0,0,0,.2), 6px 6px 0 rgba(0,0,0,.12);
  z-index: 1;
}

.fly-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
.fly-card {
  position: absolute;
  width: 48px;
  height: 68px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #1a237e 0 6px, #283593 6px 12px);
  border: 1.5px solid #c9a227;
  box-shadow: 0 6px 12px rgba(0,0,0,.35);
  transition: transform .4s cubic-bezier(.2,.75,.2,1), opacity .18s ease;
  will-change: transform;
}

.hint {
  margin: 0;
  text-align: center;
  color: #c4a882;
  font-size: 13px;
  min-height: 1.2em;
}

.dock {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 6px;
  padding: 8px;
  background: rgba(20, 12, 8, .78);
  border: 1px solid rgba(165, 106, 61, .35);
  border-radius: 8px;
}

.act {
  appearance: none;
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 8px 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: #5d4037;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), 0 1px 0 rgba(255,255,255,.08);
  cursor: pointer;
}
.act:active { transform: translateY(1px); filter: brightness(.95); }
.act:disabled { opacity: .4; cursor: not-allowed; }
.act.start {
  background: linear-gradient(#f6c344, #d39b16);
  color: #3e2723;
}
.act.call { background: linear-gradient(#43a047, #2e7d32); }
.act.raise { background: linear-gradient(#fb8c00, #ef6c00); }
.act.compare { background: linear-gradient(#1e88e5, #1565c0); }
.act.fold { background: linear-gradient(#e53935, #c62828); }
.act.wide { width: 100%; }

.rub-overlay,
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 10, 4, .72);
  display: grid;
  place-items: center;
  padding: 16px;
}
.rub-overlay[hidden],
.modal[hidden] { display: none !important; }

.rub-panel,
.modal-card {
  width: min(400px, 100%);
  background: #3e2723;
  border: 1px solid #8d6e63;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
}
.rub-title,
.modal-card h2 {
  margin: 0 0 10px;
  text-align: center;
  font-family: var(--display);
  font-size: 22px;
  color: #ffe082;
  font-weight: 400;
}
.rub-stage {
  height: 260px;
  display: grid;
  place-items: center;
  touch-action: none;
  background: #1b5e20;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.2);
}
.rub-card {
  width: 150px;
  height: 214px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0,0,0,.4);
}
.rub-face, .rub-back {
  position: absolute;
  inset: 0;
  border-radius: 8px;
}
.rub-face {
  background: #fffaf0;
  color: #212121;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12px 14px;
  z-index: 1;
}
.rub-face.red { color: #c62828; }
.rub-face .big {
  display: grid;
  place-items: center;
  font-size: 52px;
}
.rub-face .corner { font-size: 18px; font-weight: 800; line-height: 1.1; }
.rub-face .corner .suit { display: block; }
.rub-face .br { justify-self: end; align-self: end; transform: rotate(180deg); }
.rub-back {
  z-index: 2;
  background: repeating-linear-gradient(45deg, #1a237e 0 8px, #283593 8px 16px);
  border: 2px solid #c9a227;
  clip-path: inset(0 0 0 0);
}
.rub-back::after {
  content: "搓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 42px;
  color: rgba(255, 224, 130, .85);
}
.rub-progress {
  height: 6px;
  border-radius: 3px;
  background: rgba(0,0,0,.35);
  margin: 12px 4px;
  overflow: hidden;
}
.rub-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: #ffca28;
}
.rub-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 6px;
}

.settle-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.settle-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,.28);
}
.settle-list .delta.pos { color: #81c784; font-weight: 700; }
.settle-list .delta.neg { color: #ef9a9a; font-weight: 700; }
.settle-list .meta { color: #bcaaa4; font-size: 12px; margin-top: 2px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 120;
  background: rgba(33, 20, 12, .92);
  border: 1px solid #8d6e63;
  color: #fff3e0;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}
.toast[hidden] { display: none !important; }

@media (min-width: 640px) {
  :root {
    --card-w: 76px;
    --card-h: 106px;
  }
  .table-rail, .felt { min-height: 520px; }
}
