/* =========================== 炸金花 全局样式 =========================== */

:root {
  --neon-blue: #4d9dff;
  --neon-purple: #a855f7;
  --neon-pink: #f472b6;
  --neon-green: #00ff64;
  --neon-orange: #ff8c42;
  --neon-red: #ff3b3b;
  --neon-cyan: #00e5ff;
  --neon-yellow: #ffd740;
  --bg-deep: #080810;
  --bg-panel: rgba(10,12,28,0.75);
  --bg-input: rgba(16,20,44,0.5);
  --text: #e0e0f0;
  --text-muted: #7a7a9e;
  --border: rgba(255,255,255,0.06);
  --card-width: 66px;
  --card-height: 94px;
  --card-radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100vw; height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #050510;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%; height: 100%;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

/* =========================== 页面切换 =========================== */
.page {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page.active { display: flex; }

/* =========================== 按钮 =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}
.btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: -1;
  filter: blur(8px);
}
.btn:active { transform: scale(0.94); }
.btn:hover::before { opacity: 0.35; }

.btn-primary {
  background: rgba(77,157,255,0.08);
  color: var(--neon-blue);
  border-color: rgba(77,157,255,0.45);
  text-shadow: 0 0 8px rgba(77,157,255,0.4);
  box-shadow: 0 0 12px rgba(77,157,255,0.15), inset 0 0 12px rgba(77,157,255,0.05);
}
.btn-primary::before { background: var(--neon-blue); }
.btn-primary:hover { border-color: var(--neon-blue); box-shadow: 0 0 20px rgba(77,157,255,0.35); }

.btn-secondary {
  background: rgba(168,85,247,0.06);
  color: var(--neon-purple);
  border-color: rgba(168,85,247,0.35);
  text-shadow: 0 0 6px rgba(168,85,247,0.3);
}
.btn-secondary::before { background: var(--neon-purple); }
.btn-secondary:hover { border-color: var(--neon-purple); box-shadow: 0 0 16px rgba(168,85,247,0.3); }

.btn-danger {
  background: rgba(255,59,59,0.08);
  color: var(--neon-red);
  border-color: rgba(255,59,59,0.4);
  text-shadow: 0 0 8px rgba(255,59,59,0.3);
}
.btn-danger::before { background: var(--neon-red); }
.btn-danger:hover { border-color: var(--neon-red); box-shadow: 0 0 18px rgba(255,59,59,0.3); }

.btn-text { background: transparent; border-color: transparent; color: var(--neon-purple); }
.btn-text::before { display: none; }
.btn-sm { padding: 8px 16px; font-size: 14px; min-height: 36px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.25; pointer-events: none; filter: grayscale(0.6); }

.btn-back {
  background: transparent;
  color: var(--neon-purple);
  border: 1px solid rgba(168,85,247,0.3);
  font-size: 16px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 8px;
  transition: all 0.2s;
}
.btn-back:hover { border-color: var(--neon-purple); box-shadow: 0 0 12px rgba(168,85,247,0.2); }

/* =========================== 首页 =========================== */
#home-page {
  align-items: center;
  padding: 30px 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 50% 25%, rgba(80,60,200,0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 35% 70%, rgba(77,157,255,0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 40%, rgba(168,85,247,0.05) 0%, transparent 40%),
    var(--bg-deep);
}

.home-header { text-align: center; margin-bottom: 30px; margin-top: 20px; }
.game-title {
  font-size: 44px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  letter-spacing: 2px;
  filter: drop-shadow(0 0 12px rgba(168,85,247,0.4));
}
.game-subtitle { color: var(--text-muted); font-size: 14px; letter-spacing: 1px; }

.home-form {
  width: 100%;
  background: rgba(10,12,28,0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 24px 20px;
  margin-bottom: 24px;
  border: 1px solid rgba(168,85,247,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.input-group { margin-bottom: 20px; }
.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.input-group input,
.join-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(77,157,255,0.2);
  background: rgba(8,12,28,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
  transition: all 0.25s;
}
.input-group input:focus,
.join-input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 16px rgba(77,157,255,0.2), 0 0 0 3px rgba(77,157,255,0.06);
}

.home-buttons { display: flex; flex-direction: column; gap: 16px; }
.divider {
  display: flex; align-items: center;
  color: var(--text-muted); font-size: 13px;
}
.divider::before, .divider::after {
  content: ''; flex: 1;
  height: 1px; background: linear-gradient(90deg, transparent, rgba(168,85,247,0.3), transparent);
  margin: 0 10px;
}
.join-row { display: flex; gap: 8px; }
.join-row .join-input { flex: 1; }

.room-list-section { width: 100%; margin-bottom: 24px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-header h3 { font-size: 16px; font-weight: 700; color: var(--neon-purple); }

.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10,12,28,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(168,85,247,0.1);
}
.room-item:hover { border-color: rgba(168,85,247,0.35); box-shadow: 0 0 16px rgba(168,85,247,0.1); }
.room-item:active { background: rgba(20,24,44,0.8); }
.room-item-id {
  font-weight: 800; font-size: 18px; color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0,229,255,0.3); letter-spacing: 2px;
}
.room-item-info { font-size: 13px; color: var(--text-muted); }
.room-item-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700;
}
.badge-waiting { background: rgba(0,255,100,0.12); color: var(--neon-green); border: 1px solid rgba(0,255,100,0.25); }
.badge-playing { background: rgba(255,59,59,0.12); color: var(--neon-red); border: 1px solid rgba(255,59,59,0.25); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-size: 14px;
}

.home-footer { text-align: center; margin-top: auto; }
.status-disconnected { color: var(--neon-red); font-size: 13px; }
.status-connected { color: var(--neon-green); font-size: 13px; }

/* =========================== 房间大厅 =========================== */
#room-page {
  background:
    radial-gradient(ellipse at 50% 24%, rgba(80,60,200,0.1) 0%, transparent 50%),
    var(--bg-deep);
}

.room-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: rgba(8,10,24,0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(168,85,247,0.1);
}
.room-info { flex: 1; text-align: center; }
.room-id-label { font-size: 11px; color: var(--text-muted); display: block; letter-spacing: 1px; }
.room-id-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--neon-cyan);
  letter-spacing: 4px;
  text-shadow: 0 0 12px rgba(0,229,255,0.4);
}
.btn-copy { font-size: 13px; padding: 6px 12px; }

