/* ============================================================
   GameHub 样式表
   ============================================================ */

:root {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dark: #5a4bd1;
  --bg: #0f1117;
  --bg-card: #1a1d29;
  --bg-hover: #252937;
  --text: #e8e8e8;
  --text-muted: #8e8e8e;
  --border: #2d3142;
  --success: #00b894;
  --danger: #e74c3c;
  --warning: #fdcb6e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); text-decoration: underline; }

/* ==================== 导航栏 ==================== */

.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none !important;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none !important;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-username {
  color: var(--primary-light);
  font-size: 0.9rem;
}

/* ==================== 容器 ==================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ==================== 区块 ==================== */

.section {
  margin-bottom: 48px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ==================== 游戏卡片 ==================== */

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

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.game-cover {
  height: 140px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-info {
  padding: 16px;
}

.game-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.game-tag {
  background: var(--bg-hover);
  color: var(--primary-light);
  padding: 2px 10px;
  border-radius: 20px;
}

.game-plays {
  color: var(--text-muted);
}

/* ==================== 按钮 ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none !important;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-lg { padding: 12px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }

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

/* ==================== 表单 ==================== */

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

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

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

.code-input {
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.85rem;
}

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-input {
  width: 200px;
}

/* ==================== 认证页 ==================== */

.auth-container {
  display: flex;
  justify-content: center;
  padding-top: 60px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-title {
  text-align: center;
  margin-bottom: 24px;
}

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

.auth-switch {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.error-msg {
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.success-msg {
  background: rgba(0, 184, 148, 0.1);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ==================== 上传页 ==================== */

.upload-card {
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.page-title {
  margin-bottom: 24px;
}

.auth-warning {
  background: rgba(253, 203, 110, 0.1);
  color: var(--warning);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
  color: var(--text);
}

.file-name {
  margin-top: 10px;
  color: var(--success);
  font-size: 0.9rem;
}

/* ==================== 游戏详情 ==================== */

.game-detail-header {
  margin-bottom: 32px;
}

.game-detail-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.game-detail-title {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.game-detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.game-detail-desc {
  color: var(--text-muted);
  line-height: 1.7;
}

.play-area {
  margin-bottom: 48px;
}

.play-header {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.game-iframe {
  width: 100%;
  max-width: 100%;
  background: white;
}

.login-prompt {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-prompt-inner h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.login-prompt-inner p {
  color: var(--text-muted);
  margin-bottom: 20px;
}
.login-prompt-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.game-author { color: var(--primary-light); }

/* ==================== 评论 ==================== */

.comments-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.comments-title {
  font-size: 1.3rem;
  margin-bottom: 20px;
}

.comment-count-badge {
  background: var(--bg-hover);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.comment-form-area {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.comment-login-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.comment-form-wrapper #comment-input {
  margin-bottom: 10px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comment-item {
  display: flex;
  gap: 12px;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.comment-avatar.small {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 600;
  font-size: 0.9rem;
}

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

.comment-content {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 8px;
  word-wrap: break-word;
}

.comment-actions {
  display: flex;
  gap: 16px;
}

.comment-action {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.2s;
}
.comment-action:hover { color: var(--primary-light); }
.comment-action.liked { color: var(--danger); }

.reply-form-area {
  margin-top: 12px;
  margin-bottom: 12px;
}
.reply-input {
  margin-bottom: 8px;
}
.reply-actions {
  display: flex;
  gap: 8px;
}

.replies-list {
  margin-top: 16px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reply-item {
  display: flex;
  gap: 10px;
}

/* ==================== 排行榜 ==================== */

.leaderboard-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leaderboard-table-inner {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table-inner th {
  background: var(--bg-hover);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.leaderboard-table-inner td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table-inner tr:hover td {
  background: var(--bg-hover);
}

.leaderboard-table-inner tr.rank-1 td { background: rgba(255, 215, 0, 0.05); }
.leaderboard-table-inner tr.rank-2 td { background: rgba(192, 192, 192, 0.05); }
.leaderboard-table-inner tr.rank-3 td { background: rgba(205, 127, 50, 0.05); }

.rank-badge {
  display: inline-block;
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
}
.rank-badge.rank-1 { background: rgba(255, 215, 0, 0.15); }
.rank-badge.rank-2 { background: rgba(192, 192, 192, 0.15); }
.rank-badge.rank-3 { background: rgba(205, 127, 50, 0.15); }

.col-rank { width: 80px; text-align: center; }
.col-score { font-weight: 600; color: var(--primary-light); }
.col-games { color: var(--text-muted); }

/* ==================== 分页 ==================== */

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}

.page-btn {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.page-btn:hover {
  border-color: var(--primary);
}
.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ==================== 通用 ==================== */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.link { color: var(--primary-light); }

/* ==================== 响应式 ==================== */

@media (max-width: 768px) {
  .nav-inner {
    padding: 0 12px;
  }
  .nav-links {
    gap: 8px;
  }
  .nav-link {
    padding: 4px 8px;
    font-size: 0.85rem;
  }
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input {
    width: 100%;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==================== 新增：游戏详情页控制按钮 ==================== */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--primary-light);
  text-decoration: none;
}

.play-header {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

#stop-btn {
  display: none;
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
#stop-btn:hover {
  background: #c0392b;
}

/* iframe 容器 */
.iframe-wrapper {
  position: relative;
  width: 100%;
}

.game-iframe {
  width: 100%;
  background: white;
  border-radius: var(--radius);
}
