:root {
  --bg: #0f1419;
  --felt: #0d5c3d;
  --felt-edge: #084429;
  --card: #f7f3ea;
  --red: #c0392b;
  --black: #1a1a1a;
  --gold: #e8c547;
  --primary: #2ecc71;
  --danger: #e74c3c;
  --warn: #f39c12;
  --panel: rgba(0, 0, 0, 0.45);
  --text: #f0f0f0;
  --muted: #9aa3ad;
  --radius: 12px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at center, #1a2332 0%, var(--bg) 70%);
  color: var(--text);
}

.hidden { display: none !important; }

.view {
  min-height: 100vh;
  padding: 16px;
}

/* Lobby */
.lobby-card {
  max-width: 420px;
  margin: 8vh auto;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 28px 24px;
  backdrop-filter: blur(8px);
}
.lobby-card h1 {
  margin: 0;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: var(--gold);
}
.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 6px 0 24px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field span { font-size: 0.85rem; color: var(--muted); }
.field input, .chat-form input, .raise-box input {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  outline: none;
}
.field input:focus { border-color: var(--primary); }
.lobby-actions { margin-bottom: 8px; }
.divider {
  text-align: center;
  color: var(--muted);
  margin: 18px 0;
  font-size: 0.85rem;
}
.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.rules-brief {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}
.rules-brief ul { padding-left: 1.2em; line-height: 1.6; }

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #3a4656;
  color: var(--text);
  transition: transform 0.08s, filter 0.15s;
  width: 100%;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #34d399, #059669); color: #062; font-weight: 600; }
