* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --felt: #0e7a54;
  --felt-dark: #064633;
  --rim: #27100f;
  --rim-light: #6f2f24;
  --panel: rgba(3, 28, 24, 0.78);
  --panel-strong: rgba(2, 16, 15, 0.92);
  --line: rgba(255, 255, 255, 0.2);
  --gold: #ffe45d;
  --gold-dark: #b66b17;
  --mint: #53e0ae;
  --red: #ff4136;
  --text: #fffbea;
  --muted: #bde7d6;
}

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

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 18%, rgba(32, 214, 148, 0.36), transparent 32%),
    radial-gradient(circle at 50% 92%, rgba(255, 228, 93, 0.16), transparent 24%),
    linear-gradient(135deg, #034637 0%, #00946f 48%, #042820 100%);
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 960px;
  min-height: 620px;
  overflow: hidden;
}

.top-bar {
  position: absolute;
  top: 14px;
  left: 24px;
  right: 24px;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.top-bar > div,
.round-meta {
  pointer-events: auto;
}

h1,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 1;
  font-weight: 950;
  font-style: italic;
  color: #fff452;
  text-shadow:
    2px 3px 0 rgba(4, 46, 35, 0.9),
    0 8px 18px rgba(0, 0, 0, 0.34);
}

p {
  width: fit-content;
  max-width: 520px;
  margin-top: 8px;
  padding: 5px 10px;
  color: #e9fff8;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  border-radius: 4px;
  background: rgba(2, 19, 16, 0.42);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.72);
}

.round-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.round-meta span,
#phase-label,
.lobby-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid rgba(255, 250, 167, 0.56);
  border-radius: 5px;
  color: #fff6b5;
  background: rgba(3, 26, 22, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(7px);
  white-space: nowrap;
}

#phase-label {
  color: #2b1800;
  background: linear-gradient(180deg, #fff483, #f3b636 58%, #b86417);
  border-color: rgba(255, 247, 174, 0.9);
  font-weight: 950;
}

.lobby-btn {
  width: 46px;
  min-width: 46px;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  font: 0/0 a;
  cursor: pointer;
}

.lobby-btn::before {
  content: "<";
  color: #edfff8;
  font: 950 28px/1 Arial, sans-serif;
}

.lobby-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #fff9a6;
}

.lobby-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.table {
  position: absolute;
  inset: 70px 28px 18px;
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 50% 47%, rgba(11, 128, 86, 0.66) 0 31%, transparent 32%),
    radial-gradient(ellipse at 50% 47%, var(--felt) 0 42%, #351916 43% 48%, #160909 49% 51%, transparent 52%),
    url("../img/table_green.png") center / cover no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 -80px 95px rgba(0, 0, 0, 0.2),
    0 20px 55px rgba(0, 0, 0, 0.36);
}

.table::before,
.table::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.table::before {
  background:
    radial-gradient(ellipse at 50% 47%, transparent 0 34%, rgba(255, 255, 255, 0.1) 35%, transparent 36%),
    radial-gradient(ellipse at 50% 47%, transparent 0 44%, rgba(0, 0, 0, 0.28) 45%, transparent 54%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), transparent 28%, transparent 72%, rgba(0, 0, 0, 0.34));
}

.table::after {
  background: radial-gradient(ellipse at 50% 47%, rgba(255, 255, 255, 0.08), transparent 26%);
}

.table-logo {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 1;
  transform: translate(-50%, -50%) skewX(-8deg);
  color: rgba(230, 255, 242, 0.16);
  font-size: clamp(64px, 9vw, 132px);
  font-weight: 950;
  font-style: italic;
  letter-spacing: 0;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.stage-banner {
  position: absolute;
  left: 50%;
  top: 26.5%;
  z-index: 4;
  min-width: 138px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 6px 18px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 250, 167, 0.72);
  border-radius: 999px;
  color: #2d1500;
  background: linear-gradient(180deg, #fff8a8, #ffc63a 60%, #b76014);
  box-shadow:
    0 9px 22px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(255, 228, 93, 0.26);
  font-size: 20px;
  font-weight: 950;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.36);
  pointer-events: none;
}

body[data-phase="idle"] .stage-banner {
  opacity: 0.72;
}

body[data-phase="rob"] .stage-banner {
  animation: robPulse 1.1s ease-in-out infinite alternate;
}

