* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --page: #07100d;
  --panel: rgba(8, 18, 17, 0.82);
  --panel-strong: rgba(7, 15, 18, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --line-bright: rgba(149, 213, 178, 0.42);
  --text: #f8fafc;
  --muted: #b7c9c3;
  --gold: #f4c76b;
  --green: #4ade80;
  --cyan: #7dd3fc;
  --red: #fb7185;
  --wood: #5d351f;
  --felt: #0d6b45;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(47, 118, 83, 0.26), transparent 34%),
    linear-gradient(180deg, #07100d 0%, #10131a 100%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 18px;
}

.top-bar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px;
}

.round-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: #dbeafe;
}

.round-meta span,
#phase-label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(244, 199, 107, 0.34);
  background: rgba(7, 15, 18, 0.72);
  color: #fef3c7;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

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

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}

p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.table {
  position: relative;
  width: 100%;
  min-height: min(720px, calc(100vh - 132px));
  display: grid;
  grid-template-rows: minmax(136px, 0.82fr) minmax(176px, auto) minmax(142px, 0.72fr);
  gap: 12px;
  padding: 24px clamp(18px, 3vw, 38px);
  overflow: hidden;
  border: 1px solid rgba(244, 199, 107, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(4, 12, 10, 0.1), rgba(4, 12, 10, 0.2)),
    url("../img/table_green.png") center / cover no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -56px 90px rgba(0, 0, 0, 0.2),
    0 18px 44px rgba(0, 0, 0, 0.32);
}

.table::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 0%, transparent 48%, rgba(0, 0, 0, 0.2) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 28%, transparent 72%, rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

.table::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 47%, rgba(244, 199, 107, 0.12), transparent 18%);
  pointer-events: none;
}

.opponents,
.middle-row,
.seat-human,
.center-panel {
  position: relative;
  z-index: 1;
}

.opponents {
  display: grid;
  place-items: start center;
}

.middle-row {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(240px, 320px) minmax(220px, 300px);
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 2vw, 24px);
}

.seat {
  min-height: 134px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(5, 18, 16, 0.72), rgba(6, 18, 18, 0.56));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
}

.seat-human {
  align-self: end;
  justify-self: center;
  width: min(760px, 92%);
  min-height: 144px;
  background: linear-gradient(180deg, rgba(5, 18, 16, 0.74), rgba(6, 18, 18, 0.58));
}

.seat-top {
  width: min(360px, 100%);
}

.seat.banker {
  border-color: rgba(244, 199, 107, 0.95);
  box-shadow:
    0 0 0 1px rgba(244, 199, 107, 0.2),
    0 16px 36px rgba(0, 0, 0, 0.3),
    0 0 26px rgba(244, 199, 107, 0.16);
}

.seat-head,
.bet-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.seat-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.seat-head span,
.bet-row,
.balance {
  color: var(--muted);
  font-size: 13px;
}

.balance {
  color: #fef3c7;
  font-weight: 800;
}

.bet-row {
  margin-top: 10px;
}

.cards {
  min-height: 72px;
  display: flex;
  gap: 0;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding-inline: 4px;
}

.card,
.empty-card {
  width: 50px;
  height: 70px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: #fffaf0;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

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

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

.card.back {
  border-color: #9cc4f1;
  background-color: #0f4263;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

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

.hand-type {
  min-height: 24px;
  margin-top: 8px;
  color: var(--gold);
  text-align: center;
  font-weight: 900;
}

.center-panel {
  min-height: 148px;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(244, 199, 107, 0.3);
  border-radius: 8px;
  background: rgba(8, 18, 17, 0.74);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.banker-badge {
  min-height: 40px;
  display: grid;
  place-items: center;
  color: #fef3c7;
  font-weight: 900;
  text-align: center;
}

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

button {
  min-width: 64px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  background: rgba(14, 30, 34, 0.92);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 199, 107, 0.58);
  background: rgba(30, 64, 68, 0.96);
}

.primary-btn {
  color: #2a1504;
  border-color: rgba(255, 255, 255, 0.28);
  background: linear-gradient(180deg, #ffd777, #d7902f);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #ffe69d, #e2a13a);
}

.hidden {
  display: none;
}

.result-panel {
  min-height: 76px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(7, 15, 18, 0.86);
}

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

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

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

  .top-bar {
    display: grid;
    gap: 10px;
  }

  .middle-row {
    grid-template-columns: 1fr;
  }

  .center-panel {
    order: -1;
  }

  .table {
    min-height: auto;
    grid-template-rows: auto auto auto;
    padding: 14px;
  }

  .table::before {
    inset: 0;
  }

  .seat {
    min-height: 132px;
  }

  .card,
  .empty-card {
    width: 42px;
    height: 60px;
  }

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