:root {
  --night: #0a1530; --night2: #14244a; --ice: #bcd3ff; --fire: #ffb347; --fire2: #ff7a1a; --ink: #eaf1ff;
  --card: rgba(14, 26, 58, .86); --line: rgba(188, 211, 255, .22); --good: #7be0a0; --bad: #ff8a80;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: "Baloo 2", "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

/* ---------- Nút ---------- */
.btn { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; font-weight: 600; font-size: 1rem; transition: transform .1s, background .2s; backdrop-filter: blur(6px); }
.btn:hover { background: rgba(255, 255, 255, .16); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--fire), var(--fire2)); color: #3a1a00; border: none; box-shadow: 0 6px 22px rgba(255, 140, 40, .45); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 20px; font-size: 1.15rem; width: 100%; }
.btn.small { padding: 8px 12px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn small { opacity: .8; font-weight: 500; margin-left: 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.icon { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(14, 26, 58, .7); font-size: 1.05rem; }

/* ---------- Màn hình chung ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; overflow-y: auto; touch-action: pan-y; background: radial-gradient(ellipse at 50% 100%, rgba(255, 150, 50, .16), transparent 55%), linear-gradient(rgba(5, 12, 30, .55), rgba(5, 12, 30, .75)); }
.menu-card, .panel { width: min(460px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 26px 24px; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.panel { max-height: calc(100% - 8px); overflow-y: auto; touch-action: pan-y; }
.eyebrow { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--fire); font-weight: 600; }
h1 { margin: 6px 0 0; font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: .95; text-shadow: 0 0 28px rgba(255, 170, 60, .55); }
h2 { margin: 6px 0 12px; font-size: 1.5rem; color: var(--fire); font-weight: 600; }
.lead { margin: 0 0 18px; color: var(--ice); font-size: 1.02rem; line-height: 1.35; }
.menu-btns { display: grid; gap: 10px; }
.menu-foot { margin-top: 16px; font-size: .8rem; color: rgba(188, 211, 255, .6); text-align: center; }
.panel h3 { margin: 0 0 4px; font-size: 1.5rem; }
.panel .sub { color: var(--ice); margin: 0 0 14px; font-size: .95rem; }
.lv-list { display: grid; gap: 8px; margin-bottom: 14px; }
.lv { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); text-align: left; width: 100%; }
.lv:hover { background: rgba(255, 255, 255, .12); }
.lv b.n { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(var(--fire), var(--fire2)); color: #3a1a00; display: grid; place-items: center; flex: none; }
.lv .t { flex: 1; line-height: 1.15; } .lv .t small { display: block; color: var(--ice); opacity: .8; font-weight: 500; }
.lv .st { color: var(--fire); letter-spacing: 2px; white-space: nowrap; }
table.board { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.board td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.board tr.me { background: rgba(255, 179, 71, .18); font-weight: 700; }
table.board td:last-child { text-align: right; color: var(--fire); }
.tag-npc { font-size: .68rem; background: rgba(188, 211, 255, .2); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.badge { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: rgba(255, 255, 255, .05); line-height: 1.15; }
.badge.off { opacity: .35; filter: grayscale(1); } .badge .e { font-size: 1.6rem; display: block; } .badge small { color: var(--ice); }
.stars-big { font-size: 2.2rem; color: var(--fire); letter-spacing: 6px; text-align: center; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.res-grid div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 8px 12px; } .res-grid b { display: block; font-size: 1.3rem; color: var(--fire); }
.cta { margin-top: 8px; background: linear-gradient(90deg, #2e7d5b, #3fa37a); border: none; color: #fff; }
.note { font-size: .78rem; color: rgba(188, 211, 255, .65); margin-top: 8px; line-height: 1.3; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px; z-index: 20; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud-title { font-weight: 700; font-size: 1.05rem; text-shadow: 0 2px 10px #000; }
#hud-sub { font-size: .8rem; color: var(--ice); text-shadow: 0 2px 8px #000; }
#hud-right { display: flex; gap: 8px; align-items: center; }
#hud-hearts { background: rgba(14, 26, 58, .7); border: 1px solid var(--line); border-radius: 20px; padding: 6px 10px; font-size: .85rem; color: #ff9aa8; }

#meters { position: fixed; bottom: calc(132px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(420px, 90vw); display: grid; gap: 6px; z-index: 20; }
.meter { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 8px; font-size: .78rem; color: var(--ice); text-shadow: 0 1px 6px #000; }
.meter i { display: block; height: 10px; background: rgba(255, 255, 255, .15); border-radius: 6px; overflow: hidden; } .meter b { display: block; height: 100%; width: 100%; border-radius: 6px; transition: width .1s linear; }
#m-life { background: linear-gradient(90deg, #ff6a1a, #ffd05a); } #m-warm { background: linear-gradient(90deg, #4ea1ff, #9fe0ff); } #m-prog, #mash-bar { background: linear-gradient(90deg, #7be0a0, #c8ffd9); }
.meter.big { grid-template-columns: 1fr; text-align: center; font-size: 1rem; } .meter.big i { height: 16px; }
#gust { position: fixed; bottom: calc(232px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: rgba(120, 180, 255, .9); color: #06204a; padding: 8px 18px; border-radius: 22px; font-weight: 700; z-index: 21; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.08); } }
#shield { position: fixed; bottom: calc(26px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(340px, 88vw); height: 92px; border-radius: 46px; border: 2px solid rgba(188, 211, 255, .5); background: rgba(40, 80, 150, .55); font-size: 1.25rem; font-weight: 700; z-index: 21; backdrop-filter: blur(6px); }
#shield.on { background: rgba(255, 170, 60, .8); color: #3a1a00; }
#walkpad { position: fixed; bottom: calc(26px + var(--safe-b)); left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 22px; z-index: 21; pointer-events: none; }
#walkpad button { pointer-events: auto; width: 86px; height: 86px; border-radius: 50%; border: 2px solid var(--line); background: rgba(14, 26, 58, .7); font-size: 1.8rem; }
#walkpad button.on { background: rgba(255, 170, 60, .75); }
#sold { position: fixed; top: 112px; right: 12px; background: rgba(14, 26, 58, .75); border: 1px solid var(--line); padding: 6px 12px; border-radius: 14px; font-size: .85rem; z-index: 20; }
#sold b { color: var(--fire); }
#speech { position: fixed; top: 38%; left: 50%; transform: translateX(-50%); max-width: min(520px, 88vw); background: rgba(255, 244, 214, .94); color: #3a2a10; padding: 10px 18px; border-radius: 18px; font-weight: 600; text-align: center; z-index: 22; font-size: 1.05rem; box-shadow: 0 8px 28px rgba(0, 0, 0, .4); }

/* ---------- Quẹt diêm ---------- */
#strike { position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(360px, 92vw); z-index: 25; text-align: center; }
#strike-label { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; text-shadow: 0 2px 10px #000; }
#strike-hint { font-size: .8rem; color: var(--ice); margin-top: 6px; text-shadow: 0 1px 6px #000; }
#box { position: relative; height: 170px; width: 190px; margin: 0 auto; border-radius: 14px; background: linear-gradient(135deg, #b8321f, #8a1f12); border: 3px solid #5a1209; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); overflow: hidden; touch-action: none; }
#striker { position: absolute; left: 0; right: 0; top: 0; height: 52px; background: repeating-linear-gradient(90deg, #6b3a2a 0 4px, #8a5238 4px 8px); border-bottom: 3px solid #3a1a10; }
#stick { position: absolute; left: 50%; bottom: 10px; width: 14px; height: 108px; transform: translateX(-50%); background: linear-gradient(#d9b36a, #b88a3e); border-radius: 7px; cursor: grab; touch-action: none; }
#stick i { position: absolute; top: -8px; left: -4px; width: 22px; height: 24px; background: radial-gradient(circle at 40% 35%, #e0523a, #8f1f10); border-radius: 50% 50% 45% 45%; }
#stick.go { transition: transform .25s, opacity .25s; opacity: 0; }

/* ---------- Hộp thoại ---------- */
#dialog { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(680px, 94vw); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px 18px 12px; z-index: 26; backdrop-filter: blur(10px); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
#dlg-name { color: var(--fire); font-weight: 700; font-size: .9rem; margin-bottom: 2px; }
#dlg-text { font-size: 1.1rem; line-height: 1.4; min-height: 2.8em; }
#dlg-choices { display: grid; gap: 8px; margin-top: 10px; }
#dlg-choices .btn { text-align: left; }
#dlg-next { text-align: right; font-size: .78rem; color: var(--ice); opacity: .7; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- Quiz ---------- */
#quiz { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); width: min(680px, 95vw); max-height: 86vh; overflow-y: auto; touch-action: pan-y; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px; z-index: 27; backdrop-filter: blur(12px); box-shadow: 0 14px 50px rgba(0, 0, 0, .55); }
.q-tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: rgba(255, 179, 71, .2); color: var(--fire); padding: 2px 10px; border-radius: 10px; margin-bottom: 6px; }
.q-title { font-size: 1.12rem; font-weight: 600; line-height: 1.35; margin-bottom: 10px; }
.q-opts { display: grid; gap: 8px; }
.q-opts .btn { text-align: left; padding: 10px 14px; }
.btn.ok { background: rgba(123, 224, 160, .3); border-color: var(--good); } .btn.no { background: rgba(255, 138, 128, .25); border-color: var(--bad); } .btn.sel { background: rgba(255, 179, 71, .3); border-color: var(--fire); }
.q-fb { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: .95rem; line-height: 1.35; } .q-fb.good { background: rgba(123, 224, 160, .18); } .q-fb.bad { background: rgba(255, 138, 128, .16); }
.q-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 42px; padding: 6px; border: 1px dashed var(--line); border-radius: 12px; }
.q-slots .btn, .q-chips .btn { padding: 6px 12px; } .q-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.q-match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .q-match .btn { text-align: left; padding: 8px 10px; font-size: .92rem; } .q-match .btn.done { opacity: .45; pointer-events: none; }
.q-input { width: 100%; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); user-select: text; -webkit-user-select: text; margin-bottom: 8px; }
.q-actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

