/* ============================================================
   English Story Game — Complete Styles
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f6ef7;
  --primary-light: #e8ecff;
  --primary-dark: #3a56d4;
  --secondary: #ff6b6b;
  --accent: #ffd93d;
  --success: #6bcb77;
  --bg: #f0f4ff;
  --card: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --border: #dfe6e9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(79, 110, 247, 0.10);
  --shadow-lg: 0 8px 30px rgba(79, 110, 247, 0.15);
  --transition: 0.25s ease;
}
html { font-size: 16px; }
body {
  font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---- Header ---- */
#app-header {
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 960px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 1.25rem; font-weight: 700; cursor: pointer; color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  font-size: 0.85rem; color: var(--text-light);
  background: var(--primary-light); padding: 4px 12px; border-radius: 20px;
}
.user-expire {
  font-size: 0.82rem; color: var(--text-light);
  padding: 4px 10px; border-radius: 20px;
  background: #f0faf0;
}
.user-expire-warn {
  color: #e67e22; background: #fef9e7;
}
.user-expire-expired {
  color: #e74c3c; background: #fdedec;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); gap: 6px;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: #e05555; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #52b864; }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-choice {
  display: block; width: 100%; text-align: left;
  padding: 14px 18px; background: var(--card);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; cursor: pointer; transition: var(--transition);
}
.btn-choice:hover { border-color: var(--primary); background: var(--primary-light); }

/* ---- Page Layout ---- */
.page { max-width: 600px; margin: 0 auto; padding: 24px 20px; }
.page-wide { max-width: 800px; }
.page-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; text-align: center;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.page-subtitle { color: var(--text-light); margin-bottom: 24px; }