.room-players {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

.room-settings {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(8,10,24,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(168,85,247,0.08);
  border-bottom: 1px solid rgba(168,85,247,0.08);
}
.room-settings-item { flex: 1; text-align: center; }
.room-settings-label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
  letter-spacing: 0.5px;
}
.room-settings-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0,229,255,0.3);
}

.player-seat {
  width: 82px;
  text-align: center;
  padding: 14px 8px;
  border-radius: 16px;
  background: rgba(8,10,28,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(168,85,247,0.12);
  transition: all 0.3s;
}
.player-seat.host {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 18px rgba(0,229,255,0.15);
}
.player-seat.disconnected { opacity: 0.4; border-color: rgba(255,59,59,0.3); }

.player-seat-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(77,157,255,0.15), rgba(168,85,247,0.1));
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--neon-cyan);
  border: 1px solid rgba(0,229,255,0.25);
  text-shadow: 0 0 8px rgba(0,229,255,0.4);
}
.player-seat-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-seat-badge {
  font-size: 11px;
  color: var(--neon-purple);
  margin-top: 2px;
  font-weight: 700;
}

.room-actions {
  padding: 16px 20px;
  flex-shrink: 0;
}

/* =========================== 聊天 =========================== */
.chat-section {
  border-top: 1px solid rgba(168,85,247,0.1);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 160px;
  background: rgba(8,10,24,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  font-size: 13px;
  min-height: 40px;
  max-height: 100px;
}
.chat-msg { margin-bottom: 4px; line-height: 1.5; }
.chat-msg-name { color: var(--neon-cyan); font-weight: 700; text-shadow: 0 0 6px rgba(0,229,255,0.3); }
.chat-msg-system { color: var(--text-muted); font-style: italic; }
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: rgba(6,8,20,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(168,85,247,0.08);
}
.chat-input-row input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid rgba(77,157,255,0.2);
  background: rgba(8,12,28,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.25s;
}
.chat-input-row input:focus { border-color: var(--neon-blue); box-shadow: 0 0 12px rgba(77,157,255,0.15); }

/* =========================== 右侧常驻聊天栏 =========================== */
.game-chat-sidebar {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(6,10,22,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(168,85,247,0.1);
}
.game-chat-header {
  padding: 10px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(168,85,247,0.12);
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-purple);
  letter-spacing: 0.5px;
  text-shadow: 0 0 8px rgba(168,85,247,0.3);
}
.game-chat-sidebar .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 12px;
  scrollbar-width: thin;
}
.game-chat-sidebar .chat-msg { margin-bottom: 3px; line-height: 1.4; word-break: break-all; }
.game-chat-sidebar .chat-msg-name { color: var(--neon-cyan); font-weight: 700; text-shadow: 0 0 4px rgba(0,229,255,0.25); }
.game-chat-sidebar .chat-msg-system { color: var(--text-muted); font-style: italic; }
.game-chat-sidebar .chat-input-row {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  padding-bottom: calc(6px + var(--safe-bottom));
  flex-shrink: 0;
  border-top: 1px solid rgba(168,85,247,0.1);
  background: rgba(6,8,20,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.game-chat-sidebar .chat-input-row input {
  flex: 1; width: 0; min-width: 0;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(77,157,255,0.2);
  background: rgba(8,12,28,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.game-chat-sidebar .chat-input-row input:focus { border-color: var(--neon-blue); box-shadow: 0 0 10px rgba(77,157,255,0.15); }
.game-chat-sidebar .chat-input-row .btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  min-height: 30px;
  flex-shrink: 0;
}

/* 窄屏适配 */
@media (max-width: 420px) {
  .game-chat-sidebar { width: 135px; }
}

/* =========================== 游戏界面 =========================== */
#game-page {
  flex-direction: row;
  background: var(--bg-deep);
}

/* 左侧：游戏主体 — 深黑网格 + 霓虹光晕 */
.game-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background:
    /* 暗角 */
    radial-gradient(ellipse at 50% 32%, transparent 18%, rgba(0,0,0,0.7) 90%),
    /* 网格线 */
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(77,157,255,0.03) 39px, rgba(77,157,255,0.03) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(77,157,255,0.03) 39px, rgba(77,157,255,0.03) 40px),
    /* 中心蓝紫光晕 */
    radial-gradient(ellipse at 50% 35%, rgba(80,60,200,0.18) 0%, transparent 45%, rgba(0,0,0,0.3) 85%),
    var(--bg-deep);
}

