:root { --c: #9B5DE5; --c2: #00F5D4; --bg: #1A1033; --ink: #14203d; --mut: #5d6a8a; --sat: env(safe-area-inset-top, 0px); }
* { 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; }
.home { min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: calc(var(--sat) + 76px) 16px 32px; max-width: 520px; margin: 0 auto; }
.logo { text-align: center; color: #fff; text-shadow: 0 4px 18px rgba(0,0,0,.3); }
.logo .mark { width: 76px; height: 76px; margin: 0 auto 6px; border-radius: 24px; display: grid; place-items: center; font-size: 42px; background: linear-gradient(135deg, var(--c2), var(--c)); box-shadow: 0 10px 30px rgba(0,0,0,.3); transform: rotate(-8deg); }
.logo h1 { margin: 0; font-size: clamp(40px, 11vw, 60px); font-weight: 900; letter-spacing: -1px; line-height: 1; }
.logo p { margin: 4px 0 0; font-weight: 800; font-size: 18px; }
.story { color: #fff; text-align: center; font-weight: 600; margin: 0; opacity: .92; }
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 18px; background: #fff; font-weight: 800; font-size: 17px; margin: 8px 0; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.btn.main { background: linear-gradient(180deg, var(--c2), var(--c)); color: #fff; }
.btn.big { min-height: 72px; font-size: 24px; font-weight: 900; }
.btn.big small { display: block; font-size: 14px; font-weight: 700; opacity: .9; }
.link { border: 0; background: rgba(255,255,255,.88); border-radius: 14px; padding: 12px 16px; font-weight: 800; width: 100%; }
.panel { background: #fff; border-radius: 22px; padding: 20px; max-width: 480px; margin: calc(var(--sat) + 70px) auto 24px; width: calc(100% - 32px); }
.panel h2 { margin: 0 0 8px; }
.panel p, .panel li { color: var(--mut); font-weight: 600; line-height: 1.5; }
.foot { color: #fff; font-size: 13px; text-align: center; opacity: .85; }
.foot a { color: #fff; }
/* ===== Tưởng Tượng ===== */
#menu.homeBg { background: radial-gradient(120% 60% at 50% 0%, #ffd9f0 0%, #c9a6ff 45%, #6a3fc0 100%); }
#menu.storyBg { background: linear-gradient(180deg, #fff3e0, #ffe3f1 50%, #e6dcff); }
.logo canvas { width: min(340px, 86vw); height: 150px; display: block; margin: 0 auto -4px; cursor: pointer; }
.logo h1 { color: #fff; text-shadow: 0 4px 0 #7a3fd6, 0 8px 22px rgba(60,20,110,.4); }
.logo p { color: #4a2280; text-shadow: none; }
.btn.main { background: linear-gradient(180deg, #ff9fd0, #9b5de5); color: #fff; }
.btn.sm { min-height: 52px; font-size: 16px; }
.btn { color: #3a2b50; }
.btn.main { color: #fff; }
.btn:disabled { opacity: .45; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.md { min-height: 100px; border: 0; border-radius: 20px; text-align: left; padding: 12px; display: flex; flex-direction: column; gap: 4px; justify-content: center; box-shadow: 0 6px 16px rgba(50,20,90,.25); color: #fff; }
.md b { font-size: 16.5px; font-weight: 900; }
.md span { font-size: 12.5px; font-weight: 700; opacity: .95; line-height: 1.3; }
.md.st { background: linear-gradient(160deg, #ff8fb1, #d6457a); }
.md.gd { background: linear-gradient(160deg, #6fd47a, #2f9e5a); }
.md.dy { background: linear-gradient(160deg, #ffe07a, #f2a900); color: #4a2a00; }
.md.lib { background: linear-gradient(160deg, #7ab8ff, #4a5fd6); }
.sec { color: #fff; margin: 6px 0 0; font-size: 22px; font-weight: 900; align-self: flex-start; text-shadow: 0 2px 8px rgba(60,20,110,.45); }
.sec small, .panel h2 small { font-size: 14px; opacity: .8; }
.note { color: #fff; font-weight: 700; font-size: 14px; text-align: center; margin: 0; text-shadow: 0 1px 4px rgba(60,20,110,.4); }
.jr { display: flex; gap: 8px; overflow-x: auto; width: 100%; padding: 4px 2px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.jn { position: relative; flex: 0 0 104px; border: 0; background: rgba(255,255,255,.92); border-radius: 18px; padding: 6px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 4px 10px rgba(50,20,90,.2); scroll-snap-align: start; min-height: 44px; }
.jn canvas { width: 72px; height: 72px; background: #fffdf6; border-radius: 12px; }
.jn em { font-style: normal; font-size: 30px; height: 72px; display: grid; place-items: center; }
.jn span { font-size: 12px; font-weight: 800; color: #3a2b50; line-height: 1.2; text-align: center; }
.jn small { font-size: 11px; font-weight: 700; color: #7a5aa0; }
.jn i { position: absolute; top: 4px; right: 4px; background: #5cc75f; color: #fff; font-style: normal; font-weight: 900; border-radius: 12px; padding: 1px 7px; font-size: 12px; }
.jn.cur { outline: 4px solid #ffe14a; }
.jn.lock { opacity: .6; }
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.bd { background: rgba(255,255,255,.55); border-radius: 14px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; gap: 2px; filter: grayscale(1); opacity: .6; }
.bd.on { background: linear-gradient(160deg, #fff4c2, #ffd6ea); filter: none; opacity: 1; }
.bd i { font-style: normal; font-size: 26px; }
.bd b { font-size: 11.5px; color: #3a2b50; line-height: 1.2; }
.bd span { font-size: 10px; color: #6a5a80; line-height: 1.2; font-weight: 700; }
.howto { padding-left: 20px; }
.panel h3 { margin: 12px 0 2px; color: #3a2b50; }
/* thanh trên + thanh dưới */
#top { position: fixed; left: 12px; top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: 16; display: none; }
#top.on { display: block; }
.tb { min-height: 44px; border: 0; border-radius: 22px; padding: 0 16px; background: rgba(255,255,255,.92); font-weight: 900; font-size: 15px; color: #3a2b50; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
#acts { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: none; flex-direction: column; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); max-width: 560px; margin: 0 auto; }
#acts.on { display: flex; }
#acts.sheet { background: #fff; border-radius: 26px 26px 0 0; box-shadow: 0 -8px 30px rgba(40,10,80,.3); padding-top: 14px; max-height: 58vh; overflow-y: auto; }
#acts .rw { display: flex; gap: 8px; }
#acts .rw .btn { margin: 0; flex: 1; }
#acts .rw .btn.main { flex: 1.6; min-height: 60px; font-size: 19px; }
.sw, .tl { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 2px 4px; }
.col { flex: 0 0 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); background: var(--c); box-shadow: 0 2px 6px rgba(0,0,0,.25); padding: 0; }
.col.on { outline: 4px solid #ffe14a; outline-offset: 1px; transform: scale(1.05); }
.tool { flex: 0 0 auto; min-width: 66px; min-height: 56px; border: 0; border-radius: 16px; background: rgba(255,255,255,.9); font-size: 21px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 8px; line-height: 1; }
.tool small { font-size: 11.5px; font-weight: 800; color: #3a2b50; margin-top: 3px; white-space: nowrap; }
.tool.on { background: #ffe14a; box-shadow: 0 0 0 3px #fff inset; }
.tool canvas { width: 40px; height: 40px; }
.lb { display: block; font-weight: 900; color: #3a2b50; font-size: 15px; margin: 4px 2px 0; }
.inp { width: 100%; min-height: 48px; border: 2px solid #d9c8f5; border-radius: 14px; padding: 0 14px; font: inherit; font-weight: 800; font-size: 18px; color: #3a2b50; background: #fbf8ff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 44px; border: 2px solid #e2d6f7; background: #f7f2ff; border-radius: 22px; padding: 0 14px; font-weight: 800; font-size: 14.5px; color: #4a2a80; }
.chip.on { background: #9b5de5; border-color: #9b5de5; color: #fff; }
.chip.del { color: #c0392b; border-color: #f2c4bd; background: #fff5f3; }
/* truyện */
.story { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 30px; }
.sth { display: flex; gap: 8px; align-items: center; }
.dots { display: flex; gap: 4px; flex: 1; justify-content: flex-end; }
.dot { min-width: 50px; min-height: 48px; border: 0; border-radius: 14px; background: rgba(155,93,229,.15); color: #6a3fc0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px 4px; line-height: 1.05; }
.dot b { font-size: 16px; } .dot small { font-size: 9.5px; font-weight: 800; }
.dot.on { background: #9b5de5; color: #fff; }
.stt { margin: 10px 2px 6px; color: #4a2280; font-size: 22px; }
.pv { width: 100%; display: block; border-radius: 18px; border: 4px solid #2b2540; background: #fff; box-shadow: 0 8px 20px rgba(60,20,110,.25); }
.cau { background: #fff; border-radius: 18px; padding: 12px 14px; margin: 10px 0; box-shadow: 0 4px 12px rgba(60,20,110,.12); }
.cau p { margin: 0 0 8px; font-size: 19px; font-weight: 800; line-height: 1.45; color: #2b2540; }
.tk { padding: 0 4px; border-radius: 6px; }
.tk.A { background: #ffe0ee; color: #c0306e; } .tk.B { background: #dde9ff; color: #2f5fc6; } .tk.N { background: #dcf6e4; color: #17804c; } .tk.P { background: #fff0c2; color: #8a5a00; }
.story h3 { margin: 12px 2px 4px; color: #4a2280; font-size: 16px; }
.story h3 small { font-weight: 700; opacity: .7; }
.pick { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 2px 8px; }
.pk { flex: 0 0 96px; border: 3px solid transparent; background: #fff; border-radius: 16px; padding: 4px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 60px; box-shadow: 0 3px 8px rgba(60,20,110,.12); }
.pk canvas { width: 88px; height: 66px; border-radius: 10px; display: block; }
.pk span { font-size: 12px; font-weight: 800; color: #3a2b50; line-height: 1.2; text-align: center; }
.pk.txt { justify-content: center; background: #f7f2ff; border: 2px dashed #b79de8; }
.pk.txt span { font-size: 14px; color: #6a3fc0; }
.pk.on { border-color: #9b5de5; background: #f3eaff; }
.nav { display: flex; gap: 8px; margin-top: 16px; }
.nav .btn { margin: 0; flex: 1; } .nav .btn.main { flex: 1.5; }
/* tủ truyện */
.books { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.book { background: #fbf6ff; border-radius: 16px; padding: 6px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 3px 8px rgba(60,20,110,.12); }
.book canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; display: block; }
.book b { font-size: 13.5px; color: #3a2b50; line-height: 1.25; }
.book small { font-size: 11.5px; color: #8a7aa0; font-weight: 700; }
.bk { display: flex; flex-wrap: wrap; gap: 4px; }
.bk .chip { min-height: 44px; padding: 0 10px; font-size: 13px; }
