/* ═══════════════════════════════════════════════
   游侠德州 - 全新 UI 设计
   灵感：绿色牌桌 + 金色点缀 + 现代卡片
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700;900&display=swap');

:root {
  --bg: #0d1b2a;
  --bg-card: #1b2838;
  --bg-input: #1a2d42;
  --border: #2a4a6b;
  --accent: #f0a500;
  --accent-hover: #d49500;
  --green: #2ecc71;
  --green-dark: #27ae60;
  --red: #e74c3c;
  --red-dark: #c0392b;
  --text: #e8e8e8;
  --text-dim: #7f8c8d;
  --table-green: #1a4a3a;
  --table-border: #2d6a4f;
  --gold: #f0a500;
  --gold-light: #f7c948;
  --chip-red: #e74c3c;
  --chip-blue: #3498db;
  --chip-green: #2ecc71;
  --chip-black: #2c3e50;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(240,165,0,0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(46,204,113,0.03) 0%, transparent 60%);
}

/* ═══ 滚动条 ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══ 容器 ═══ */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px;
}

.screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes glowPulse { 0%,100% { box-shadow: 0 0 8px rgba(240,165,0,0.3); } 50% { box-shadow: 0 0 20px rgba(240,165,0,0.6); } }
@keyframes dealCard { from { opacity: 0; transform: translateY(-30px) rotateY(90deg); } to { opacity: 1; transform: translateY(0) rotateY(0); } }
@keyframes chipDrop { from { opacity: 0; transform: translateY(-20px) scale(0.5); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes winGlow { 0%,100% { box-shadow: 0 0 10px rgba(240,165,0,0.5); } 50% { box-shadow: 0 0 30px rgba(240,165,0,0.9), 0 0 60px rgba(240,165,0,0.4); } }

/* ═══ 头部 ═══ */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  gap: 10px;
}

.header-left { display: flex; align-items: center; gap: 10px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══ 认证页 ═══ */
#auth-screen {
  background: linear-gradient(135deg, #0d1b2a 0%, #1a2d42 50%, #0d1b2a 100%);
}

#auth-screen .container {
  text-align: center;
  padding: 40px 20px;
  animation: slideUp 0.5s ease;
}

.auth-logo {
  font-size: 4rem;
  margin-bottom: 8px;
  animation: pulse 2s infinite;
}

h1 {
  font-size: 2.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 36px;
  font-size: 0.95rem;
}

#auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.tab.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.form { display: none; }
.form.active { display: flex; flex-direction: column; gap: 14px; }

/* ═══ 输入框 ═══ */
input {
  padding: 14px 18px;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  width: 100%;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240,165,0,0.15);
}

input::placeholder { color: var(--text-dim); }

/* ═══ 按钮 ═══ */
button {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 2px 8px rgba(240,165,0,0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(240,165,0,0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover { background: var(--red-dark); }

.btn-success {
  background: var(--green);
  color: white;
}
.btn-success:hover { background: var(--green-dark); }

.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; }
.btn-block { width: 100%; display: block; }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ═══ 错误提示 ═══ */
.error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 2px;
  min-height: 20px;
}

/* ═══ 大厅 ═══ */
#lobby-screen {
  min-height: 100vh;
}

#lobby-screen .container {
  padding-top: 24px;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.lobby-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.lobby-actions-bar {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.lobby-actions-bar input { flex: 1; }

.divider {
  text-align: center;
  color: var(--text-dim);
  margin: 20px 0;
  position: relative;
  font-size: 0.85rem;
}

.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

/* ═══ 房间列表 ═══ */
.room-list { margin: 16px 0; }

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  gap: 12px;
  transition: all 0.2s;
}

.room-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(240,165,0,0.1);
}

.room-info { flex: 1; min-width: 0; }

.room-info strong {
  font-size: 1.05rem;
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.room-detail {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.room-detail span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.empty-list {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 20px;
  font-size: 0.95rem;
}

.empty-list .empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ═══ 弹窗 ═══ */
.dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.dialog.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.dialog-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 92%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.dialog-content h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--accent);
}

.dialog-content label {
  display: block;
  margin: 14px 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.dialog-content label span {
  display: block;
  margin-bottom: 4px;
}

.dialog-content input { margin-top: 4px; }

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ═══ 牌桌 ═══ */
#game-screen {
  min-height: 100vh;
  background: linear-gradient(180deg,
    var(--table-green) 0%,
    #1a5c44 30%,
    #1a4a3a 60%,
    var(--bg) 100%);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
}

.game-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-header-left .room-name {
  font-weight: 700;
  font-size: 1rem;
}

.game-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pot-display {
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-light);
  border: 1px solid rgba(240,165,0,0.3);
}

/* ═══ 牌桌区域 ═══ */
.table-area {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 420px;
}

/* 牌桌椭圆 */
.table-felt {
  position: relative;
  background: radial-gradient(ellipse at center, #1e6b4e 0%, #1a5c44 40%, #154a36 100%);
  border: 4px solid #2d6a4f;
  border-radius: 50%;
  min-height: 280px;
  margin: 10px auto;
  max-width: 500px;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.3),
    0 8px 40px rgba(0,0,0,0.5),
    0 0 0 8px #1a3a2a,
    0 0 0 12px #2d6a4f;
}

