/* ============================================================
   StudyAI — Nền tảng dạy học tương tác
   Design system dùng chung cho toàn bộ site
   ============================================================ */

:root {
  --brand-1: #0ea5a4;   /* teal */
  --brand-2: #2563eb;   /* blue */
  --brand-3: #f97316;   /* orange accent */
  --brand-4: #facc15;   /* yellow accent */
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-100: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --danger: #ef4444;
  --success: #22c55e;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.16);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--surface-soft);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ink-100);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink-900);
}
.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: 0.68rem;
  color: var(--ink-500);
  letter-spacing: 0.03em;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.main-nav a.nav-link {
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-700);
}
.main-nav a.nav-link:hover { background: var(--ink-100); }
.main-nav a.nav-link.active { color: var(--brand-2); background: #eef4ff; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--ink-100); color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-300); }
.btn-outline { background: transparent; border: 1.5px solid var(--ink-300); color: var(--ink-700); }
.btn-outline:hover { border-color: var(--brand-2); color: var(--brand-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Hero ---------------- */
.hero {
  background:
    radial-gradient(1200px 400px at 15% -10%, rgba(14, 165, 164, 0.25), transparent),
    radial-gradient(900px 400px at 90% 0%, rgba(37, 99, 235, 0.25), transparent),
    linear-gradient(180deg, #0f172a, #10233f 60%, var(--surface-soft) 100%);
  color: #fff;
  padding: 72px 0 90px;
}
.hero .container { text-align: center; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 800;
  margin-bottom: 16px;
}
.hero h1 span {
  background: linear-gradient(135deg, var(--brand-4), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p.lead {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.78);
  max-width: 620px;
  margin: 0 auto 32px;
}
.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 54px;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat b { display: block; font-size: 1.7rem; font-weight: 800; }
.hero-stat span { font-size: 0.82rem; color: rgba(255,255,255,0.65); }

/* ---------------- Sections ---------------- */
.section { padding: 64px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.section-head .kicker {
  color: var(--brand-2);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  display: block;
}
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; margin-bottom: 12px; }
.section-head p { color: var(--ink-500); }

/* ---------------- Game grid & cards ---------------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 20px;
}
.game-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--ink-100);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.game-card .badge-new {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--brand-3);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.game-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: #fff;
}
.game-card h3 { font-size: 1.08rem; font-weight: 800; }
.game-card p { color: var(--ink-500); font-size: 0.88rem; line-height: 1.5; flex: 1; }
.game-card .btn { align-self: flex-start; }

/* palette rotation for icons */
.gi-1 { background: linear-gradient(135deg,#0ea5a4,#0f766e); }
.gi-2 { background: linear-gradient(135deg,#f97316,#c2410c); }
.gi-3 { background: linear-gradient(135deg,#2563eb,#1e40af); }
.gi-4 { background: linear-gradient(135deg,#db2777,#9d174d); }
.gi-5 { background: linear-gradient(135deg,#7c3aed,#5b21b6); }
.gi-6 { background: linear-gradient(135deg,#eab308,#a16207); }
.gi-7 { background: linear-gradient(135deg,#059669,#065f46); }
.gi-8 { background: linear-gradient(135deg,#0284c7,#075985); }

/* ---------------- Footer ---------------- */
.site-footer {
  background: var(--ink-900);
  color: rgba(255,255,255,0.7);
  padding: 50px 0 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-grid h4 { color: #fff; font-size: 0.95rem; margin-bottom: 14px; }
.footer-grid li { margin-bottom: 8px; font-size: 0.88rem; }
.footer-grid a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 20px;
  font-size: 0.82rem;
  text-align: center;
  color: rgba(255,255,255,0.5);
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
  .main-nav { display: none; }
}

/* ============================================================
   Game shell — dùng chung cho các trang trò chơi
   ============================================================ */
.game-shell { min-height: 100vh; display: flex; flex-direction: column; }
.game-topbar {
  background: var(--ink-900);
  color: #fff;
  padding: 12px 0;
}
.game-topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.game-topbar .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.85);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
}
.game-topbar .back-link:hover { background: rgba(255,255,255,0.16); }
.game-topbar .game-title { font-weight: 800; font-size: 1rem; }
.game-topbar .topbar-tools { display: flex; gap: 8px; }

.game-stage {
  flex: 1;
  background: var(--surface-soft);
  padding: 28px 0 60px;
}
.game-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--ink-100);
  padding: 28px;
}
.scoreboard {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.score-chip {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-chip .dot { width: 9px; height: 9px; border-radius: 50%; }

.question-box {
  text-align: center;
  padding: 18px 10px 30px;
}
.question-progress {
  font-weight: 700;
  color: var(--brand-2);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.question-text {
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  font-weight: 800;
  color: var(--ink-900);
  max-width: 700px;
  margin: 0 auto;
}
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 720px;
  margin: 26px auto 0;
}
@media (max-width: 560px) { .answer-grid { grid-template-columns: 1fr; } }
.answer-btn {
  background: var(--surface);
  border: 2px solid var(--ink-100);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}
.answer-btn .opt-key {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--ink-100);
  color: var(--ink-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem;
  flex-shrink: 0;
}
.answer-btn:hover:not(:disabled) { border-color: var(--brand-2); transform: translateY(-2px); }
.answer-btn.correct { border-color: var(--success); background: #f0fdf4; }
.answer-btn.correct .opt-key { background: var(--success); color: #fff; }
.answer-btn.wrong { border-color: var(--danger); background: #fef2f2; }
.answer-btn.wrong .opt-key { background: var(--danger); color: #fff; }
.answer-btn:disabled { cursor: not-allowed; }

.result-box { text-align: center; padding: 40px 10px; }
.result-box .emoji { font-size: 3.4rem; margin-bottom: 10px; }
.result-box h3 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.result-box p { color: var(--ink-500); margin-bottom: 26px; }

.side-note {
  background: #eef4ff;
  border: 1px solid #dbe7ff;
  color: #1e3a8a;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* ---------------- Modal (soạn câu hỏi) ---------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--ink-100);
}
.modal-head h3 { font-size: 1.1rem; font-weight: 800; }
.modal-close {
  background: var(--ink-100); border: none; width: 32px; height: 32px;
  border-radius: 50%; font-size: 1rem; color: var(--ink-700);
}
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 16px 24px 22px;
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--ink-100);
}
.field-label { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; display: block; color: var(--ink-700); }
.field-hint { font-size: 0.78rem; color: var(--ink-500); margin-top: 6px; line-height: 1.5; }
textarea, input[type=text], input[type=number] {
  width: 100%;
  border: 1.5px solid var(--ink-300);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 0.92rem;
  resize: vertical;
  color: var(--ink-900);
}
textarea:focus, input:focus { outline: none; border-color: var(--brand-2); }
.form-row { margin-bottom: 16px; }
.form-row-inline { display: flex; gap: 12px; }
.form-row-inline > div { flex: 1; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink-900);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.confetti-piece {
  position: fixed;
  top: -10px;
  border-radius: 2px;
  z-index: 300;
  pointer-events: none;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-500);
}
.empty-state .emoji { font-size: 2.6rem; margin-bottom: 12px; }
