/* ============ 全局样式 ============ */
:root {
  --primary: #1a5c2a;
  --primary-dark: #0e3d1a;
  --accent: #f5a623;
  --accent-light: #ffe0a0;
  --bg: #f0f4f0;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --danger: #ef4444;
  --live: #ef4444;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 70px;
}

/* ============ 顶部导航 ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.logo-icon { font-size: 24px; }

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  object-fit: cover;
}

.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-dark);
  border: 2px solid rgba(255,255,255,0.5);
}

/* ============ 横幅 ============ */
.banner {
  margin: 12px;
  background: linear-gradient(135deg, #1a5c2a, #2d8a4e);
  border-radius: var(--radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}

.banner::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.banner h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.banner p {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 12px;
}

.banner-stats {
  display: flex;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  opacity: 0.75;
}

/* ============ 标签切换 ============ */
.tab-bar {
  display: flex;
  margin: 0 12px 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

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

/* ============ 日期分组 ============ */
.date-group {
  margin: 0 12px 16px;
}

.date-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.date-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============ 比赛卡片 ============ */
.match-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
  overflow: hidden;
}

.match-card:active {
  transform: scale(0.98);
}

.match-card.live {
  border-left: 3px solid var(--live);
}

.match-card.finished {
  opacity: 0.85;
}

.match-left {
  flex: 1;
}

.match-teams {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-flag {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.team-name {
  font-size: 15px;
  font-weight: 600;
}

.team-score {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-left: auto;
  min-width: 24px;
  text-align: center;
}

.match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
}

.match-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.status-upcoming {
  background: #e8f5e9;
  color: var(--primary);
}

.status-live {
  background: #ffebee;
  color: var(--live);
  animation: pulse 1.5s infinite;
}

.status-finished {
  background: #f3f4f6;
  color: var(--text-secondary);
}

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

.match-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.match-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.match-stage {
  font-size: 11px;
  color: var(--text-secondary);
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.match-arrow {
  font-size: 14px;
  color: var(--text-secondary);
}

.guess-badge {
  font-size: 11px;
  background: var(--accent-light);
  color: #b8860b;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* ============ 竞猜弹窗 ============ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

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

.modal {
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px 16px 30px;
  animation: slideUp 0.3s;
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
}

.score-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.score-team {
  text-align: center;
  flex: 1;
}

.score-team-flag {
  font-size: 40px;
  display: block;
  margin-bottom: 4px;
}

.score-team-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.score-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.score-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.score-btn:active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.score-value {
  font-size: 36px;
  font-weight: 800;
  min-width: 50px;
  text-align: center;
  color: var(--primary);
}

.score-vs {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 4px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s, toastOut 0.3s 2s forwards;
  max-width: 90%;
  text-align: center;
}

.toast-success {
  background: #d1fae5;
  color: #065f46;
}

.toast-error {
  background: #fee2e2;
  color: #991b1b;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* ============ 排行榜 ============ */
.rank-list {
  margin: 0 12px;
}

.rank-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-num {
  font-size: 18px;
  font-weight: 800;
  width: 28px;
  text-align: center;
  color: var(--text-secondary);
}

.rank-num.top { font-size: 24px; }

.rank-item:nth-child(1) .rank-num { color: #f5a623; }
.rank-item:nth-child(2) .rank-num { color: #94a3b8; }
.rank-item:nth-child(3) .rank-num { color: #cd7f32; }

.rank-item.me {
  background: #e8f5e9;
  border: 2px solid var(--primary);
}

.rank-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.rank-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.rank-info {
  flex: 1;
}

.rank-name {
  font-size: 15px;
  font-weight: 600;
}

.rank-stats {
  font-size: 11px;
  color: var(--text-secondary);
}

.rank-points {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

/* ============ 个人中心 ============ */
.profile-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  margin: 12px;
  border-radius: var(--radius);
  padding: 24px;
  color: white;
  text-align: center;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  object-fit: cover;
  margin-bottom: 8px;
}

.profile-avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  border: 3px solid rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 12px;
}

.profile-stat {
  text-align: center;
}

.profile-stat-num {
  font-size: 22px;
  font-weight: 700;
}

.profile-stat-label {
  font-size: 11px;
  opacity: 0.75;
}

.guess-list {
  margin: 12px;
}

.guess-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guess-teams {
  flex: 1;
}

.guess-match-teams {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.guess-result {
  font-size: 12px;
  color: var(--text-secondary);
}

.guess-outcome {
  text-align: right;
}

.guess-points {
  font-size: 16px;
  font-weight: 700;
}

.guess-points.win { color: var(--success); }
.guess-points.lose { color: var(--danger); }
.guess-points.pending { color: var(--accent); }

.guess-status-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-top: 4px;
  display: inline-block;
}

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s;
  gap: 2px;
}

.nav-item .nav-icon {
  font-size: 22px;
}

.nav-item.active {
  color: var(--primary);
}

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
}

/* ============ 登录页 ============ */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #0e3d1a, #1a5c2a, #2d8a4e);
  color: white;
  text-align: center;
}

.login-logo {
  font-size: 80px;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

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

.login-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-desc {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 40px;
}

.login-btn {
  display: block;
  width: 80%;
  max-width: 300px;
  padding: 14px;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.login-btn-wechat {
  background: #07c160;
  color: white;
}

.login-btn-wechat:active {
  background: #06ad56;
}

.login-btn-dev {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.login-btn-dev:active {
  background: rgba(255,255,255,0.3);
}

/* ============ 隐藏页面 ============ */
.page { display: none; }
.page.active { display: block; }

/* ============ 加载动画 ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading::after {
  content: '';
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ 管理端样式 ============ */
.admin-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: #f3f4f6;
}

.admin-login-card {
  background: white;
  border-radius: var(--radius);
  padding: 30px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.admin-login-card h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 22px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
}

.admin-header {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header h2 {
  font-size: 18px;
}

.admin-header button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px;
}

.admin-stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.admin-stat-card .stat-num {
  font-size: 28px;
  color: var(--primary);
}

.admin-stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-actions {
  padding: 0 12px 12px;
  display: flex;
  gap: 8px;
}

.admin-actions .btn {
  width: auto;
  padding: 10px 20px;
  font-size: 14px;
}

.admin-table-wrap {
  padding: 0 12px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  margin-right: 4px;
}

.admin-table .btn-sm.danger {
  color: var(--danger);
  border-color: var(--danger);
}

.admin-table .btn-sm.primary {
  color: var(--primary);
  border-color: var(--primary);
}

.admin-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

.admin-modal-content h3 {
  margin-bottom: 16px;
  font-size: 18px;
}

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

.form-row .form-group {
  flex: 1;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
