:root {
  --bg: #10181d;
  --bg-soft: #0f2229;
  --ink: #f7f8f6;
  --muted: #b8c3bc;
  --table-felt: #1d5b47;
  --table-rail: #4c3525;
  --primary: #f3b449;
  --primary-strong: #cf9430;
  --card: #13252d;
  --line: #2c3f46;
  --danger: #f07f7f;
  --chip: #e9f2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #1f333b 0%, transparent 38%),
    radial-gradient(circle at 90% 90%, #102229 0%, transparent 45%),
    linear-gradient(165deg, var(--bg-soft), var(--bg));
}

.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.topbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1, h2 {
  margin: 0;
}

.topbar-title h1 {
  font-size: 22px;
  letter-spacing: 0.02em;
}

.balance-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 140px;
  text-align: right;
  background: #102029;
}

.table-shell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  overflow: visible;
}

.table-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 56%;
  background:
    radial-gradient(ellipse at 50% 35%, #297258 0%, var(--table-felt) 55%, #174f3f 100%);
  border: 16px solid var(--table-rail);
  box-shadow:
    inset 0 0 0 2px #6a4c33,
    inset 0 20px 40px rgba(0, 0, 0, 0.28);
  overflow: visible;
}

.table-center {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: min(70%, 640px);
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(14, 40, 34, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 2;
}

.table-felt-brand {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  font-weight: 900;
  letter-spacing: 0.32em;
  font-size: clamp(40px, 7vw, 80px);
  color: rgba(0, 0, 0, 0.3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.table-center p {
  margin: 6px 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.bank-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(5, 16, 13, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.bank-line.animate {
  animation: potPulse 0.6s ease;
}
.bank-dot {
  color: rgba(255, 255, 255, 0.55);
}

@keyframes potPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(243, 180, 73, 0.35); }
  60% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(243, 180, 73, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(243, 180, 73, 0); }
}
.bank-dot {
  color: rgba(255, 255, 255, 0.55);
}

.table-notice {
  margin: 8px auto 0;
  max-width: 80%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(77, 14, 14, 0.86);
  border: 1px solid rgba(255, 150, 150, 0.4);
  color: #ffd8d8;
  text-align: center;
}

.board-cards {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}

.board-card-token {
  width: 46px;
  height: 64px;
  padding: 8px 6px;
  border-radius: 6px;
  background: var(--chip);
  color: #18231b;
  font-weight: 700;
  text-align: center;
  border: 1px solid #cfdccf;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.board-card-token.winner-combo-card,
.log-card-token.winner-combo-card {
  border-color: rgba(255, 219, 110, 0.92);
  box-shadow: 0 0 0 1px rgba(255, 219, 110, 0.45);
}

.board-card-token.winner-combo-lift {
  margin-top: -12px;
  box-shadow: 0 0 0 1px rgba(255, 219, 110, 0.55), 0 8px 16px rgba(0, 0, 0, 0.35);
  animation: winnerComboLift 0.36s ease-out;
}

@keyframes winnerComboLift {
  0% {
    margin-top: 0;
    box-shadow: 0 0 0 1px rgba(255, 219, 110, 0.35);
  }
  100% {
    margin-top: -12px;
    box-shadow: 0 0 0 1px rgba(255, 219, 110, 0.55), 0 8px 16px rgba(0, 0, 0, 0.35);
  }
}

.board-card-token.placeholder {
  background: transparent;
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.2);
}

.card-suit-red {
  color: #b82323;
}

.table-seats {
  position: absolute;
  inset: 0;
  z-index: 3;
}
.chip-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.table-info-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 6;
  background: #1f3846;
  color: #e2ece6;
  border: 1px solid #3b515d;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}
.table-info-btn:hover {
  background: #264455;
}

.status-grid {
  display: none;
}

.actions-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.status-card span {
  font-size: 12px;
  color: var(--muted);
}

.status-card strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.actions-card p {
  margin: 8px 0 0;
}

.action-main-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  margin-top: 10px;
}

.action-row {
  display: flex;
  gap: 8px;
}

.preset-row {
  display: flex;
  gap: 8px;
}

.preset-row button {
  flex: 1;
  border: 1px solid #51606c;
  border-radius: 8px;
  background: #213847;
  color: #d7e1d9;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}

.preset-row button:hover {
  background: #2b4556;
}

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

.action-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #0f1e25;
  color: var(--ink);
}

.raise-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.raise-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #0f1e25;
  color: var(--ink);
}

.hole-cards {
  min-height: 50px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.action-row button {
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.action-row button:disabled {
  background: #60707a;
  cursor: not-allowed;
}

.raise-row button {
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.raise-row button:disabled {
  background: #60707a;
  cursor: not-allowed;
}

.raise-row .allin-btn {
  background: #c53a3a;
}

.raise-row .allin-btn:hover:not(:disabled) {
  background: #df4747;
}

.panels-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.log-open-row {
  margin-top: 10px;
}

.log-open-row button {
  width: 100%;
  border: 1px solid #51606c;
  border-radius: 8px;
  background: #213847;
  color: #d7e1d9;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}

.seat {
  position: absolute;
  width: clamp(96px, 11vw, 120px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 6px;
  background: rgba(8, 22, 28, 0.9);
  display: grid;
  gap: 4px;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(2px);
  --turn-remaining-deg: 360deg;
  --turn-color: #52cc75;
  z-index: 5;
}

.seat.seated {
  border-color: #85a890;
}

.seat.mine {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}

.seat.turn {
  box-shadow: 0 0 0 2px #f5d074 inset, 0 0 18px rgba(245, 208, 116, 0.3);
}

.seat.win-pulse {
  animation: seatWinPulse 1s ease-out;
}

@keyframes seatWinPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(126, 230, 151, 0);
  }
  25% {
    box-shadow: 0 0 0 2px rgba(126, 230, 151, 0.95), 0 0 18px rgba(126, 230, 151, 0.55);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(126, 230, 151, 0);
  }
}

.seat.inactive {
  opacity: 0.55;
  filter: saturate(0.7);
}

.seat-action-badge {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 10px;
  background: #12262f;
  border: 1px solid #48606c;
  color: #e7efe9;
  z-index: 12;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.seat-core {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.seat-avatar-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  z-index: 1;
}

.seat-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  font-size: 9px;
  font-weight: 800;
  padding: 3px;
  border: 1px solid #66757d;
}

.seat-avatar.has-image {
  background-size: cover;
  background-position: center;
  color: transparent;
}

.seat-avatar.no-image {
  background: #050709;
  color: #f5f7f5;
  word-break: break-word;
}

.seat.turn .seat-avatar-wrap::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  background: conic-gradient(from 0deg, var(--turn-color) 0deg var(--turn-remaining-deg), rgba(11, 20, 24, 0.15) var(--turn-remaining-deg) 360deg);
  z-index: -1;
}

.seat-title {
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  font-size: 11px;
  max-width: 96%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-stack {
  text-align: center;
  font-size: 10px;
  color: #d7e6d8;
}

.seat-subline {
  text-align: center;
  font-size: 9px;
  color: #a8b7ad;
}

.seat-role-badge {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #20323b;
  border: 1px solid #5e7682;
  color: #e7f2ea;
  font-size: 10px;
  line-height: 16px;
  font-weight: 800;
  text-align: center;
}

.chip-pile {
  position: absolute;
  width: 36px;
  height: 34px;
  transform: translate(-50%, -50%);
  transition: top 0.35s ease, left 0.35s ease, opacity 0.35s ease, transform 0.2s ease;
}
.chip-animate {
  animation: chipDrop 0.35s ease-out;
}
@keyframes chipDrop {
  from { transform: translate(-50%, -60%) scale(1.1); opacity: 0.3; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.chip-stack {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 28px;
  height: 20px;
}
.chip-disc {
  position: absolute;
  left: 0;
  width: 28px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}
.chip-color-0 { background: #d84f46; }
.chip-color-1 { background: #3a7de0; }
.chip-color-2 { background: #f0b348; }
.chip-color-3 { background: #59b76b; }
.chip-amount {
  position: absolute;
  left: 50%;
  bottom: -3px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  color: #f7f9f7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}
.chip-pile.bump {
  transform: translate(-50%, -50%) scale(1.05);
}
.chip-pile.winner {
  filter: drop-shadow(0 0 10px rgba(120, 220, 140, 0.7));
}
.chip-pile.fly {
  opacity: 0.95;
}

.card-animate {
  animation: cardFlip 0.35s ease-out;
  transform-origin: center;
}
@keyframes cardFlip {
  0%   { transform: rotateY(90deg) scale(0.9); opacity: 0; }
  60%  { transform: rotateY(-10deg) scale(1.02); opacity: 1; }
  100% { transform: rotateY(0) scale(1); opacity: 1; }
}

.seat button {
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #222014;
  padding: 4px 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 10px;
}

.seat button:hover {
  background: var(--primary-strong);
}

.seat button.secondary {
  background: #50616b;
  color: var(--ink);
}

.seat.empty-only {
  opacity: 0.9;
}

.seat-pos-1 { left: 50%; top: 99%; }
.seat-pos-2 { left: 18%; top: 86%; }
.seat-pos-3 { left: 4%; top: 62%; }
.seat-pos-4 { left: 9%; top: 28%; }
.seat-pos-5 { left: 29%; top: 8%; }
.seat-pos-6 { left: 71%; top: 8%; }
.seat-pos-7 { left: 91%; top: 28%; }
.seat-pos-8 { left: 96%; top: 62%; }
.seat-pos-9 { left: 82%; top: 86%; }

@media (max-width: 880px) {
  .action-main-row {
    grid-template-columns: 1fr;
  }
  .action-row,
  .preset-row,
  .raise-row {
    flex-wrap: wrap;
  }
}

.seat-hole-cards {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

.seat-hole-cards .board-card-token {
  width: 38px;
  height: 50px;
  padding: 4px 3px;
  font-size: 10px;
  border-radius: 6px;
}

.seat-hole-cards .board-card-token.winner-combo-card {
  box-shadow: 0 0 0 1px rgba(255, 219, 110, 0.7);
}

#events-list {
  margin: 10px 0 0;
  padding-left: 20px;
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

#events-list li {
  font-size: 13px;
}

.events-title {
  margin-top: 16px;
}

.log-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 14, 18, 0.66);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.log-modal-card {
  width: min(720px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #112530;
  border: 1px solid #2f4650;
  border-radius: 14px;
  padding: 12px;
  font-size: 13px;
}

.log-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.log-modal-head button {
  border: 1px solid #4d5f69;
  background: #1f3947;
  color: #e5ece7;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 12px;
}

.log-hand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
}

.log-cards {
  display: flex;
  gap: 4px;
}

.log-card-token {
  width: 32px;
  height: 44px;
  padding: 4px 3px;
  border-radius: 6px;
  background: var(--chip);
  color: #18231b;
  font-weight: 700;
  text-align: center;
  border: 1px solid #cfdccf;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.error-box {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #6b3434;
  color: #ffc5c5;
  background: #3b1d1d;
}

.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.info-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f2028;
  border: 1px solid #2c3f46;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}
.info-list span {
  color: var(--muted);
  font-weight: 600;
}

.chat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 6px;
  max-height: 180px;
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 12px;
}
.chat-messages {
  max-height: 110px;
  min-height: 72px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}
.chat-row {
  background: #10232d;
  border: 1px solid #27373f;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.25;
  word-break: break-word;
}
.chat-empty {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.chat-form {
  display: flex;
  gap: 8px;
}
.chat-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #0f1e25;
  color: var(--ink);
  font-size: 12px;
}
.chat-form button {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--primary);
  color: #1a1d13;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

@media (max-width: 920px) {
  .table-stage {
    aspect-ratio: 4 / 3;
  }

  .seat {
    width: clamp(86px, 20vw, 106px);
    padding: 8px;
  }

  .seat button {
    padding: 6px 8px;
  }
}

@media (max-width: 640px) {
  .layout {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
    border-radius: 12px;
  }

  .balance-box {
    width: 100%;
    text-align: left;
  }

  .table-shell {
    padding: 8px;
    border-radius: 14px;
  }

  .table-stage {
    border-width: 10px;
    aspect-ratio: 4 / 3.2;
  }

  .table-center {
    width: 82%;
    top: 38%;
    padding: 8px;
  }

  .bank-line {
    font-size: 12px;
    gap: 6px;
    padding: 6px 8px;
  }

  .seat {
    width: clamp(44px, 14vw, 54px);
    border-radius: 10px;
    padding: 2px;
    gap: 1px;
  }

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

  .seat-avatar {
    border-radius: 7px;
    font-size: 6px;
    padding: 1px;
  }

  .seat-title {
    font-size: 7px;
    max-width: 92%;
  }

  .seat-stack {
    font-size: 6px;
  }

  .seat-action-badge {
    top: -14px;
    font-size: 7px;
    padding: 1px 5px;
  }

  .seat button {
    font-size: 7px;
    padding: 2px 4px;
    border-radius: 7px;
  }

  .seat-hole-cards {
    gap: 2px;
    margin-top: 1px;
  }

  .seat-hole-cards .board-card-token {
    width: 18px;
    height: 24px;
    padding: 1px 0;
    font-size: 6px;
    border-radius: 4px;
  }

  .board-card-token {
    width: 28px;
    height: 40px;
    padding: 3px 2px;
    font-size: 10px;
  }

  .table-felt-brand {
    font-size: clamp(16px, 5.6vw, 24px);
    letter-spacing: 0.18em;
  }

  .seat-pos-1 { left: 50%; top: 99%; }
  .seat-pos-2 { left: 22%; top: 89%; }
  .seat-pos-3 { left: 8%; top: 64%; }
  .seat-pos-4 { left: 13%; top: 32%; }
  .seat-pos-5 { left: 31%; top: 12%; }
  .seat-pos-6 { left: 69%; top: 12%; }
  .seat-pos-7 { left: 87%; top: 32%; }
  .seat-pos-8 { left: 92%; top: 64%; }
  .seat-pos-9 { left: 78%; top: 89%; }
}

@media (max-width: 420px) {
  .seat {
    width: clamp(40px, 12.5vw, 48px);
    padding: 1px;
  }

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

  .seat-title {
    font-size: 6px;
  }

  .seat-stack {
    font-size: 5px;
  }

  .seat-action-badge {
    font-size: 6px;
    top: -12px;
    padding: 1px 4px;
  }
}

.hidden {
  display: none;
}
