/* ============================================
   联机小游戏 - 现代暗色游戏风格
   Modern Dark Gaming Theme
   ============================================ */

/* Google Fonts - Chakra Petch (Gaming Style) */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Variables / Design Tokens
   ============================================ */
:root {
  /* Background Layers */
  --bg-deep: #0a0a0f;
  --bg-base: #0f0f15;
  --bg-elevated: #16161d;
  --bg-card: #1a1a24;
  --bg-glass: rgba(26, 26, 36, 0.8);

  /* Surface & Borders */
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(255, 255, 255, 0.15);

  /* Text Colors */
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;

  /* Accent Colors - Neon Gaming */
  --accent-primary: #6366f1;      /* Indigo */
  --accent-primary-glow: rgba(99, 102, 241, 0.4);
  --accent-secondary: #8b5cf6;    /* Purple */
  --accent-success: #22c55e;      /* Green */
  --accent-danger: #ef4444;       /* Red */
  --accent-warning: #f59e0b;      /* Amber */
  --accent-info: #06b6d4;         /* Cyan */

  /* Game-specific Colors */
  --game-gomoku-black: #1a1a1a;
  --game-gomoku-white: #f5f5f5;
  --board-color: #2a2a35;
  --board-grid: #3a3a45;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);

  /* Typography */
  --font-family: 'Chakra Petch', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
  display: none !important;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3 {
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

h3 {
  font-size: 1rem;
  color: var(--text-secondary);
}

p {
  color: var(--text-secondary);
}

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-2xl);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 48px; /* Touch target */
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Primary Button - Main CTA */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  box-shadow: var(--shadow-md), 0 0 0 0 var(--accent-primary-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-lg), 0 0 30px var(--accent-primary-glow);
  transform: translateY(-2px);
}

/* Secondary Button */
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-accent);
}