@keyframes robPulse {
  from {
    transform: translateX(-50%) scale(1);
    box-shadow:
      0 9px 22px rgba(0, 0, 0, 0.28),
      0 0 18px rgba(255, 228, 93, 0.28);
  }

  to {
    transform: translateX(-50%) scale(1.04);
    box-shadow:
      0 11px 26px rgba(0, 0, 0, 0.32),
      0 0 32px rgba(255, 228, 93, 0.48);
  }
}

.opponents,
.middle-row {
  display: contents;
}

.seat,
.center-panel,
.result-panel {
  position: absolute;
  z-index: 3;
}

.seat {
  width: 285px;
  min-height: 166px;
  padding: 0;
  color: var(--text);
}

.seat-player-2 {
  top: 2.2%;
  left: 50%;
  transform: translateX(-50%);
}

.seat-player-1 {
  left: 4.6%;
  top: 41.5%;
  transform: translateY(-50%);
}

.seat-player-3 {
  right: 4.6%;
  top: 41.5%;
  transform: translateY(-50%);
}

.seat-human {
  left: 50%;
  bottom: 0.7%;
  width: min(680px, 58vw);
  min-height: 180px;
  transform: translateX(-50%);
}

.player-plate {
  position: relative;
  min-height: 52px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border-radius: 6px;
  background: rgba(3, 23, 20, 0.78);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.26);
}

.avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #052018;
  background:
    radial-gradient(circle at 36% 30%, #fffad8 0 12%, transparent 13%),
    linear-gradient(145deg, #ffef73, #31d39b 50%, #0e7b61);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.34);
  font-size: 15px;
  font-weight: 950;
}

.avatar-0 {
  background:
    radial-gradient(circle at 33% 28%, #fff9cb 0 13%, transparent 14%),
    linear-gradient(145deg, #ffec71, #73d85b 48%, #1d5d39);
}

.player-copy {
  min-width: 0;
}

.player-copy strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 18px;
  font-style: italic;
  font-weight: 950;
  line-height: 1.08;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.72);
  white-space: nowrap;
}

.player-copy span {
  display: block;
  margin-top: 3px;
  color: #d1fff2;
  font-size: 12px;
  font-weight: 800;
}

.balance {
  display: grid;
  justify-items: end;
  gap: 2px;
  font-weight: 950;
  line-height: 1;
}

.balance span {
  min-width: 62px;
  padding: 4px 7px;
  border-radius: 4px;
  color: #fffed0;
  background: rgba(1, 16, 14, 0.64);
  text-align: right;
}

.balance small {
  min-width: 54px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.76);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 5px 12px rgba(0, 0, 0, 0.28);
}