/* 顶部悬浮信息栏 */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  margin: 6px 8px 0;
  background: rgba(6,10,22,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  flex-shrink: 0;
  font-size: 12px;
  border: 1px solid rgba(168,85,247,0.1);
}
.game-room-id { color: var(--text-muted); font-size: 12px; }
.game-pot { text-align: center; }
.pot-label { font-size: 10px; color: var(--text-muted); display: block; letter-spacing: 1px; }
.pot-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px rgba(255,215,64,0.5), 0 0 40px rgba(255,215,64,0.2);
  line-height: 1.1;
  transition: all 0.3s;
}
.game-round {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
}

/* 对手区域 */
.opponents-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px;
  flex-shrink: 0;
  min-height: 52px;
}

.opponent-card {
  width: 72px;
  padding: 6px 4px;
  border-radius: 12px;
  background: rgba(8,10,24,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
  border: 1px solid rgba(168,85,247,0.1);
  transition: all 0.3s;
  position: relative;
}
.opponent-card.current-turn {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 16px rgba(0,229,255,0.25);
  animation: neon-pulse 1.5s infinite;
}
.opponent-card.folded {
  opacity: 0.3;
  filter: grayscale(0.6);
}
.opponent-card.folded .opp-card-mini { display: none; }
.opponent-card.folded .opponent-name { text-decoration: line-through; }

.opp-card-mini {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-bottom: 4px;
}
.mini-card {
  width: 16px; height: 22px;
  border-radius: 3px;
  background: #141428;
  border: 1px solid rgba(77,157,255,0.4);
  box-shadow: 0 0 6px rgba(77,157,255,0.2);
  position: relative;
}
.mini-card::after {
  content: '';
  position: absolute;
  width: 5px; height: 5px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid rgba(77,157,255,0.35);
  border-radius: 1px;
}
.opp-card-eyes { font-size: 12px; margin-bottom: 2px; opacity: 0.7; }
.opponent-name {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text);
}

