/* =============================================================
 *  HÀNH TRÌNH SỬ VIỆT — giao diện hoành tráng dùng chung
 * ============================================================= */
:root {
  --accent: #b91c1c;
  --gold: #f59e0b;
  --gold-2: #fde047;
  --ink: #1a120b;
  --paper: #fbf3e3;
  --paper-2: #f3e6cd;
  --ok: #16a34a;
  --bad: #dc2626;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

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

body {
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(245, 158, 11, .18), transparent 60%),
    linear-gradient(180deg, #2a1408, #160a04 60%, #0d0603);
  min-height: 100vh;
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 18px; }

/* hoa văn trống đồng mờ trên nền */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .05; z-index: 0;
  background-image: radial-gradient(circle, #f59e0b 1px, transparent 1.5px);
  background-size: 26px 26px;
}

/* ---------- TOP BAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: rgba(22, 10, 4, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(245, 158, 11, .25);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 900; letter-spacing: .5px; }
.brand .seal {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold-2), var(--gold) 55%, #b45309);
  display: grid; place-items: center; color: #3b1d05; font-size: 20px;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .25), var(--shadow);
}
.brand b { font-size: 1.15rem; }
.brand small { display: block; font-weight: 600; font-size: .62rem; opacity: .75; letter-spacing: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  border: none; cursor: pointer; border-radius: 10px; font-weight: 800;
  padding: 10px 16px; font-size: .9rem; transition: transform .12s, box-shadow .12s; color: #fff;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--accent)); box-shadow: var(--shadow); }
.btn-ghost { background: rgba(255, 255, 255, .1); color: #fde9c8; border: 1px solid rgba(245, 158, 11, .35); }
.btn-icon { background: rgba(255, 255, 255, .08); color: #fde9c8; width: 42px; height: 42px; padding: 0; border-radius: 10px; font-size: 1.05rem; }

.user-chip { color: #fde9c8; font-size: .85rem; display: flex; align-items: center; gap: 8px; }
.user-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- HERO (hub) ---------- */
.hero { position: relative; z-index: 1; text-align: center; padding: 70px 18px 40px; color: #fff; }
.hero .kicker {
  display: inline-block; padding: 6px 16px; border-radius: 999px; font-weight: 800; letter-spacing: 3px;
  font-size: .7rem; color: var(--gold-2); border: 1px solid rgba(245, 158, 11, .4); background: rgba(245, 158, 11, .08); margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 1.18; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff 30%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 30px rgba(245, 158, 11, .25);
}
.hero p { max-width: 640px; margin: 16px auto 0; color: #f1dcc0; font-size: 1.08rem; }
.hero .hero-cta { margin-top: 26px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- GAME CARDS (hub) ---------- */
.games { position: relative; z-index: 1; padding: 30px 0 60px; }
.section-title { color: #fff; text-align: center; margin-bottom: 28px; }
.section-title h2 { font-size: 1.8rem; font-weight: 900; }
.section-title span { color: var(--gold); }
.section-title p { color: #cbb699; margin-top: 6px; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.game-card {
  position: relative; border-radius: 18px; overflow: hidden; min-height: 280px; color: #fff; text-decoration: none;
  display: flex; flex-direction: column; justify-content: flex-end;
  border: 1px solid rgba(245, 158, 11, .25); box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s; isolation: isolate;
}
.game-card:hover { transform: translateY(-6px); box-shadow: 0 20px 44px rgba(0, 0, 0, .45); }
.game-card .gc-bg {
  position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center;
  transition: transform .4s;
}
.game-card:hover .gc-bg { transform: scale(1.08); }
.game-card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 5, 2, .1), rgba(10, 5, 2, .92)); }
.game-card .gc-num { position: absolute; top: 14px; left: 16px; font-size: 2.4rem; font-weight: 900; opacity: .35; }
.game-card .gc-badge { position: absolute; top: 16px; right: 16px; background: rgba(0, 0, 0, .4); border: 1px solid rgba(245, 158, 11, .5); color: var(--gold-2); font-size: .68rem; font-weight: 800; padding: 5px 10px; border-radius: 999px; }
.game-card .gc-body { padding: 20px; }
.game-card h3 { font-size: 1.4rem; font-weight: 900; line-height: 1.4; }
.game-card p { color: #e7d3b6; font-size: .9rem; margin-top: 4px; }
.game-card .gc-go { margin-top: 14px; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--gold-2); }
.game-card .gc-prog { margin-top: 10px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.game-card .gc-prog span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); width: 0; }

/* ---------- GAME PAGE LAYOUT ---------- */
.game-head { position: relative; z-index: 1; text-align: center; padding: 44px 18px 10px; color: #fff; }
.game-head h1 { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 900; line-height: 1.2; padding-bottom: 4px;
  background: linear-gradient(180deg, #fff, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.game-head p { color: #e7d3b6; max-width: 620px; margin: 10px auto 0; }

.progress-wrap { position: relative; z-index: 1; max-width: 720px; margin: 22px auto 8px; padding: 0 18px; }
.progress-bar { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, .4); border: 1px solid rgba(245, 158, 11, .3); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--gold), var(--gold-2)); transition: width .5s; }
.progress-label { text-align: center; color: var(--gold-2); font-weight: 800; font-size: .85rem; margin-top: 8px; }

/* ---------- LEVEL MAP ---------- */
.map-section { position: relative; z-index: 1; padding: 18px 0 40px; }
.level-map {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; padding: 0 4px;
}
.node {
  position: relative; border: none; cursor: pointer; text-align: left; color: #fff;
  border-radius: 16px; overflow: hidden; min-height: 184px; padding: 16px 16px 20px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: #2a1408; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; isolation: isolate;
}
.node .node-bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; opacity: .55; }
.node::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 5, 2, .15), rgba(10, 5, 2, .9)); }
.node:not(.locked):hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 16px 36px rgba(0, 0, 0, .45); }
.node-num { position: absolute; top: 10px; left: 14px; font-size: 1.6rem; font-weight: 900; opacity: .6; }
.node-title { font-weight: 800; font-size: .95rem; line-height: 1.6; padding-bottom: 3px; }
.node-era { font-size: .72rem; color: var(--gold-2); font-weight: 700; margin-top: 6px; }
.node-check { position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; font-weight: 900; box-shadow: 0 0 12px rgba(22, 163, 74, .7); }
.node-lock { position: absolute; top: 10px; right: 12px; font-size: 1.1rem; }
.node-sword, .node-q { position: absolute; top: 10px; right: 12px; font-size: 1.1rem; filter: drop-shadow(0 0 6px var(--gold)); }
.node.locked { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.node.open { box-shadow: 0 0 0 2px rgba(245, 158, 11, .55), var(--shadow); animation: pulse 2.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, .5), var(--shadow); } 50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, .18), var(--shadow); } }
.node.done .node-bg { opacity: .7; }

