:root {
  --cream: #fff8e8;
  --purple: #6c4fb3;
  --purple-d: #4a3488;
  --yellow: #ffc83a;
  --red: #e5484d;
  --green: #52b947;
  --ink: #3b2a55;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2d2752; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; color: var(--ink); }
#app { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none; z-index: 5; align-items: start; }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-right { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pill { background: var(--cream); border: 3px solid var(--purple); border-radius: 999px; padding: 3px 12px; font-weight: 900;
  box-shadow: 0 3px 0 var(--purple-d), 0 6px 14px #0003; font-size: 15px; white-space: nowrap; }
.level-pill { background: var(--purple); color: #fff; border-color: #fff; font-size: 12px; letter-spacing: .5px; }
.count-pill b { font-size: 18px; }
.count-pill small { font-weight: 800; opacity: .7; }
.hands { background: #ffffffd9; border-radius: 12px; padding: 3px 10px; font-weight: 800; font-size: 12px; box-shadow: 0 3px 10px #0002; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hands-label { opacity: .6; margin-right: 4px; }
.score-pill { font-size: 20px; padding: 3px 16px 3px 10px; }
.score-pill .star { color: #ffb400; -webkit-text-stroke: 1.5px #c46d00; font-size: 22px; }
.combo { font-weight: 1000; font-size: 18px; color: #fff; padding: 2px 12px; border-radius: 12px; background: linear-gradient(#ff7a59, #e5484d);
  border: 3px solid #fff3b0; box-shadow: 0 3px 0 #a52c3a; transform: rotate(-4deg); animation: pop .35s ease-out; }
.combo b { color: #fff36a; font-size: 22px; }
.hud-btns { display: flex; gap: 6px; pointer-events: auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 3px solid var(--purple); background: var(--cream); font-size: 20px; cursor: pointer; box-shadow: 0 3px 0 var(--purple-d); }
.img-btn { width: 48px; height: 48px; padding: 0; border: 0; background: none; cursor: pointer; }
.img-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 4px #0004); }

.timer { display: flex; align-items: center; gap: 6px; background: var(--cream); border: 3px solid var(--purple); border-radius: 999px; padding: 3px 10px 3px 4px;
  box-shadow: 0 3px 0 var(--purple-d), 0 8px 18px #0003; }
.timer .clock { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 0 #c43); }
.timer .bar { width: min(34vw, 220px); height: 18px; border-radius: 99px; background: #6b5aa0; border: 2px solid #4b3a7d; overflow: hidden; }
#timerFill { height: 100%; width: 100%; border-radius: 99px; background: repeating-linear-gradient(115deg, #7ee05a 0 10px, #5fc63c 10px 20px); transition: width .15s linear; }
.timer.mid #timerFill { background: repeating-linear-gradient(115deg, #ffd23f 0 10px, #f5b400 10px 20px); }
.timer.low #timerFill { background: repeating-linear-gradient(115deg, #ff6b5e 0 10px, #e5484d 10px 20px); }
.timer.low { animation: shake .3s infinite; }
.secs { font-weight: 1000; font-size: 24px; min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.timer.low .secs { color: var(--red); }
.mom-line { font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px #000a; background: #0003; padding: 1px 10px; border-radius: 99px; }

/* ---------- Thong bao ---------- */
.toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px) scale(.9); opacity: 0; pointer-events: none; z-index: 8;
  background: #fff; color: var(--ink); font-weight: 1000; font-size: clamp(15px, 2.4vw, 22px); padding: 8px 18px; border-radius: 16px;
  border: 3px solid var(--purple); box-shadow: 0 4px 0 var(--purple-d), 0 10px 24px #0004; transition: all .18s ease-out; text-align: center; max-width: 86vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.bad { border-color: var(--red); box-shadow: 0 4px 0 #9e2a33, 0 10px 24px #0004; color: #b4232c; }
.toast.good { border-color: var(--green); box-shadow: 0 4px 0 #2f7d29, 0 10px 24px #0004; color: #2b7a23; }
.prompt { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; pointer-events: none;
  background: #2d2350e6; color: #fff; font-weight: 900; font-size: 14px; padding: 7px 16px; border-radius: 99px; border: 2px solid #ffffff55; white-space: nowrap; }
.prompt kbd { background: var(--yellow); color: var(--ink); border-radius: 6px; padding: 0 6px; margin-right: 4px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 9; pointer-events: none; }
.countdown span { font-size: clamp(90px, 22vw, 190px); font-weight: 1000; color: #ffd23f; -webkit-text-stroke: 6px #8a2a1a; paint-order: stroke fill;
  text-shadow: 0 8px 0 #8a2a1a, 0 14px 30px #0006; animation: count .8s ease-out both; }
.countdown span.go { color: #4aa3ff; -webkit-text-stroke-color: #1f3d8a; text-shadow: 0 8px 0 #1f3d8a, 0 14px 30px #0006; }
.flash { position: absolute; inset: 0; background: #ff3b3b; opacity: 0; pointer-events: none; z-index: 4; transition: opacity .25s; }
.flash.on { opacity: .22; }

/* ---------- Dieu khien cam ung ---------- */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.joy { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 150px; height: 150px; pointer-events: auto; touch-action: none; opacity: .92; }
.joy-base { width: 100%; height: 100%; }
.joy-knob { position: absolute; width: 66px; height: 66px; left: 42px; top: 42px; pointer-events: none; transition: transform .06s; }
.round-btn { position: absolute; border: 0; background: none; padding: 0; pointer-events: auto; touch-action: none; cursor: pointer; }
.round-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 6px #0005); }
.act-btn { right: max(20px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 112px; height: 112px; }
.act-btn span { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); background: var(--purple); color: #fff; font-weight: 1000; font-size: 13px;
  padding: 2px 10px; border-radius: 99px; border: 2px solid #fff; white-space: nowrap; }
.act-btn.pressed, .run-btn.pressed { transform: scale(.9); }
.act-btn.dim { opacity: .55; }
.run-btn { right: calc(max(20px, env(safe-area-inset-right)) + 118px); bottom: max(26px, env(safe-area-inset-bottom)); width: 70px; height: 70px; }

/* ---------- Overlay ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 12px; overflow: auto;
  background: radial-gradient(ellipse at 50% 30%, #8d74d8cc, #2d2752ee); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { width: min(860px, 96vw); background: var(--cream); border: 4px solid #fff; border-radius: 28px; padding: 16px 22px 20px;
  box-shadow: 0 8px 0 #b79be6, 0 24px 60px #0007; animation: pop .35s ease-out; text-align: center; max-height: 96dvh; overflow: auto; }
.logo { width: min(330px, 64vw); filter: drop-shadow(0 4px 0 #0002); }
.menu-body { display: flex; gap: 18px; align-items: center; text-align: left; }
.hero { width: clamp(90px, 18vw, 190px); flex: none; animation: bob 2.2s ease-in-out infinite; }
.menu-right { flex: 1; min-width: 0; }
.lead { font-size: clamp(14px, 1.9vw, 17px); font-weight: 700; margin: 4px 0 12px; line-height: 1.45; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level-card { border: 3px solid var(--purple); background: #fff; border-radius: 18px; padding: 10px 8px 8px; cursor: pointer; font: inherit; color: inherit;
  box-shadow: 0 4px 0 var(--purple-d); transition: transform .1s; text-align: center; }
.level-card:hover:not(:disabled) { transform: translateY(-3px); }
.level-card:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--purple-d); }
.level-card:disabled { filter: grayscale(.9); opacity: .6; cursor: not-allowed; }
.level-card .lv-badge { display: inline-block; font-weight: 1000; font-size: 12px; color: #fff; border-radius: 99px; padding: 1px 10px; }
.level-card .lv-name { font-weight: 1000; font-size: clamp(13px, 1.8vw, 16px); margin: 5px 0 2px; }
.level-card .lv-info { font-size: 12px; font-weight: 700; opacity: .75; }
.level-card .lv-stars { font-size: 18px; letter-spacing: 2px; color: #ffb400; -webkit-text-stroke: 1px #b06a00; }
.level-card .lv-stars .off { color: #d8d0e6; -webkit-text-stroke: 1px #a99bc4; }
.how { margin-top: 12px; font-size: 12.5px; font-weight: 700; background: #efe7ff; border-radius: 14px; padding: 8px 12px; display: grid; gap: 4px; }
.how b { color: var(--purple); margin-right: 4px; }
kbd { background: #fff; border: 1px solid #b9a8de; border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; font-family: inherit; font-weight: 900; font-size: .92em; }
h2 { margin: 6px 0 16px; font-size: 34px; color: var(--purple); }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.btn { font: inherit; font-weight: 1000; font-size: 18px; padding: 10px 24px; border-radius: 16px; border: 3px solid #fff; cursor: pointer; color: #fff; min-width: 140px; }
.btn:active { transform: translateY(2px); }
.btn.yellow { background: linear-gradient(#ffd75e, #f5ae1c); color: var(--ink); box-shadow: 0 4px 0 #b9790b; }
.btn.green { background: linear-gradient(#77d965, #3ea533); box-shadow: 0 4px 0 #26741f; }
.btn.purple { background: linear-gradient(#9c82ea, #6c4fb3); box-shadow: 0 4px 0 #46318a; }
.btn.plain { background: #fff; color: var(--ink); border-color: #d7c9f3; box-shadow: 0 4px 0 #b9a8de; }
.result { width: min(480px, 94vw); }
.result-art { width: min(340px, 78vw); display: block; margin: 0 auto; }
.result .stars { width: min(220px, 56vw); margin: 4px auto 0; display: block; }
.score-line { font-size: 26px; font-weight: 1000; margin-top: 6px; }
.score-line b { color: var(--purple); }
.score-sub { font-weight: 800; font-size: 14px; opacity: .8; margin-top: 4px; line-height: 1.5; }
.result.fail { background: #efe8ff; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: #2d2752; color: #fff; font-weight: 900; font-size: 20px; z-index: 50; }

@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes count { 0% { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-2px) rotate(-1deg); } 75% { transform: translateX(2px) rotate(1deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Man hinh nho / doc */
@media (max-width: 640px) {
  #hud { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; row-gap: 4px; }
  .hud-center { grid-column: 1 / span 2; grid-row: 2; }
  .timer .bar { width: 52vw; }
  .pill { font-size: 13px; }
  .score-pill { font-size: 16px; }
  .menu-body { flex-direction: column; text-align: center; }
  .hero { width: 96px; }
  .levels { grid-template-columns: 1fr; }
  .level-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; text-align: left; padding: 8px 12px; }
  .level-card .lv-badge { grid-column: 1 / -1; justify-self: start; }
  .level-card .lv-name { margin: 0; }
  .how { text-align: left; }
  .joy { width: 130px; height: 130px; }
  .joy-knob { width: 58px; height: 58px; left: 36px; top: 36px; }
  .act-btn { width: 96px; height: 96px; }
  .run-btn { width: 60px; height: 60px; right: calc(max(20px, env(safe-area-inset-right)) + 100px); }
}
@media (max-height: 480px) {
  #hud { padding-top: max(6px, env(safe-area-inset-top)); }
  .pill { font-size: 12px; padding: 2px 10px; border-width: 2px; }
  .count-pill b { font-size: 15px; }
  .score-pill { font-size: 15px; }
  .hands { font-size: 11px; padding: 2px 8px; }
  .timer { padding: 2px 8px 2px 3px; border-width: 2px; }
  .timer .clock { font-size: 20px; }
  .timer .bar { height: 14px; width: min(30vw, 200px); }
  .secs { font-size: 19px; }
  .mom-line { font-size: 10px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .img-btn { width: 40px; height: 40px; }
  .hud-right { flex-direction: row-reverse; align-items: flex-start; }
  .panel { padding: 8px 14px 12px; }
  .logo { width: 200px; }
  .hero { width: 80px; }
  .how { display: none; }
  .joy { width: 120px; height: 120px; }
  .joy-knob { width: 52px; height: 52px; left: 34px; top: 34px; }
  .act-btn { width: 88px; height: 88px; }
  .run-btn { width: 60px; height: 60px; right: calc(max(20px, env(safe-area-inset-right)) + 14px); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 104px); }
}

/* Me */
.heroes { position: relative; flex: none; display: flex; align-items: flex-end; }
.heroes .hero { width: clamp(64px, 12vw, 135px); }
.heroes .mom-hero { width: clamp(76px, 14.5vw, 162px); margin-right: -30px; animation-delay: -1.1s; }
.mom-say { display: flex; align-items: center; gap: 10px; margin: 8px auto 0; max-width: 400px; background: #fff; border: 3px solid #b79be6; border-radius: 18px; padding: 4px 12px 4px 4px; text-align: left; font-weight: 900; font-size: 14px; color: #4a3488; }
.mom-say img { width: 58px; height: 58px; object-fit: contain; flex: none; }
.mom-say.bad { border-color: #f2a0a8; color: #a8323c; }
@media (max-width: 640px) { .heroes .hero { width: 70px; } .heroes .mom-hero { width: 84px; margin-right: -22px; } }
@media (max-height: 480px) { .heroes .mom-hero { width: 70px; } .mom-say img { width: 44px; height: 44px; } }

/* ===================== v2: quoc te hoa, che do choi, chia se ===================== */
.link-btn { background: none; border: 0; color: #fff; text-decoration: underline; font: inherit; font-weight: 800; cursor: pointer; opacity: .85; }
.corner-btns { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 2; }
.panel.small { width: min(460px, 94vw); }
.logo-wrap { display: flex; justify-content: center; }
.title-logo { margin: 2px 0 6px; font-size: clamp(34px, 6.4vw, 60px); line-height: 1; font-weight: 1000; letter-spacing: .5px; color: #ffd23f;
  -webkit-text-stroke: 7px #5b2f9e; paint-order: stroke fill; text-shadow: 0 6px 0 #3d1f72, 0 10px 22px #0005; transform: rotate(-2deg); }
.title-logo .brand { display: block; font-size: .32em; color: #fff; -webkit-text-stroke: 4px #5b2f9e; letter-spacing: 2px; margin-top: 4px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.tab { font: inherit; border: 3px solid #d7c9f3; background: #fff; border-radius: 16px; padding: 6px 8px; cursor: pointer; color: var(--ink); display: grid; gap: 1px; text-align: center; min-height: 54px; }
.tab b { font-size: clamp(13px, 1.7vw, 16px); }
.tab small { font-size: 11px; font-weight: 700; opacity: .7; line-height: 1.2; }
.tab.on { border-color: var(--purple); background: linear-gradient(#fff, #efe6ff); box-shadow: 0 4px 0 var(--purple-d); }
.theme-h { font-weight: 1000; font-size: 13px; margin: 8px 2px 4px; color: var(--purple); text-align: left; }
.lv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lv { border: 3px solid var(--purple); background: #fff; border-radius: 14px; padding: 5px 4px 4px; cursor: pointer; font: inherit; color: inherit; box-shadow: 0 3px 0 var(--purple-d); display: grid; gap: 1px; justify-items: center; min-height: 64px; }
.lv:hover:not(:disabled) { transform: translateY(-2px); }
.lv:disabled { filter: grayscale(.9); opacity: .55; cursor: not-allowed; }
.lv .n { font-weight: 1000; font-size: 18px; color: #fff; border-radius: 99px; min-width: 30px; padding: 0 6px; line-height: 24px; }
.lv .nm { font-size: 10.5px; font-weight: 800; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lv .st { font-size: 12px; letter-spacing: 1px; color: #ffb400; -webkit-text-stroke: .6px #b06a00; line-height: 1; }
.lv .st .off { color: #d8d0e6; -webkit-text-stroke: .6px #a99bc4; }
.panic-box { display: grid; gap: 8px; justify-items: center; padding: 10px; background: linear-gradient(#fff3e0, #ffe0d1); border-radius: 18px; border: 3px solid #ffb38a; }
.panic-box .best { font-weight: 900; }
.btn.blue { background: linear-gradient(#5fb7ff, #2f7fe0); box-shadow: 0 4px 0 #1f56a0; }
.btn.big { font-size: 22px; padding: 12px 30px; }
.small-btn { font-size: 14px; padding: 7px 12px; min-width: 0; border-radius: 12px; }
.share-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.run-warn { color: #a8323c; }
.menu-foot { margin-top: 8px; font-size: 12px; font-weight: 800; opacity: .75; text-align: center; }
.mission-chip { font-size: 11.5px; font-weight: 900; background: #fffaf0; color: var(--ink); border: 2px solid #f5ae1c; border-radius: 99px; padding: 1px 10px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mission-chip.done { border-color: var(--green); background: #e8ffe3; }
.mission-chip.failed { border-color: #c9bfd9; opacity: .65; text-decoration: line-through; }
.new-best { display: inline-block; font-size: 13px; color: #fff; background: var(--red); border-radius: 99px; padding: 1px 8px; vertical-align: middle; transform: rotate(-4deg); }

/* banner co chu dong (asset da xoa chu tieng Viet ve san) */
.art-wrap { position: relative; width: min(340px, 78vw); margin: 0 auto; --aw: min(340px, 78vw); }
.art-wrap .result-art { width: 100%; }
.ribbon-text { position: absolute; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; font-weight: 1000; color: #fff; -webkit-text-stroke: 4px #8e1f2c; paint-order: stroke fill;
  text-shadow: 0 3px 0 #8e1f2c; pointer-events: none; }
.win-art .ribbon-text { top: 83%; font-size: calc(var(--aw) * 0.085); max-width: 56%; }
.fail-art .ribbon-text { top: 66%; font-size: calc(var(--aw) * 0.085); max-width: 46%; }
.fail-art .sub-text { position: absolute; left: 50%; top: 92%; transform: translate(-50%, -50%); white-space: nowrap; font-weight: 900; color: #3b2a55; font-size: calc(var(--aw) * 0.055); max-width: 62%; }
.warn-banner { position: absolute; left: 50%; top: 31%; width: min(420px, 78vw); transform: translate(-50%, -30px) scale(.6); opacity: 0; pointer-events: none; z-index: 7;
  transition: all .3s cubic-bezier(.2, 1.6, .4, 1); filter: drop-shadow(0 8px 14px #0005); --bw: min(420px, 78vw); }
.warn-banner img { width: 100%; display: block; }
.warn-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.warn-full { width: min(360px, 70vw); --bw: min(360px, 70vw); }
.wm-text { position: absolute; left: 73.4%; top: 64%; transform: translate(-50%, -50%) rotate(-3deg); width: 44%; text-align: center; font-weight: 1000; color: #c8202e;
  font-size: calc(var(--bw) * 0.05); line-height: 1.05; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }
.wf-title { position: absolute; left: 73.8%; top: 43%; transform: translate(-50%, -50%); width: 38%; text-align: center; font-weight: 1000; color: #c8202e; font-size: calc(var(--bw) * 0.058); line-height: 1; }
.wf-sub { position: absolute; left: 73.8%; top: 71%; transform: translate(-50%, -50%); width: 36%; text-align: center; font-weight: 800; color: #3b2a55; font-size: calc(var(--bw) * 0.04); line-height: 1.15; }

/* coach tutorial + me goi dien */
.coach { position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 44px); transform: translateX(-50%); z-index: 9; display: flex; gap: 10px; align-items: center;
  background: #2d2350f0; color: #fff; font-weight: 900; font-size: clamp(14px, 2vw, 18px); padding: 9px 16px; border-radius: 18px; border: 3px solid #ffd23f; max-width: 92vw; box-shadow: 0 8px 24px #0006; animation: pop .3s ease-out; }
.coach kbd { color: var(--ink); }
.phone { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 30%; z-index: 8; display: flex; align-items: flex-end; pointer-events: none;
  transform: translateX(130%); transition: transform .35s cubic-bezier(.2, 1.4, .4, 1); }
.phone.show { transform: translateX(0); }
.phone img { width: clamp(70px, 11vw, 110px); filter: drop-shadow(0 6px 10px #0005); }
.phone-bubble { background: #fff; border: 3px solid var(--purple); border-radius: 16px 16px 4px 16px; padding: 6px 10px; font-weight: 900; font-size: 13px; max-width: 190px; margin: 0 -8px 60% 0; order: -1; box-shadow: 0 4px 0 var(--purple-d); }
.phone .ring { display: inline-block; animation: shake .25s infinite; margin-right: 4px; }

/* cai dat / gioi thieu */
.field { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-weight: 900; margin: 8px 0; text-align: left; }
.field select { font: inherit; font-weight: 800; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--purple); background: #fff; max-width: 60%; }
.field.check { justify-content: flex-start; }
.field.check input { width: 22px; height: 22px; accent-color: var(--purple); flex: none; }
.note { font-size: 12px; font-weight: 700; opacity: .7; text-align: left; margin: 0 0 6px; }
.about { text-align: left; font-weight: 700; font-size: 14px; line-height: 1.45; max-height: 55dvh; overflow: auto; }
.about h3 { margin: 10px 0 4px; color: var(--purple); font-size: 15px; }
.about ul { margin: 0; padding-left: 18px; }
.about .ach.off { opacity: .45; }

@media (max-width: 640px) {
  .lv-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .lv { min-height: 52px; padding: 4px 2px; }
  .lv .nm { display: none; }
  .tab small { display: none; }
  .tab { min-height: 40px; }
  .title-logo { font-size: 36px; -webkit-text-stroke-width: 5px; }
  .phone { top: 24%; }
  .corner-btns .icon-btn { width: 38px; height: 38px; font-size: 17px; }
}
@media (max-height: 480px) {
  .lv .nm { display: none; }
  .lv { min-height: 46px; }
  .tab small { display: none; }
  .tab { min-height: 36px; padding: 4px; }
  .title-logo { font-size: 30px; -webkit-text-stroke-width: 5px; margin: 0; }
  .lead { display: none; }
  .art-wrap { width: min(220px, 46vw); --aw: min(220px, 46vw); }
  .coach { bottom: 8px; font-size: 13px; }
  .corner-btns .icon-btn { width: 36px; height: 36px; font-size: 16px; }
}

/* v2.1: coach rong hon, nam tren nut cam ung; HUD doc gon hon */
.coach { width: max-content; max-width: min(620px, 92vw); }
.touch-on .coach { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 160px); }
.icon-btn.on { background: #ffe58a; }
@media (max-width: 640px) {
  .hud-btns .icon-btn { width: 36px; height: 36px; font-size: 16px; border-width: 2px; }
  .hud-btns .img-btn { width: 40px; height: 40px; }
  .hud-right { gap: 4px; }
  .hud-btns { gap: 4px; }
  .score-pill { font-size: 15px; padding: 2px 10px 2px 8px; }
  .coach { font-size: 14px; }
}

/* HUD: cot trai khong duoc day cot phai ra ngoai man hinh */
#hud { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.hud-left, .hud-right { min-width: 0; }
.level-pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { #hud { grid-template-columns: minmax(0, 1fr) auto; } .hud-left .level-pill { font-size: 11px; } }

/* menu doc: chua cho nut goc, logo khong de len dong thuong hieu */
.title-logo .brand { margin-top: 10px; }
@media (max-width: 640px) { #menuPanel .logo-wrap { margin-top: 30px; } .heroes .hero { width: 58px; } .heroes .mom-hero { width: 70px; margin-right: -18px; } .phone { top: 36%; } }
@media (min-width: 900px) and (max-height: 800px) { .heroes .hero { width: clamp(64px, 9vw, 120px); } .heroes .mom-hero { width: clamp(76px, 11vw, 140px); } }
/* chon ngon ngu: nhan o tren, o chon rong het khung (tuy chon "Tu dong – quoc gia" dai) */
.field:has(#langSelect) { flex-direction: column; align-items: stretch; gap: 4px; }
.field #langSelect { max-width: none; width: 100%; }

/* ===================== v3: 3 che do khac biet ===================== */
/* hien/an theo che do */
body:not(.mode-panic) .only-panic { display: none !important; }
body.mode-cozy .not-cozy, body.mode-cozy #timerBox, body.mode-cozy #momLine { display: none !important; }
body.mode-story .level-pill { background: #5b6fd6; }
body.mode-panic .level-pill { background: linear-gradient(#ff8a3d, #e5484d); }
body.mode-cozy .level-pill { background: #3fae8f; }
body.mode-panic .timer { border-color: #e5484d; box-shadow: 0 3px 0 #9e2a33, 0 8px 18px #0003; }
body.mode-panic .secs { font-size: 28px; }

/* Panic Meter / tieng on */
.meter { display: flex; align-items: center; gap: 6px; background: #2d2350d9; border-radius: 99px; padding: 2px 10px 2px 8px; }
.meter-lbl { color: #ffd23f; font-weight: 1000; font-size: 11px; letter-spacing: .5px; }
.mbar { width: min(26vw, 150px); height: 10px; border-radius: 99px; background: #ffffff33; overflow: hidden; }
#meterFill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #7ee05a, #ffd23f 55%, #e5484d); transition: width .2s; }
.meter.hot { animation: shake .3s infinite; }
.meter.noise .meter-lbl { color: #9fd2ff; }
.mods { display: flex; gap: 4px; }
.mods span { background: #fff; border: 2px solid #ffb38a; border-radius: 99px; font-size: 13px; padding: 0 6px; line-height: 20px; }
.mods span.on { background: #ffe1d1; animation: pop .3s; }
.goal-chip { font-size: 12px; font-weight: 1000; color: #fff; background: #5b6fd6; border: 2px solid #fff; border-radius: 99px; padding: 1px 12px; max-width: 62vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 2px 0 #3c4aa3; }
.goal-chip.done { background: #3ea533; box-shadow: 0 2px 0 #26741f; }
.goal-chip.failed { background: #9e8fb8; text-decoration: line-through; }

/* Cozy: cong cu + trang tri */
.cozy-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 7; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
.touch-on .cozy-bar { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 96px); }
.tool-btn { font: inherit; font-weight: 900; font-size: 14px; padding: 6px 12px; border-radius: 14px; border: 3px solid #bfe9da; background: #f4fffa; color: #24624f; cursor: pointer; box-shadow: 0 3px 0 #8fcfb9; min-height: 40px; }
.tool-btn:active { transform: translateY(2px); }
.tool-btn.deco { background: #ffe9a8; border-color: #ffd36b; color: #6a4a00; box-shadow: 0 3px 0 #d9a92f; }
.tool-btn:disabled { opacity: .45; }
.autosave { font-size: 11px; font-weight: 800; color: #fff; background: #3fae8fcc; border-radius: 99px; padding: 2px 8px; opacity: 0; transition: opacity .3s; }
.autosave.on { opacity: 1; }
.decor-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); z-index: 12; width: min(640px, 96vw);
  background: #f4fffaf2; border: 3px solid #fff; border-radius: 22px; padding: 8px 10px; box-shadow: 0 6px 0 #8fcfb9, 0 16px 40px #0005; display: grid; gap: 6px; }
.decor-tabs { display: flex; gap: 4px; overflow-x: auto; }
.decor-tabs button { font: inherit; font-weight: 900; font-size: 13px; border: 2px solid #bfe9da; background: #fff; border-radius: 99px; padding: 4px 12px; cursor: pointer; white-space: nowrap; color: #24624f; }
.decor-tabs button.on { background: #3fae8f; color: #fff; border-color: #3fae8f; }
.decor-opts { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.d-opt { flex: none; width: 64px; height: 64px; border-radius: 14px; border: 3px solid #e1f2ec; background: #fff center / contain no-repeat; cursor: pointer; font-size: 11px; font-weight: 900; color: #24624f; display: grid; place-items: center; position: relative; }
.d-opt.on { border-color: #ffc83a; box-shadow: 0 0 0 3px #ffe9a8; }
.d-opt.lock { opacity: .5; cursor: not-allowed; }
.d-opt.lock::after { content: '🔒'; position: absolute; right: 2px; top: 0; font-size: 14px; }
.d-opt canvas { width: 100%; height: 100%; }

/* Hoi thoai Story */
.dialog { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 15; width: min(640px, 94vw); animation: pop .3s ease-out; }
.dlg-card { display: flex; gap: 12px; align-items: center; background: #fffdf6; border: 4px solid #5b6fd6; border-radius: 22px; padding: 10px 14px; box-shadow: 0 6px 0 #3c4aa3, 0 18px 40px #0006; }
.dlg-face { width: 72px; height: 72px; object-fit: contain; flex: none; background: #e9eeff; border-radius: 18px; }
.dlg-body { min-width: 0; text-align: left; }
.dlg-who { font-weight: 1000; color: #5b6fd6; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.dlg-text { font-weight: 800; font-size: clamp(15px, 2.2vw, 19px); line-height: 1.35; color: var(--ink); }
.dlg-goal { margin-top: 6px; display: inline-block; font-weight: 1000; font-size: 13px; color: #fff; background: #5b6fd6; border-radius: 99px; padding: 2px 10px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog.cut .dlg-card { border-color: #e59a3a; box-shadow: 0 6px 0 #b0661b, 0 18px 40px #0006; }
.dialog.cut .dlg-who { color: #c46d00; }
.say { position: absolute; left: max(12px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 120px); z-index: 8; max-width: min(360px, 70vw); background: #fffdf6; border: 3px solid #5b6fd6; border-radius: 16px 16px 16px 4px;
  padding: 6px 12px; font-weight: 900; font-size: 14px; box-shadow: 0 4px 0 #3c4aa3; animation: pop .25s; pointer-events: none; }

/* Menu chinh: 3 the che do */
.pick-h { font-weight: 1000; font-size: 15px; color: var(--purple); margin: 2px 0 8px; }
.mode-cards { display: grid; gap: 10px; }
.mode-card { font: inherit; display: flex; align-items: center; gap: 12px; text-align: left; border: 4px solid #fff; border-radius: 20px; padding: 10px 14px; cursor: pointer; color: #fff; min-height: 72px; transition: transform .12s; }
.mode-card:hover { transform: translateY(-3px) rotate(-.4deg); }
.mode-card:active { transform: translateY(2px); }
.mode-card .mc-ico { font-size: 34px; flex: none; filter: drop-shadow(0 3px 0 #0003); }
.mode-card .mc-txt { display: grid; gap: 1px; min-width: 0; }
.mode-card b { font-size: clamp(17px, 2.3vw, 22px); font-weight: 1000; text-shadow: 0 2px 0 #0003; }
.mode-card small { font-size: 12.5px; font-weight: 800; opacity: .92; }
.mode-card em { font-style: normal; font-size: 12px; font-weight: 900; background: #ffffff33; border-radius: 99px; padding: 0 8px; justify-self: start; margin-top: 2px; }
.mode-card.story { background: linear-gradient(135deg, #6a7fe8, #7a4fc4); box-shadow: 0 5px 0 #3c3a95; }
.mode-card.panic { background: linear-gradient(135deg, #ffcf3a, #ff7a2f 55%, #e5484d); box-shadow: 0 5px 0 #a52c3a; color: #3b1500; }
.mode-card.panic b, .mode-card.panic small, .mode-card.panic em { color: #fff; }
.mode-card.cozy { background: linear-gradient(135deg, #8fe3c3, #3fae8f); box-shadow: 0 5px 0 #237a62; }
.notice { margin-top: 10px; background: #fff3c4; border: 2px solid #f5ae1c; border-radius: 14px; padding: 6px 10px; font-size: 12.5px; font-weight: 800; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.link-btn.dark { color: var(--purple); opacity: 1; }

/* Hub chung */
.hub { width: min(900px, 96vw); text-align: center; }
.hub-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-bottom: 6px; }
.hub-top h2 { margin: 0; font-size: clamp(22px, 3.4vw, 32px); }
.hub-back { font: inherit; font-weight: 900; border: 2px solid currentColor; background: #fff8; border-radius: 99px; padding: 4px 12px; cursor: pointer; color: inherit; }
.hub-stat { font-weight: 1000; font-size: 14px; }
.sub-h { font-weight: 1000; text-align: left; margin: 12px 2px 6px; font-size: 14px; }

/* Hub Story: xanh/tim am, ban do chuong */
.hub-story { background: linear-gradient(170deg, #e4ecff, #efe3ff 60%, #fde9ff); color: #3c3a95; border-color: #c9d4ff; box-shadow: 0 8px 0 #8f9fe6, 0 24px 60px #0007; }
.hub-story h2 { color: #4b4fc0; }
.chapters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chapter { background: #fff; border-radius: 20px; padding: 8px 10px 10px; border: 3px solid var(--cc); box-shadow: 0 4px 0 color-mix(in srgb, var(--cc) 70%, #000); position: relative; }
.chapter.locked { filter: grayscale(.85); opacity: .6; }
.ch-head { display: flex; align-items: center; gap: 6px; font-weight: 1000; color: var(--cc); font-size: 14px; }
.ch-head .ico { font-size: 22px; }
.ch-head .badge { margin-left: auto; font-size: 20px; }
.ch-area { font-weight: 900; font-size: 13px; color: var(--ink); text-align: left; }
.ch-mech { font-size: 11.5px; font-weight: 800; opacity: .75; text-align: left; min-height: 2.4em; }
.path { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; position: relative; }
.path::before { content: ''; position: absolute; left: 14px; right: 14px; top: 50%; border-top: 3px dashed color-mix(in srgb, var(--cc) 55%, #fff); z-index: 0; }
.node { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--cc); background: #fff; font: inherit; font-weight: 1000; color: var(--cc); cursor: pointer; display: grid; place-items: center; padding: 0; }
.node.done { background: var(--cc); color: #fff; }
.node.cur { box-shadow: 0 0 0 4px #ffd23f; animation: bob 1.6s ease-in-out infinite; }
.node:disabled { cursor: not-allowed; opacity: .55; }
.node .st { position: absolute; bottom: -13px; font-size: 9px; color: #ffb400; letter-spacing: -1px; white-space: nowrap; -webkit-text-stroke: .4px #b06a00; }
.node .st .off { color: #d8d0e6; -webkit-text-stroke: 0; }
.next-card { margin: 14px auto 0; max-width: 520px; background: #fff; border-radius: 18px; border: 3px dashed #8f9fe6; padding: 8px 12px; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.next-card:empty { display: none; }
.next-card .nc-ico { font-size: 28px; grid-row: span 2; }
.next-card b { font-size: 15px; }
.next-card small { font-size: 12.5px; font-weight: 800; opacity: .8; }
.next-card.mini { margin-top: 8px; border-color: #c9bfe8; }
.album { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.memory { font: inherit; background: #fff; border: 3px solid #e59a3a; border-radius: 16px; padding: 8px; cursor: pointer; font-weight: 900; display: grid; gap: 2px; }
.memory .mi { font-size: 28px; }
.memory.off { opacity: .4; border-style: dashed; cursor: default; }

/* Hub Panic: vang/cam/do, dong ho lon, CHOI NGAY */
.hub-panic { background: linear-gradient(170deg, #fff6c9, #ffd58c 55%, #ffab7d); color: #7a2a12; border-color: #ffe3a1; box-shadow: 0 8px 0 #e0814c, 0 24px 60px #0007; }
.hub-panic h2 { color: #c4321f; }
.panic-hero { display: flex; align-items: center; justify-content: center; gap: 16px; }
.big-clock { width: clamp(96px, 16vw, 130px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #fff, #ffe7c4); border: 6px solid #e5484d; box-shadow: 0 6px 0 #9e2a33, inset 0 -6px 0 #ffd0a8;
  display: grid; place-content: center; font-weight: 1000; color: #c4321f; animation: shake 2.4s infinite; }
.big-clock span { font-size: clamp(40px, 7vw, 56px); line-height: .9; }
.big-clock small { font-size: 16px; }
.panic-best { font-weight: 1000; font-size: 16px; text-align: left; display: grid; gap: 2px; }
.panic-best b { font-size: 30px; color: #c4321f; }
.dur-row { display: flex; gap: 6px; justify-content: center; margin: 8px 0; flex-wrap: wrap; }
.dur { font: inherit; font-weight: 1000; border: 3px solid #e5484d; background: #fff; color: #c4321f; border-radius: 99px; padding: 3px 14px; cursor: pointer; }
.dur.on { background: #e5484d; color: #fff; }
.dur:disabled { opacity: .5; border-style: dashed; cursor: not-allowed; }
.btn.panic-go { font-size: clamp(24px, 4vw, 34px); padding: 12px 40px; background: linear-gradient(#ff6b3d, #e5484d); box-shadow: 0 6px 0 #8e1f2c, 0 12px 26px #e5484d66; border-radius: 22px; letter-spacing: 1px; animation: pulse 1.4s ease-in-out infinite; }
.p-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.p-card { font: inherit; background: #fff; border: 3px solid #ffb38a; border-radius: 16px; padding: 8px 6px; cursor: pointer; display: grid; gap: 2px; color: #7a2a12; }
.p-card b { font-size: 15px; }
.p-card small { font-size: 11.5px; font-weight: 800; opacity: .85; }
.p-card.on { border-color: #e5484d; background: #fff1e8; box-shadow: 0 4px 0 #e5484d; }
.records { margin-top: 8px; background: #fff; border-radius: 16px; padding: 8px 12px; text-align: left; font-weight: 800; font-size: 13px; }
.records h4 { margin: 6px 0 2px; color: #c4321f; }
.records ol { margin: 0; padding-left: 22px; }
.ch-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ch-card { font: inherit; text-align: left; background: #fff; border: 3px solid #ff9466; border-radius: 16px; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; color: #7a2a12; }
.ch-card b { font-size: 14px; }
.ch-card small { font-size: 11.5px; font-weight: 800; opacity: .85; }
.ch-card em { font-style: normal; font-size: 11.5px; font-weight: 1000; color: #2b7a23; }
.panic-res { background: linear-gradient(#fff6c9, #ffd9a8); }
.pr-head { display: flex; align-items: center; gap: 14px; justify-content: center; }
.pr-head h2 { margin: 0; color: #c4321f; }
.grade { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 42px; font-weight: 1000; color: #fff; background: linear-gradient(#ff8a3d, #e5484d); border: 4px solid #fff; box-shadow: 0 4px 0 #8e1f2c; }
.grade.S { background: linear-gradient(#ffe066, #f5ae1c); color: #7a4a00; }
.pr-score { font-size: 30px; font-weight: 1000; color: #7a2a12; }
.pr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin: 8px 0; }
.pr-stats div { background: #fff; border-radius: 14px; padding: 4px 6px; font-weight: 800; font-size: 12px; }
.pr-stats b { display: block; font-size: 20px; color: #c4321f; }
.pr-board { background: #fff8; border-radius: 14px; padding: 4px 10px; font-size: 12.5px; font-weight: 800; text-align: left; margin-bottom: 8px; }
.pr-board ol { margin: 2px 0; padding-left: 22px; }
.pr-board li.me { color: #c4321f; }

/* Hub Cozy: xanh mint/kem */
.hub-cozy { background: linear-gradient(170deg, #e8fbf3, #fff8e8 70%); color: #24624f; border-color: #cdeee2; box-shadow: 0 8px 0 #8fcfb9, 0 24px 60px #0007; }
.hub-cozy h2 { color: #2f8f73; }
.cozy-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; align-items: stretch; }
.cozy-cards { display: grid; gap: 8px; }
.c-card { font: inherit; background: #fff; border: 3px solid #8fe3c3; border-radius: 18px; padding: 10px; cursor: pointer; display: grid; gap: 2px; color: #24624f; text-align: left; }
.c-card b { font-size: 17px; }
.c-card small { font-size: 12px; font-weight: 800; opacity: .8; }
.c-card.deco { border-color: #ffd36b; background: #fffaf0; }
.c-card:disabled { opacity: .5; cursor: not-allowed; }
.compare { position: relative; border-radius: 18px; overflow: hidden; background: #d9f3ea; min-height: 130px; aspect-ratio: 16 / 9; border: 3px solid #fff; box-shadow: 0 4px 0 #8fcfb9; }
.compare.big { max-width: 520px; margin: 6px auto 10px; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .after { clip-path: inset(0 0 0 var(--cut, 50%)); }
.compare .cut { position: absolute; top: 0; bottom: 0; left: var(--cut, 50%); width: 3px; background: #fff; box-shadow: 0 0 6px #0005; pointer-events: none; }
.compare input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare .lbl { position: absolute; top: 6px; font-size: 11px; font-weight: 1000; background: #fffd; border-radius: 99px; padding: 1px 8px; color: #24624f; pointer-events: none; }
.compare .lbl.b { left: 6px; } .compare .lbl.a { right: 6px; }
.compare .empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; font-weight: 900; font-size: 13px; color: #2f8f73; text-align: center; }
.room-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.room { font: inherit; text-align: left; background: #fff; border: 3px solid #bfe9da; border-radius: 16px; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; color: #24624f; position: relative; }
.room b { font-size: 14px; }
.room small { font-size: 11.5px; font-weight: 800; opacity: .8; }
.room em { font-style: normal; font-size: 11.5px; font-weight: 1000; }
.room .ri { font-size: 24px; }
.room.done { border-color: #3fae8f; }
.more-rooms { margin-top: 8px; text-align: left; }
.more-rooms summary { cursor: pointer; font-weight: 1000; }
.room-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.room-grid .room { padding: 6px; text-align: center; justify-items: center; }
.collect { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; background: #fff; border-radius: 14px; padding: 6px; }
.collect canvas { width: 40px; height: 40px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.gallery img { width: 100%; border-radius: 12px; border: 3px solid #fff; box-shadow: 0 3px 0 #8fcfb9; }
.gallery .empty { font-size: 12px; font-weight: 800; opacity: .7; grid-column: 1 / -1; text-align: left; }
.cozy-res { background: linear-gradient(#e8fbf3, #fff8e8); }
.cozy-res h2 { color: #2f8f73; }
.cd-pct { font-weight: 1000; color: #24624f; }

/* Ket qua: 1 CTA chinh + lien ket phu nho */
.cta { display: block; margin: 12px auto 4px; min-width: min(300px, 80vw); }
.sec-row { font-size: 13px; margin-top: 6px; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; align-items: center; }
.star-list { list-style: none; margin: 4px auto; padding: 0; display: grid; gap: 2px; font-weight: 800; font-size: 13px; max-width: 360px; text-align: left; }
.star-list li::before { content: '☆ '; color: #b9a8de; }
.star-list li.ok::before { content: '★ '; color: #ffb400; }
.outro { font-weight: 800; font-size: 14px; margin-top: 6px; font-style: italic; color: #4b4fc0; }

/* About: cuon duoc tren mobile, nut dong luon thay */
.about-panel { display: flex; flex-direction: column; max-height: 94dvh; padding-top: 10px; }
.about-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; }
.about-head h2 { margin: 0; }
.about-panel .about { flex: 1; max-height: none; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-right: 4px; -webkit-overflow-scrolling: touch; }
.about-foot { padding-top: 8px; }
.about .legal { background: #fff; border-radius: 14px; padding: 8px 12px; border: 2px solid #e6dcfb; }
.about .legal h4 { margin: 8px 0 2px; color: var(--purple); }
.about .legal p { margin: 3px 0; }
.about .review { font-size: 12px; background: #fff3c4; border-radius: 10px; padding: 4px 8px; }
.about table { width: 100%; border-collapse: collapse; font-size: 12px; }
.about td, .about th { border-bottom: 1px solid #e6dcfb; padding: 3px 4px; text-align: left; vertical-align: top; }
.about .unv { color: #b4232c; font-weight: 900; }
.about .lead-p { font-size: 15px; }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; }

@media (max-width: 640px) {
  .chapters { grid-template-columns: 1fr; }
  .chapter { padding: 6px 10px 12px; }
  .ch-mech { min-height: 0; }
  .p-cards, .ch-row { grid-template-columns: 1fr; }
  .ch-card, .p-card { grid-template-columns: 1fr; }
  .cozy-top { grid-template-columns: 1fr; }
  .room-row { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: repeat(3, 1fr); }
  .mode-card { min-height: 60px; padding: 8px 12px; }
  .mode-card .mc-ico { font-size: 28px; }
  .mode-card small { font-size: 11.5px; }
  .hub-top { grid-template-columns: auto 1fr; }
  .hub-top .hub-stat { grid-column: 1 / -1; }
  .panic-hero { gap: 10px; }
  .btn.panic-go { padding: 10px 26px; }
  .dlg-face { width: 56px; height: 56px; }
  .dialog { bottom: max(10px, env(safe-area-inset-bottom)); }
  .touch-on .dialog { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 150px); }
  .say { top: calc(max(10px, env(safe-area-inset-top)) + 128px); font-size: 13px; }
  .tool-btn { font-size: 13px; padding: 5px 9px; min-height: 36px; }
  .decor-bar { bottom: max(8px, env(safe-area-inset-bottom)); }
  .d-opt { width: 54px; height: 54px; }
  .mbar { width: 34vw; }
}
@media (max-width: 360px) {
  .mode-card small { display: none; }
  .tool-btn { font-size: 12px; padding: 4px 7px; }
  .hub-top h2 { font-size: 20px; }
  .big-clock { width: 84px; }
}
@media (max-height: 480px) {
  .mode-cards { grid-template-columns: repeat(3, 1fr); }
  .mode-card { flex-direction: column; text-align: center; gap: 2px; min-height: 0; padding: 6px; }
  .mode-card .mc-txt { justify-items: center; }
  .mode-card small { display: none; }
  .chapters { grid-template-columns: repeat(3, 1fr); }
  .ch-mech { display: none; }
  .dialog { width: min(560px, 70vw); }
  .touch-on .dialog { bottom: 8px; }
  .say { top: 70px; }
  .cozy-top { grid-template-columns: 1fr 1fr; }
}
/* trang tri chi mo sau khi don xong (qua bang ket qua) */
#decoBtn { display: none; }
.touch-on .cozy-bar { top: calc(max(10px, env(safe-area-inset-top)) + 104px); }
/* v3.1 QA: can giua khong dung transform (hieu ung pop dung transform -> lech) */
.dialog, .coach { left: 0; right: 0; margin-left: auto; margin-right: auto; transform: none; }
.count-pill { transform-origin: left center; }
.decor-tabs { flex-wrap: wrap; overflow: visible; }
@media (max-width: 380px) {
  .goal-chip { white-space: normal; max-width: 92vw; line-height: 1.2; text-align: center; }
  .run-btn { right: calc(max(20px, env(safe-area-inset-right)) + 16px); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 104px); width: 56px; height: 56px; }
}
/* Cozy tren dien thoai: cot cong cu ben phai, khong de len HUD / nut */
.touch-on .cozy-bar { top: 34%; bottom: auto; left: auto; right: max(8px, env(safe-area-inset-right)); transform: none; flex-direction: column; align-items: stretch; max-width: 40vw; }
.touch-on .cozy-bar .autosave { text-align: center; }
@media (max-height: 480px) {
  .touch-on .cozy-bar { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 56vw; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .result .art-wrap { width: min(250px, 62vw); --aw: min(250px, 62vw); }
  .result .stars { width: min(150px, 40vw); }
  .result .score-line { font-size: 22px; }
  .next-card.mini { margin-top: 4px; padding: 4px 10px; }
}
@media (max-width: 640px) { .result.fail .art-wrap { width: min(340px, 78vw); --aw: min(340px, 78vw); } }