/* 状态圆点 */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.dot-alive { background: var(--neon-green); box-shadow: 0 0 6px var(--neon-green); }
.status-dot.dot-folded { background: #555; }
.status-dot.dot-disconnected { background: var(--neon-red); box-shadow: 0 0 6px var(--neon-red); }
.opponent-bet {
  font-size: 10px;
  color: var(--neon-yellow);
  margin-top: 1px;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(255,215,64,0.3);
}
.opponent-status {
  font-size: 10px;
  color: var(--text-muted);
}
.opponent-badge {
  display: inline-block;
  background: rgba(0,229,255,0.15);
  color: var(--neon-cyan);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  margin-top: 1px;
  font-weight: 800;
  border: 1px solid rgba(0,229,255,0.25);
}

/* 庄家标识 */
.dealer-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #ff8c42, #ff3b3b);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(255,140,66,0.6), 0 0 20px rgba(255,59,59,0.3);
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.opponent-card.dealer {
  border-color: rgba(255,140,66,0.6);
  box-shadow: 0 0 12px rgba(255,140,66,0.2);
}

.opponent-card.dealer.current-turn {
  border-color: var(--neon-orange);
  box-shadow: 0 0 22px rgba(255,140,66,0.4);
}

/* 庄家座位标识（房间大厅） */
.player-seat.dealer {
  border-color: var(--neon-orange);
  box-shadow: 0 0 18px rgba(255,140,66,0.2);
}

.dealer-seat-badge {
  color: var(--neon-orange) !important;
  text-shadow: 0 0 8px rgba(255,140,66,0.5);
}

@keyframes neon-pulse {
  0%, 100% { border-color: var(--neon-cyan); box-shadow: 0 0 10px rgba(0,229,255,0.2); }
  50% { border-color: rgba(0,229,255,0.7); box-shadow: 0 0 22px rgba(0,229,255,0.4); }
}

/* 自己手牌 */
.my-cards-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  min-height: 150px;
}

.cards-container {
  display: flex;
  gap: 10px;
  perspective: 1000px;
}

/* 3D 翻转卡牌容器 */
.card-flip-container {
  width: var(--card-width);
  height: var(--card-height);
  perspective: 800px;
  cursor: pointer;
}

/* 发牌入场动画 — 带霓虹拖尾 */
@keyframes dealIn {
  0%   { opacity: 0; transform: translateY(-80px) scale(0.5) rotateZ(-15deg); filter: drop-shadow(0 0 0 rgba(77,157,255,0)); }
  50%  { opacity: 1; filter: drop-shadow(0 0 30px rgba(77,157,255,0.6)) drop-shadow(0 0 60px rgba(168,85,247,0.3)); }
  75%  { transform: translateY(4px) scale(1.03) rotateZ(1deg); filter: drop-shadow(0 0 18px rgba(77,157,255,0.4)); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateZ(0deg); filter: drop-shadow(0 0 0 rgba(77,157,255,0)); }
}
.card-flip-container { animation: dealIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.card-flip-container:nth-child(1) { animation-delay: 0.05s; }
.card-flip-container:nth-child(2) { animation-delay: 0.18s; }
.card-flip-container:nth-child(3) { animation-delay: 0.30s; }
.card-flip-container.dealt { animation: none; }

.card-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.40s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--card-radius);
}

.card-flip-inner.flipped {
  transform: rotateY(180deg);
}

.card-flip-inner.permanent {
  transform: rotateY(180deg);
  transition: none;
}

/* 正面和背面共享 */
.card-flip-inner .card-front,
.card-flip-inner .card-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--card-radius);
}

