/* ============================================
   龙舟竞速 · 障碍赛 — 全局样式
   共享给所有页面
   ============================================ */

/* --- CSS 自定义属性 (主题色) --- */
:root {
  --color-primary: #0a1628;
  --color-primary-light: #1a3a6a;
  --color-accent: #00ccff;
  --color-accent-light: #00ff88;
  --color-bg: linear-gradient(150deg, #0a1628 0%, #0f2847 40%, #1a3a6a 70%, #2a5a8a);
  --color-card-bg: #0f1e3a;
  --color-text: #d0e8ff;
  --color-text-light: #80c8ff;
  --color-text-muted: #5a8aaa;
  --color-white: #e0f0ff;
  --color-shadow: rgba(0, 200, 255, 0.15);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  padding: 0;
  margin: 0;
}

/* --- 通用容器 --- */
.container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: linear-gradient(170deg, #0a1628, #0f2847);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* --- 标题 --- */
.page-title {
  font-size: 24px;
  color: var(--color-primary);
  text-align: center;
  letter-spacing: 1px;
  margin: 4px 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.page-title .badge {
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 12px;
  font-weight: 600;
}

.subtitle {
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  margin: 0 0 8px;
}

/* --- 渐变文字效果 --- */
.gradient-text {
  background: linear-gradient(135deg, #00ccff, #00ff88);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* --- 卡片网格 --- */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.card {
  background: rgba(15, 30, 58, 0.85);
  border: 1px solid rgba(0, 200, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 2px 12px var(--color-shadow);
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 24px rgba(0, 200, 255, 0.25);
  border-color: rgba(0, 200, 255, 0.4);
}

.card:active {
  transform: translateY(0) scale(0.98);
}

.card-icon {
  font-size: 32px;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00ccff, #0a1628);
  border-radius: var(--radius-sm);
  color: var(--color-white);
}

.card-body {
  flex: 1;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}

.card-desc {
  font-size: 12px;
  color: var(--color-text-muted);
}

.card-arrow {
  font-size: 20px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(0, 200, 255, 0.3);
  background: linear-gradient(135deg, #0f2847, #1a3a6a);
  color: var(--color-white);
  font-weight: 700;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px var(--color-shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 200, 255, 0.3);
  border-color: rgba(0, 200, 255, 0.6);
}

.btn:active {
  transform: translateY(0) scale(0.96);
}

.btn-sm {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.btn-accent {
  background: linear-gradient(135deg, #00ccff, #0088cc);
  border-color: #00ccff;
  color: #0a1628;
}

.btn-outline {
  background: transparent;
  color: var(--color-accent);
  border: 2px solid var(--color-accent);
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--color-accent);
  color: #0a1628;
}

/* --- 导航栏 --- */
.nav-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 13px;
  color: var(--color-text-light);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: rgba(0, 200, 255, 0.1);
  color: var(--color-accent);
}

.nav-link.active {
  background: rgba(0, 200, 255, 0.15);
  color: var(--color-accent);
  border: 1px solid rgba(0, 200, 255, 0.3);
}

/* --- 返回首页链接 --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--color-text-light);
  text-decoration: none;
  margin-bottom: 8px;
  transition: color var(--transition);
}

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

/* --- 统计面板 (HUD) --- */
.hud {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.stat {
  flex: 1;
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid rgba(0, 200, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  text-align: center;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
}

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

.stat .num {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-primary);
}

/* --- 游戏舞台 --- */
.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px;
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 200px;
  margin: 0 auto;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background: #b3d9f0;
  box-shadow: 0 4px 12px var(--color-shadow);
  touch-action: none;
  cursor: pointer;
}

/* --- 控制按钮组 --- */
.controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 200, 255, 0.2);
  background: linear-gradient(135deg, #0f2847, #1a3a6a);
  color: var(--color-white);
  font-weight: 700;
  font-size: 22px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 8px var(--color-shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  touch-action: manipulation;
}

.ctrl-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 200, 255, 0.25);
  border-color: rgba(0, 200, 255, 0.5);
}

.ctrl-btn:active {
  transform: scale(0.92);
}

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

/* --- 弹窗 (Modal) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: rgba(10, 22, 40, 0.95);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 200, 255, 0.15);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-box h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.modal-box p {
  font-size: 14px;
  color: var(--color-text-light);
  margin-bottom: 16px;
}

.modal-box .btn {
  margin: 4px;
}

/* --- Toast 提示 --- */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: var(--color-white);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 200;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
}

@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; transform: translateX(-50%) translateY(-20px); }
}

/* --- 规则页面样式 --- */
.rules-list {
  list-style: none;
  padding: 0;
}

.rules-list li {
  background: rgba(15, 30, 58, 0.7);
  border: 1px solid rgba(0, 200, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 1px 4px var(--color-shadow);
}

.rules-list li .emoji {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* --- 响应式 --- */
@media (max-width: 400px) {
  .container { padding: 10px 6px; }
  .page-title { font-size: 20px; }
  .card { padding: 12px 14px; }
  .card-icon { font-size: 26px; width: 40px; height: 40px; }
  .ctrl-btn { width: 48px; height: 48px; font-size: 18px; }
  .stat .num { font-size: 17px; }
}

@media (min-width: 600px) {
  .container { max-width: 520px; padding: 20px 16px; }
  .page-title { font-size: 28px; }
  .card-grid { flex-direction: row; flex-wrap: wrap; }
  .card { flex: 1 1 200px; flex-direction: column; text-align: center; }
  .card-arrow { display: none; }
}