/* ---- Cards ---- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--text-light); }
.input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem; transition: var(--transition);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: auto; }

/* ---- Tags (word pills) ---- */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; background: var(--primary-light);
  color: var(--primary); border-radius: 20px; font-size: 0.85rem; font-weight: 500;
}
.tag .remove { cursor: pointer; font-weight: bold; opacity: 0.6; }
.tag .remove:hover { opacity: 1; }
.tag-ok { background: #e6f9ed; color: #1a8a3a; }
.tag-wrong { background: #ffe8e8; color: #d32f2f; }

/* ---- Highlighted word ---- */
.word-highlight { color: var(--primary); font-weight: 700; cursor: pointer; border-bottom: 2px dashed var(--primary); }

/* ---- Story Reader ---- */
.story-text { font-size: 1.05rem; line-height: 1.8; margin-bottom: 20px; }
.story-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.progress-bar {
  height: 4px; background: var(--border); border-radius: 2px; margin-bottom: 20px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.5s ease; }

/* ---- Vocab Panel ---- */
.vocab-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.vocab-panel {
  background: var(--card); border-radius: var(--radius);
  padding: 24px 28px; max-width: 360px; width: 90%;
  box-shadow: var(--shadow-lg); text-align: center;
}
.vocab-panel .word { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.vocab-panel .meaning { font-size: 1.2rem; margin: 8px 0; }
.vocab-panel .close-btn {
  margin-top: 16px; padding: 8px 20px; background: var(--primary-light);
  border: none; border-radius: var(--radius-sm); color: var(--primary); cursor: pointer;
  font-size: 0.9rem;
}

/* ---- Type Picker ---- */
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.type-card {
  padding: 16px; border: 1.5px solid var(--border); border-radius: var(--radius);
  text-align: center; cursor: pointer; transition: var(--transition);
  background: var(--card);
}
.type-card:hover { border-color: var(--primary); }
.type-card.selected { border-color: var(--primary); background: var(--primary-light); }
.type-card .icon { font-size: 2rem; margin-bottom: 6px; }
.type-card .name { font-weight: 600; font-size: 0.9rem; }

/* ---- Review ---- */
.review-question { font-size: 1.1rem; margin-bottom: 16px; line-height: 1.6; }
.review-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.review-opt {
  padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; text-align: center; transition: var(--transition); font-size: 0.95rem;
}
.review-opt:hover { border-color: var(--primary); }
.review-opt.selected-correct { border-color: var(--success); background: #e6f9ed; }
.review-opt.selected-wrong { border-color: var(--secondary); background: #ffe8e8; }

/* ---- History ---- */
.history-item {
  display: flex; align-items: center; padding: 14px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition);
}
.history-item:hover { background: var(--primary-light); margin: 0 -20px; padding: 14px 20px; border-radius: var(--radius-sm); }
.history-item:last-child { border-bottom: none; }
.history-date { color: var(--text-light); font-size: 0.8rem; min-width: 85px; }
.history-info { flex: 1; }
.history-title { font-weight: 600; }
.history-meta { font-size: 0.8rem; color: var(--text-light); }

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page { animation: fadeIn 0.3s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite; margin: 20px auto;
}
@keyframes dots { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
.dot-pulse { display: inline-flex; gap: 6px; }
.dot-pulse span {
  width: 8px; height: 8px; background: var(--primary); border-radius: 50%;
  animation: dots 1.4s infinite ease-in-out both;
}
.dot-pulse span:nth-child(1) { animation-delay: -0.32s; }
.dot-pulse span:nth-child(2) { animation-delay: -0.16s; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 24px;
  border-radius: var(--radius-sm); font-size: 0.88rem;
  z-index: 300; box-shadow: var(--shadow-lg);
  transition: opacity 0.3s ease;
}
.toast.error { background: var(--secondary); }
.toast.success { background: var(--success); }

/* ---- Loading overlay ---- */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85); z-index: 150;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.loading-overlay p { margin-top: 12px; color: var(--text-light); font-size: 0.95rem; }

/* ---- Story Timeline ---- */
.timeline-chapter {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 20px;
  position: relative;
  border-left: 2px solid var(--border);
  margin-left: 16px;
}
.timeline-chapter:last-child { border-left-color: transparent; }
.timeline-dot {
  width: 30px; height: 30px;
  background: var(--primary); color: #fff;
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600;
  margin-left: -31px;
  z-index: 1;
}
.timeline-dot.dot-end { background: var(--success); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.timeline-choice {
  font-size: 0.8rem; color: var(--primary); font-style: italic;
}
.timeline-text {
  font-size: 0.9rem; line-height: 1.65; color: var(--text);
  margin-bottom: 8px;
}
.timeline-text p { margin: 4px 0; }
.timeline-options {
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* ---- Word clickable (non-target words) ---- */
.word-clickable {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-light);
  transition: all 0.15s;
}
.word-clickable:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(79, 172, 254, 0.08);
}

/* ---- Phonetic (vocab panel) ---- */
.phonetic {
  font-size: 1.1rem;
  color: var(--text-light);
  margin: 4px 0 6px;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  letter-spacing: 0.5px;
}

/* ---- History list ---- */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.history-item:hover { background: var(--bg-alt); }
.history-item + .history-item { border-top: 1px solid var(--border); }
.history-info { flex: 1; min-width: 0; }
.history-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.history-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }

/* ---- Admin Mini Buttons ---- */
.admin-mini-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border-radius: 10px; cursor: pointer;
  background: rgba(245,158,11,0.08); border: 1.5px solid rgba(245,158,11,0.2);
  transition: all 0.2s; text-align: center;
}
.admin-mini-btn:hover {
  background: rgba(245,158,11,0.15);
  border-color: rgba(245,158,11,0.5);
  transform: translateY(-1px);
}

/* ---- Story Game Cards ---- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px 16px;
}
.game-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}
.game-card:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,215,0,0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.game-card:active { transform: scale(0.97); }
.game-card-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
}
.game-card-info { flex: 1; min-width: 0; }
.game-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.game-card-namecn {
  font-size: 0.72rem;
  color: rgba(255,215,0,0.7);
  margin: 1px 0 3px;
}
.game-card-desc {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-card-age {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .page { padding: 16px 12px; }
  .type-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .review-options { grid-template-columns: 1fr 1fr; }
  .header-inner { padding: 10px 12px; }
  .logo { font-size: 1.1rem; }
  .game-grid { grid-template-columns: 1fr; gap: 8px; }
}
