/* UI kit "hộp quà dập nhũ" — một bộ cho mọi màn */
:root {
  --dark: #4A0F1C; --dark2: #2E0812; --cream: #FFF4DE; --paper: #F7E6C4; --red: #D7263D; --red2: #A3172B;
  --jade: #1F7A6B; --gold: #F2B33D; --gold2: #C9861E; --ink: #2B1210;
  --ft: var(--title, var(--font-sans, sans-serif)); --fp: var(--paragraph, var(--font-sans, sans-serif));
  --inputfs: 18px; --biz-btn: linear-gradient(180deg, #F0485C 0%, #D7263D 55%, #A3172B 100%); --biz-btn-text: #FFF4DE; --biz-accent: #F2B33D;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1E050C; color: var(--cream); font-family: var(--fp); }
body { background: radial-gradient(circle at 50% 30%, #5A1424, #1E050C 75%); }
#wrap { position: fixed; top: env(safe-area-inset-top, 0px); bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px); }
#stage { position: absolute; left: 50%; top: 50%; width: 390px; height: 760px; transform-origin: 50% 50%; overflow: hidden; background: var(--dark); border-radius: 0; user-select: none; -webkit-user-select: none; }
#game { position: absolute; inset: 0; width: 390px; height: 760px; touch-action: none; display: block; }
.ribbon { position: absolute; left: 0; right: 0; top: 0; height: 5px; z-index: 50; pointer-events: none;
  background: radial-gradient(circle, #F2B33D 1.4px, transparent 1.6px) 0 0/10px 5px, linear-gradient(#D7263D, #A3172B); }
#screens { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#screens > * { pointer-events: auto; }
.scr { position: absolute; inset: 0; z-index: 0; display: flex; flex-direction: column; align-items: center; padding: 22px 20px 20px; overflow-y: auto; overflow-x: hidden; animation: fadeIn .35s ease both; }
.scr.dim { background: rgba(30, 5, 12, .62); }
.scr.solid { background: radial-gradient(circle at 50% 20%, #6B1A2A, var(--dark) 55%, var(--dark2)); }
.grow { flex: 1 1 auto; min-height: 8px; }
.ov { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; background: rgba(30, 5, 12, .55); animation: fadeIn .25s ease both; }
.ov.center { justify-content: center; padding: 18px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sweep { 0% { left: -60%; } 60%, 100% { left: 130%; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* chữ */
.kicker { font-family: var(--ft); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.paper .kicker { color: var(--red2); }
.h1 { font-family: var(--ft); font-weight: 800; font-size: 26px; line-height: 1.25; text-align: center; margin: 6px 0; overflow-wrap: anywhere; }
.h2 { font-family: var(--ft); font-weight: 800; font-size: 21px; line-height: 1.3; text-align: center; margin: 4px 0 8px; overflow-wrap: anywhere; }
.p { font-size: 16px; line-height: 1.5; text-align: center; margin: 6px 0; overflow-wrap: anywhere; }
.small { font-size: 13px; opacity: .85; text-align: center; line-height: 1.45; overflow-wrap: anywhere; }
.err { color: #FFD0D5; background: rgba(215, 38, 61, .25); border: 1px solid rgba(255, 140, 150, .6); border-radius: 12px; padding: 8px 12px; font-size: 14px; text-align: center; margin: 8px 0; display: none; overflow-wrap: anywhere; }
.err.on { display: block; }

/* nút */
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; min-width: 200px; max-width: 100%; padding: 10px 26px;
  border-radius: 999px; border: 2.5px solid var(--gold); background: linear-gradient(180deg, #F0485C 0%, #D7263D 55%, #A3172B 100%); color: var(--cream);
  font-family: var(--ft); font-weight: 800; font-size: 19px; line-height: 1.2; text-align: center; cursor: pointer; overflow-wrap: anywhere;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), inset 0 -3px 0 rgba(0, 0, 0, .2), 0 5px 0 var(--ink), 0 8px 18px rgba(0, 0, 0, .35); transition: transform .1s; }
.btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--ink); }
.btn[disabled] { filter: grayscale(.8); opacity: .55; pointer-events: none; }
.btn.hero::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent); animation: sweep 3.2s ease-in-out infinite; }
.btn.sec { background: linear-gradient(180deg, #FFF8EA, #F7E6C4 60%, #E8CFA0); color: var(--ink); border-color: var(--ink); }
.btn.wide { width: 100%; }
.btnrow { display: flex; gap: 10px; width: 100%; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { min-width: 0; flex: 1 1 140px; }
.medal { width: 52px; height: 52px; border-radius: 50%; border: 2.5px solid var(--ink); background: radial-gradient(circle at 35% 30%, #FFE08A, var(--gold) 55%, var(--gold2)); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 3px 0 var(--ink); color: var(--ink); flex: 0 0 auto; }
.medal.sm { width: 48px; height: 48px; }
.medal svg { width: 24px; height: 24px; }
.medal:active { transform: translateY(2px); }
.medwrap { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-family: var(--ft); font-weight: 700; color: var(--cream); max-width: 90px; text-align: center; }
.corner { position: absolute; top: 14px; z-index: 40; }
.corner.l { left: 12px; } .corner.r { right: 12px; }

/* bề mặt */
.panel { width: 100%; background: rgba(46, 8, 18, .9); border: 1px solid rgba(242, 179, 61, .55); border-radius: 22px; padding: 18px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); animation: popIn .3s ease both; }
.sheet { border-radius: 22px 22px 0 0; max-height: 86%; overflow-y: auto; padding-bottom: 26px; }
.grab { width: 54px; height: 6px; margin: -6px auto 12px; border-radius: 3px; background: radial-gradient(circle, #F2B33D 1.4px, transparent 1.6px) 0 0/8px 6px, #D7263D; }
.tile { display: block; width: 100%; text-align: left; background: rgba(255, 244, 222, .08); border: 1px solid rgba(255, 244, 222, .22); border-radius: 14px; padding: 12px 14px; margin: 8px 0; color: var(--cream); font-family: var(--fp); font-size: 16px; line-height: 1.4; min-height: 50px; cursor: pointer; overflow-wrap: anywhere; }
.tile:active { background: rgba(255, 244, 222, .16); }
.tile.ok { border-color: #6FD3A8; background: rgba(31, 122, 107, .45); }
.tile.bad { border-color: #FF8C96; background: rgba(215, 38, 61, .35); }
.tile.me { border-color: var(--gold); background: rgba(242, 179, 61, .2); }
.paper { background: linear-gradient(180deg, #FFF8EA, var(--paper)); color: var(--ink); border: 1.5px solid #8A5A3A; border-radius: 16px; padding: 14px 16px; box-shadow: 0 4px 0 rgba(43, 18, 16, .5); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.grid2 .tile { margin: 0; text-align: center; font-family: var(--ft); font-weight: 700; font-size: 15px; }

/* form */
.field { width: 100%; margin: 8px 0; text-align: left; }
.field label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--paper); overflow-wrap: anywhere; }
.inp { width: 100%; min-height: 50px; border-radius: 14px; border: 2px solid rgba(242, 179, 61, .6); background: var(--cream); color: var(--ink); padding: 10px 14px; font-size: var(--inputfs); font-family: var(--fp); outline: none; }
.inp:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 179, 61, .35); }
textarea.inp { min-height: 90px; resize: vertical; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; border-radius: 12px; background: rgba(255, 244, 222, .08); margin: 6px 0; font-size: 16px; overflow-wrap: anywhere; }
.opt input { width: 22px; height: 22px; accent-color: var(--red); flex: 0 0 auto; }
.rowflex { display: flex; gap: 8px; width: 100%; align-items: stretch; }
.rowflex .inp { flex: 1 1 auto; min-width: 0; }
.rowflex .btn { min-width: 110px; padding: 8px 14px; font-size: 16px; }

/* màn nghiệp vụ: màu chiến dịch khi có palette */
body.pal .biz .btn:not(.sec) { background: var(--palette-1); color: var(--biz-btn-text); }
body.pal .biz .kicker { color: var(--palette-2); }
body.pal .biz .paper .kicker { color: var(--red2); }
body.pal .biz .tile.me { border-color: var(--palette-2); }

/* màn bắt đầu */
.titlecv { width: 350px; height: 300px; margin-top: 8px; }
.logo-slot { border: 1.5px dashed rgba(242, 179, 61, .7); border-radius: 12px; padding: 6px 12px; font-size: 12px; color: var(--paper); margin-top: 20px; }
.medals { display: flex; gap: 34px; justify-content: center; margin-top: 18px; margin-bottom: 26px; }
.turns { font-size: 14px; margin-top: 10px; color: var(--paper); text-align: center; }

/* vé */
.ticket { width: 100%; display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden; }
.ticket::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 10px; background: radial-gradient(circle, #D7263D 2px, transparent 2.5px) 0 0/10px 10px; }
.ticket canvas { width: 86px; height: 86px; flex: 0 0 auto; }
.ticket .nm { font-family: var(--ft); font-weight: 800; font-size: 24px; overflow-wrap: anywhere; line-height: 1.2; }
.avs { display: flex; gap: 12px; justify-content: center; margin: 14px 0; }
.avs canvas { width: 62px; height: 62px; border-radius: 50%; cursor: pointer; transition: transform .15s; }
.avs canvas.on { transform: scale(1.15); box-shadow: 0 0 0 4px var(--gold); }

/* bản đồ */
.mapcv { width: 360px; height: 360px; }
.lvtag { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 999px; background: rgba(46, 8, 18, .9); border: 1.5px solid var(--gold); font-family: var(--ft); font-weight: 800; font-size: 18px; color: var(--cream); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* HUD */
/* HUD nằm dưới hàng nút góc: giữa mép trên là logo của SDK; xếp dưới các lớp truyện/nhiệm vụ (z 28–30) */
.hud { position: absolute; left: 12px; right: 12px; top: 70px; z-index: 26; height: 54px; border-radius: 22px; background: rgba(46, 8, 18, .88); border: 1.5px solid rgba(242, 179, 61, .7);
  display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 14px; pointer-events: none; }
.hud .info { flex: 1 1 auto; min-width: 0; }
.hud .row { display: flex; align-items: center; gap: 8px; }
.hud .t { flex: 1 1 auto; min-width: 0; font-family: var(--ft); font-weight: 800; font-size: 16px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud .clk { flex: 0 0 auto; font-family: var(--ft); font-weight: 800; font-size: 17px; color: var(--cream); background: var(--jade); border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.hud .clk.warn { background: var(--red); animation: pulse .5s ease-in-out infinite; }
.hud > canvas { width: 112px; height: 34px; flex: 0 0 auto; background: rgba(255, 244, 222, .16); border-radius: 999px; }
.say { position: absolute; left: 16px; right: 16px; bottom: 46px; z-index: 27; padding: 10px 14px; border-radius: 16px; background: linear-gradient(180deg, #FFF8EA, var(--paper)); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 4px 0 rgba(43, 18, 16, .5);
  font-size: 16px; line-height: 1.4; pointer-events: none; transition: opacity .5s; animation: popIn .25s ease both; overflow-wrap: anywhere; }
.say b { display: block; font-family: var(--ft); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--red2); }
.hud .bar { height: 8px; border-radius: 4px; background: rgba(255, 244, 222, .15); margin-top: 4px; overflow: hidden; }
.hud .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #FFE08A); transition: width .3s; }
.hint { position: absolute; left: 30px; right: 30px; bottom: 46px; z-index: 26; text-align: center; padding: 10px 14px; border-radius: 999px; background: rgba(46, 8, 18, .85); border: 1px solid rgba(242, 179, 61, .55); font-size: 15px; pointer-events: none; transition: opacity .5s; overflow-wrap: anywhere; }

/* truyện */
.slide { position: absolute; inset: 0; z-index: 28; background: var(--dark2); display: flex; flex-direction: column; animation: fadeIn .4s ease both; }
.slide canvas { width: 390px; height: 470px; display: block; }
.slide .cap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 14px 20px 22px; gap: 12px; }
.slide .cap .paper { font-size: 19px; line-height: 1.5; text-align: center; font-family: var(--fp); overflow-wrap: anywhere; }
.slide.quiet .cap .paper { background: none; border: none; box-shadow: none; color: var(--paper); font-size: 22px; font-family: var(--ft); }
.skip { position: absolute; top: 14px; right: 72px; z-index: 40; min-height: 48px; padding: 8px 16px; border-radius: 999px; background: rgba(46, 8, 18, .85); border: 1px solid rgba(242, 179, 61, .55); color: var(--cream); font-family: var(--ft); font-weight: 700; font-size: 14px; cursor: pointer; }
.talk { display: flex; gap: 12px; align-items: flex-end; width: 100%; }
.talk canvas { width: 72px; height: 72px; flex: 0 0 auto; }
.talk .paper { flex: 1; font-size: 17px; line-height: 1.45; position: relative; overflow-wrap: anywhere; }
.act { position: absolute; inset: 0; z-index: 29; touch-action: none; }
.act canvas { position: absolute; inset: 0; width: 390px; height: 760px; }
.act .top { position: absolute; top: 76px; left: 20px; right: 20px; text-align: center; pointer-events: none; }
.endsc .paper { width: 100%; margin: 8px 0; text-align: center; }
.score { font-family: var(--ft); font-weight: 800; font-size: 44px; color: var(--gold); text-shadow: 0 3px 0 var(--ink); text-align: center; }
.lbrow { display: flex; align-items: center; gap: 10px; }
.lbrow .rk { width: 34px; font-family: var(--ft); font-weight: 800; color: var(--gold); text-align: center; flex: 0 0 auto; }
.lbrow .nm { flex: 1; overflow-wrap: anywhere; }
.lbrow .sc { font-family: var(--ft); font-weight: 800; flex: 0 0 auto; }
.rulesbox { max-height: 220px; overflow-y: auto; text-align: left; font-size: 14px; line-height: 1.5; }
.rulesbox ul { margin: 0; padding-left: 18px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* ẩn thanh cuộn mặc định (vẫn cuộn được); ẩn nút CTA SDK chèn cuối game, khung không còn nút khác thì ẩn luôn */
#stage *{scrollbar-width:none}#stage ::-webkit-scrollbar{display:none}
[data-octokit-cta]{display:none!important}[data-octokit-overlay]:not(:has(button:not([data-octokit-cta]))){display:none!important}