.card-flip-inner .card-front { transform: rotateY(180deg); }

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ---------- 牌背：深灰底 + 霓虹蓝紫发光边框 + 中心几何logo ---------- */
.card-back {
  background:
    linear-gradient(160deg, #1c1c30 0%, #141428 50%, #101020 100%);
  border: 2px solid rgba(77,157,255,0.5);
  box-shadow:
    0 0 12px rgba(77,157,255,0.35),
    0 0 30px rgba(77,157,255,0.12),
    0 4px 14px rgba(0,0,0,0.6);
  color: transparent;
  font-size: 0;
  position: relative;
  overflow: hidden;
}
.card-back::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(77,157,255,0.2);
  border-radius: 3px;
}
.card-back::after {
  content: '';
  position: absolute;
  width: 32px; height: 32px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 2px solid rgba(77,157,255,0.5);
  border-radius: 4px;
  background: rgba(77,157,255,0.06);
  box-shadow: 0 0 14px rgba(77,157,255,0.25);
}

/* ---------- 牌面：暗黑牌面 + 荧光花色数字 + 外发光 ---------- */
.card-front {
  background: linear-gradient(160deg, #1e1e32 0%, #181826 40%, #141420 100%);
  color: #fff;
  border: 1.5px solid rgba(200,200,220,0.2);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.5),
    inset 0 0 20px rgba(255,255,255,0.03);
  text-shadow: 0 0 8px currentColor;
}

.card-front .card-rank {
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -1px;
}
.card-front .card-suit {
  font-size: 22px;
  margin-top: 1px;
  line-height: 1;
}

.card-front.spade { color: #d0d0f0; }
.card-front.club  { color: #b0ffb0; text-shadow: 0 0 8px rgba(176,255,176,0.6); }
.card-front.heart { color: #ff6060; text-shadow: 0 0 10px rgba(255,96,96,0.5); }
.card-front.diamond { color: #ffa040; text-shadow: 0 0 10px rgba(255,160,64,0.5); }

/* 悬浮霓虹增强 */
.card-flip-container:hover .card-back {
  border-color: var(--neon-cyan);
  box-shadow:
    0 0 20px rgba(0,229,255,0.5),
    0 0 50px rgba(0,229,255,0.15),
    0 4px 14px rgba(0,0,0,0.6);
}
.card-flip-container:hover .card-back::after {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 20px rgba(0,229,255,0.4);
}
.card-flip-container:hover .card-front {
  box-shadow:
    0 0 18px rgba(168,85,247,0.3),
    0 4px 16px rgba(0,0,0,0.5),
    inset 0 0 24px rgba(255,255,255,0.04);
}

/* 赢家呼吸发光 */
.card-flip-container.winner-glow .card-front,
.card-flip-container.winner-glow .card-back {
  animation: winner-breathe 1.2s ease-in-out infinite;
}
@keyframes winner-breathe {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255,215,64,0.4)); }
  50% { filter: drop-shadow(0 0 22px rgba(255,215,64,0.8)) drop-shadow(0 0 40px rgba(255,140,66,0.4)); }
}

.my-hand-info {
  margin-top: 10px;
  font-size: 13px;
  color: var(--neon-cyan);
  text-align: center;
  min-height: 20px;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(0,229,255,0.3);
}

/* 庄家指示器（自己手牌上方） */
.dealer-indicator {
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--neon-orange);
  text-shadow: 0 0 10px rgba(255,140,66,0.6);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

/* 操作按钮 */
.action-area {
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  flex-shrink: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}
.action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.action-row:last-child { margin-bottom: 0; }

.btn-action {
  flex: 1;
  padding: 14px 8px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  min-height: 48px;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}
.btn-action::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 18px;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: -1;
  filter: blur(10px);
}
.btn-action:hover::before { opacity: 0.5; }
.btn-action:active {
  transform: scale(0.93);
  filter: brightness(0.8);
}
.btn-action:disabled {
  opacity: 0.2;
  pointer-events: none;
  filter: grayscale(0.7);
}

/* 旁观操作栏 */
.spectator-bar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.spectator-hint {
  font-size: 13px;
  color: #a0a0a0;
  margin-bottom: 12px;
}
.spectator-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn-spectator {
  padding: 10px 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #c8c8d0;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.25s;
}
.btn-spectator:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}
.btn-spectator-danger:hover {
  border-color: var(--neon-red);
  color: var(--neon-red);
}