/* Danger Button */
.btn-danger {
  background: var(--accent-danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

/* Small Button */
.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
}

/* Icon Button */
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

.btn-icon.copied {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-icon .icon-check {
  color: white;
}

.btn-icon.copied .icon-copy {
  display: none;
}

.btn-icon.copied .icon-check {
  display: block !important;
}

/* Button Group */
.btn-group {
  display: flex;
  gap: var(--space-sm);
}

.btn-group .btn {
  flex: 1;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}

.card:hover {
  border-color: var(--border-accent);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

/* ============================================
   Form Elements
   ============================================ */
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: all var(--transition-fast);
  min-height: 48px;
}

.input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 12px 0;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  width: 48px;
  height: 26px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 13px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .toggle-switch {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .toggle-switch::after {
  left: 24px;
  background: white;
}

.checkbox-label span {
  font-size: 1rem;
  color: var(--text-primary);
}

/* ============================================
   Modals
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: 1000;
  animation: modalIn var(--transition-normal);
}

@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn var(--transition-normal);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.modal-header h2 {
  margin-bottom: var(--space-xs);
}

.modal-body {
  margin-bottom: var(--space-lg);
}

.modal-footer {
  display: flex;
  gap: var(--space-sm);
}

.modal-footer .btn {
  flex: 1;
}

/* ============================================
   Login Page
   ============================================ */
.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding-top: var(--space-xl);
}

.login-header h1 {
  font-size: 1.75rem;
  margin-bottom: var(--space-sm);
}

.login-header p {
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================
   Lobby
   ============================================ */
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.lobby-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.lobby-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 2px solid var(--accent-primary);
}

.lobby-user-info {
  display: flex;
  flex-direction: column;
}

.lobby-nickname {
  font-weight: 600;
  color: var(--text-primary);
}

.lobby-stats-mini {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   Game Tabs
   ============================================ */
.game-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--space-xs);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.game-tabs::-webkit-scrollbar {
  display: none;
}

.game-tab {
  flex: 1 1 auto;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-out;
  white-space: nowrap;
  position: relative;
}

.game-tab:hover:not(.disabled) {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.game-tab.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  box-shadow: 0 0 20px var(--accent-primary-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.game-tab.active .game-tab-icon {
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

.game-tab.disabled {
  cursor: not-allowed;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border);
}

.game-tab.disabled .game-tab-icon {
  opacity: 0.5;
  filter: grayscale(100%);
}

.game-tab.disabled .tab-label {
  font-size: 0.75rem;
  opacity: 0.6;
}

.game-tab-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease-out;
  flex-shrink: 0;
}

.game-tab:hover:not(.disabled) .game-tab-icon {
  transform: scale(1.1);
}

/* ============================================
   Lobby Content
   ============================================ */
.lobby-content {
  display: none;
}

.lobby-content.active {
  display: block;
}

.game-hero {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.game-hero-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-hero-icon svg {
  width: 36px;
  height: 36px;
  color: white;
}

.game-hero h2 {
  margin-bottom: var(--space-xs);
}

.game-hero p {
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
}

.match-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

/* Match Status */
.match-status {
  text-align: center;
  padding: var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-primary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-primary-glow); }
  50% { box-shadow: 0 0 20px 5px var(--accent-primary-glow); }
}

.match-status.hidden {
  display: none;
}

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

/* ============================================
   Common Room Actions
   ============================================ */
.room-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.room-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.room-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.room-action-btn svg {
  width: 24px;
  height: 24px;
}

/* ============================================
   History & Leaderboard Sections
   ============================================ */
.lobby-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

/* 我的排名卡片 */
.my-rank-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
  border: 1px solid var(--accent-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  text-align: center;
}

.my-rank-card.hidden {
  display: none;
}

.my-rank-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.my-rank-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.my-rank-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1;
}

.my-rank-divider {
  color: var(--border-accent);
  font-size: 1.5rem;
}

.my-rank-mmr {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.my-rank-mmr span {
  color: var(--accent-info);
  font-weight: 600;
}

.my-rank-stats {
  margin-top: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-header h2 {
  font-size: 1rem;
}

/* Leaderboard Game Type Tabs */
.leaderboard-game-tabs {
  display: flex;
  gap: var(--space-xs);
}

.leaderboard-game-tab {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.leaderboard-game-tab:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.leaderboard-game-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-xs);
}

.tab {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* List */
.list-content {
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 战绩列表项 */
.history-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.history-item:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
  box-shadow: -4px 0 0 var(--accent-primary);
}

.history-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.history-item.win::before {
  background: var(--accent-success);
}

.history-item.lose::before {
  background: var(--accent-danger);
}

.history-item.draw::before {
  background: var(--text-muted);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-game-type {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-opponent {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.history-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-result {
  font-weight: 700;
  font-size: 1rem;
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.history-result.win {
  color: var(--accent-success);
  background: rgba(34, 197, 94, 0.15);
}

.history-result.lose {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.15);
}

.history-result.draw {
  color: var(--text-muted);
  background: var(--surface);
}

.history-mmr {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-mmr.positive {
  color: var(--accent-success);
}

.history-mmr.negative {
  color: var(--accent-danger);
}

.history-details {
  display: flex;
  gap: var(--space-md);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--surface);
}

/* 通用列表项 */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  transition: all var(--transition-fast);
}

.list-item:last-child {
  margin-bottom: 0;
}

.list-item:hover {
  background: var(--surface-hover);
}

.list-item-rank {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.list-item-rank.top-1 {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #1a1a1a;
}

.list-item-rank.top-2 {
  background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
  color: #1a1a1a;
}

.list-item-rank.top-3 {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: white;
}

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

.list-item-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 排行榜列表项 */
.leaderboard-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  transition: all var(--transition-fast);
}

.leaderboard-item:hover {
  border-color: var(--border-accent);
  background: var(--surface-hover);
}

.leaderboard-item.is-me {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-primary-glow);
}

.leaderboard-item.top-1 {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.leaderboard-item.top-2 {
  background: linear-gradient(135deg, rgba(209, 213, 219, 0.1) 0%, rgba(156, 163, 175, 0.05) 100%);
}

.leaderboard-item.top-3 {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.1) 0%, rgba(180, 83, 9, 0.05) 100%);
}

.leaderboard-main {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.leaderboard-rank {
  font-size: 1.5rem;
  min-width: 40px;
  text-align: center;
}

.leaderboard-nickname {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-value {
  font-weight: 700;
  color: var(--accent-success);
  font-size: 1rem;
}

.leaderboard-stats {
  display: flex;
  gap: var(--space-md);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-left: 52px;
}

.list-item-value {
  font-weight: 700;
  color: var(--accent-success);
}

.list-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

/* ============================================
   Room View
   ============================================ */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.room-header-info h2 {
  font-size: 1rem;
  line-height: 1;
  margin-bottom: var(--space-xs);
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-header-info .btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.room-header-info .btn-icon svg {
  width: 18px;
  height: 18px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.room-header-info span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Ready Screen */
.ready-screen {
  text-align: center;
  padding: var(--space-xl) 0;
}

.ready-screen.hidden {
  display: none;
}

.ready-players {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.ready-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  min-width: 140px;
  flex: 1;
  max-width: 180px;
  transition: all var(--transition-fast);
}

.ready-player.is-me {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.ready-player .crown-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 32px;
  margin-bottom: -4px;
}

.ready-player .crown {
  width: 32px;
  height: 32px;
  color: #fbbf24;
  animation: bounce 1s ease-in-out infinite;
}

.ready-player .crown.hidden {
  display: none;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.ready-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 3px solid var(--border);
}

.ready-player.is-me .ready-avatar {
  border-color: var(--accent-primary);
}

.ready-player-name {
  font-weight: 600;
  color: var(--text-primary);
}

.ready-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text-muted);
}

.ready-badge.ready {
  background: var(--accent-success);
  color: white;
}

.ready-vs {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.ready-actions {
  margin-top: var(--space-lg);
}

.ready-countdown {
  margin-top: var(--space-md);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-warning);
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Game Area */
.game-area {
  display: none;
}

.game-area.active {
  display: block;
}

/* Game Players */
.game-players {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--surface) 100%);
  border-radius: var(--radius-2xl);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.game-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-xl);
  min-width: 120px;
  flex: 1;
  max-width: 160px;
  position: relative;
  transition: all var(--transition-normal);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.game-player.is-me {
  border-color: var(--accent-primary);
}

/* Crown - centered relative to player name */
.game-player .crown-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 24px;
  margin-bottom: -4px;
}

.game-player .crown {
  width: 24px;
  height: 24px;
  color: #fbbf24;
  filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.4));
  animation: bounce 1s ease-in-out infinite;
}

.game-player .crown.hidden {
  display: none;
}

/* Avatar with status ring */
.game-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  border: 3px solid var(--border);
  position: relative;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Status indicator dot */
.game-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-success);
  border: 2px solid var(--bg-elevated);
}

