/* Game shell + real (non-static) components on top of base.css (tokens/primitives from docs/mockups/mockups.css).
   Rules: animations use transform/opacity only; bars use scaleX(var(--v)); layouts are flex/grid so extra height on tall phones flows into the panel. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050608; color: var(--ink); overscroll-behavior: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
body { font: 11px/1.35 var(--mono); }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }
/* #app = the WHOLE screen (viewport-fit=cover, 100dvh); the stage is scaled to fill it and the notch / home-indicator insets are re-added INSIDE the stage as --sat / --sab (logical px, set by ui/stage.js) */
#app { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100dvh; background: #050608; }
#safeprobe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#fit { position: relative; width: 100%; height: 100%; }
#stage { position: absolute; left: 0; top: 0; width: 360px; height: 640px; transform-origin: 0 0; overflow: hidden; background: #12141a; font: 11px/1.35 var(--mono); color: var(--ink); contain: layout paint; }
#base, #layers { position: absolute; inset: 0; }
#layers { pointer-events: none; }
.layer { pointer-events: auto; position: absolute; }
.sc { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4b546a #181b23; }
.row.wrap { flex-wrap: wrap; }
.hudbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; color: inherit; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: default; }

/* ---------- regions (GDD 13.2 grid; panel + nav anchor to the bottom so tall phones add height to the content panel) ---------- */
.topbar { top: 0; height: calc(40px + var(--sat, 0px)); padding-top: var(--sat, 0px); z-index: 2; }
.topbar .l1 .stage { font-weight: 700; color: #fff; }
.topbar .l1 { gap: 5px; }
.battle { top: calc(40px + var(--sat, 0px)); height: 200px; overflow: hidden; background: #6fa7d6; }
#battle { display: block; width: 360px; height: 200px; image-rendering: pixelated; image-rendering: crisp-edges; }
#bhud { position: absolute; inset: 0; pointer-events: none; }
#bhud .btn, #bhud .toggle { pointer-events: auto; }
.wallb { position: absolute; left: 50%; transform: translateX(-50%); top: 30px; background: rgba(90,20,15,.92); color: #ffd6cf; padding: 3px 7px; box-shadow: 0 0 0 1px #000; white-space: nowrap; font: 700 10px/1.2 var(--mono); }
.pstrip { top: calc(240px + var(--sat, 0px)); height: 44px; }
.panel { top: calc(284px + var(--sat, 0px)); bottom: calc(60px + var(--sab, 0px)); height: auto; }
.nav { top: auto; bottom: 0; height: calc(60px + var(--sab, 0px)); padding-bottom: var(--sab, 0px) !important; }
.nav button .lk { position: absolute; top: 4px; right: 8px; font-size: 9px; }
.nav button.locked { opacity: .5; }
.nav span { pointer-events: none; }
.tabp { position: absolute; inset: 0; overflow: hidden; }
.tabp.col { display: flex; flex-direction: column; }
.bar.tf > i { width: calc(100% - 2px); transform: scaleX(var(--v, 0)); transform-origin: 0 50%; }
.bar.tf.run > i { animation: runbar 1.5s linear forwards; }
@keyframes runbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* portrait strip */
.pc { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
.pc .hp { margin-top: 3px; height: 3px; background: #000; overflow: hidden; }
.pc .hp i { display: block; width: 100%; height: 3px; background: var(--green); transform: scaleX(var(--v, 1)); transform-origin: 0 50%; }
.pc .hp i.lowhp { background: var(--red); }
.pc .rf.none, .pc .rf.locked { width: 24px; height: 24px; border: 0; }
.ports { gap: 1px; }
.revive { font-family: var(--mono); }
.revive.glow { animation: none; }
.revive::after { content: ""; position: absolute; inset: -3px; box-shadow: 0 0 8px 3px #d59cff; opacity: 0; pointer-events: none; }
.revive.glow::after { animation: glowp 1.2s ease-in-out infinite; }
@keyframes glowp { 50% { opacity: 1; } }

/* toast */
#toast { position: absolute; left: 50%; bottom: calc(70px + var(--sab, 0px)); transform: translate(-50%, 8px); background: rgba(8,9,12,.92); color: #fff; padding: 5px 10px; opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity .15s, transform .15s; white-space: nowrap; max-width: 344px; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 0 0 1px #4b546a, 0 4px 12px rgba(0,0,0,.6); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* hub summary (S3) */
.hubp { padding: 10px; }
.hubh { display: flex; flex-direction: column; gap: 2px; }
.hubg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.hubt { position: relative; height: 52px; background: #20242e; border: 0; box-shadow: inset 1px 1px 0 #4b546a, inset -1px -1px 0 #0a0b0f, 0 0 0 1px #000; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; padding: 0 10px; text-align: left; font-size: 12px; cursor: pointer; }
.hubt:active { transform: translateY(1px); }
.hubt.hot { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 1px #000; }
.hubt .dot { position: absolute; top: 6px; right: 8px; }
.hubl { font-size: 10px; line-height: 17px; }

/* upgrade list */
.buybar { flex: none; }
.ulist { flex: 1; min-height: 0; }
.urow .pf { background: none; border: 0; padding: 0; cursor: pointer; flex: none; }
.urow .info .nm { overflow: hidden; text-overflow: ellipsis; }
.urow .info { overflow: hidden; }
.buy { font-family: var(--mono); }
.no-dots .nav .dot { display: none; }

/* team */
.tsum { flex: none; padding: 3px 8px; font-size: 10px; line-height: 16px; box-shadow: inset 0 -1px 0 #000; }
.tteam { flex: none; padding: 1px 6px 3px; background: #1c2029; }
.tcells { display: grid; grid-template-columns: repeat(6, 48px); gap: 2px; margin-top: 2px; justify-content: start; }
.tcell { background: none; border: 0; padding: 0; width: 48px; height: 48px; cursor: pointer; position: relative; display: grid; place-items: center; }
.tcell.drop { outline: 1px dashed #8fc3ff; outline-offset: -1px; }
.tcell.rf { box-shadow: inset 0 0 0 2px var(--rc, #3a3f4b), 0 0 0 1px #000; }
.tflt { flex: none; height: 24px; padding: 0 6px; gap: 4px; }
.tflt .btn { height: 18px; font-size: 9px; padding: 0 4px; }
.tinv { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px; padding: 2px 6px; }
.itile { background: none; border: 0; padding: 0; cursor: pointer; }
.tpre { flex: none; height: 32px; padding: 0 6px; background: #1f232d; box-shadow: inset 0 1px 0 #000; gap: 4px; }
.tpre .seg .btn { padding: 0 6px; }
.bgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px 6px; align-content: start; }
.bcard { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0; cursor: pointer; }
.chead { flex: none; height: 32px; padding: 0 8px; background: #1f232d; box-shadow: inset 0 -1px 0 #000; }
.clist { flex: 1; min-height: 0; }
.crow { display: flex; align-items: center; gap: 3px; padding: 2px 4px; box-shadow: inset 0 -1px 0 #11141a; min-height: 36px; }
.cfac { width: 58px; flex: none; font-size: 10px; border-left: 3px solid; padding-left: 3px; display: flex; flex-direction: column; line-height: 1.2; }
.cfac small { font-size: 9px; font-weight: 400; }
.ccells { display: flex; flex-wrap: wrap; gap: 1px; flex: 1; }
.ccell { background: none; border: 0; padding: 0; cursor: pointer; }
.cbonus { width: 46px; flex: none; color: #b5e08a; text-align: right; line-height: 1.2; }
.cinfo { flex: none; min-height: 48px; padding: 5px 8px; background: #1f232d; box-shadow: inset 0 1px 0 #000; font-size: 10px; line-height: 16px; }

/* gacha */
.banner { position: relative; flex: none; margin: 6px 6px 0; left: auto; right: auto; top: auto; }
.bfeat { position: absolute; }
.btxt { position: absolute; left: 196px; top: 8px; right: 8px; font-size: 10px; line-height: 14px; text-shadow: 1px 1px 0 #000; }
.brate { position: absolute; right: 8px; bottom: 8px; }
.rateup { position: absolute; left: 8px; top: 6px; background: var(--red); color: #fff; font: 700 9px/1.2 var(--mono); padding: 1px 4px; box-shadow: 0 0 0 1px #000; }
.gtxt { flex: none; padding: 4px 8px; font-size: 10px; line-height: 15px; }
.grow { flex: none; display: flex; gap: 5px; padding: 2px 6px; }
.gbtn:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
.gbtn.dis { filter: grayscale(.6) brightness(.8); }
.gbtn .badge { top: 4px; right: 4px; }
.btn > .badge { position: relative; top: auto; right: auto; flex: none; }   /* a red dot inside a text button (Đổi 100 điểm, GDD 18.1) sits after the label: an absolute corner dot covered the ▶ */
.gcur { flex: none; height: 32px; padding: 0 8px; }
.ghist { flex: none; height: 30px; padding: 0 8px; background: #1f232d; box-shadow: inset 0 1px 0 #000; }
.hh { display: inline-block; }
.gnote { padding: 6px 8px; line-height: 11px; }

/* adventure */
.advh { flex: none; height: 36px; padding: 0 8px; background: #1f232d; box-shadow: inset 0 -1px 0 #000; }
.asc { flex: 1; min-height: 0; overflow-y: auto; }
.acard { margin: 6px 6px 4px; padding: 6px 8px; font-size: 10px; line-height: 15px; height: 56px; }
.acard.locked { opacity: .6; }
.mitem { min-height: 36px; padding: 4px 10px; box-shadow: inset 0 -1px 0 #0b0d12, inset 0 -2px 0 #262b37; gap: 6px; }

/* ---------- layers: sheets, modals, full screens ---------- */
.layer.sheet { left: 0; right: 0; top: calc(40px + var(--sat, 0px)); bottom: calc(60px + var(--sab, 0px)); background: #1a1d25; display: flex; flex-direction: column; box-shadow: 0 -2px 0 #000, inset 0 1px 0 #4b546a; animation: sheetin .16s ease-out; }
.layer.sheet.s84 { top: 84px; }
@keyframes sheetin { from { transform: translateY(24px); } }
.layer.sheet > .reg { flex: none; position: relative; }
.layer.sheet > .reg-all { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.layer.sheet > .reg-body, .layer.sheet > .reg-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.layer.sheet > .reg-foot { margin-top: auto; }
.layer.sheet > .reg-fight:empty { display: none; }
.layer.sheet > .reg-fight { position: absolute; inset: 0; z-index: 5; }
.fightov { position: absolute; inset: 0; background: rgba(10,10,16,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.shead button { background: none; border: 0; padding: 0; font: inherit; }
.shead .back { padding: 0 6px; }
.layer.modal, .layer.full { inset: 0; }
.layer.modal > .reg, .layer.full > .reg { display: contents; }
.layer.modal { display: flex; align-items: center; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(5,6,10,.62); }
.mbox { position: relative; width: 288px; padding: 12px; background: #1d212b; box-shadow: 0 0 0 1px #000, 0 0 0 3px #59637c, 0 0 0 4px #000, 0 8px 24px rgba(0,0,0,.6); font-size: 10px; line-height: 17px; animation: pop .16s ease-out; }
.mbox.wide { width: 328px; }
.mbox.welcome { min-height: 300px; }
.wbtn { position: absolute; left: 12px; right: 12px; bottom: 14px; gap: 8px; }
.layer.relic { left: 0; right: 0; top: calc(240px + var(--sat, 0px)); bottom: calc(60px + var(--sab, 0px)); background: #181b23; display: flex; flex-direction: column; box-shadow: 0 -2px 0 #000, inset 0 1px 0 #4b546a; animation: sheetin .18s ease-out; }
.rhead { flex: none; background: #1f232d; box-shadow: inset 0 -1px 0 #000; }
.rfoot { margin-top: auto; }

/* pick 1/3 (relic, awakening) */
.picks { display: flex; gap: 6px; padding: 2px 6px; flex: none; }
.pick { position: relative; top: auto; left: auto; flex: 1; width: auto; min-width: 0; height: 216px; border: 0; font: inherit; color: inherit; }
.pick .ri { margin: 2px 0; }

/* unit sheet (M3): grid so the sprite sits left of the info */
.layer[data-view="S5a"] { display: grid; grid-template-columns: 160px 1fr; grid-template-rows: 44px 160px minmax(0, 1fr) auto; }
.layer[data-view="S5a"] > .reg-head { grid-column: 1 / 3; }
.layer[data-view="S5a"] > .reg-spr { grid-column: 1; grid-row: 2; }
.layer[data-view="S5a"] > .reg-info { grid-column: 2; grid-row: 2; }
.layer[data-view="S5a"] > .reg-body { grid-column: 1 / 3; grid-row: 3; overflow-y: auto; overscroll-behavior: contain; display: block; }
.layer[data-view="S5a"] > .reg-foot { grid-column: 1 / 3; grid-row: 4; margin: 0; }
.uspr { padding: 8px; }
.uinfo { padding: 8px 6px 0 0; font-size: 10px; }
.ufoot { padding: 6px 8px; font-size: 10px; line-height: 15px; background: #1f232d; box-shadow: inset 0 1px 0 #000; }
.t7spr { display: flex; align-items: flex-start; justify-content: space-around; padding: 6px 10px; height: 126px; }
.t7c.glow { filter: drop-shadow(0 0 4px #ffe27a); }
.t7need { padding: 4px 10px; font-size: 10px; line-height: 16px; background: #1f232d; box-shadow: inset 0 1px 0 #000, inset 0 -1px 0 #000; }
.t7btn { margin-top: auto; padding: 4px 8px; gap: 8px; }
.m16n { padding: 6px 10px; line-height: 16px; background: #1f232d; box-shadow: inset 0 1px 0 #000; }
.opt { background: none; border: 0; padding: 0; text-align: left; font: inherit; width: 100%; }
.opt:disabled { opacity: .45; cursor: default; }
.setb { flex: 1; min-height: 0; }
.dbg { padding: 8px 10px; background: #15171d; margin-top: 6px; }
.dbg .row { gap: 4px; margin-top: 4px; }
.dbg .btn { height: 22px; }

/* adventure sheets */
.tow { position: relative; height: 180px; }
.towr { position: absolute; left: 112px; top: 8px; right: 0; }
.towm { padding: 4px 8px; font-size: 10px; line-height: 16px; background: #1f232d; box-shadow: inset 0 1px 0 #000; }
.trow { height: 52px; padding: 0 10px; box-shadow: inset 0 -1px 0 #0b0d12, inset 0 -2px 0 #262b37; font-size: 10px; }
.dfoot { padding: 8px 10px; font-size: 10px; line-height: 16px; background: #1f232d; box-shadow: inset 0 1px 0 #000; }
.wboss { display: flex; gap: 10px; padding: 8px 10px; height: 160px; }
.wrec { padding: 4px 10px; font-size: 10px; line-height: 15px; }
.elist { flex: 1; min-height: 0; padding: 12px 8px 0; }
.ecard { margin-bottom: 14px; padding: 12px 8px 6px; font-size: 10px; line-height: 16px; }
.ecard.empty { border: 1px dashed #4b546a; display: flex; align-items: center; justify-content: center; color: #7c8191; height: 56px; padding: 0; background: none; box-shadow: none; }

/* revive (S8) */
.rvbg { position: absolute; inset: 0; background: linear-gradient(#241a33, #14121c); }
.rvhead { position: absolute; top: 0; left: 0; right: 0; height: 80px; padding-top: 18px; }
.rvcols { position: absolute; top: 80px; left: 6px; right: 6px; height: 280px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rvcols .pn { padding: 8px; font-size: 10px; line-height: 18px; overflow: hidden; }
.rvtxt { position: absolute; top: 366px; left: 10px; right: 10px; font-size: 10px; }
.rvbtns { position: absolute; top: 440px; left: 8px; right: 8px; }
.tut { background: rgba(5,6,10,.35); }
.tutcard { position: absolute; left: 16px; right: 16px; bottom: calc(76px + var(--sab, 0px)); padding: 10px; background: #1d212b; box-shadow: 0 0 0 1px #000, 0 0 0 3px #59637c; }
.hand { font-size: 26px; display: inline-block; animation: poke .7s ease-in-out infinite alternate; }
@keyframes poke { to { transform: translateY(-6px); } }

/* 3x3 machine (S6a): regions are anchored; extra height only adds space between the result and the buttons */
.slot .slot-bg, .slot .rvbg { position: absolute; inset: 0; }
.slot .slhead { position: absolute; left: 0; right: 0; top: var(--sat, 0px); }
.slot .sbar { position: absolute; left: 0; right: 0; top: calc(40px + var(--sat, 0px)); }
.slot .swell { position: absolute; left: 0; width: 360px; top: calc(72px + var(--sat, 0px)); height: 332px; }
.slot .spanel { position: absolute; left: 0; width: 360px; top: calc(404px + var(--sat, 0px)); height: 152px; }
.slot .pity { position: absolute; left: 0; right: 0; bottom: calc(60px + var(--sab, 0px)); }
.slot .sbtns { position: absolute; left: 0; right: 0; bottom: 0; height: calc(60px + var(--sab, 0px)); padding: 8px 8px 0; gap: 8px; }
.slhead .btn { height: 22px; }

/* hold-to-confirm: progress is a scaleX on a pseudo element (transform only) */
.hold::before { width: 100% !important; transform: scaleX(0); transform-origin: 0 50%; transition: none !important; }
.hold.holding::before { transform: scaleX(1); transition: transform 1.2s linear !important; }
.hold:active::before { width: 100% !important; }
.hold:disabled::before { display: none; }

/* settings that change rendering cost */
#stage.rm *, #stage.rm *::after { animation: none !important; transition: none !important; }
#stage.rm .hold.holding::before { transition: transform 1.2s linear !important; }
#stage[data-fps="eco"] .spr.idle { animation-duration: 1s; }
@media (prefers-reduced-motion: reduce) { #stage *, #stage *::after { animation: none !important; } }
.slhead .mhead { font-size: 11px; white-space: nowrap; letter-spacing: 0; }
.tcell > .slotdot { position: absolute; top: 1px; right: 1px; z-index: 6; pointer-events: none; }