.btn-look {
  background: rgba(77,157,255,0.08);
  color: var(--neon-blue);
  border-color: rgba(77,157,255,0.4);
  text-shadow: 0 0 8px rgba(77,157,255,0.4);
  box-shadow: 0 0 12px rgba(77,157,255,0.12);
}
.btn-look::before { background: var(--neon-blue); }
.btn-look:hover { border-color: var(--neon-blue); box-shadow: 0 0 20px rgba(77,157,255,0.3); }

.btn-call {
  background: rgba(0,255,100,0.07);
  color: var(--neon-green);
  border-color: rgba(0,255,100,0.4);
  text-shadow: 0 0 8px rgba(0,255,100,0.4);
  box-shadow: 0 0 12px rgba(0,255,100,0.12);
}
.btn-call::before { background: var(--neon-green); }
.btn-call:hover { border-color: var(--neon-green); box-shadow: 0 0 20px rgba(0,255,100,0.3); }

.btn-raise {
  background: rgba(255,140,66,0.07);
  color: var(--neon-orange);
  border-color: rgba(255,140,66,0.4);
  text-shadow: 0 0 8px rgba(255,140,66,0.4);
  box-shadow: 0 0 12px rgba(255,140,66,0.12);
}
.btn-raise::before { background: var(--neon-orange); }
.btn-raise:hover { border-color: var(--neon-orange); box-shadow: 0 0 20px rgba(255,140,66,0.3); }

.btn-compare {
  background: rgba(168,85,247,0.07);
  color: var(--neon-purple);
  border-color: rgba(168,85,247,0.4);
  text-shadow: 0 0 8px rgba(168,85,247,0.4);
  box-shadow: 0 0 12px rgba(168,85,247,0.12);
}
.btn-compare::before { background: var(--neon-purple); }
.btn-compare:hover { border-color: var(--neon-purple); box-shadow: 0 0 20px rgba(168,85,247,0.3); }

.btn-fold {
  background: rgba(255,59,59,0.07);
  color: var(--neon-red);
  border-color: rgba(255,59,59,0.4);
  text-shadow: 0 0 8px rgba(255,59,59,0.4);
  box-shadow: 0 0 12px rgba(255,59,59,0.12);
}
.btn-fold::before { background: var(--neon-red); }
.btn-fold:hover { border-color: var(--neon-red); box-shadow: 0 0 20px rgba(255,59,59,0.3); }

/* =========================== 弹窗/模态框 =========================== */
.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.show {
  display: flex;
  animation: overlayIn 0.25s ease-out;
}
@keyframes overlayIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal-box {
  background: linear-gradient(160deg, rgba(14,16,36,0.96), rgba(8,10,22,0.98));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 22px;
  padding: 24px;
  width: 85%;
  max-width: 340px;
  text-align: center;
  border: 1px solid rgba(168,85,247,0.2);
  box-shadow: 0 0 40px rgba(168,85,247,0.15), 0 16px 48px rgba(0,0,0,0.7);
  animation: modalIn 0.30s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  0% { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}
.modal-box h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--neon-cyan);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(0,229,255,0.3);
}
.modal-box h2 {
  font-size: 24px;
  margin-bottom: 12px;
  font-weight: 800;
}

