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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

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

.btn-large {
  padding: 15px 40px;
  font-size: 16px;
}

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

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.login-box h1 {
  font-size: 48px;
  margin-bottom: 10px;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
  font-size: 16px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.game-info {
  margin-top: 30px;
  text-align: left;
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
}

.game-info h3 {
  margin-bottom: 10px;
  color: #667eea;
}

.game-info ul {
  list-style: none;
  padding-left: 0;
}

.game-info li {
  padding: 5px 0;
  padding-left: 20px;
  position: relative;
}

.game-info li:before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
}

/* ==================== 大厅页面样式 ==================== */

.lobby-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.lobby-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  padding: 20px 40px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lobby-header h1 {
  font-size: 32px;
  font-weight: 700;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.player-name {
  font-size: 16px;
  font-weight: 600;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
}

.lobby-main {
  padding: 40px 20px;
}

.lobby-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* 创建房间区域 */
.create-room-section {
  margin-bottom: 40px;
}

.create-room-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.create-room-card h2 {
  color: #333;
  font-size: 28px;
  margin-bottom: 25px;
}

.create-room-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  text-align: center;
}

.input-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.room-hint {
  margin-top: 15px;
  color: #888;
  font-size: 14px;
}

/* 房间列表区域 */
.room-list-section {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  margin: 0 auto;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}

.section-title h2 {
  color: #333;
  font-size: 24px;
}

.room-count {
  color: #888;
  font-size: 14px;
  font-weight: 600;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.room-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.room-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  border-color: #667eea;
}

.room-info h3 {
  margin-bottom: 10px;
  color: #333;
  font-size: 20px;
  font-weight: 600;
}

.room-details {
  color: #666;
  font-size: 14px;
  margin-bottom: 20px;
}

.join-room-btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
}

.no-rooms {
  text-align: center;
  padding: 60px 20px;
  color: #888;
  font-size: 18px;
}

.no-rooms p {
  background: #f8f9fa;
  padding: 30px;
  border-radius: 15px;
  display: inline-block;
}

.no-rooms,
.loading,
.error {
  text-align: center;
  padding: 40px;
  color: #666;
  grid-column: 1 / -1;
}

.create-room-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.create-room-modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 15px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-bottom: 20px;
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
}

/* ==================== 游戏页面样式 ==================== */

.game-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 游戏头部 */
.game-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  padding: 15px 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.game-header .header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-title h1 {
  font-size: 28px;
  font-weight: 700;
}

.game-info-bar {
  display: flex;
  align-items: center;
  gap: 20px;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
}

.timer-box {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 10px;
}

.timer-value {
  font-size: 24px;
  font-weight: bold;
  color: #ffeb3b;
}

.btn-success {
  background: #4caf50;
  color: white;
  padding: 10px 24px;
  font-weight: 600;
}

.btn-success:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

/* 游戏主内容 */
.game-main {
  padding: 20px;
}

.game-content {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 20px;
  height: calc(100vh - 120px);
}

/* 画布区域 */
.canvas-section {
  display: flex;
  flex-direction: column;
}

.canvas-card {
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.word-hint {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 15px;
  padding: 15px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  letter-spacing: 8px;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 15px;
  overflow: hidden;
}

#drawingCanvas {
  border: 3px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  max-width: 100%;
  max-height: 100%;
}

/* 侧边栏 */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  min-height: 0;
}

/* 玩家列表卡片 - 固定高度 */
.sidebar-card.players-card {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  height: 300px;
  flex-shrink: 0;
}

.sidebar-card.players-card h3 {
  color: #333;
  font-size: 18px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
}

.players-list-content {
  overflow-y: auto;
  height: calc(100% - 45px);
}

/* 聊天卡片 - 自适应填充剩余空间 */
.sidebar-card.chat-card {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-card.chat-card h3 {
  color: #333;
  font-size: 18px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-bottom: 10px;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-top: auto;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.chat-input-area input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* 游戏遮罩层 */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.overlay-content {
  background: white;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
  color: #333;
  font-size: 28px;
  margin-bottom: 15px;
}

.overlay-content p {
  color: #666;
  font-size: 16px;
  margin-bottom: 25px;
}

.players-list {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: 100%;
  overflow-y: auto;
}

.players-list h3 {
  margin-bottom: 15px;
  color: #333;
  font-size: 18px;
}

.players-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.player-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 12px;
  flex-shrink: 0;
}

.player-card:nth-child(1) .player-rank {
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
}

.player-card:nth-child(2) .player-rank {
  background: linear-gradient(135deg, #c0c0c0 0%, #a0a0a0 100%);
}

.player-card:nth-child(3) .player-rank {
  background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
}

.player-card.current-player {
  background: #e3f2fd;
  border: 2px solid #2196f3;
}

.player-card.drawer {
  background: #fff3e0;
  border: 2px solid #ff9800;
}

.player-card.guessed {
  background: #e8f5e9;
  border: 2px solid #4caf50;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 18px;
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 600;
  color: #333;
}

.drawer-badge,
.guessed-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 5px;
}

.drawer-badge {
  background: #ff9800;
  color: white;
}

.guessed-badge {
  background: #4caf50;
  color: white;
}

.player-score {
  font-weight: bold;
  color: #667eea;
}

.canvas-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

#drawingCanvas {
  border: 3px solid #e0e0e0;
  border-radius: 8px;
  background: white;
}