.seat-body {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 82px;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.seat-human .seat-body {
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: end;
}

.cards {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.card,
.empty-card {
  width: 50px;
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 4px;
  background: #fffaf0;
  box-shadow: 0 10px 17px rgba(0, 0, 0, 0.34);
}

.seat-human .card,
.seat-human .empty-card {
  width: 78px;
  height: 112px;
}

.card + .card,
.card + .empty-card,
.empty-card + .empty-card,
.empty-card + .card {
  margin-left: -7px;
}

.seat-human .card + .card,
.seat-human .card + .empty-card,
.seat-human .empty-card + .empty-card,
.seat-human .empty-card + .card {
  margin-left: -18px;
}

.card-image,
.card.back {
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.card.back {
  border-color: #ddf9ff;
  background-color: #11435b;
}

.empty-card {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.action-stack {
  display: grid;
  gap: 4px;
}

.action-stack span,
.action-stack strong {
  min-height: 26px;
  display: grid;
  place-items: center;
  padding: 3px 8px;
  border-radius: 3px;
  color: #effff9;
  background: rgba(2, 52, 38, 0.72);
  font-size: 13px;
  font-weight: 950;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.action-stack .positive {
  color: var(--gold);
  background: rgba(12, 100, 67, 0.86);
}

.action-stack .negative,
.action-stack strong {
  color: #ff3e2e;
  background: rgba(99, 27, 20, 0.76);
}

.balance .round-score,
.action-stack .round-score {
  min-height: 30px;
  border: 1px solid transparent;
  font-size: 15px;
  letter-spacing: 0;
}

.balance .score-positive,
.action-stack .score-positive {
  color: #062116;
  border-color: rgba(151, 255, 204, 0.92);
  background: linear-gradient(180deg, #9dffd0, #35e99b 58%, #12915f);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 0 2px rgba(59, 245, 163, 0.20),
    0 8px 18px rgba(0, 0, 0, 0.34);
}

.balance .score-negative,
.action-stack .score-negative {
  color: #fff4ef;
  border-color: rgba(255, 177, 160, 0.92);
  background: linear-gradient(180deg, #ff6d66, #d92824 58%, #7a1715);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
  box-shadow:
    0 0 0 2px rgba(255, 72, 66, 0.25),
    0 8px 18px rgba(0, 0, 0, 0.34);
}

.balance .score-even,
.action-stack .score-even {
  color: #effff9;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(2, 52, 38, 0.82);
}

.hand-type {
  min-height: 24px;
  display: grid;
  place-items: center;
  margin: 2px auto 0;
  padding: 2px 12px;
  width: fit-content;
  max-width: 100%;
  color: var(--gold);
  font-size: 18px;
  font-weight: 950;
  font-style: italic;
  line-height: 1.15;
  text-align: center;
  text-shadow:
    1px 2px 0 rgba(0, 0, 0, 0.7),
    0 0 10px rgba(255, 228, 93, 0.28);
}

.seat-human .hand-type {
  margin-top: -2px;
  font-size: 22px;
}

.banker-token {
  position: absolute;
  left: 58px;
  top: 41px;
  z-index: 5;
  min-width: 34px;
  min-height: 24px;
  display: grid;
  place-items: center;
  color: #261100;
  border: 1px solid rgba(255, 249, 189, 0.9);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff58d, #d18b1c);
  font-weight: 950;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.32);
}

.seat.banker .avatar {
  border-color: #fff46c;
  box-shadow:
    0 0 0 2px rgba(255, 228, 93, 0.32),
    0 0 20px rgba(255, 228, 93, 0.36);
}

.center-panel {
  left: 50%;
  top: 53%;
  width: min(360px, 34vw);
  min-height: 118px;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px 18px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: rgba(3, 40, 32, 0.62);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
}

body[data-phase="rob"] .center-panel {
  border: 1px solid rgba(255, 247, 143, 0.48);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 228, 93, 0.2), transparent 52%),
    rgba(3, 40, 32, 0.76);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.24),
    0 0 28px rgba(255, 228, 93, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

body[data-phase="rob"] #rob-controls button {
  min-width: 70px;
  color: #1d1100;
  border-color: rgba(255, 255, 210, 0.72);
  background: linear-gradient(180deg, #fffbd1, #ffd351 58%, #ba6b18);
}

body[data-phase="rob"] #rob-controls button:first-child {
  color: #f6fff9;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(4, 58, 47, 0.94);
}

.banker-badge {
  min-height: 30px;
  display: grid;
  place-items: center;
  color: #fff9a6;
  font-size: 19px;
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.64);
}

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

button {
  min-width: 66px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 248, 150, 0.42);
  border-radius: 4px;
  color: #f6fff9;
  background: rgba(3, 58, 44, 0.9);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.24);
  font: inherit;
  font-weight: 950;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 250, 146, 0.9);
  background: rgba(9, 93, 66, 0.96);
}

.primary-btn {
  color: #132216;
  border-color: rgba(255, 255, 210, 0.72);
  background: linear-gradient(180deg, #ffffce, #4df1b0 46%, #11a971);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.primary-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff, #75ffd0 46%, #15bd7c);
}

.hidden {
  display: none;
}

.result-panel {
  left: auto;
  right: 24px;
  bottom: 18px;
  width: min(430px, calc(100vw - 48px));
  z-index: 26;
  max-height: none;
  overflow: visible;
  pointer-events: none;
}

.result-panel:empty {
  display: none;
}

table {
  width: min(680px, 100%);
  margin-left: auto;
  border-collapse: collapse;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(2, 24, 20, 0.86);
  pointer-events: auto;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

.score-positive {
  color: #48f5ad;
  font-weight: 950;
}

.score-negative {
  color: #ff6d66;
  font-weight: 950;
}

.score-even {
  color: #d8fff3;
  font-weight: 850;
}

th {
  color: var(--gold);
  font-weight: 950;
}

@media (max-width: 1160px) {
  .app-shell {
    min-width: 860px;
    min-height: 580px;
  }

  .table {
    inset: 66px 14px 12px;
  }

  .seat {
    width: 250px;
  }

  .seat-player-1 {
    left: 2.5%;
  }

  .seat-player-3 {
    right: 2.5%;
  }

  .seat-human {
    width: min(610px, 60vw);
  }

  .card,
  .empty-card {
    width: 52px;
    height: 74px;
  }

  .seat-human .card,
  .seat-human .empty-card {
    width: 68px;
    height: 98px;
  }

  .center-panel {
    width: 315px;
  }
}
