/* English Learning Zone - Common Styles */
/* 深色主题，移动优先，触摸友好 */

:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --accent: var(--game-color, #4a90d9);
  --success: #2eb872;
  --error: #e94560;
  --warning: #e07c24;
  --radius: 12px;
  --radius-sm: 8px;
  --font-main: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ---- Game Header ---- */
.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.game-nav {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.game-header .back-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-primary);
  font-size: 20px; cursor: pointer; border-radius: 50%;
}
.game-header .back-btn:active { background: rgba(255,255,255,0.1); }

.game-header h1 {
  font-size: 18px; font-weight: 600;
  flex: 1;
}

.game-header .level-badge {
  font-size: 12px; padding: 2px 8px;
  background: var(--accent); color: #fff;
  border-radius: 10px; font-weight: 600;
}

.game-nav-tail {
  width: 36px;
  height: 36px;
  display: inline-flex;
  flex-shrink: 0;
}

/* ---- Container ---- */
.game-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 12px 24px;
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  color: #fff; background: var(--accent);
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}
.btn-sm { min-height: 36px; padding: 8px 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-success { background: var(--success); }
.btn-error { background: var(--error); }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* ---- Score Bar ---- */
.score-bar {
  display: flex; justify-content: space-around;
  padding: 12px; background: var(--bg-card);
  border-radius: var(--radius); margin-bottom: 16px;
}
.score-bar .stat { text-align: center; }
.score-bar .stat-value { font-size: 24px; font-weight: 700; color: var(--accent); }
.score-bar .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px; max-width: 400px; width: 100%;
  text-align: center;
}
.modal h2 { font-size: 22px; margin-bottom: 12px; }
.modal p { color: var(--text-secondary); margin-bottom: 20px; }

/* ---- Timer ---- */
.timer {
  font-size: 14px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.timer.urgent { color: var(--error); font-weight: 600; }

/* ---- TTS Button ---- */
.tts-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 50%; cursor: pointer; color: var(--text-secondary);
  font-size: 16px; flex-shrink: 0;
}
.tts-btn:active { background: rgba(255,255,255,0.15); }

/* ---- Progress Bar ---- */
.progress-bar {
  height: 4px; background: rgba(255,255,255,0.1);
  border-radius: 2px; overflow: hidden;
}
.progress-bar .fill {
  height: 100%; background: var(--accent);
  transition: width 0.3s ease;
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* ---- Hub Game Grid ---- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.game-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none; color: inherit;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.1s;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px;
}
.game-card:active { transform: scale(0.97); }
.game-card .game-icon { font-size: 36px; }
.game-card .game-name { font-size: 14px; font-weight: 600; }
.game-card .game-desc { font-size: 11px; color: var(--text-secondary); }
.game-card .game-tags {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
}
.game-card .tag {
  font-size: 10px; padding: 1px 6px;
  border-radius: 6px; background: rgba(255,255,255,0.08);
  color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (min-width: 768px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .game-container { max-width: 700px; padding: 24px; }
}

/* Phase 1-2 hub compatibility classes */
.page { max-width: 980px; margin: 0 auto; padding: 20px 16px 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(74, 144, 217, 0.2);
  border: 1px solid rgba(74, 144, 217, 0.5);
  color: #c9e5ff;
  font-size: 12px;
}
.title { font-size: 22px; margin: 0 0 8px; }
.subtitle { margin: 0; color: var(--text-secondary); }
.button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}
.button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ---- Help Button & Modal ---- */
.help-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.1); border: none;
  border-radius: 50%; cursor: pointer;
  color: var(--text-primary); font-size: 18px; font-weight: 700;
  flex-shrink: 0; transition: background 0.15s;
}
.help-btn:active { background: rgba(255,255,255,0.2); }
.help-modal-body { text-align: left; }
.help-modal-body h3 {
  font-size: 15px; color: var(--accent);
  margin: 14px 0 6px; font-weight: 600;
}
.help-modal-body h3:first-child { margin-top: 0; }
.help-modal-body p,
.help-modal-body li {
  font-size: 14px; color: var(--text-secondary);
  line-height: 1.6; margin: 0;
}
.help-modal-body ul {
  padding-left: 18px; margin: 4px 0 8px;
  list-style: disc;
}
.help-modal-body .help-keys {
  display: inline-block; padding: 2px 8px;
  background: rgba(255,255,255,0.1); border-radius: 4px;
  font-size: 12px; font-family: monospace; color: var(--text-primary);
}
