:root {
  --felt: #0d5c45;
  --felt-dark: #084032;
  --felt-edge: #0a2f24;
  --gold: #e8c547;
  --chip: #f5f0e6;
  --danger: #e74c3c;
  --warn: #f39c12;
  --primary: #2ecc71;
  --text: #f4f7f5;
  --muted: #a8c0b6;
  --card: #fffef9;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  font-family: 'Noto Sans TC', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, #123d32 0%, #061a14 70%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body { min-height: 100dvh; }

#app { min-height: 100dvh; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Lobby */
#lobby {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lobby-card {
  width: min(420px, 100%);
  background: rgba(8, 40, 30, 0.85);
  border: 1px solid rgba(232, 197, 71, 0.25);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.logo {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  margin-bottom: 8px;
}
.lobby-card h1 {
  margin: 0;
  text-align: center;
  font-weight: 900;
  font-size: 2rem;
  letter-spacing: 0.08em;
}
.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 28px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.field input {
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  outline: none;
}
.field input:focus {
  border-color: var(--gold);
}
.lobby-actions { display: flex; flex-direction: column; gap: 4px; }
.or {
  text-align: center;
  color: var(--muted);
  margin: 10px 0;
  font-size: 0.85rem;
}
.error {
  color: #ff8a80;
  margin-top: 12px;
  text-align: center;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #3ddc84, #1f9d57); color: #042016; }
.btn.secondary { background: rgba(255,255,255,0.12); color: var(--text); }
.btn.danger { background: linear-gradient(180deg, #ff6b5b, #c0392b); color: #fff; }
.btn.warn { background: linear-gradient(180deg, #ffc857, #e67e22); color: #2a1600; }
.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--text);
}
.btn.tiny { padding: 4px 10px; font-size: 0.75rem; border-radius: 8px; }

/* Game top */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.room-info { display: flex; align-items: center; gap: 8px; }
.badge {
  background: var(--gold);
  color: #1a1200;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}
.hand-info { color: var(--muted); font-size: 0.85rem; }

/* Table */
.table-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px 4px;
  min-height: 320px;
}
.felt {
  position: relative;
  width: min(920px, 100%);
  aspect-ratio: 16 / 10;
  min-height: 280px;
  max-height: 52vh;
  background:
    radial-gradient(ellipse at center, #127a58 0%, var(--felt) 55%, var(--felt-dark) 100%);
  border: 10px solid #5c3a1e;
  box-shadow:
    inset 0 0 0 4px #8b5a2b,
    var(--shadow);
  border-radius: 50% / 45%;
}
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  width: 110px;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
}
.seat .avatar {
  width: 48px;
  height: 48px;
  margin: 0 auto 4px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a4a3e, #123028);
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}
.seat.acting .avatar {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,197,71,0.45);
  animation: pulse 1.2s ease-in-out infinite;
}
.seat.folded { opacity: 0.45; }
.seat.self .avatar { border-color: #7ee0b0; }
.seat .name {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px #000;
}
.seat .chips {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 700;
}
.seat .tags {
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.tag {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0,0,0,0.45);
}
.tag.d { background: #222; color: #fff; }
.tag.sb { background: #3498db; }
.tag.bb { background: #9b59b6; }
.tag.allin { background: var(--warn); color: #000; }
.seat-bet {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 4px);
  background: rgba(0,0,0,0.55);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--chip);
  white-space: nowrap;
}
.seat-cards {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 4px;
  min-height: 36px;
}

.center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 85%;
  z-index: 1;
}
.pot {
  display: inline-block;
  background: rgba(0,0,0,0.4);
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 10px;
  font-size: 0.95rem;
}
.board {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 64px;
}
.status-msg {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #d7efe4;
  text-shadow: 0 1px 2px #000;
  min-height: 1.2em;
}
.winners {
  margin-top: 8px;
  background: rgba(232, 197, 71, 0.15);
  border: 1px solid rgba(232,197,71,0.4);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--gold);
}

/* Cards */
.card {
  width: 42px;
  height: 60px;
  border-radius: 6px;
  background: var(--card);
  color: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  line-height: 1.1;
  user-select: none;
}
.card .suit { font-size: 1rem; }
.card.red { color: #c0392b; }
.card.black { color: #1a1a1a; }
.card.back {
  background: repeating-linear-gradient(
    45deg,
    #1e3a8a,
    #1e3a8a 4px,
    #1e40af 4px,
    #1e40af 8px
  );
  border: 2px solid #fff;
}
.card.sm { width: 28px; height: 40px; font-size: 0.65rem; border-radius: 4px; }
.card.sm .suit { font-size: 0.75rem; }
.card.lg { width: 56px; height: 80px; font-size: 1.1rem; border-radius: 8px; }
.card.lg .suit { font-size: 1.3rem; }

.hole-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px;
  min-height: 88px;
}

.actions {
  padding: 8px 12px 16px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.35));
}
.raise-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.raise-row input[type="range"] { flex: 1; }
#raiseLabel { font-size: 0.85rem; color: var(--muted); min-width: 90px; }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
}
.btn-row .btn { flex: 1 1 90px; min-width: 80px; }

.lobby-panel {
  text-align: center;
  padding: 16px;
  color: var(--muted);
}
.lobby-panel .btn { margin-top: 8px; min-width: 160px; }

.log-panel {
  max-height: 72px;
  overflow: auto;
  padding: 4px 14px 12px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(232,197,71,0.35); }
  50% { box-shadow: 0 0 0 6px rgba(232,197,71,0.15); }
}

/* Seat positions for up to 8 around oval */
.seat[data-pos="0"] { left: 50%; top: 88%; }   /* bottom self-ish */
.seat[data-pos="1"] { left: 18%; top: 78%; }
.seat[data-pos="2"] { left: 8%; top: 48%; }
.seat[data-pos="3"] { left: 18%; top: 18%; }
.seat[data-pos="4"] { left: 50%; top: 10%; }
.seat[data-pos="5"] { left: 82%; top: 18%; }
.seat[data-pos="6"] { left: 92%; top: 48%; }
.seat[data-pos="7"] { left: 82%; top: 78%; }

@media (max-width: 640px) {
  .felt {
    aspect-ratio: auto;
    height: 340px;
    border-radius: 40% / 35%;
    border-width: 8px;
  }
  .seat { width: 88px; }
  .seat .avatar { width: 40px; height: 40px; font-size: 0.95rem; }
  .card.lg { width: 48px; height: 68px; }
  .btn-row .btn { padding: 10px 8px; font-size: 0.9rem; }
}
