/* Apple Design System - 极简风格 */
:root {
  --bg-light: #f5f5f7;
  --bg-dark: #1c1c1e;
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-bg-dark: rgba(28, 28, 30, 0.8);
  --text-primary: #1d1d1f;
  --text-primary-dark: #ffffff;
  --text-secondary: #6e6e73;
  --text-secondary-dark: #98989d;
  --accent: #007aff;
  --accent-hover: #0051d5;
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-soft-dark: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --radius-small: 12px;
}

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

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-light);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--bg-dark);
    color: var(--text-primary-dark);
  }
  
  .auth-card,
  .lobby-panel,
  .control-panel {
    background: var(--card-bg-dark);
  }
  
  .chip-count {
    border-color: rgba(255, 255, 255, 0.2);
  }
  
  .table-oval {
    background: radial-gradient(
      circle at 30% 0,
      rgba(255, 255, 255, 0.03),
      transparent 50%
    ),
    radial-gradient(
      circle at 70% 100%,
      rgba(0, 0, 0, 0.6),
      rgba(0, 0, 0, 0.9)
    ),
    radial-gradient(circle at center, #2a5a1f 0, #1a3a0f 60%, #0a1a05 100%);
  }
}

#app {
  width: 100%;
  min-height: 100vh;
}

.view {
  display: none;
  min-height: 100vh;
  padding: 24px 16px 32px;
}

@media (max-width: 480px) {
  .view {
    padding: 16px 12px 24px;
  }
}

.view.active {
  display: block;
}

/* 认证卡片 - 毛玻璃效果 */
.auth-card {
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 40px 32px;
  border-radius: var(--radius);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

@media (max-width: 480px) {
  .auth-card {
    max-width: 100%;
    margin: 5vh auto 0;
    padding: 24px 20px;
  }
}

.brand-title {
  margin: 0 0 32px;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.tab-button {
  flex: 1;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.tab-button::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.tab-button.active {
  color: var(--text-primary);
}

.tab-button.active::after {
  transform: scaleX(1);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.form-group {
  margin-bottom: 20px;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-small);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
  transform: scale(1.01);
}

input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.code-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.code-input-wrapper input {
  flex: 1;
}

.code-button {
  padding: 12px 20px;
  border-radius: var(--radius-small);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  outline: none;
}

.code-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.02);
}

.code-button:active:not(:disabled) {
  transform: scale(0.98);
}

.code-button:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.6;
}

.primary-button {
  width: 100%;
  padding: 14px 24px;
  border-radius: var(--radius-small);
  border: 0;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.primary-button:hover {
  background: var(--accent-hover);
  transform: scale(1.01);
}

.primary-button:active {
  transform: scale(0.99);
}

.primary-button.wide {
  width: 100%;
}

.ghost-button {
  padding: 8px 16px;
  border-radius: var(--radius-small);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.ghost-button:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.02);
}

.ghost-button.small {
  padding: 6px 12px;
  font-size: 12px;
}

.message-line {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: #ff3b30;
  text-align: center;
}