/* ═══ 公牌 ═══ */
.community-cards {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 30px 10px 20px;
  min-height: 100px;
  align-items: center;
}

/* ═══ 扑克牌 ═══ */
.card {
  width: 58px;
  height: 84px;
  background: #fff;
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  position: relative;
  transition: transform 0.2s;
  user-select: none;
}

.card:hover { transform: translateY(-4px); }

.card.red { color: #d63031; }
.card.black { color: #2d3436; }

.card.face-down {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: transparent;
  border: 2px solid #4a6fa5;
}

.card.face-down::after {
  content: '🃏';
  font-size: 1.4rem;
  color: rgba(255,255,255,0.3);
}

.card.dealt {
  animation: dealCard 0.4s ease forwards;
}

/* 小号牌 */
.card-sm {
  width: 42px;
  height: 62px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ═══ 座位 ═══ */
.seats-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  margin-top: 8px;
}

.seat {
  width: 105px;
  text-align: center;
  padding: 10px 8px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.35);
  position: relative;
  transition: all 0.3s;
  backdrop-filter: blur(4px);
}

.seat.current-turn {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(240,165,0,0.5);
  animation: glowPulse 1.5s infinite;
  transform: scale(1.05);
}

.seat.folded {
  opacity: 0.35;
  filter: grayscale(0.5);
}

.seat.ready {
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(46,204,113,0.3);
}

.seat-name {
  font-size: 0.78rem;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-me-badge {
  font-size: 0.6rem;
  color: var(--accent);
  font-weight: 400;
}

.seat-owner-badge {
  font-size: 0.7rem;
}

.seat-chips {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 2px 0;
}

.seat-bet {
  font-size: 0.7rem;
  color: var(--gold-light);
  min-height: 16px;
}

.seat-status {
  font-size: 0.7rem;
  font-weight: 600;
  min-height: 16px;
}

.seat-status.folded-text { color: var(--text-dim); }
.seat-status.allin-text { color: var(--red); }

.swap-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  border: none;
  color: var(--text-dim);
  transition: all 0.2s;
}

.swap-btn:hover { background: var(--accent); color: var(--bg); }

/* ═══ 手牌 ═══ */
.my-hand-area {
  text-align: center;
  padding: 12px;
  margin-top: 8px;
}

.my-hand-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.my-hand-cards {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.my-hand-cards .card {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px rgba(240,165,0,0.15);
}

/* ═══ 操作栏 ═══ */
.action-bar {
  text-align: center;
  padding: 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}

.action-bar button {
  min-width: 80px;
  font-size: 0.9rem;
}

.action-bar .btn-fold { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); }
.action-bar .btn-fold:hover { background: var(--red); color: white; border-color: var(--red); }

.action-bar .btn-call { background: var(--green); color: white; }
.action-bar .btn-call:hover { background: var(--green-dark); }

.action-bar .btn-raise { background: var(--accent); color: var(--bg); }
.action-bar .btn-raise:hover { background: var(--accent-hover); }

.action-bar .btn-allin { background: var(--red); color: white; animation: pulse 2s infinite; }
.action-bar .btn-allin:hover { background: var(--red-dark); }

.action-bar input[type="number"] {
  width: 90px;
  text-align: center;
  padding: 10px;
}

.waiting-indicator {
  text-align: center;
  padding: 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
  animation: pulse 2s infinite;
}

/* ═══ 游戏信息 ═══ */
.game-info-bar {
  text-align: center;
  color: var(--text-dim);
  padding: 6px;
  font-size: 0.82rem;
  min-height: 24px;
}

/* ═══ 摊牌 ═══ */
.showdown-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.showdown-result.winner {
  background: rgba(240,165,0,0.1);
  border-radius: var(--radius-sm);
  animation: winGlow 2s infinite;
}

.showdown-result .player-name { font-weight: 600; flex: 1; }
.showdown-result .hand-name { color: var(--text-dim); font-size: 0.85rem; }
.showdown-result .hole-cards { font-size: 0.8rem; color: var(--accent); }
.showdown-result .winner-badge { color: var(--gold); font-size: 1.2rem; }

/* ═══ 连接状态指示器 ═══ */
.connection-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 200;
  transition: all 0.3s;
  transform: translateY(-100%);
}

.connection-status.show {
  transform: translateY(0);
}

.connection-status.connected {
  background: var(--green);
  color: white;
}

.connection-status.disconnected {
  background: var(--red);
  color: white;
}

.connection-status.reconnecting {
  background: var(--accent);
  color: var(--bg);
}

/* ═══ 响应式 ═══ */
@media (max-width: 480px) {
  .container { padding: 14px; }
  .card { width: 48px; height: 70px; font-size: 0.9rem; }
  .card-sm { width: 36px; height: 54px; font-size: 0.7rem; }
  .seat { width: 85px; padding: 8px 6px; }
  .seat-name { font-size: 0.7rem; }
  .action-bar button { min-width: 65px; font-size: 0.8rem; padding: 10px 14px; }
  .action-bar input[type="number"] { width: 70px; }
  h1 { font-size: 1.8rem; }
  .table-felt { border-radius: 30px; min-height: 240px; }
}

@media (max-width: 360px) {
  .seats-container { gap: 6px; }
  .seat { width: 72px; padding: 6px 4px; }
  .card { width: 40px; height: 60px; font-size: 0.75rem; }
}
