﻿:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #34a853;
  --danger: #ea4335;
  --warning: #fbbc04;
  --text: #202124;
  --text-secondary: #5f6368;
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --border: #dadce0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  padding-bottom: 60px;
}

/* ============ 登录页 ============ */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(180deg, #f0f4ff 0%, #ffffff 100%);
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  width: 100%;
  max-width: 360px;
}

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

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

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

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

.phone-input-group {
  display: flex;
  gap: 8px;
}

.phone-input-group .form-input {
  flex: 1;
}

.send-code-btn {
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.send-code-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
  display: block;
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 6px;
}

.login-tip {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 16px;
}

/* ============ 用户信息栏 ============ */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-nickname {
  font-size: 16px;
  font-weight: 600;
}

.user-balance {
  font-size: 14px;
  opacity: 0.9;
}

.logout-btn {
  padding: 6px 12px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* ============ 按钮样式 ============ */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

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

.btn-success:hover {
  background: #2d9147;
}

.btn-success:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ============ 页面容器 ============ */
.page-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* 页头 */
.page-header {
  padding: 16px 0;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.page-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-tip {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

/* 底部导航 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  transition: color 0.2s;
}

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

.tab-icon {
  font-size: 24px;
  line-height: 1;
}

.tab-label {
  margin-top: 2px;
}

/* ============ 统计卡片 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

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

/* ============ 挑战选项 ============ */
.selection-group {
  margin-bottom: 8px;
}

.selection-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.duration-options,
.amount-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.option-card:active {
  border-color: var(--primary);
  background: #f0f4ff;
}

.option-card.selected {
  border-color: var(--primary);
  background: #e8f0fe;
}

.option-card .option-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.option-card .option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============ 挑战预览 ============ */
.challenge-preview {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-row span:first-child {
  color: var(--text-secondary);
}

.preview-row span:last-child {
  font-weight: 600;
}

/* ============ 充值相关 ============ */
.recharge-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.recharge-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.recharge-option.selected {
  border-color: var(--primary);
  background: #e8f0fe;
}

.recharge-option .amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.recharge-option .points {
  font-size: 12px;
  color: var(--success);
  margin-top: 4px;
}

.recharge-btn {
  margin-top: 16px;
}

/* ============ 钱包页 ============ */
.wallet-assets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.asset-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.asset-card.balance {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.asset-card.points {
  background: linear-gradient(135deg, var(--success), #2d9147);
  color: white;
}

.asset-label {
  display: block;
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.asset-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.asset-desc {
  font-size: 10px;
  opacity: 0.8;
}

.recharge-section,
.recharge-history {
  margin-top: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.section-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-amount {
  font-weight: 600;
  color: var(--success);
}

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

.history-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

.history-status.pending {
  background: #fef3c7;
  color: #92400e;
}

.history-status.paid {
  background: #d1fae5;
  color: #065f46;
}

/* ============ 挑战历史记录 ============ */
.challenge-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.challenge-record {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--bg);
  border-radius: 12px;
  border-left: 4px solid var(--border);
}

.challenge-record.completed {
  border-left-color: var(--success);
}

.challenge-record.failed_blur,
.challenge-record.failed_heartbeat,
.challenge-record.failed_close {
  border-left-color: var(--danger);
}

.record-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.record-duration {
  font-weight: 600;
  color: var(--text);
}

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

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

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

.record-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
}

.record-status.completed {
  background: #d1fae5;
  color: #065f46;
}

.record-status.failed_blur,
.record-status.failed_heartbeat,
.record-status.failed_close {
  background: #fee2e2;
  color: #991b1b;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-secondary);
}

.modal-body {
  padding: 20px;
}

/* ============ 挑战确认弹窗 ============ */
.confirm-info {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.confirm-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-weight: 600;
}

.confirm-row.total span:last-child {
  color: var(--danger);
}

.confirm-warning {
  margin-bottom: 20px;
}

.warning-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 12px;
}

.warning-list {
  list-style: none;
}

.warning-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.warning-list li:last-child {
  border-bottom: none;
}

/* 复选框样式 */
.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-label input {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
  content: "";
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

/* ============ 支付中转 ============ */
.payment-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.payment-content {
  text-align: center;
  padding: 24px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.payment-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ============ 全屏计时页面 ============ */
.timer-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  color: white;
}

.timer-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px;
  text-align: center;
}

.timer-duration {
  font-size: 14px;
  opacity: 0.9;
}

.timer-display {
  text-align: center;
}

.timer-countdown {
  font-size: 72px;
  font-weight: 200;
  font-family: "SF Mono", "Monaco", "Inconsolata", monospace;
  letter-spacing: 4px;
  margin-bottom: 16px;
}

.timer-status {
  font-size: 18px;
  opacity: 0.9;
}

.timer-footer {
  position: absolute;
  bottom: 40px;
  text-align: center;
}

.heartbeat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  opacity: 0.9;
}

.heartbeat-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* ============ 失焦警告 ============ */
.blur-warning {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.blur-warning-content {
  text-align: center;
  padding: 32px;
}

.blur-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.blur-warning-content h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.blur-countdown {
  color: var(--warning);
  font-weight: 700;
}

.blur-tip {
  font-size: 14px;
  opacity: 0.7;
  margin-top: 8px;
}

/* ============ 挑战结果页面 ============ */
.result-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 2000;
}

.result-header {
  text-align: center;
  padding: 48px 24px 32px;
  background: linear-gradient(180deg, #f0f4ff 0%, #ffffff 100%);
}

.result-icon {
  font-size: 72px;
  margin-bottom: 16px;
}

.result-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-header p {
  color: var(--text-secondary);
}

.result-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.result-card.highlight {
  background: var(--bg-secondary);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.result-row .positive {
  color: var(--success);
  font-weight: 600;
}

.result-summary {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.result-summary .result-row {
  padding: 0;
  font-size: 16px;
}

.result-summary .result-row span:last-child {
  font-weight: 600;
}

.result-footer {
  padding: 16px 24px;
  background: white;
  border-top: 1px solid var(--border);
}

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

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.empty-state p {
  margin-bottom: 16px;
}

/* ============ 响应式 ============ */
@media (max-width: 480px) {
  .duration-options,
  .amount-options {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .timer-countdown {
    font-size: 56px;
  }
}

/* 全局统计 - 首页 */
.global-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
}

.global-stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.global-stat-icon {
  font-size: 24px;
}

.global-stat-info {
  display: flex;
  flex-direction: column;
}

.global-stat-value {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
}

.global-stat-label {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}

/* 记录页统计 */
.records-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.summary-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.summary-card.highlight {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.summary-card.highlight .summary-value,
.summary-card.highlight .summary-label {
  color: #fff;
}

.summary-value {
  display: block;
  font-size: 22px;
  font-weight: bold;
  color: #333;
}

.summary-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

/* 邀请裂变样式 */
.invite-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}
.invite-code-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  background: #f5f5f5;
  border-radius: 8px;
}
.invite-code-label {
  font-size: 14px;
  color: #666;
}
.invite-code {
  font-size: 18px;
  font-weight: bold;
  color: #1a73e8;
  letter-spacing: 2px;
  flex: 1;
}
.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
}
.invite-input-box {
  display: flex;
  gap: 8px;
}
.invite-input-box .form-input {
  flex: 1;
  text-transform: uppercase;
}
.invite-tip {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* 邀请裂变样式 */
.invite-section { background: #fff; border-radius: 12px; padding: 16px; margin-top: 16px; }
.invite-code-box { display: flex; align-items: center; gap: 8px; margin: 12px 0; padding: 12px; background: #f5f5f5; border-radius: 8px; }
.invite-code-label { font-size: 14px; color: #666; }
.invite-code { font-size: 18px; font-weight: bold; color: #1a73e8; letter-spacing: 2px; flex: 1; }
.btn-small { padding: 6px 12px; font-size: 12px; border-radius: 4px; }
.invite-input-box { display: flex; gap: 8px; }
.invite-input-box .form-input { flex: 1; text-transform: uppercase; }
.invite-tip { font-size: 12px; color: #888; margin-top: 8px; }