/* 自定义画笔光标 - 使用SVG绘制画笔形状 */
.cursor-brush {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%23333' stroke='white' stroke-width='1' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E") 0 20, auto !important;
}

/* 自定义橡皮擦光标 - 使用SVG绘制橡皮擦形状 */
.cursor-eraser {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Crect x='2' y='8' width='20' height='12' rx='2' fill='%23f5f5f5' stroke='%23666' stroke-width='1.5'/%3E%3Crect x='4' y='10' width='16' height='8' rx='1' fill='%23fff'/%3E%3C/svg%3E") 10 10, auto !important;
}

.drawing-tools {
  display: none;
  align-wrap: wrap;
  gap: 15px;
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  width: 100%;
  justify-content: center;
  align-items: center;
}

/* 水平排列的绘画工具栏 */
.drawing-tools-horizontal {
  display: none;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 15px;
  padding: 12px 15px;
  background: #f8f9fa;
  border-radius: 8px;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.drawing-tools-horizontal .tool-selector,
.drawing-tools-horizontal .color-picker,
.drawing-tools-horizontal .brush-size {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawing-tools-horizontal span {
  font-size: 14px;
  color: #555;
}

.drawing-tools-horizontal input[type="color"] {
  width: 40px;
  height: 30px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.drawing-tools-horizontal input[type="range"] {
  width: 80px;
}

/* 画笔和橡皮擦按钮样式 */
.drawing-tools-horizontal .tool-selector button {
  padding: 8px 16px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #555;
}

.drawing-tools-horizontal .tool-selector button:hover {
  border-color: #667eea;
  color: #667eea;
}

/* 选中状态 */
.drawing-tools-horizontal .tool-selector button.btn-active {
  background: #667eea;
  color: white;
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.color-picker {
  display: flex;
  gap: 8px;
}

.color-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ddd;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.brush-size {
  display: flex;
  gap: 8px;
}

.size-btn {
  padding: 6px 12px;
  background: white;
  border: 2px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.size-btn:hover {
  background: #f0f0f0;
}

.size-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.drawer-indicator {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(102, 126, 234, 0.9);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
  z-index: 10;
}

.chat-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-container h3 {
  margin-bottom: 15px;
  color: #333;
  font-size: 18px;
}

.chat-message {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #f8f9fa;
  animation: slideIn 0.3s ease;
}

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

.chat-message.correct {
  background: #e8f5e9;
  border-left: 4px solid #4caf50;
}

.chat-message.system {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  font-style: italic;
}

.correct-message {
  color: #4caf50;
  font-weight: bold;
}

.system-message {
  color: #ff9800;
}

.player-name {
  font-weight: 600;
  color: #667eea;
}

.message-content {
  color: #333;
}

.chat-input {
  display: flex;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.chat-input input:focus {
  outline: none;
  border-color: #667eea;
}

.chat-input input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.game-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.game-overlay.active {
  display: flex;
}

.overlay-content {
  background: white;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.overlay-content h2 {
  font-size: 32px;
  margin-bottom: 15px;
  color: #667eea;
}

.overlay-content p {
  font-size: 18px;
  color: #666;
  margin-bottom: 25px;
}

.overlay-content .btn-large {
  width: 100%;
}

#timer.urgent {
  color: #ff4444;
  animation: pulse 1s infinite;
}

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

@media (max-width: 1024px) {
  .game-content {
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto;
  }
  
  .right-panel {
    grid-column: 1 / -1;
  }
  
  .chat-container {
    height: 300px;
  }
  
  /* 平板设备上确保聊天消息区域和猜词区域有足够高度 */
  .chat-messages {
    min-height: 120px;
  }
  
  .word-hint {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .game-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
  }
  
  .players-list,
  .chat-container {
    height: 300px;
  }
  
  #drawingCanvas {
    max-width: 100%;
    height: auto;
  }
  
  .lobby-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .rooms-list {
    grid-template-columns: 1fr;
  }
}