.game-avatar.disconnected {
  filter: grayscale(100%);
  opacity: 0.5;
}

.game-avatar.disconnected::after {
  background: var(--text-muted);
}

.game-player.is-me .game-avatar {
  border-color: var(--accent-primary);
}

/* Player name */
.game-player-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* VS divider */
.game-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text-muted);
  padding: 0 var(--space-sm);
  position: relative;
}

.game-vs::before,
.game-vs::after {
  content: '';
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--border), transparent);
  position: absolute;
}

.game-vs::before {
  top: -30px;
}

.game-vs::after {
  bottom: -30px;
}

.game-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
}

.game-turn {
  font-weight: 600;
  color: var(--text-primary);
}

.game-timer {
  padding: 4px 12px;
  background: var(--surface);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
}

.game-timer.urgent {
  background: var(--accent-danger);
  color: white;
  animation: blink 0.5s ease-in-out infinite;
}

.board-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.board {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* ============================================
   Game Over Modal
   ============================================ */
.game-over-modal .modal-content {
  text-align: center;
}

.game-over-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.game-over-title.win {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-over-title.lose {
  color: var(--accent-danger);
}

.game-over-message {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* Countdown Modal */
.countdown-modal {
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.countdown-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-primary-glow) 0%, transparent 70%);
  border-radius: 50%;
  animation: glowPulse 2s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.countdown-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  position: relative;
  z-index: 1;
}

.countdown-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  animation: fadeSlideDown 0.4s var(--ease-out);
}