/* ---------- Quẹt tự do ---------- */
#free { position: fixed; inset: 0; z-index: 22; pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px 12px calc(14px + var(--safe-b)); }
#free > * { pointer-events: auto; }
#free-top { background: rgba(14, 26, 58, .78); border: 1px solid var(--line); border-radius: 16px; padding: 8px 14px; align-self: flex-end; width: min(290px, 44vw); margin-top: 60px; font-size: .86rem; }
#free-feed { color: var(--ice); font-size: .78rem; min-height: 1.2em; margin-top: 2px; }
#free-bottom { width: min(560px, 100%); margin: 0 auto; display: grid; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 12px 14px; backdrop-filter: blur(10px); }
#free-wish-row { display: flex; gap: 8px; } #wish { flex: 1; min-width: 0; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; color: var(--ink); user-select: text; -webkit-user-select: text; }
#wish:disabled { opacity: .5; } #free-note { font-size: .74rem; color: rgba(188, 211, 255, .7); line-height: 1.25; }

/* ---------- Rhythm / Mash ---------- */
#rhythm { position: fixed; inset: 0; z-index: 21; }
#ring { position: absolute; left: 50%; top: 34%; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 3px dashed var(--fire); box-shadow: 0 0 30px rgba(255, 179, 71, .45), inset 0 0 20px rgba(255, 179, 71, .25); }
.rstar { position: absolute; left: 0; top: 0; font-size: 2.6rem; filter: drop-shadow(0 0 14px #ffe08a); will-change: transform; }
#catch { position: absolute; bottom: calc(26px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(320px, 86vw); height: 88px; border-radius: 44px; background: linear-gradient(var(--fire), var(--fire2)); color: #3a1a00; font-weight: 700; font-size: 1.3rem; border: none; box-shadow: 0 8px 26px rgba(255, 140, 40, .5); }
#mash { position: fixed; bottom: calc(26px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(420px, 92vw); z-index: 21; display: grid; gap: 10px; }
#mash-btn { height: 96px; border-radius: 48px; background: linear-gradient(var(--fire), var(--fire2)); color: #3a1a00; font-weight: 700; font-size: 1.3rem; border: none; box-shadow: 0 8px 26px rgba(255, 140, 40, .5); }

/* ---------- Khác ---------- */
#toasts { position: fixed; bottom: calc(285px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column-reverse; gap: 8px; width: min(340px, 88vw); pointer-events: none; }
.toast { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: .88rem; animation: slidein .3s; pointer-events: auto; display: flex; gap: 8px; align-items: flex-start; }
.toast .x { margin-left: auto; background: none; border: none; opacity: .7; padding: 0 4px; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
#banner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 45; text-align: center; font-size: clamp(1.4rem, 5vw, 2.4rem); font-weight: 700; color: #ffe08a; text-shadow: 0 0 24px #ff9a1a, 0 4px 14px #000; width: min(640px, 92vw); animation: pop .5s; pointer-events: none; }
@keyframes pop { from { transform: translateX(-50%) scale(.4); opacity: 0; } }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 50; transition: opacity .6s; }
#fade { position: fixed; inset: 0; background: #050b1c; opacity: 0; pointer-events: none; z-index: 48; transition: opacity .7s; }
#fade.on { opacity: 1; pointer-events: auto; }
#modal { position: fixed; inset: 0; z-index: 60; background: rgba(3, 8, 20, .7); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-box { width: min(420px, 100%); background: #101f45; border: 1px solid var(--line); border-radius: 22px; padding: 20px; max-height: 92vh; overflow-y: auto; touch-action: pan-y; }
#modal-box h4 { margin: 0 0 8px; font-size: 1.25rem; } #modal-box p { margin: 0 0 10px; line-height: 1.4; }
.qr { display: block; margin: 8px auto; border-radius: 10px; background: #fff; padding: 8px; }
.sim { text-align: center; color: #ffd27a; font-weight: 700; font-size: .85rem; }


@media (max-height: 560px) { #quiz { max-height: 78vh; } #shield { height: 70px; } #walkpad button { width: 70px; height: 70px; } }

/* ---------- Độ khó & kịch tính ---------- */
#vig { position: fixed; inset: 0; z-index: 19; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 35%, rgba(4, 10, 40, .92) 100%); }
#vig.danger { background: radial-gradient(ellipse at center, transparent 30%, rgba(120, 10, 10, .75) 100%); animation: beat .7s infinite; }
@keyframes beat { 50% { filter: brightness(1.7); } }
#cold { position: fixed; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(300px, 70vw); z-index: 20; }
#cold .meter { grid-template-columns: 100px 1fr; } #cold b { background: linear-gradient(90deg, #4ea1ff, #ffd05a); }
#cold.low b { background: #ff6a6a; }
#pad-j { pointer-events: auto; width: 86px; height: 86px; border-radius: 50%; border: 2px solid var(--fire); background: rgba(255, 140, 40, .35); font-size: 1.6rem; line-height: 1; } #pad-j small { display: block; font-size: .6rem; }
#walkpad { align-items: flex-end; }
#spare { position: fixed; top: 72px; right: 12px; background: rgba(14, 26, 58, .78); border: 1px solid var(--line); padding: 6px 12px; border-radius: 14px; font-size: .85rem; z-index: 20; }
#spare.low { border-color: var(--bad); color: var(--bad); }
.q-time { height: 8px; background: rgba(255, 255, 255, .14); border-radius: 5px; margin: 4px 0 8px; overflow: hidden; } .q-time b { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #7be0a0, #ffd05a); } .q-time.low b { background: #ff6a6a; }
#quiz.pop { bottom: auto; top: 150px; max-height: 70vh; border-color: var(--fire); box-shadow: 0 0 40px rgba(255, 140, 40, .55); animation: pop2 .3s; } @keyframes pop2 { from { transform: translateX(-50%) scale(.85); opacity: 0; } }
#dlg-time { height: 6px; background: rgba(255, 255, 255, .14); border-radius: 4px; margin-top: 8px; overflow: hidden; } #dlg-time b { display: block; height: 100%; width: 100%; background: #ffd05a; }
.q-tf { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; } .q-tf > span { flex: 1 1 200px; } .q-tf .btn { padding: 6px 14px; }
.q-tf.ok { border-color: var(--good); background: rgba(123, 224, 160, .12); } .q-tf.no { border-color: var(--bad); background: rgba(255, 138, 128, .12); }
.q-sent { font-size: 1.05rem; line-height: 1.6; margin-bottom: 8px; padding: 8px 10px; background: rgba(255, 255, 255, .05); border-radius: 12px; } .q-sent u { text-decoration: none; border-bottom: 2px dashed var(--fire); color: var(--fire); font-weight: 700; padding: 0 4px; }
.q-lbl { font-size: .8rem; color: var(--ice); align-self: center; }
#mash .row { gap: 10px; } #mash .row button { flex: 1; height: 96px; border-radius: 48px; background: linear-gradient(var(--fire), var(--fire2)); color: #3a1a00; font-weight: 700; font-size: 1.15rem; border: none; box-shadow: 0 8px 26px rgba(255, 140, 40, .5); } #mash .row button:active { filter: brightness(1.2); transform: scale(.96); }
.rstar.decoy { filter: drop-shadow(0 0 14px #ff4040); }

/* ---------- Nhiệm vụ, cần điều khiển, mũi tên chỉ đường ---------- */
#quest { position: fixed; top: 62px; left: 12px; width: min(310px, 64vw); z-index: 21; background: rgba(10, 20, 48, .82); border: 1px solid rgba(255, 179, 71, .45); border-radius: 16px; padding: 8px 12px 10px; backdrop-filter: blur(8px); box-shadow: 0 8px 28px rgba(0, 0, 0, .4); font-size: .84rem; }
#quest .q-head { font-weight: 700; color: var(--fire); cursor: pointer; display: flex; gap: 6px; align-items: center; } #quest .q-head em { margin-left: auto; font-style: normal; opacity: .7; }
#quest ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
#quest li { display: flex; gap: 7px; line-height: 1.25; opacity: .85; } #quest li i { font-style: normal; color: var(--fire); width: 14px; flex: none; }
#quest li.now { opacity: 1; font-weight: 700; color: #fff; } #quest li.now i { animation: blink 1s infinite; }
#quest li.done { opacity: .55; text-decoration: line-through; } #quest li.done i { color: var(--good); }
#quest.min ul, #quest.min #quest-ctl, #quest.min #quest-dist { display: none; }
#quest-dist { margin-top: 6px; color: #ffe08a; font-weight: 700; } #quest-dist:empty { display: none; }
#quest-ctl { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--ice); font-size: .74rem; line-height: 1.3; }
#joy { position: fixed; left: 24px; bottom: calc(30px + var(--safe-b)); width: 128px; height: 128px; border-radius: 50%; background: rgba(14, 26, 58, .55); border: 2px solid rgba(188, 211, 255, .4); z-index: 21; touch-action: none; }
#joy.free { bottom: calc(250px + var(--safe-b)); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 179, 71, .8); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); pointer-events: none; }
#walkpad { justify-content: flex-end; } #walkpad.free { bottom: calc(250px + var(--safe-b)); }
#goal-arrow { position: fixed; z-index: 22; pointer-events: none; text-align: center; color: #ffd27a; text-shadow: 0 2px 8px #000; font-weight: 700; } #goal-arrow i { display: block; font-style: normal; font-size: 2rem; filter: drop-shadow(0 0 10px #ff9a1a); } #goal-arrow b { font-size: .8rem; }
@media (max-width: 700px) { #quest { font-size: .76rem; top: 58px; } #joy { width: 112px; height: 112px; } }

/* ---------- Emoji 3D ---------- */
img.e3 { height: 1.18em; width: 1.18em; vertical-align: -0.24em; display: inline-block; object-fit: contain; pointer-events: none; -webkit-user-drag: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.rstar img.e3 { height: 1em; width: 1em; vertical-align: 0; }
#banner img.e3 { height: 1.1em; width: 1.1em; }
#free-icons img.e3 { height: 1.1em; width: 1.1em; margin-right: -2px; }

#quest li.flash { color: var(--good); opacity: 1; text-decoration: none; font-weight: 700; animation: pop2 .35s; } #quest li.flash i { color: var(--good); }
#quest li.now { font-size: .95rem; } #quest ul { margin-top: 4px; }
@media (max-width: 760px) { #free-top { margin-top: 150px; } }

.icon.off { opacity: .45; filter: grayscale(.7); }
.aud { display: grid; gap: 6px; margin: 10px 0; font-weight: 600; } .aud input { width: 100%; accent-color: var(--fire); touch-action: pan-x; }

#free-bottom #free-top { background: none; border: none; padding: 0; margin: 0; width: auto; align-self: auto; max-width: none; font-size: .9rem; }
#free-bottom #free-top > div:first-child { font-weight: 600; }

/* ---- HUD gọn trên màn hình hẹp, quiz nóng che nhiệm vụ ---- */
#hud-hearts { white-space: nowrap; } #hud-right { flex-wrap: nowrap; }
#hud-left { min-width: 0; flex: 1 1 auto; padding-right: 8px; } #hud-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 760px) { .icon { width: 36px; height: 36px; font-size: .9rem; } #hud-right { gap: 5px; } #hud-hearts { padding: 5px 8px; font-size: .78rem; } #hud-title { font-size: .92rem; } }
body:has(#quiz.pop:not(.hidden)) #quest { visibility: hidden; }

#fire { position: fixed; right: 30px; bottom: calc(150px + var(--safe-b)); width: 86px; height: 86px; border-radius: 50%; border: 2px solid #9fd4ff; background: rgba(60, 130, 220, .6); font-weight: 700; font-size: 1rem; z-index: 21; touch-action: none; } #fire small { display: block; font-size: .6rem; opacity: .8; }
.btn.locked { opacity: .55; } h4.rt { margin: 12px 0 6px; color: var(--fire); font-size: 1rem; }
/* Thanh nhiệm vụ gọn hơn, dễ đọc: nền đậm, ẩn dòng hướng dẫn phím (chạm tiêu đề để xem) */
#quest { background: rgba(8, 16, 38, .94); backdrop-filter: none; width: min(300px, 58vw); padding: 6px 10px 8px; }
#quest li.now { font-size: .88rem; line-height: 1.3; }
#quest #quest-ctl { display: none; }
#quest.ctl #quest-ctl { display: block; }
#quest.min { width: auto; }
@media (max-width: 700px) { #quest { width: min(250px, 62vw); font-size: .74rem; } #quest li.now { font-size: .8rem; } }
#peek-mk { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
#peek-mk i { position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; border: 3px solid #ffd27a; background: rgba(255, 210, 122, .25); box-shadow: 0 0 18px #ffb347; animation: pkpulse 1.1s ease-in-out infinite; }
#peek-mk i.off { display: none; }
@keyframes pkpulse { 50% { transform: scale(1.25); opacity: .65; } }
/* Phản hồi học tập, khám phá manh mối, hỏi "đã hiểu chưa" */
.q-outcome { font-size: .8rem; color: var(--ice); background: rgba(120, 180, 255, .12); border-radius: 10px; padding: 5px 10px; margin: 2px 0 8px; }
.q-fb.hint { background: rgba(255, 224, 138, .16); }
.q-tier { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255, 255, 255, .22); font-size: .88rem; line-height: 1.4; }
.q-tier.deep { background: rgba(120, 180, 255, .12); border-radius: 10px; padding: 8px 10px; border-top: 0; }
.q-ask { flex: 1 1 100%; font-weight: 700; color: #fff; text-align: left; align-self: center; }
.q-actions:has(.q-ask) { flex-wrap: wrap; justify-content: flex-end; }
.q-hunt .h-title { font-weight: 800; color: var(--fire); margin: 4px 0; }
.q-hunt .h-sub { font-size: .85rem; opacity: .85; margin-bottom: 8px; }
.q-hunt .h-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.h-card { min-height: 92px; border-radius: 14px; border: 1px solid rgba(255, 179, 71, .4); background: rgba(255, 255, 255, .06); color: #fff; padding: 8px; font: inherit; font-size: .8rem; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; text-align: left; cursor: pointer; }
.h-card .h-q { font-size: 1.6rem; } .h-card.open { align-items: flex-start; justify-content: flex-start; cursor: default; background: rgba(10, 20, 48, .9); line-height: 1.3; }
.h-card.key { border-color: #ffe08a; box-shadow: 0 0 14px rgba(255, 224, 138, .5); } .h-card em { color: #ffe08a; font-style: normal; font-weight: 700; }
/* Cây thông điều ước: màn chơi toàn màn hình */
#wt-full { position: fixed; inset: 0; z-index: 80; background: #0a1230; color: #fff; font-family: inherit; }
#wt-canvas { position: absolute; inset: 0; }
#wt-full .wt-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: linear-gradient(rgba(5, 10, 28, .85), transparent); pointer-events: none; }
#wt-full .wt-top > * { pointer-events: auto; } #wt-full .wt-cnt { font-size: .8rem; opacity: .85; margin-top: 2px; }
#wt-full .wt-hint { position: absolute; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); text-align: center; font-size: .82rem; background: rgba(8, 16, 40, .78); padding: 8px 12px; border-radius: 14px; pointer-events: none; } #wt-full .wt-hint button { pointer-events: auto; margin-left: 6px; }
#wt-full .wt-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; justify-content: center; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(5, 10, 28, .9)); }
#wt-full .wt-bar .btn { flex: 1 1 0; max-width: 200px; }
.wt-sheet { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(3, 8, 22, .55); }
.wt-sheet.hidden { display: none; }
.wt-paper { width: min(440px, 100%); max-height: calc(100% - 8px); overflow-y: auto; background: linear-gradient(#f7ecd0, #efdcb0); color: #3a2a1a; border-radius: 18px; padding: 18px 18px 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(190, 40, 40, .35); }
.wt-paper .btn { color: #3a2a1a; border-color: rgba(60, 40, 20, .35); background: rgba(255, 255, 255, .55); } .wt-paper .btn.primary { color: #fff; background: linear-gradient(#e0553a, #b9301f); border: 0; }
.wt-ph { font-weight: 800; font-size: 1.15rem; color: #b9301f; margin-bottom: 6px; } .wt-me { font-size: .72rem; background: #ffd34d; border-radius: 8px; padding: 1px 7px; color: #5a3a00; vertical-align: middle; }
.wt-big { font-size: 1.08rem; line-height: 1.45; font-style: italic; margin: 6px 0; } .wt-sig { text-align: right; opacity: .75; }
.wt-lbl { display: block; font-weight: 700; font-size: .88rem; margin: 10px 0 4px; }
.wt-paper textarea, .wt-paper input[type=text], .wt-paper input:not([type]) { width: 100%; box-sizing: border-box; border-radius: 10px; border: 1px solid rgba(60, 40, 20, .35); background: rgba(255, 255, 255, .7); color: #3a2a1a; padding: 9px 11px; font: inherit; margin-top: 4px; }
.wt-pledges { display: grid; gap: 6px; margin: 4px 0 8px; } .wt-pledges .btn { text-align: left; } .wt-p.sel { outline: 2px solid #b9301f; background: #fff3c4 !important; }
.wt-sw { display: flex; gap: 8px; flex-wrap: wrap; } .wt-c { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; } .wt-c.sel { border-color: #3a2a1a; transform: scale(1.12); }
.wt-chk { display: flex; gap: 8px; align-items: flex-start; font-size: .76rem; margin: 8px 0; opacity: .85; } .wt-chk input { width: auto; margin-top: 3px; }
.wt-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

#btn-badge { position: relative; } #btn-badge small { position: absolute; right: -4px; bottom: -4px; background: #ffb347; color: #2a1500; border-radius: 9px; font-size: .62rem; font-weight: 800; padding: 0 5px; line-height: 1.3; }
#btn-badge.pulse { animation: bpulse .6s ease-in-out 5; } @keyframes bpulse { 50% { transform: scale(1.35); box-shadow: 0 0 18px #ffb347; } }
.badges-modal, .badges { grid-template-columns: repeat(3, 1fr) !important; } .badges-modal { display: grid; gap: 8px; margin-top: 8px; } .badge { text-align: center; padding: 10px 4px !important; } .badge .e { font-size: 3.4rem !important; line-height: 1.1; margin-bottom: 4px; } .badge b { font-size: .88rem; display: block; } .badge small { display: block; font-size: .7rem; margin-top: 2px; }
.badge.off { opacity: .45; filter: grayscale(.7); }

/* Chúc mừng huy hiệu */
#badge-pop { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 45%, rgba(40, 30, 80, .75), rgba(5, 8, 24, .92)); animation: bpIn .35s ease-out; }
#badge-pop.out { opacity: 0; transition: opacity .35s; }
#badge-pop .bp-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#badge-pop .bp-rays { position: absolute; width: min(120vw, 900px); height: min(120vw, 900px); background: repeating-conic-gradient(from 0deg, rgba(255, 214, 120, .22) 0 8deg, transparent 8deg 20deg); border-radius: 50%; mask-image: radial-gradient(circle, #000 10%, transparent 68%); -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 68%); animation: bpSpin 14s linear infinite; }
#badge-pop .bp-card { position: relative; text-align: center; padding: 10px 20px; }
#badge-pop .bp-top { font-size: 1.2rem; font-weight: 800; color: #ffd34d; letter-spacing: .04em; animation: bpDrop .5s .15s both; }
#badge-pop .bp-e { font-size: clamp(8rem, 36vw, 13rem); line-height: 1.05; filter: drop-shadow(0 0 40px rgba(255, 190, 70, .85)); animation: bpZoom .9s cubic-bezier(.2, 1.6, .4, 1) both; }
#badge-pop .bp-n { font-size: 1.9rem; font-weight: 800; margin-top: 4px; animation: bpDrop .5s .5s both; }
#badge-pop .bp-d { font-size: 1.05rem; opacity: .9; margin: 4px 0 16px; animation: bpDrop .5s .65s both; }
#badge-pop .btn { animation: bpDrop .5s .8s both; font-size: 1.05rem; padding: 10px 26px; }
@keyframes bpIn { from { opacity: 0; } } @keyframes bpSpin { to { transform: rotate(360deg); } }
@keyframes bpZoom { 0% { transform: scale(.05) rotate(-40deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes bpDrop { from { opacity: 0; transform: translateY(-14px); } }

/* Onboarding xoay thế giới */
#onb { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; width: min(420px, calc(100% - 24px)); text-align: center; background: rgba(8, 16, 40, .88); border: 2px solid #ffb347; border-radius: 20px; padding: 12px 14px 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); pointer-events: none; }
#onb .btn { pointer-events: auto; position: absolute; right: 10px; top: 8px; }
#onb .onb-head { font-weight: 800; color: #ffb347; font-size: 1.05rem; } #onb .onb-t { font-size: 1.02rem; margin: 4px 0 8px; line-height: 1.35; }
#onb .onb-hand { height: 64px; position: relative; overflow: hidden; } #onb .onb-hand i { position: absolute; left: 50%; top: 8px; font-style: normal; font-size: 2.6rem; }
#onb .onb-hand.h i { animation: onbH 1.6s ease-in-out infinite; } #onb .onb-hand.v i { animation: onbV 1.6s ease-in-out infinite; } #onb .onb-hand.z i { animation: onbZ 1.6s ease-in-out infinite; }
@keyframes onbH { 0%, 100% { transform: translateX(-90px); } 50% { transform: translateX(50px); } } @keyframes onbV { 0%, 100% { transform: translate(-20px, -4px); } 50% { transform: translate(-20px, 22px); } } @keyframes onbZ { 0%, 100% { transform: translateX(-20px) scale(.8); } 50% { transform: translateX(-20px) scale(1.5); } }
#onb .onb-dots { display: flex; gap: 8px; justify-content: center; } #onb .onb-dots span { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, .25); } #onb .onb-dots span.on { background: #ffb347; } #onb .onb-dots span.done { background: #7be0a0; }
#onb.ok { border-color: #7be0a0; }