.raise-options, .compare-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.raise-option, .compare-option {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid rgba(77,157,255,0.2);
  background: rgba(10,14,30,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.15s;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.raise-option:hover, .compare-option:hover {
  background: rgba(77,157,255,0.12);
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(77,157,255,0.2);
}
.raise-option:active, .compare-option:active {
  transform: scale(0.94);
  border-color: var(--neon-cyan);
}

/* 入房审批弹窗 */
.approval-box {
  max-width: 300px;
}
.approval-player {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}
.approval-player span {
  color: var(--neon-cyan);
  font-weight: 800;
}
.approval-queue-count {
  font-size: 13px;
  color: #a78bfa;
  margin-top: -8px;
  margin-bottom: 12px;
}
.approval-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.approval-actions .btn {
  min-width: 90px;
}

/* 看牌弹窗 */
.look-cards {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.look-cards .card {
  width: 72px; height: 100px;
  font-size: 22px;
}
.look-hand-info {
  font-size: 17px;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0,229,255,0.4);
  margin-bottom: 16px;
}

/* 游戏结束弹窗霓虹版 */
.game-over-box { padding: 28px 20px; }
.game-over-title {
  color: var(--neon-yellow) !important;
  font-weight: 900 !important;
  text-shadow: 0 0 16px rgba(255,215,64,0.5) !important;
}
.game-over-detail {
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.game-over-detail .cards-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}
.game-over-detail .mini-card-front {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(160deg, #1e1e32, #141420);
  color: var(--neon-cyan);
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 0 8px rgba(0,229,255,0.2);
  border: 1px solid rgba(0,229,255,0.3);
  text-shadow: 0 0 6px rgba(0,229,255,0.4);
}

/* =========================== Toast =========================== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6,8,20,0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  font-weight: 600;
  border: 1px solid rgba(168,85,247,0.2);
  box-shadow: 0 0 20px rgba(168,85,247,0.15);
}
.toast.show { opacity: 1; }
.toast.error { background: rgba(40, 8, 8, 0.94); border-color: rgba(255,59,59,0.4); box-shadow: 0 0 20px rgba(255,59,59,0.2); }
.toast.success { background: rgba(4, 30, 10, 0.94); border-color: rgba(0,255,100,0.4); box-shadow: 0 0 20px rgba(0,255,100,0.2); }

/* =========================== 滚动条 =========================== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* =========================== 响应式 =========================== */

/* ---------- 平板 (480px+) ---------- */
@media (min-width: 480px) {
  :root {
    --card-width: 74px;
    --card-height: 104px;
  }
  .opponent-card { width: 82px; }
}

/* ---------- 窄屏聊天栏 (≤420px) ---------- */
@media (max-width: 420px) {
  .game-chat-sidebar { width: 135px; }
}

/* ==============================================================
   电脑端大屏 (≥768px)：games-table 居中 + 元素放大 + 间距优化
   ============================================================== */
@media (min-width: 768px) {

  /* ----- 全局容器 ----- */
  #app { max-width: none; }

  html, body {
    background: radial-gradient(ellipse at 50% 30%, rgba(80,60,200,0.08) 0%, transparent 60%), #050510;
  }

  /* ----- 首页 ----- */
  #home-page { padding: 48px 40px; }

  .game-title { font-size: 56px; letter-spacing: 3px; }
  .game-subtitle { font-size: 16px; }

  .home-form {
    max-width: 460px;
    padding: 32px 28px;
    border-radius: 24px;
  }
  .input-group label { font-size: 14px; }
  .input-group input, .join-input {
    padding: 16px 20px;
    font-size: 17px;
    border-radius: 14px;
  }
  .home-buttons { gap: 20px; }
  .home-buttons .btn { padding: 16px 32px; font-size: 18px; border-radius: 14px; }

  .room-list-section { max-width: 460px; }
  .room-item { padding: 16px 20px; border-radius: 16px; }
  .room-item-id { font-size: 20px; }

  .divider { font-size: 14px; }

  /* ----- 房间大厅 ----- */
  #room-page {
    background:
      radial-gradient(ellipse at 50% 24%, rgba(80,60,200,0.1) 0%, transparent 50%),
      var(--bg-deep);
  }
  #room-page .room-header { padding: 16px 28px; }
  .room-id-value { font-size: 30px; letter-spacing: 6px; }
  .room-id-label { font-size: 12px; }
  .btn-back { font-size: 18px; padding: 10px 16px; }

  .room-players {
    gap: 24px;
    padding: 30px;
  }
  .player-seat {
    width: 106px;
    padding: 18px 12px;
    border-radius: 18px;
  }
  .player-seat-avatar {
    width: 58px; height: 58px;
    font-size: 24px;
    margin-bottom: 10px;
  }
  .player-seat-name { font-size: 15px; }
  .player-seat-badge { font-size: 12px; }

  .room-settings { padding: 14px 28px; gap: 24px; }
  .room-settings-label { font-size: 12px; }
  .room-settings-value { font-size: 24px; }

  .room-actions { padding: 20px 28px; }
  .room-actions .btn { padding: 14px 28px; font-size: 17px; border-radius: 14px; }

  /* 大厅聊天 */
  .chat-section { max-height: 200px; }
  .chat-messages { font-size: 14px; max-height: 140px; padding: 10px 20px; }
  .chat-input-row { padding: 10px 20px; }
  .chat-input-row input { font-size: 15px; padding: 10px 14px; }
  .chat-input-row .btn-sm { padding: 10px 18px; font-size: 14px; }

  /* ----- 游戏页面 ----- */
   #game-page {
     max-width: 1100px;
     margin: 0 auto;
     border-radius: 16px;
     overflow: hidden;
     box-shadow: 0 0 60px rgba(0,0,0,0.5);
     justify-content: center;
   }

  .game-main {
    max-width: 720px;
    flex-shrink: 0;
  }

  /* 顶部信息栏 */
  .game-top-bar {
    padding: 12px 22px;
    margin: 10px 14px 0;
    font-size: 14px;
    border-radius: 14px;
  }
  .game-room-id { font-size: 14px; }
  .pot-label { font-size: 11px; }
  .pot-value { font-size: 36px; }
  .game-round { font-size: 14px; }

  /* 对手卡片 */
  .opponents-area {
    gap: 10px;
    padding: 12px 16px;
    min-height: 64px;
  }
  .opponent-card {
    width: 96px;
    padding: 10px 6px;
    border-radius: 14px;
  }
  .mini-card { width: 20px; height: 28px; }
  .mini-card::after { width: 6px; height: 6px; }
  .opp-card-eyes { font-size: 14px; }
  .opponent-name { font-size: 13px; }
  .opponent-bet { font-size: 11px; }
  .opponent-status { font-size: 11px; }
  .opponent-badge { font-size: 10px; padding: 2px 6px; }

  /* 手牌 */
  :root {
    --card-width: 90px;
    --card-height: 126px;
    --card-radius: 10px;
  }
  .my-cards-area { padding: 16px 24px; }
  .cards-container { gap: 16px; }
  .card-back::after { width: 40px; height: 40px; }
  .card-back::before { inset: 8px; }
  .card-front .card-rank { font-size: 26px; }
  .card-front .card-suit { font-size: 28px; }

  .my-hand-info { font-size: 15px; margin-top: 14px; }

  /* 操作按钮 */
  .action-area { padding: 14px 20px; }
  .action-row { gap: 12px; margin-bottom: 12px; }
  .btn-action {
    padding: 18px 14px;
    font-size: 17px;
    min-height: 56px;
    border-radius: 16px;
    letter-spacing: 0.8px;
  }
  .btn-action::before { border-radius: 20px; inset: -5px; filter: blur(12px); }

  /* ----- 右侧聊天栏 (桌面端) ----- */
   .game-chat-sidebar {
     width: 260px;
   }
   .game-chat-header {
     font-size: 15px;
     padding: 14px 16px;
   }
  .game-chat-sidebar .chat-messages {
    font-size: 13px;
    padding: 12px 14px;
  }
  .game-chat-sidebar .chat-msg { margin-bottom: 5px; }
  .game-chat-sidebar .chat-input-row {
    padding: 10px 12px;
    gap: 8px;
  }
  .game-chat-sidebar .chat-input-row input {
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 16px;
  }
  .game-chat-sidebar .chat-input-row .btn-sm {
    padding: 8px 14px;
    font-size: 14px;
    min-height: 36px;
    border-radius: 12px;
  }

  /* ----- 弹窗 (桌面端) ----- */
  .modal-box {
    max-width: 420px;
    padding: 32px 28px;
    border-radius: 24px;
  }
  .modal-box h3 { font-size: 20px; }
  .modal-box h2 { font-size: 28px; }
  .raise-option, .compare-option {
    padding: 14px 24px;
    font-size: 17px;
  }
  .raise-options, .compare-options { gap: 10px; }

  .look-cards .card { width: 82px; height: 112px; font-size: 26px; }
  .look-hand-info { font-size: 19px; }

  .game-over-box { padding: 36px 28px; }
  .game-over-detail { font-size: 15px; }
  .game-over-detail .mini-card-front { font-size: 16px; padding: 4px 10px; }

  /* ----- Toast ----- */
  .toast { font-size: 15px; padding: 12px 28px; border-radius: 24px; }

  /* ----- 滚动条 (桌面端更宽) ----- */
  ::-webkit-scrollbar { width: 6px; }
}