.countdown-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-number {
  font-size: 7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  text-shadow:
    0 0 40px var(--accent-primary-glow),
    0 0 80px var(--accent-primary-glow);
  animation: countEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.countdown-number.exit {
  animation: countExit 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

.countdown-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  animation: fadeSlideUp 0.4s var(--ease-out) 0.1s both;
}

@keyframes countEnter {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes countExit {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.5);
    opacity: 0;
  }
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ring decoration around countdown */
.countdown-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent-primary);
  border-radius: 50%;
  opacity: 0.3;
  animation: ringPulse 1.5s ease-in-out infinite;
}

.countdown-wrapper::after {
  content: '';
  position: absolute;
  inset: -10px;
  border: 1px solid var(--accent-secondary);
  border-radius: 50%;
  opacity: 0.2;
  animation: ringPulse 1.5s ease-in-out infinite 0.3s;
}

@keyframes ringPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.2;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.4;
  }
}

/* ============================================
   Avatar
   ============================================ */
.avatar-preview {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  border: 3px solid var(--accent-primary);
}

.avatar-options {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.avatar-option {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid transparent;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option:hover {
  transform: scale(1.1);
  border-color: var(--border-accent);
}

.avatar-option.selected {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

/* ============================================
   Guest Notice
   ============================================ */
.guest-notice-box {
  padding: var(--space-md);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  text-align: center;
}

.guest-notice-box p {
  color: var(--accent-warning);
  font-size: 0.9rem;
}

.guest-notice-box strong {
  display: block;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

/* ============================================
   Responsive / Mobile
   ============================================ */
@media (max-width: 480px) {
  .container {
    padding: var(--space-sm);
  }

  h1 {
    font-size: 1.5rem;
  }

  .modal-content {
    padding: var(--space-lg);
    margin: var(--space-sm);
    max-height: calc(100vh - var(--space-lg));
  }

  .ready-players {
    flex-direction: column;
    gap: var(--space-md);
  }

  .ready-vs {
    transform: rotate(90deg);
  }

  .room-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .lobby-header {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .lobby-user {
    flex-direction: column;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Safe area for notch devices */
@supports (padding-top: env(safe-area-inset-top)) {
  .container {
    padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--accent-primary);
  color: white;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-accent);
}

/* ============================================
   Disconnected Player Avatar
   ============================================ */
.player-avatar.disconnected {
  filter: grayscale(100%);
  opacity: 0.5;
  position: relative;
}

.disconnect-timer {
  display: block;
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: 4px;
}

/* Bot托管提示 */
.game-board.bot-托管 {
  pointer-events: none;
  opacity: 0.7;
}

/* AI难度选择弹窗 */
#ai-difficulty-modal .modal-content {
  text-align: center;
  max-width: 360px;
}
#ai-difficulty-modal h3 {
  margin-bottom: 24px;
  font-size: 18px;
}
.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  width: 100%;
}
.difficulty-label {
  font-size: 16px;
  font-weight: bold;
}
.difficulty-desc {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 4px;
}

/* 接管按钮 */
.takeover-btn {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  z-index: 1000;
}

.takeover-btn:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* Toast 通知 */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  font-size: 14px;
  max-width: 320px;
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast.toast-info {
  border-left: 4px solid #3b82f6;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}