/* ---------- ALL DONE BANNER ---------- */
.all-done { display: none; position: relative; z-index: 1; margin: 10px 0 30px; text-align: center;
  border-radius: 16px; padding: 26px; color: #3b1d05;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); box-shadow: var(--shadow); }
.all-done.show { display: block; animation: rise .5s; }
.all-done h3 { font-size: 1.5rem; font-weight: 900; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- LIBRARY (đọc sử đã mở khóa) ---------- */
.lib-section { position: relative; z-index: 1; padding: 10px 0 70px; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.lib-card { background: var(--paper); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s; border: 1px solid rgba(0, 0, 0, .08); }
.lib-card.open:hover { transform: translateY(-4px); }
.lib-card.locked { cursor: default; }
.lib-img { height: 130px; background-size: cover; background-position: center; background-color: #3a2412; position: relative; display: grid; place-items: center; }
.lib-card.locked .lib-img { background: repeating-linear-gradient(45deg, #2a1810, #2a1810 12px, #1f1109 12px, #1f1109 24px); }
.lib-lock { font-size: 1.8rem; opacity: .7; }
.lib-meta { padding: 14px; }
.lib-era { font-size: .7rem; font-weight: 800; color: var(--accent); }
.lib-meta h4 { margin: 4px 0 6px; font-size: 1.02rem; line-height: 1.45; color: var(--ink); }
.lib-meta p { font-size: .85rem; color: #6b5640; }

/* ---------- MODAL ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(8, 4, 2, .82); backdrop-filter: blur(6px); padding: 20px; overflow-y: auto; }
.modal.show { display: flex; align-items: flex-start; justify-content: center; }
.modal-card { background: var(--paper); border-radius: 20px; max-width: 640px; width: 100%; margin: 30px auto; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); position: relative; animation: pop .25s; }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 5; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; background: rgba(0, 0, 0, .45); color: #fff; font-size: 1.1rem; }

/* read / story scene (kể chuyện) */
.story-hero { position: relative; height: 240px; overflow: hidden; background: #3a2412; display: flex; align-items: flex-end; }
.story-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.kenburns { animation: kenburns 16s ease-in-out infinite alternate; transform-origin: center; }
@keyframes kenburns { 0% { transform: scale(1) translate(0, 0); } 100% { transform: scale(1.18) translate(-2%, -3%); } }
.story-hero-ov { position: relative; z-index: 2; width: 100%; padding: 18px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .9)); color: #fff; }
.story-title { font-size: 1.6rem; font-weight: 900; line-height: 1.4; padding-bottom: 4px; animation: rise .5s; }
.read-era { font-size: .74rem; font-weight: 800; color: var(--gold-2); }
.narrate-btn { position: absolute; top: 12px; left: 12px; z-index: 3; border: 1px solid rgba(245,158,11,.6); background: rgba(0,0,0,.5); color: #fde9c8; font-weight: 800; font-size: .8rem; padding: 7px 12px; border-radius: 999px; cursor: pointer; backdrop-filter: blur(4px); }
.narrate-btn:hover { background: rgba(0,0,0,.7); }
.narrate-btn.video-btn { left: auto; right: 56px; }
.story-body { padding: 22px; }
.story-text { font-size: 1.06rem; color: #2e2113; min-height: 90px; line-height: 1.75; border-left: 3px solid var(--gold); padding-left: 14px; }
.read-body { padding: 22px; }
.read-body > p { font-size: 1.02rem; color: #3a2c1c; }

/* các mục cinematic trong cảnh kể chuyện */
.sect { margin-top: 18px; }
.sect-h { font-weight: 800; color: var(--accent); font-size: 1rem; margin-bottom: 8px; }
.sect-body { font-size: .98rem; color: #3a2c1c; line-height: 1.7; }
.gen-list { display: flex; flex-wrap: wrap; gap: 8px; }
.gen-chip { border: 2px solid #e3d3b4; background: #fff; border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: .9rem; cursor: pointer; transition: all .12s; }
.gen-chip:hover { transform: translateY(-2px); }
.gen-chip.side-ta { border-color: #b45309; color: #92400e; background: #fff7ed; }
.gen-chip.side-dich { border-color: #6b7280; color: #374151; background: #f3f4f6; }
.gen-chip.side-fig { border-color: #0d9488; color: #115e59; background: #f0fdfa; }
.fact-list { margin: 0; padding-left: 20px; }
.fact-list li { font-size: .95rem; color: #3a2c1c; line-height: 1.65; margin-bottom: 6px; }
.gen-note { margin-top: 10px; font-size: .92rem; color: #4a3826; min-height: 4px; background: #fff; border-radius: 10px; padding: 0; }
.gen-note:not(:empty) { padding: 12px 14px; box-shadow: 0 2px 8px rgba(0,0,0,.06); animation: rise .3s; }
.gen-note .lnk { background: none; border: none; color: var(--accent); cursor: pointer; font-weight: 800; text-decoration: underline; }
.place-list { display: grid; gap: 8px; }
.place-item { background: #fff; border-left: 3px solid var(--gold); border-radius: 8px; padding: 10px 13px; font-size: .92rem; color: #4a3826; cursor: context-menu; }
.place-item b { color: var(--accent); }
.read-cta { margin-top: 20px; text-align: center; }
.enemy-tag { font-size: .9rem; color: #6b5640; margin-bottom: 12px; }
.enemy-tag b { color: var(--accent); }
.btn-start, .btn-next, .btn-retry, .btn-reread {
  border: none; cursor: pointer; border-radius: 12px; font-weight: 800; font-size: 1rem; padding: 13px 24px; color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--accent)); box-shadow: var(--shadow); transition: transform .12s; margin: 6px;
}
.btn-start:hover, .btn-next:hover, .btn-retry:hover, .btn-reread:hover { transform: translateY(-2px); }
.btn-reread { background: #6b5640; }

/* mission */
.mission { padding: 22px; }
.quiz-progress { text-align: center; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
.q-card { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.q-text { font-size: 1.12rem; font-weight: 800; color: var(--ink); margin-bottom: 14px; }
.q-opts { display: grid; gap: 10px; }
.opt {
  text-align: left; border: 2px solid #e7d8bf; background: var(--paper); color: var(--ink);
  border-radius: 10px; padding: 12px 14px; font-size: .98rem; font-weight: 600; cursor: pointer; transition: all .12s;
}
.opt:hover:not(:disabled) { border-color: var(--gold); transform: translateX(3px); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: #dcfce7; color: #14532d; }
.opt.wrong { border-color: var(--bad); background: #fee2e2; color: #7f1d1d; }
.q-feedback { text-align: center; margin-top: 14px; min-height: 24px; font-weight: 800; }
.q-feedback .ok { color: var(--ok); }
.q-feedback .bad { color: var(--bad); }

/* battle stage */
.battle-stage { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px;
  background: linear-gradient(135deg, #2a1408, #4a1d0c); border-radius: 14px; padding: 16px; }
.combatant { flex: 1; text-align: center; color: #fff; }
.cbt-img { width: 78px; height: 78px; margin: 0 auto 8px; border-radius: 12px; background-size: cover; background-position: center;
  background-color: #1a0c05; border: 2px solid rgba(245, 158, 11, .5); display: grid; place-items: center; font-size: 2.2rem; }
.cbt-name { font-size: .8rem; font-weight: 800; margin-bottom: 6px; }
.hpbar { height: 12px; border-radius: 999px; background: rgba(0, 0, 0, .5); overflow: hidden; border: 1px solid rgba(255, 255, 255, .2); }
.hpbar span { display: block; height: 100%; background: linear-gradient(90deg, #dc2626, #f87171); transition: width .4s; }
.hearts { font-size: 1.05rem; letter-spacing: 2px; }
.vs { color: var(--gold-2); font-weight: 900; font-size: 1.1rem; }
.battle-stage.hit-enemy .enemy .cbt-img { animation: shake .4s; }
.battle-stage.hit-hero .hero .cbt-img { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px) rotate(-4deg); } 75% { transform: translateX(7px) rotate(4deg); } }

/* result */
.result { padding: 34px 24px; text-align: center; }
.rs-emoji { font-size: 3.6rem; animation: rise .4s; }
.result h2 { font-size: 1.8rem; font-weight: 900; margin: 6px 0; }
.result.win h2 { color: var(--ok); }
.result.lose h2 { color: var(--bad); }
.result p { color: #5a4632; max-width: 420px; margin: 0 auto; }
.rs-points { margin: 16px auto 0; display: inline-block; padding: 10px 18px; border-radius: 999px; font-weight: 800;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #3b1d05; }
.rs-points.muted { background: #efe2c8; color: #6b5640; }
.rs-actions { margin-top: 20px; }

/* leaderboard */
.lb-section { position: relative; z-index: 1; padding: 0 0 60px; }
.lb-box { max-width: 560px; margin: 0 auto; background: rgba(22, 10, 4, .6); border: 1px solid rgba(245, 158, 11, .3); border-radius: 16px; overflow: hidden; }
.lb-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; color: var(--gold-2); font-weight: 900; border-bottom: 1px solid rgba(245, 158, 11, .2); }
#leaderboard { padding: 8px; }
.sv-lb-row { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; color: #f1dcc0; }
.sv-lb-row:nth-child(odd) { background: rgba(255, 255, 255, .04); }
.sv-lb-player { background: rgba(245, 158, 11, .15) !important; }
.sv-lb-rank { font-weight: 900; text-align: center; color: var(--gold-2); }
.sv-lb-name { font-weight: 700; }
.sv-lb-score { font-weight: 900; color: var(--gold-2); }
.sv-lb-score::after { content: " 🪙"; }
.sv-lb-levels { font-size: .78rem; opacity: .7; }
.sv-lb-levels::after { content: " ải"; }

/* points panel */
.pts-panel { padding: 18px; text-align: center; color: #f1dcc0; }
.pts-panel p { margin-bottom: 12px; }
.pts-acc { font-size: .9rem; color: #e7d3b6; }
.pts-acc b { color: var(--gold-2); }
.pts-score { font-size: 2rem; font-weight: 900; color: var(--gold-2); margin: 6px 0 14px; }
.pts-score span { font-size: 1rem; font-weight: 700; color: #cbb699; }
.pts-score.muted { font-size: .9rem; color: #cbb699; }
.pts-panel small { display: block; margin-top: 10px; color: #9c8467; font-size: .76rem; }
.pts-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.pts-ok { color: #34d399; font-weight: 700; font-size: .9rem; margin: 6px 0; }
.pts-pool { margin-top: 10px; color: var(--gold-2); font-size: .85rem; }
.pts-panel .lnk { background: none; border: none; color: #f59e0b; cursor: pointer; font-size: .8rem; text-decoration: underline; padding: 0; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .2; } }

/* footer */
.site-foot { position: relative; z-index: 1; text-align: center; padding: 26px 18px; color: #93785a; font-size: .82rem; border-top: 1px solid rgba(245, 158, 11, .15); }

@media (max-width: 600px) {
  .battle-stage { flex-direction: column; }
  .cbt-img { width: 64px; height: 64px; }
  .hero h1 { font-size: 2.4rem; }
}