.btn.danger { background: linear-gradient(180deg, #f87171, #dc2626); }
.btn.warn { background: linear-gradient(180deg, #fbbf24, #d97706); color: #222; font-weight: 600; }
.btn.tiny { width: auto; padding: 4px 10px; font-size: 0.8rem; }

/* Table topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.room-info { display: flex; align-items: center; gap: 8px; flex: 1; }
.conn { font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; }
.conn.online { background: rgba(46,204,113,0.2); color: #2ecc71; }
.conn.offline { background: rgba(231,76,60,0.2); color: #e74c3c; }

.table-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}
.felt {
  position: relative;
  width: min(920px, 100%);
  aspect-ratio: 16 / 10;
  min-height: 360px;
  background: radial-gradient(ellipse at center, #128a58 0%, var(--felt) 55%, var(--felt-edge) 100%);
  border: 10px solid #5c3a1e;
  border-radius: 50% / 45%;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35), 0 12px 40px rgba(0,0,0,0.45);
}
.turn-timer {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
}
.turn-timer-label {
  color: var(--muted);
  font-size: 0.8rem;
}
.turn-timer-value {
  min-width: 1.6em;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.turn-timer.warn .turn-timer-value {
  color: var(--warn);
}
.turn-timer.danger .turn-timer-value {
  color: var(--danger);
  animation: timer-pulse 0.8s ease-in-out infinite;
}
.turn-timer.mine {
  border-color: rgba(46, 204, 113, 0.45);
  box-shadow: 0 0 0 1px rgba(46, 204, 113, 0.15);
}
@keyframes timer-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
.seat .seat-timer {
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.seat.active .seat-timer.danger {
  color: var(--danger);
}

.pot-area {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
}
.pot-label { font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.pot-value { font-size: 1.8rem; font-weight: 700; color: var(--gold); text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.stake-line { font-size: 0.85rem; margin-top: 4px; color: rgba(255,255,255,0.85); }
.game-msg { margin-top: 8px; font-size: 0.8rem; color: #ffeaa7; max-width: 260px; }

.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  width: 140px;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 3;
}
.seat .avatar {
  width: 48px;
  height: 48px;
  margin: 0 auto 4px;
  border-radius: 50%;
  background: #2c3e50;
  border: 2px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}
.seat.active .avatar {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,197,71,0.45);
  animation: pulse 1.2s infinite;
}
.seat.dealer .avatar::after {
  content: "庄";
  position: absolute;
  margin-left: 36px;
  margin-top: -28px;
  background: var(--gold);
  color: #333;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
}
.seat .name { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .chips { font-size: 0.75rem; color: #a7f3d0; }
.seat .badge {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.35);
}
.seat.folded { opacity: 0.45; }
.seat.offline .avatar { border-style: dashed; opacity: 0.6; }
.seat .mini-cards {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 4px;
  min-height: 36px;
}

/* —— 闷牌 / 已看 视觉分流 —— */
.seat.blind .avatar {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.35);
  background: linear-gradient(145deg, #1e3a5f, #0f2744);
}
.seat.looked .avatar {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4);
  background: linear-gradient(145deg, #5c3d0e, #3a2808);
}
.seat.just-bet .avatar {
  animation: bet-glow 0.7s ease;
}

.status-pill {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  color: #e5e7eb;
}
.status-pill.status-blind {
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #eff6ff;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.45);
}
.status-pill.status-looked {
  background: linear-gradient(90deg, #b45309, #f59e0b);
  color: #1c1400;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.45);
}
.status-pill.status-allin {
  background: linear-gradient(90deg, #7c3aed, #c026d3);
  color: #faf5ff;
}
.status-pill.status-fold {
  background: rgba(75, 85, 99, 0.85);
  color: #d1d5db;
}
.action-tag {
  margin-top: 2px;
  font-size: 0.68rem;
  color: #fde68a;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* 座位前筹码堆 */
.bet-stack {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 3px 10px 3px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(232, 197, 71, 0.55);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
}
.bet-stack.hidden { display: none; }
.bet-amount {
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
}
.bet-coin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #e8c547 45%, #a67c00 100%);
  border: 1px solid #7a5a00;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.bet-stack.bet-pop,
.self-bet.bet-pop {
  animation: bet-pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.seat-fx {
  position: absolute;
  left: 50%;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 6;
}
.bet-float {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fde047;
  text-shadow:
    0 0 8px rgba(253, 224, 71, 0.8),
    0 2px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
  animation: bet-float-up 1.1s ease-out forwards;
  pointer-events: none;
}

.pot-value.pot-bump {
  animation: pot-bump 0.5s ease;
}

@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); }
}
@keyframes bet-float-up {
  0%   { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.7); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.15); }
  70%  { opacity: 1; transform: translateX(-50%) translateY(-28px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-48px) scale(0.9); }
}
@keyframes bet-pop {
  0%   { transform: scale(0.6); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes bet-glow {
  0%   { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.8); }
  50%  { box-shadow: 0 0 16px 6px rgba(253, 224, 71, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0); }
}
@keyframes pot-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); color: #fff3a0; }
  100% { transform: scale(1); }
}

/* Cards */
.card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 72px;
  border-radius: 6px;
  background: var(--card);
  color: var(--black);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 1px solid rgba(0,0,0,0.08);
  line-height: 1.1;
  user-select: none;
}
.card .suit { font-size: 1.1rem; }
.card .rank { font-size: 0.95rem; }
.card.red { color: var(--red); }
.card.back {
  background: repeating-linear-gradient(
    45deg,
    #1e3a5f,
    #1e3a5f 6px,
    #254a78 6px,
    #254a78 12px
  );
  color: transparent;
  border: 2px solid #d4af37;
}
/* 闷牌：冷蓝斜纹 + 蓝边 */
.card.back.back-blind {
  background: repeating-linear-gradient(
    45deg,
    #0c2a4d,
    #0c2a4d 5px,
    #1a4a7a 5px,
    #1a4a7a 10px
  );
  border: 2px solid #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.35);
}
/* 已看：暖金斜纹 + 金边 */
.card.back.back-looked {
  background: repeating-linear-gradient(
    -45deg,
    #3d2a08,
    #3d2a08 5px,
    #6b4a12 5px,
    #6b4a12 10px
  );
  border: 2px solid #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}
.card.mini { width: 28px; height: 40px; font-size: 0.65rem; border-radius: 4px; }
.card.mini .suit { font-size: 0.75rem; }
.card.mini .rank { font-size: 0.7rem; }

.cards-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 76px;
}
.cards-row.blind-backs .card {
  animation: card-breathe 2.2s ease-in-out infinite;
}
.cards-row.revealed .card {
  animation: card-flip-in 0.35s ease;
}
@keyframes card-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes card-flip-in {
  from { transform: rotateY(70deg) scale(0.9); opacity: 0.4; }
  to   { transform: rotateY(0) scale(1); opacity: 1; }
}

.self-panel {
  max-width: 920px;
  margin: 0 auto;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.self-look-state {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.self-look-state.blind {
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.45);
}
.self-look-state.looked {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.45);
}
.self-look-state.hidden { display: none; }
.self-meta {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  font-size: 0.95rem;
  align-items: center;
}
.self-bet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(232, 197, 71, 0.5);
  color: var(--gold);
  font-size: 0.9rem;
}
.self-bet strong {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.hand-name { color: var(--gold); }

.actions {
  max-width: 920px;
  margin: 12px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.actions .btn { width: auto; min-width: 88px; }
.raise-box { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.raise-box input { width: 90px; padding: 8px; }
.raise-min-hint {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  color: #e5e7eb;
}
.raise-min-hint.blind {
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(37, 99, 235, 0.2);
}
.raise-min-hint.looked {
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(245, 158, 11, 0.18);
}

.host-actions {
  max-width: 920px;
  margin: 10px auto 0;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.host-actions .btn { width: auto; min-width: 120px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: #1c2430;
  border-radius: 12px;
  padding: 20px;
  min-width: 260px;
  max-width: 90vw;
}
.modal-card h3 { margin: 0 0 12px; }
.target-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

/* Settlement result */
.settlement-card {
  min-width: min(360px, 92vw);
  max-width: min(520px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid rgba(232, 197, 71, 0.35);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.settlement-card h3 {
  text-align: center;
  color: var(--gold);
  letter-spacing: 0.12em;
}
.settlement-reason {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.settlement-winners {
  text-align: center;
  margin-bottom: 14px;
  font-size: 1rem;
  color: var(--primary);
  font-weight: 600;
}
.settlement-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.settlement-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.settlement-row.is-winner {
  border-color: rgba(46, 204, 113, 0.45);
  background: rgba(46, 204, 113, 0.08);
}
.settlement-row.is-folded {
  opacity: 0.78;
}
.settlement-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.settlement-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settlement-sub {
  font-size: 0.8rem;
  color: var(--muted);
}
.settlement-sub .gain {
  color: var(--primary);
  font-weight: 600;
}
.settlement-cards {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.settlement-cards .card {
  width: 40px;
  height: 56px;
  font-size: 0.85rem;
}
.settlement-card .btn {
  width: 100%;
}

/* Chat */
.chat-panel {
  max-width: 920px;
  margin: 14px auto 0;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px;
}
.chat-log {
  height: 90px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #d1d5db;
  margin-bottom: 8px;
}
.chat-log .line { margin: 2px 0; }
.chat-log .who { color: #93c5fd; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 100;
  max-width: 90vw;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

@media (max-width: 640px) {
  .felt {
    aspect-ratio: 1 / 1.05;
    border-radius: 24px;
    min-height: 420px;
  }
  .seat { width: 110px; }
  .card { width: 46px; height: 64px; }
  .actions .btn { min-width: 72px; padding: 8px 10px; font-size: 0.85rem; }
}
