/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6f8;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
}

/* 首页 */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 20px;
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  color: #2c3e50;
  margin-bottom: 8px;
}

.subtitle {
  color: #7f8c8d;
  margin-bottom: 32px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

label {
  display: block;
  text-align: left;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}

input[type="text"]:focus {
  border-color: #3498db;
}

.actions {
  margin-top: 8px;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

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

.btn-primary {
  background: #3498db;
  color: #fff;
}

.btn-secondary {
  background: #ecf0f1;
  color: #2c3e50;
}

.divider {
  margin: 16px 0;
  color: #999;
  font-size: 0.85rem;
  position: relative;
}

.divider::before,
.divider::after {
  content: "";
  display: inline-block;
  width: 60px;
  height: 1px;
  background: #e0e0e0;
  vertical-align: middle;
  margin: 0 10px;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row input {
  flex: 1;
  margin-bottom: 0;
  text-transform: uppercase;
}

.join-row .btn {
  width: auto;
  padding: 12px 20px;
}

/* 游戏页面 */
.game-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.game-header {
  background: #fff;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.game-header .room-info {
  font-size: 0.9rem;
  color: #666;
}

.game-header .room-info strong {
  color: #2c3e50;
  font-size: 1.1rem;
}

.game-header .round-info {
  text-align: center;
}

.game-header .round-info .word {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e74c3c;
  letter-spacing: 4px;
}

.game-header .round-info .timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e67e22;
  font-variant-numeric: tabular-nums;
}

.game-header .round-info .timer.warning {
  color: #e74c3c;
  animation: pulse 1s infinite;
}

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

.game-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: relative;
}

#gameCanvas {
  flex: 1;
  width: 100%;
  cursor: crosshair;
  touch-action: none;
}

.canvas-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid #eee;
  background: #fafafa;
  flex-wrap: wrap;
}

.canvas-tools .color-picker {
  display: flex;
  gap: 6px;
}

.canvas-tools .color-option {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s;
}

.canvas-tools .color-option:hover {
  transform: scale(1.15);
}

.canvas-tools .color-option.active {
  border-color: #333;
}

.canvas-tools .width-slider {
  display: flex;
  align-items: center;
  gap: 6px;
}

.canvas-tools .width-slider input {
  width: 80px;
}

.canvas-tools .tool-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.canvas-tools .tool-btn:hover {
  background: #f0f0f0;
}

.sidebar {
  width: 280px;
  background: #fff;
  border-left: 1px solid #eee;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.players-panel {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.players-panel h3 {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 10px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.9rem;
}

.player-item .role {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #ecf0f1;
  color: #666;
}

.player-item .role.drawer {
  background: #e74c3c;
  color: #fff;
}

.player-item .score {
  font-weight: 700;
  color: #f39c12;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f5f6f8;
  word-break: break-word;
}

.chat-msg.system {
  background: #fff3cd;
  color: #856404;
  text-align: center;
}

.chat-msg.correct {
  background: #d4edda;
  color: #155724;
  font-weight: 600;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  font-size: 0.9rem;
}

.chat-input-area input:focus {
  border-color: #3498db;
}

.chat-input-area .btn-send {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #3498db;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chat-input-area .btn-send:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
}

/* 响应式 */
@media (max-width: 768px) {
  .game-main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 35vh;
    border-left: none;
    border-top: 1px solid #eee;
  }

  .canvas-tools {
    gap: 8px;
    padding: 8px;
  }

  .game-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .game-header .round-info {
    width: 100%;
    order: -1;
  }
}

/* 状态提示 */
.status-bar {
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #666;
  background: #fafafa;
  border-top: 1px solid #eee;
  text-align: center;
}

.status-bar .waiting {
  color: #3498db;
}

/* 遮罩层 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 360px;
  width: 90%;
}

.modal h2 {
  margin-bottom: 12px;
}

.modal p {
  color: #666;
  margin-bottom: 20px;
}