/* 顶栏与大厅 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding: 0 8px;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 480px) {
  .top-bar {
    margin-bottom: 20px;
    padding: 0 4px;
  }
  
  .top-bar-left,
  .top-bar-right {
    flex: 1;
    min-width: 0;
  }
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.top-bar-username {
  font-size: 15px;
  font-weight: 500;
}

.chip-count {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 13px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.05);
}

.add-bot-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-small);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.add-bot-panel.visible {
  opacity: 1;
  pointer-events: auto;
}

.bot-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bot-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.add-bot-button {
  padding: 6px 14px;
  border-radius: var(--radius-small);
  border: 0;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.add-bot-button:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.add-bot-button:active {
  transform: scale(0.98);
}

.player-seat.bot-player .player-name {
  color: #8e8e93;
}

.player-seat.bot-player .avatar {
  background: radial-gradient(circle at 30% 0, #e5e5ea, #d1d1d6);
}

.lobby-main {
  display: flex;
  justify-content: center;
}

.lobby-panel {
  width: 100%;
  max-width: 600px;
  padding: 32px 28px;
  border-radius: var(--radius);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

@media (max-width: 480px) {
  .lobby-panel {
    padding: 20px 16px;
  }
}

.section-title {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 600;
}

.subsection-title {
  margin: 24px 0 16px;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-secondary);
}

.join-room-section {
  margin-bottom: 24px;
}

.room-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.room-input-wrapper input {
  flex: 1;
}

.room-input-wrapper .primary-button {
  width: auto;
  min-width: 140px;
}

@media (max-width: 480px) {
  .room-input-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .room-input-wrapper .primary-button {
    width: 100%;
    min-width: auto;
  }
}

.divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin: 24px 0;
}

.room-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.room-item:last-child {
  border-bottom: 0;
}

.room-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-name {
  font-size: 16px;
  font-weight: 500;
}

.room-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 牌桌与玩家布局 */
.table-main {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .table-main {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 860px) {
  .table-main {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.table-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.table-oval {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 2.2 / 1;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(245, 245, 247, 0.6);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
  .table-oval {
    max-width: 100%;
    aspect-ratio: 2 / 1;
  }
}

@media (max-width: 480px) {
  .table-oval {
    aspect-ratio: 1.8 / 1;
  }
}

@media (prefers-color-scheme: dark) {
  .table-oval {
    background: rgba(28, 28, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

.board-cards {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
}

.card-chip {
  width: 56px;
  height: 78px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-chip.card-red {
  color: #dc3545;
}

.card-chip.card-black {
  color: #1d1d1f;
}

.card-chip.enter {
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
}

.card-chip.enter-active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.pot-display {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 13px;
  font-weight: 500;
  color: white;
}

.players-ring {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 300px;
  margin: 20px auto 0;
}

.player-seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.player-seat:not(.occupied) {
  opacity: 0.3;
}

.player-seat.occupied {
  opacity: 1;
}

/* 6个座位的位置布局（紧凑圆形排列） */
.player-seat[data-seat="0"] {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.player-seat[data-seat="1"] {
  top: 20%;
  right: 8%;
  transform: translateY(-50%);
}

.player-seat[data-seat="2"] {
  bottom: 20%;
  right: 8%;
  transform: translateY(50%);
}

.player-seat[data-seat="3"] {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.player-seat[data-seat="4"] {
  bottom: 20%;
  left: 8%;
  transform: translateY(50%);
}

.player-seat[data-seat="5"] {
  top: 20%;
  left: 8%;
  transform: translateY(-50%);
}

/* 平板适配 */
@media (max-width: 1024px) {
  .players-ring {
    max-width: 500px;
    height: 250px;
  }
}

/* 手机横屏/小平板 */
@media (max-width: 768px) {
  .players-ring {
    max-width: 100%;
    height: 220px;
    margin: 16px auto 0;
  }
}

/* 手机竖屏 - 改为2行3列网格布局 */
@media (max-width: 480px) {
  .players-ring {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;
    aspect-ratio: auto;
    min-height: auto;
    padding: 16px;
    margin: 20px auto 0;
  }
  
  .player-seat {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
  }
  
  .player-seat[data-seat="0"] {
    grid-column: 2;
    grid-row: 1;
  }
  
  .player-seat[data-seat="1"] {
    grid-column: 3;
    grid-row: 1;
  }
  
  .player-seat[data-seat="2"] {
    grid-column: 3;
    grid-row: 2;
  }
  
  .player-seat[data-seat="3"] {
    grid-column: 2;
    grid-row: 2;
  }
  
  .player-seat[data-seat="4"] {
    grid-column: 1;
    grid-row: 2;
  }
  
  .player-seat[data-seat="5"] {
    grid-column: 1;
    grid-row: 1;
  }
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(0, 122, 255, 0.3);
  background: radial-gradient(circle at 30% 0, #ffffff, #e0e0e5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.player-seat.occupied .avatar {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

@media (max-width: 768px) {
  .avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .avatar {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  
  .player-name {
    font-size: 12px;
  }
  
  .player-stack {
    font-size: 11px;
  }
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-name {
  font-size: 14px;
  font-weight: 500;
}

.player-stack {
  font-size: 12px;
  color: var(--text-secondary);
}

.control-panel {
  padding: 24px 20px;
  border-radius: var(--radius);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-panel.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* 确保"继续游戏"按钮即使在 disabled 状态下也可点击 */
.control-panel.disabled #btn-start-round {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* 游戏状态提示面板 */
.game-status-panel {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.status-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.status-value {
  color: var(--text-primary);
  font-weight: 600;
}

.status-winner {
  margin-top: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.2));
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  text-align: center;
}

.winner-label {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 16px;
}

.winner-name {
  color: #ff6b00;
  font-weight: 700;
  font-size: 18px;
  margin-left: 8px;
}

/* 玩家座位标记 */
.player-seat.dealer-seat .avatar::after {
  content: "D";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #007aff;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid white;
}

.player-seat.small-blind-seat .avatar::after {
  content: "SB";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff9500;
  color: white;
  width: 24px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  border: 2px solid white;
}

.player-seat.big-blind-seat .avatar::after {
  content: "BB";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff3b30;
  color: white;
  width: 24px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  border: 2px solid white;
}

.player-seat.current-turn {
  z-index: 2;
}

/* 仅给头像做呼吸高亮，避免覆盖座位本身的定位 transform 引发布局抖动 */
.player-seat.current-turn .avatar {
  animation: pulse-turn-avatar 1.5s ease-in-out infinite;
}

@keyframes pulse-turn-avatar {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.55);
  }
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.control-buttons {
  display: flex;
  gap: 10px;
}

.control-button {
  padding: 10px 18px;
  border-radius: 999px;
  border: 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-button.ghost {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.control-button.primary {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent-hover);
}

.control-button.accent {
  background: var(--accent);
  color: #ffffff;
}

.control-button:hover {
  transform: scale(1.02);
}

.control-button:active {
  transform: scale(0.98);
}

.primary-button.ghost-start {
  width: auto;
  padding-inline: 20px;
}

.raise-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.raise-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.raise-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.raise-amount {
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.raise-controls input[type="range"] {
  flex: 1;
}

@media (max-width: 480px) {
  .control-panel {
    padding: 16px 12px;
    gap: 12px;
  }
  .control-row {
    flex-direction: column;
    align-items: stretch;
  }
  .control-buttons {
    justify-content: space-between;
  }
}

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

.table-log {
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.log-line {
  margin-bottom: 6px;
}
