:root { --c: #b8322a; --gold: #e3b04b; --ink: #f3e6c8; --mut: #bfa97f; --bg: #1a1210; --card: #2a1c16; --line: rgba(227,176,75,.35); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: "Be Vietnam Pro", system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; touch-action: none; display: block; }
#menu { position: fixed; inset: 0; z-index: 20; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#menu.on { display: block; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .5; }
.serif, h1, h2 { font-family: "Noto Serif", Georgia, serif; }

/* ---------- trang chính ---------- */
.home { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 70px) 16px calc(env(safe-area-inset-bottom, 0px) + 22px); max-width: 520px; margin: 0 auto; }
.logo { text-align: center; margin-bottom: auto; padding-top: 4vh; position: relative; }
.logo h1 { margin: 0; font-size: clamp(46px, 13vw, 76px); font-weight: 900; letter-spacing: 1px; line-height: 1.05; background: linear-gradient(180deg, #fff3cf, #e3b04b 55%, #a8741f); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 14px rgba(0,0,0,.6)); }
.logo p { margin: 6px 0 0; font-weight: 800; font-size: 17px; letter-spacing: 4px; text-transform: uppercase; color: #f0d9a8; text-shadow: 0 2px 10px rgba(0,0,0,.7); }
.seal { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 12px; display: grid; place-items: center; font-family: "Noto Serif", serif; font-size: 40px; font-weight: 900; color: #fff3e0; background: radial-gradient(circle at 30% 30%, #d9483a, #8e1f1f); box-shadow: 0 8px 26px rgba(160,30,30,.55), inset 0 0 0 3px rgba(255,220,180,.35); transform: rotate(-6deg); }
.btn { display: block; width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg, #3a2a20, #24170f); color: var(--ink); font-weight: 800; font-size: 17px; margin: 6px 0; box-shadow: 0 6px 18px rgba(0,0,0,.35); padding: 8px 14px; }
.btn.main { background: linear-gradient(180deg, #d0493a, #8e1f1f); border-color: rgba(255,200,150,.45); color: #fff; box-shadow: 0 8px 24px rgba(160,30,30,.45); }
.btn.gold { background: linear-gradient(180deg, #f3cf6e, #b9852b); color: #2a1608; border-color: rgba(255,240,200,.6); }
.btn.big { min-height: 74px; font-size: 23px; font-weight: 900; font-family: "Noto Serif", serif; }
.btn.big small { display: block; font-size: 14px; font-weight: 700; font-family: "Be Vietnam Pro", sans-serif; opacity: .9; margin-top: 2px; }
.btn.sm { width: auto; min-height: 44px; font-size: 14px; margin: 0; padding: 6px 12px; display: inline-block; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.tile { border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, rgba(48,32,24,.94), rgba(30,20,14,.94)); padding: 14px 12px; text-align: left; min-height: 84px; box-shadow: 0 6px 18px rgba(0,0,0,.35); display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.tile b { font-size: 18px; font-family: "Noto Serif", serif; color: #ffe3a6; }
.tile small { color: var(--mut); font-weight: 700; font-size: 13px; }
.link { border: 1px solid var(--line); background: rgba(30,20,14,.85); border-radius: 14px; padding: 12px 16px; font-weight: 800; width: 100%; min-height: 48px; color: var(--ink); }
.link.ghost { background: transparent; border-color: transparent; color: #e8d3a6; text-decoration: underline; min-height: 40px; }
.foot { color: #e8d3a6; font-weight: 700; font-size: 12px; text-align: center; text-shadow: 0 2px 8px rgba(0,0,0,.7); margin: 4px 0 0; }
.foot a { color: #ffd98a; }

/* ---------- trang con ---------- */
.page { max-width: 760px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 70px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px); min-height: 100%; background: radial-gradient(ellipse at top, #2e1f18, #160e0b 70%); }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.top h2 { margin: 0; font-size: 26px; font-weight: 900; color: #ffe3a6; }
.back { border: 1px solid var(--line); background: #2a1c16; color: var(--ink); border-radius: 14px; min-height: 46px; padding: 0 14px; font-weight: 800; }
.mut { color: var(--mut); font-size: 14px; margin: 4px 0 10px; line-height: 1.45; }
h3 { margin: 20px 0 8px; font-size: 19px; color: #ffd98a; font-family: "Noto Serif", serif; }
.cnt { font-style: normal; font-family: "Be Vietnam Pro", sans-serif; font-size: 14px; color: var(--mut); margin-left: 6px; }
.wallet { font-size: 18px; font-weight: 900; color: #f3cf6e; margin: 4px 0 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 16px; text-align: left; display: flex; flex-direction: column; min-height: 56px; }
.row span { color: var(--mut); font-weight: 600; font-size: 14px; }

/* bản đồ */
.world { position: relative; width: 100%; max-width: 560px; margin: 8px auto 6px; aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.world canvas { width: 100%; height: 100%; display: block; }
.node { position: absolute; transform: translate(-50%, -50%); min-width: 48px; min-height: 48px; border-radius: 50%; border: 3px solid #f3cf6e; background: radial-gradient(circle at 35% 30%, #d0493a, #7a1a1a); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.5); }
.node b { font-size: 17px; line-height: 1; font-weight: 900; }
.node em { font-style: normal; font-size: 10px; color: #ffe08a; position: absolute; bottom: -17px; white-space: nowrap; background: rgba(30,18,10,.82); border-radius: 8px; padding: 0 5px; line-height: 15px; }
.node.ok { background: radial-gradient(circle at 35% 30%, #e9b949, #8a5a14); }
.node.boss { border-color: #ff7b7b; min-width: 56px; min-height: 56px; }
.node.lock { background: radial-gradient(circle at 35% 30%, #8a7a66, #4a3e32); border-color: #b9a888; opacity: .92; }
.node.lock b { color: #f1e6cf; }
.zone { background: var(--card); border-radius: 20px; padding: 14px; margin: 12px 0; border-top: 5px solid var(--z); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.zone h3 { margin: 0 0 8px; color: #ffe3a6; }
.ms { display: grid; grid-template-columns: 1fr; gap: 6px; }
.mi { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; text-align: left; border: 1px solid rgba(227,176,75,.2); background: #1f1510; border-radius: 14px; padding: 10px; column-gap: 8px; min-height: 60px; }
.mi b { grid-row: span 2; font-size: 24px; font-weight: 900; color: var(--z); align-self: center; text-align: center; font-family: "Noto Serif", serif; }
.mi span { font-weight: 800; } .mi em { font-style: normal; font-size: 13px; color: var(--mut); font-weight: 700; }
.mi.ok em { color: #f3cf6e; } .mi.boss { background: #2b1414; } .mi.lock { opacity: .45; }

/* trước trận */
.brief { background: linear-gradient(180deg, #2f2018, #22160f); border-radius: 20px; padding: 16px; border-left: 6px solid var(--z); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.brief small { color: #f3cf6e; font-weight: 800; font-size: 13px; }
.brief h2 { margin: 4px 0 6px; font-size: 28px; color: #fff0cf; }
.brief p { margin: 0 0 10px; font-weight: 600; line-height: 1.5; }
.stars { list-style: none; padding: 0; margin: 4px 0 10px; }
.stars li { padding: 4px 0; font-weight: 700; color: #8d7a5a; }
.stars li.on { color: #f3cf6e; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { border: 1px solid var(--line); background: #1c130e; border-radius: 12px; padding: 5px 10px; font-weight: 700; font-size: 13px; color: #e8d3a6; }
.heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
.hc { border: 2px solid rgba(227,176,75,.2); background: #24180f; border-radius: 16px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 150px; }
.hc.sel { border-color: var(--k); box-shadow: 0 0 0 2px var(--k) inset, 0 0 16px color-mix(in srgb, var(--k) 45%, transparent); }
.hc canvas { width: 84px; height: 84px; border-radius: 12px; }
.hc b { font-size: 14px; margin-top: 4px; color: #fff0cf; } .hc small { color: var(--mut); font-weight: 700; font-size: 11px; } .hc span { font-size: 11px; color: #d9c08a; font-weight: 700; margin-top: 3px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; margin-right: 4px; vertical-align: middle; }
.locked { display: flex; gap: 10px; align-items: center; background: #1c130e; border: 1px dashed var(--line); border-radius: 14px; padding: 8px; margin: 8px 0; }
.locked canvas { width: 52px; height: 52px; border-radius: 10px; flex: none; }
.locked small { display: block; color: var(--mut); font-size: 13px; }

/* tướng */
.hero-top { display: flex; gap: 14px; align-items: flex-start; }
.hero-top canvas { width: 132px; height: 132px; border-radius: 18px; flex: none; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
.hero-top small { color: var(--k); font-weight: 800; filter: brightness(1.4); }
.hero-top h2 { margin: 2px 0; font-size: 28px; color: #fff0cf; }
.hero-top .mut { margin: 0; }
.bio { font-size: 14px; line-height: 1.5; margin: 6px 0; color: #e6d6b6; }
.xp { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
.xp > i { flex: 1; height: 10px; background: #120b08; border-radius: 6px; overflow: hidden; display: block; }
.xp > i > i { display: block; height: 100%; background: linear-gradient(90deg, #e3b04b, #ff8f5a); }
.sts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.sts div { background: #1f1510; border-radius: 12px; padding: 8px; border: 1px solid rgba(227,176,75,.15); }
.sts span { display: block; font-size: 12px; color: var(--mut); font-weight: 700; } .sts b { font-size: 20px; } .sts em { font-style: normal; color: #7bed9f; font-weight: 800; font-size: 13px; margin-left: 4px; }
.gears { display: grid; grid-template-columns: 1fr; gap: 8px; }
.gear { text-align: left; border: 1px solid var(--line); background: #1f1510; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-height: 60px; }
.gear small { color: var(--mut); font-weight: 800; font-size: 12px; } .gear span { color: #e2d2b0; font-size: 13px; }
.card-t { background: #1f1510; border-radius: 14px; padding: 10px 12px; margin: 0; line-height: 1.5; font-size: 14px; }
.skills { display: flex; flex-direction: column; gap: 8px; }
.sk { display: flex; gap: 10px; align-items: center; background: #1f1510; border-radius: 14px; padding: 10px 12px; border: 1px solid rgba(227,176,75,.15); }
.sk > div { flex: 1; display: flex; flex-direction: column; gap: 3px; } .sk small { font-size: 13px; line-height: 1.4; color: #e2d2b0; }
.rk { font-style: normal; color: #f3cf6e; letter-spacing: 2px; margin-left: 4px; }
.maxed { color: #f3cf6e; font-weight: 800; font-size: 13px; }
.tier { margin: 8px 0; } .tier > small { color: #f3cf6e; font-weight: 800; }
.tier.lock { opacity: .5; }
.pk { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.perk { text-align: left; border: 2px solid rgba(227,176,75,.2); background: #1f1510; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 3px; min-height: 84px; }
.perk.on { border-color: #f3cf6e; background: #33240f; box-shadow: 0 0 14px rgba(243,207,110,.25); }
.perk b { color: #ffe3a6; } .perk span { font-size: 13px; line-height: 1.35; color: #e2d2b0; }
.ilist { display: flex; flex-direction: column; gap: 8px; }
.it { text-align: left; border: 1px solid var(--line); background: #1f1510; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.it.on { border-color: #f3cf6e; }
.it span { font-size: 13px; color: #e2d2b0; } .it small { font-size: 12px; color: var(--mut); font-weight: 700; }
.it .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.achs { display: flex; flex-direction: column; gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; background: #1f1510; border-radius: 14px; padding: 12px; border: 1px solid rgba(227,176,75,.15); }
.ach > div { flex: 1; display: flex; flex-direction: column; gap: 4px; } .ach small { color: var(--mut); font-size: 13px; }
.ach.ok { border-color: #f3cf6e; background: #2c2010; } .ach > span { color: #f3cf6e; font-weight: 900; font-size: 13px; }
.bar { display: block; height: 8px; background: #120b08; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #e3b04b, #ff8f5a); }

/* phúc lành (trong hộp thoại SDK nền trắng) */
.bless { display: flex; flex-direction: column; gap: 8px; }
.blessb { text-align: left; border: 2px solid #ead7b0; background: linear-gradient(180deg, #fffaf0, #f7ead0); border-radius: 16px; padding: 12px; color: #3a2410; min-height: 64px; display: flex; flex-direction: column; gap: 2px; }
.blessb b { font-size: 17px; color: #8e1f1f; } .blessb small { font-size: 14px; }
.agt-modal .mut { color: #6b5a3f; }
.agt-modal .ilist .it { background: #fbf6ea; color: #2a1608; border-color: #e6d3a8; }
.agt-modal .it span { color: #4a3a22; } .agt-modal .it small { color: #7a6a4a; }

/* lời mở đầu */
.prolog { position: fixed; inset: 0; z-index: 45; display: flex; align-items: flex-end; justify-content: center; padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 40px); background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.7)); }
.pl-in { max-width: 560px; width: 100%; text-align: center; }
.pl-t { font-family: "Noto Serif", serif; font-size: clamp(20px, 5.4vw, 28px); line-height: 1.55; color: #fff0cf; text-shadow: 0 2px 14px #000; min-height: 4.6em; margin: 0 0 18px; opacity: 0; }
.pl-t.in { animation: plin 1.1s ease forwards; }
@keyframes plin { from { opacity: 0; transform: translateY(14px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
.pl-acts { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pl-acts .btn { max-width: 320px; }
@media (min-width: 700px) { .heroes { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } .gears { grid-template-columns: repeat(3, 1fr); } }
@media (orientation: landscape) and (max-height: 560px) {
  .home { display: grid; grid-template-columns: 1fr 1fr; align-content: center; column-gap: 28px; row-gap: 8px; max-width: 980px; padding-top: 64px; min-height: 100%; }
  .home > * { grid-column: 2; }
  .home > .logo { grid-column: 1; grid-row: 1 / span 8; align-self: center; margin: 0; padding: 0; }
  .logo h1 { font-size: 54px; } .btn.big { min-height: 60px; font-size: 20px; } .tile { min-height: 66px; padding: 10px 12px; }
  .world { max-width: 380px; }
}
.agt-modal .it b { filter: brightness(.72) saturate(1.2); }
.rec { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rec canvas { width: 140px; height: 140px; border-radius: 20px; box-shadow: 0 10px 26px rgba(0,0,0,.3); animation: recin .6s ease both; }
.rec b { font-family: "Noto Serif", serif; font-size: 24px; color: #8e1f1f; } .rec small { color: #7a5a2a; font-weight: 800; } .rec p { margin: 6px 0 0; color: #3a2a1a; font-size: 14px; line-height: 1.45; }
@keyframes recin { from { transform: scale(.6) rotate(-8deg); opacity: 0; } }
html .agt-root { --agt-c: #b8322a; }
