:root {
  --bg: #0a0a0a;
  --panel: #1a1a2e;
  --border: #2a2a4a;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --accent: #47c2ff;
  --accent-glow: rgba(71, 194, 255, 0.3);
  --success: #7be67e;
  --warning: #ffd93d;
  --danger: #ff6b6b;
}

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

body {
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", Tahoma, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(71, 194, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(167, 139, 250, 0.06) 0%, transparent 50%);
  color: var(--text);
  line-height: 1.6;
}

.app-shell { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ===== Header ===== */
header { text-align: center; margin-bottom: 24px; padding: 20px 0; }

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  background: linear-gradient(135deg, #47c2ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

header p { color: var(--text-muted); font-size: 0.95rem; }

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== Card ===== */
.card {
  max-width: 420px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.card h2 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 24px;
  color: var(--accent);
}

.card-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

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

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }

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

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

.divider span { padding: 0 12px; }

/* ===== Buttons ===== */
button {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:active { transform: scale(0.97); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-full { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, #2e7cff, #1875ff);
  color: white;
  box-shadow: 0 4px 15px rgba(46, 124, 255, 0.3);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(46, 124, 255, 0.5); transform: translateY(-1px); }

.btn-join {
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  color: white;
  box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
}

.btn-join:hover { box-shadow: 0 6px 20px rgba(167, 139, 250, 0.5); transform: translateY(-1px); }

.btn-secondary {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); border-color: var(--accent); }

.btn-copy {
  background: rgba(71, 194, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(71, 194, 255, 0.3);
  padding: 8px 16px;
  font-size: 0.9rem;
}

.btn-copy:hover { background: rgba(71, 194, 255, 0.25); }

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
  margin-top: 10px;
}

.btn-danger:hover { background: rgba(255, 107, 107, 0.25); }

.btn-group { display: flex; gap: 10px; }

/* 按钮间距 */
.card .btn-primary,
.card .btn-join,
.card .btn-secondary {
  margin-top: 12px;
}

.card .btn-primary:first-of-type {
  margin-top: 0;
}

/* ===== Lobby ===== */
.lobby-card {
  max-width: 480px;
  text-align: center;
}

.lobby-card h2 { margin-bottom: 8px; }

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  border: 2px dashed var(--border);
}

.room-code-label { font-size: 0.85rem; color: var(--text-muted); }

.room-code {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(71, 194, 255, 0.3);
}

.lobby-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== Game ===== */
.game-layout {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.game-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--accent);
}

.status-grid { display: flex; flex-direction: column; gap: 8px; }

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-label { font-size: 0.85rem; color: var(--text-muted); }
.status-value { font-size: 0.9rem; font-weight: 600; }
.status-value.accent { color: var(--accent); }

.timer { color: var(--success); font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.warning { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.board-section { display: flex; justify-content: center; flex: 1; }

canvas {
  width: min(100%, 720px);
  max-width: 100%;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: #d7b16f;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(215, 177, 111, 0.1);
  cursor: pointer;
  touch-action: none;
}

/* ===== Footer ===== */
footer { text-align: center; padding: 16px 0; color: var(--text-muted); font-size: 0.85rem; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .game-layout { flex-direction: column-reverse; }
  .game-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .game-sidebar .panel { flex: 1; min-width: 200px; }
}

@media (max-width: 480px) {
  .app-shell { padding: 12px; }
  .welcome-card, .lobby-card { padding: 20px; }
  .room-code { font-size: 1.5rem; letter-spacing: 4px; }
  .btn-group { flex-direction: column; }
}
