/* Action mode (third-person levels) */
body.act { background: #0B0E24; }
.dmg { position: fixed; left: 0; top: 0; opacity: 0; transform: translate(-50%, -50%); }
.dmg.go { animation: dmgUp .65s ease-out forwards; }
@keyframes dmgUp { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); } 30% { transform: translate(-50%, -80%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(.9); } }

/* ================= in-game HUD =================
   Layout rule: controls use physical sides (joystick = left thumb, actions = right thumb) in every language.
   All edges respect the phone's safe areas (notch, rounded corners, home bar). */
body.act {
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --glass: rgba(10, 8, 26, .66); --glass-b: rgba(255, 255, 255, .14);
  --edge: 10px;
  -webkit-touch-callout: none;
}
body.act .hud, body.act .hud * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* top bar: HP (right) · timer (center) · stats + pause (left) */
.a-top { position: absolute; top: calc(var(--edge) + var(--sat)); left: calc(var(--edge) + var(--sal)); right: calc(var(--edge) + var(--sar));
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 6px; pointer-events: none; }
.a-top > * { pointer-events: auto; }
.a-hp { position: relative; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 8px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-b);
  max-width: 250px; min-width: 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.a-hp-ico { font-size: 16px; line-height: 1; }
.a-hp-bar { position: relative; flex: 1; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; min-width: 36px; }
.a-hp-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #FF2E4D, #FF8A5C); box-shadow: 0 0 10px rgba(255, 46, 77, .8); transition: width .2s ease-out; }
.a-hp b { font-family: var(--display); font-size: 16px; min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
.hud.low .a-hp { border-color: rgba(255, 46, 77, .8); animation: hpLow .8s ease-in-out infinite alternate; }
@keyframes hpLow { to { box-shadow: 0 0 0 3px rgba(255, 46, 77, .25); } }

.a-timer { display: grid; justify-items: center; min-width: 84px; padding: 3px 14px 5px; border-radius: 14px; background: var(--glass); border: 1px solid rgba(255, 210, 63, .45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.a-timer small { font-size: 10px; font-weight: 700; color: #CFC6F0; line-height: 1.2; white-space: nowrap; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
.a-timer b { font-family: var(--display); font-size: 26px; line-height: 1; direction: ltr; font-variant-numeric: tabular-nums; color: #fff; }
.hud.danger .a-timer { border-color: #FF2E4D; animation: pulse .5s infinite; }
.hud.danger .a-timer b { color: #FF5470; text-shadow: 0 0 14px #FF2E4D; }
.hud.danger::before { content: ''; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px 24px rgba(255, 30, 60, .3); animation: pulse 1s infinite; }

.a-right { display: flex; gap: 6px; justify-content: flex-end; align-items: center; min-width: 0; }
.a-stats { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-b);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); min-width: 0; }
.a-stats .st { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.a-stats b { font-family: var(--display); font-size: 16px; direction: ltr; font-variant-numeric: tabular-nums; }
.a-stats .gold b { color: var(--haz); }
.a-pause { width: 40px; height: 40px; flex: none; border-radius: 14px; font-size: 16px; background: var(--glass); border-color: var(--glass-b); transition: transform .12s; }
.a-pause:active { transform: scale(.9); }

/* objective pill + distance */
.a-obj { position: absolute; top: calc(var(--edge) + var(--sat) + 48px); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center;
  width: max-content; max-width: min(520px, calc(100% - 24px)); padding: 6px 14px 6px 12px; border-radius: 999px; background: var(--glass); border: 1px solid rgba(57, 255, 136, .55);
  box-shadow: 0 0 18px -6px rgba(57, 255, 136, .7); pointer-events: none; font-size: 13px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .25s; }
.a-obj b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-obj .o-ico { font-size: 14px; }
.a-obj small { flex: none; font-weight: 800; font-size: 12px; color: #39FF88; direction: rtl; }
.a-obj small:empty, .a-obj:has(b:empty) { display: none; }

/* on-screen objective marker */
.obj-arrow { position: fixed; left: 0; top: 0; display: grid; justify-items: center; gap: 2px; pointer-events: none; z-index: 4; }
.obj-arrow i { font-style: normal; font-size: 28px; line-height: 1; color: #39FF88; text-shadow: 0 0 12px #39FF88, 0 2px 0 #000; transition: transform .1s; }
.obj-arrow small { font-weight: 800; font-size: 11px; text-shadow: 0 1px 2px #000; background: rgba(8, 4, 15, .65); padding: 1px 7px; border-radius: 8px; white-space: nowrap; }
.obj-arrow.edge i { font-size: 34px; }
.obj-arrow:not(.edge) i { animation: qbounce 1s infinite; }
@keyframes qbounce { 50% { translate: 0 -6px; } }

/* minimap: top corner on the HP side, small, tap = full map */
.mm-wrap { position: absolute; top: calc(var(--edge) + var(--sat) + 90px); right: calc(var(--edge) + var(--sar)); width: 92px; height: 92px; pointer-events: none; }
.minimap-a { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); cursor: pointer; pointer-events: auto; opacity: .92; }
.map-btn { position: absolute; bottom: -4px; left: -4px; width: 30px; height: 30px; font-size: 14px; border-radius: 50%; background: var(--glass); pointer-events: auto; }

/* boss bar sits below the objective and never under the minimap */
.boss { top: calc(var(--edge) + var(--sat) + 90px); left: calc(var(--edge) + var(--sal) + 6px); right: calc(var(--edge) + var(--sar) + 104px); width: auto; transform: none; }
.boss b { font-size: 15px; }
.boss div { height: 10px; }

/* combo counter: left edge, above the joystick, away from the hero */
.combo { position: absolute; top: 28%; left: calc(14px + var(--sal)); display: grid; justify-items: center; opacity: 0; pointer-events: none; transform: rotate(-6deg); transition: opacity .2s; }
.combo.show { opacity: 1; } .combo.pop { animation: pop .3s var(--ease); }
.combo b { font-family: var(--display); font-size: 42px; line-height: 1; color: #FFD23F; text-shadow: 0 3px 0 #7A5200, 0 0 18px rgba(255, 210, 63, .55); }
.combo small { font-weight: 900; font-size: 12px; color: #fff; text-shadow: 0 2px 0 #000; }

/* banner: above the hero, wraps instead of running off-screen */
.banner { top: 25%; width: max-content; max-width: min(92vw, 720px); white-space: normal; text-align: center; line-height: 1.15; font-size: clamp(22px, 5.6vw, 44px); }

/* toasts while playing: mid-upper screen, never under the controls */
body.playing .toast { top: calc(36% + var(--sat)); bottom: auto; padding: 9px 16px; font-size: 14px; background: rgba(255, 255, 255, .95); }
body.playing .trophy-pop { top: calc(var(--edge) + var(--sat) + 88px); }

/* ---------- joystick (left thumb) ---------- */
body.act .joy { width: 128px; height: 128px; left: calc(30px + 64px + var(--sal)); top: calc(100% - 30px - 64px - var(--sab)); z-index: 5;
  background: radial-gradient(circle, rgba(255, 255, 255, .02) 40%, rgba(255, 255, 255, .12) 70%); border: 2px solid rgba(255, 255, 255, .38);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), inset 0 0 20px rgba(0, 0, 0, .25); transition: opacity .2s, border-color .2s, box-shadow .2s; }
body.act .joy i { width: 54px; height: 54px; background: radial-gradient(circle at 35% 30%, #fff, #D9D6EA 70%); box-shadow: 0 4px 10px rgba(0, 0, 0, .45); }
body.act .joy.run { border-color: #FFB04A; box-shadow: 0 0 0 4px rgba(255, 160, 60, .25), inset 0 0 20px rgba(255, 140, 40, .25); }
.joy-tip { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font-size: 11px; font-weight: 800; color: rgba(255, 255, 255, .75); white-space: nowrap; text-shadow: 0 1px 2px #000; transition: opacity .2s; }
body.act .joy.on .joy-tip { opacity: 0; }

/* ---------- action buttons (right thumb) ----------
   The cluster is a 0x0 anchor in the bottom-right corner; each button is placed by its centre (--x left, --y up) and size (--d). */
.a-buttons { position: absolute; right: calc(14px + var(--sar)); bottom: calc(14px + var(--sab)); width: 0; height: 0; pointer-events: none; }
.a-btn { --d: 60px; --x: 0px; --y: 0px; position: absolute; right: calc(var(--x) - var(--d) / 2); bottom: calc(var(--y) - var(--d) / 2); width: var(--d); height: var(--d);
  pointer-events: auto; border-radius: 50%; display: grid; place-items: center; align-content: center; gap: 1px; color: #fff;
  border: 2px solid rgba(255, 255, 255, .75); box-shadow: 0 5px 0 rgba(0, 0, 0, .45), 0 10px 22px rgba(0, 0, 0, .35);
  transition: transform .08s ease-out, filter .2s, opacity .2s; touch-action: none; -webkit-user-select: none; user-select: none; }
.a-btn.down { transform: scale(.9); filter: brightness(1.15); }
.a-btn span { font-size: 26px; line-height: 1; pointer-events: none; }
.a-btn small { font-size: 10px; font-weight: 800; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); pointer-events: none; }

.a-btn.attack { --d: 88px; --x: 44px; --y: 44px; border-width: 3px; background: radial-gradient(circle at 35% 30%, #FF8FA0, #FF2E4D 62%, #A3002A); }
.a-btn.attack span { font-size: 36px; }
.a-btn.attack small { font-size: 11px; }
.a-btn.attack .ammo { position: absolute; top: -6px; left: -6px; background: #1B0F00; color: #FFD23F; border: 2px solid #FFD23F; border-radius: 10px; font-size: 12px; padding: 1px 7px; font-weight: 800; direction: ltr; }

.a-btn.dash { --d: 62px; --x: 142px; --y: 40px; background: radial-gradient(circle at 35% 30%, #CFF7FF, #22B8E4 70%); }
.a-btn.dash.cool { filter: grayscale(1) brightness(.6); }

.a-btn.special { --d: 62px; --x: 114px; --y: 114px; background: conic-gradient(#FFD23F var(--p, 0%), rgba(8, 4, 15, .85) 0); }
.a-btn.special::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: #2A0A18; }
.a-btn.special span, .a-btn.special small { position: relative; }
.a-btn.special:not(.ready) span { filter: grayscale(.5); opacity: .85; }
.a-btn.special.ready { animation: ultR .7s ease-in-out infinite alternate; }
.a-btn.special.ready::before { background: radial-gradient(circle, #FF2E4D, #7A0019); }

.a-btn.swap { --d: 54px; --x: 40px; --y: 142px; background: radial-gradient(circle at 35% 30%, #FFE7A3, #C9A227 70%); color: #1B0F00; }
.a-btn.swap span { font-size: 22px; } .a-btn.swap small { color: #fff; }

.a-btn.bandage { --d: 52px; --x: 40px; --y: 212px; background: radial-gradient(circle at 35% 30%, #fff, #E8EDF2 60%, #B8C2CC); color: #160B2E; }
.a-btn.bandage b { position: absolute; top: -5px; left: -5px; background: #FF2E4D; color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 6px; }
.a-btn.bandage span { font-size: 22px; }

/* context button: pops in next to the attack cluster when something can be used */
.a-btn.use { --d: 76px; --x: 140px; --y: 196px; background: conic-gradient(#39FF88 var(--p, 0%), rgba(8, 4, 15, .85) 0); transform: scale(0); opacity: 0; visibility: hidden;
  transition: transform .22s var(--ease), opacity .15s, visibility 0s .22s; }
.a-btn.use::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #15633A, #0B3D22); }
.a-btn.use span { position: relative; font-size: 30px; }
.a-btn.use.show { transform: scale(1); opacity: 1; visibility: visible; transition: transform .22s var(--ease), opacity .15s; animation: useIn 1.4s ease-in-out .3s infinite; }
.a-btn.use.show.down { transform: scale(.92); animation: none; }
@keyframes useIn { 50% { box-shadow: 0 5px 0 rgba(0, 0, 0, .45), 0 0 0 7px rgba(57, 255, 136, .22); } }
.use-tip { position: absolute !important; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 5px 10px; border-radius: 10px; white-space: nowrap;
  background: rgba(10, 40, 24, .92); border: 1px solid rgba(57, 255, 136, .6); color: #fff; font-size: 12px !important; font-weight: 800; text-shadow: none !important; }
.use-tip:empty { display: none; }

/* desktop / mouse: smaller, quieter buttons with key hints */
@media (pointer: fine) {
  .a-buttons { transform: scale(.78); transform-origin: 100% 100%; }
  .a-btn { opacity: .82; } .a-btn:hover { opacity: 1; }
  .a-btn[data-key]::after { content: attr(data-key); position: absolute; top: -8px; right: -8px; min-width: 20px; padding: 2px 6px; border-radius: 7px; font: 800 11px var(--body);
    background: rgba(10, 8, 26, .9); color: #fff; border: 1px solid rgba(255, 255, 255, .35); }
  body.act .joy { display: none; }
}
@media (pointer: fine) and (min-width: 900px) {
  .mm-wrap { width: 150px; height: 150px; top: calc(var(--edge) + 92px); }
  .boss { right: calc(var(--edge) + 170px); left: 50%; transform: translateX(-50%); width: min(520px, 46vw); right: auto; }
  .a-obj { font-size: 14px; }
}
/* touch: hide the base joystick when not playing input */
@media (pointer: coarse) { body.act .joy { opacity: .55; } body.act .joy.on { opacity: 1; } }

/* phones held sideways */
@media (orientation: landscape) and (max-height: 520px) {
  body.act { --edge: 8px; }
  .a-top { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .a-hp, .a-stats { height: 36px; } .a-pause { width: 36px; height: 36px; }
  .a-timer { padding: 2px 12px 3px; } .a-timer b { font-size: 22px; } .a-timer small { font-size: 9px; }
  .a-obj { top: calc(var(--edge) + var(--sat) + 42px); font-size: 12px; padding: 4px 12px; max-width: 46vw; }
  .mm-wrap { top: calc(var(--edge) + var(--sat) + 44px); width: 80px; height: 80px; }
  .boss { top: calc(var(--edge) + var(--sat) + 74px); left: 50%; right: auto; transform: translateX(-50%); width: min(420px, 44vw); }
  .banner { top: 30%; font-size: clamp(20px, 4.2vw, 34px); }
  .combo { top: 26%; } .combo b { font-size: 34px; }
  body.act .joy { width: 116px; height: 116px; left: calc(36px + 58px + var(--sal)); top: calc(100% - 18px - 58px - var(--sab)); }
  body.act .joy-tip { display: none; }
  .a-buttons { right: calc(18px + var(--sar)); bottom: calc(12px + var(--sab)); }
  .a-btn.attack { --d: 84px; --x: 42px; --y: 42px; }
  .a-btn.dash { --d: 58px; --x: 134px; --y: 36px; }
  .a-btn.special { --d: 58px; --x: 106px; --y: 108px; }
  .a-btn.swap { --d: 50px; --x: 36px; --y: 134px; }
  .a-btn.use { --d: 70px; --x: 200px; --y: 112px; }
  .a-btn.bandage { --d: 50px; --x: 214px; --y: 34px; }
  body.playing .toast { top: calc(28% + var(--sat)); }
  body.playing .trophy-pop { top: calc(var(--edge) + var(--sat) + 44px); }
  .menu-a { padding-top: 8px; } .m-hero { margin-top: 0; } .m-title { font-size: 54px; }
  .overlay h2 { font-size: 26px; } .stars { font-size: 44px; }
}
/* very narrow phones (e.g. 320-360px): tighten the top bar */
@media (max-width: 380px) {
  .a-hp { padding: 0 8px 0 6px; gap: 4px; } .a-hp-ico { display: none; }
  .a-stats { gap: 6px; padding: 0 8px; } .a-stats .st { font-size: 11px; } .a-stats b { font-size: 14px; }
  .a-timer { min-width: 72px; padding: 3px 10px 4px; } .a-timer b { font-size: 24px; }
}

/* menu */
.menu-a { position: fixed; inset: 0; z-index: 10; overflow-y: auto; padding: 16px 16px 30px; display: grid; justify-items: center; align-content: start; gap: 14px;
  background: linear-gradient(180deg, rgba(11, 14, 36, 0) 0%, rgba(11, 14, 36, .55) 40%, rgba(8, 6, 20, .96) 75%); }
.m-top { width: 100%; max-width: 680px; display: flex; }
.m-hero { text-align: center; display: grid; gap: 10px; justify-items: center; margin-top: 6vh; }
.m-title { margin: 0; font-family: var(--display); font-size: clamp(60px, 16vw, 120px); line-height: .88; color: #fff; text-shadow: 0 6px 0 #1B1650, 0 0 50px rgba(120, 140, 255, .45); }
.m-title em { font-style: normal; color: #FFD23F; text-shadow: 0 6px 0 #7A5200, 0 0 50px rgba(255, 180, 92, .6); }
.m-load { width: 220px; height: 8px; border-radius: 9px; background: rgba(255,255,255,.15); position: relative; }
.m-load i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, #FFD23F, #FF3D9A); transition: width .2s; }
.m-load small { position: absolute; top: 12px; inset-inline: 0; font-size: 12px; color: #CFC6F0; }
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 520px) { .levels { grid-template-columns: 1fr; } }
.lvl-card { position: relative; display: grid; gap: 4px; justify-items: start; text-align: start; padding: 16px; border-radius: 20px; overflow: hidden; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--lc) 30%, #141033), #0D0A22 75%); border: 2px solid color-mix(in srgb, var(--lc) 70%, transparent); transition: transform .2s var(--ease); }
.lvl-card:not(:disabled):hover { transform: translateY(-4px); }
.lvl-card.locked { filter: grayscale(.85) brightness(.6); }
.lvl-num { position: absolute; inset-inline-end: 12px; top: 4px; font-family: var(--display); font-size: 64px; opacity: .15; }
.lvl-ico { font-size: 34px; }
.lvl-card b { font-family: var(--display); font-size: 22px; } .lvl-card small { color: #CFC6F0; }
.lvl-meta { font-size: 13px; color: #FFD23F; font-weight: 700; }
.lvl-go { margin-top: 6px; background: #fff; color: #0B0E24; padding: 6px 14px; border-radius: 999px; font-weight: 800; }
.lvl-lock { margin-top: 6px; font-size: 13px; font-weight: 700; }
.brief-text { max-width: 460px; line-height: 1.7; color: #E6DEFF; margin: 0; }
.stars { display: flex; gap: 8px; font-size: 64px; line-height: 1; }
.stars span { color: rgba(255, 255, 255, .15); animation: starIn .5s var(--ease) both; }
.stars span.on { color: #FFD23F; text-shadow: 0 0 24px rgba(255, 210, 63, .8), 0 4px 0 #7A5200; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.rs-coins { font-size: 26px; font-weight: 800; } .rs-coins b { font-family: var(--display); color: #FFD23F; }
.results.lose h2 { color: #FF5470; }

/* full map */
.bigmap canvas { border-radius: 16px; border: 3px solid rgba(255,255,255,.3); box-shadow: 0 20px 60px rgba(0,0,0,.6); max-width: 92vw; max-height: 62vh; width: auto !important; height: auto !important; aspect-ratio: 1; }
.bigmap h2 { font-size: 28px; } .bigmap p { margin: 0; font-weight: 700; color: #39FF88; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 6px; } .legend i { width: 14px; height: 14px; display: inline-block; border-radius: 4px; }

/* progression UI */
.m-profile { width: min(680px, 100%); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mp-lvl { display: grid; justify-items: center; width: 56px; height: 56px; align-content: center; border-radius: 16px; background: linear-gradient(135deg, #39FF88, #22B8E4); color: #08140E; }
.mp-lvl b { font-family: var(--display); font-size: 24px; line-height: 1; } .mp-lvl small { font-size: 10px; font-weight: 800; }
.mp-xp { position: relative; flex: 1; min-width: 140px; height: 14px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; }
.mp-xp i { position: absolute; inset-block: 0; inset-inline-start: 0; background: linear-gradient(90deg, #39FF88, #22E4FF); }
.mp-xp span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.mp-chip { padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); font-weight: 700; font-size: 13px; color: #fff; }
.mp-chip.hot { background: linear-gradient(90deg, #FFD23F, #FF7A59); color: #1B0F00; border: 0; animation: pulse 1.2s infinite; }
.lb-tabs { flex-wrap: wrap; }
.lb-tabs button { min-width: 30%; }
.wlist, .trophies { display: grid; gap: 10px; }
.wcard { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); }
.wcard.sel { border-color: #39FF88; } .wcard.locked { opacity: .75; }
.wico { font-size: 38px; text-align: center; }
.winfo b { font-family: var(--display); font-size: 18px; } .winfo em { font-style: normal; font-size: 12px; color: #FFD23F; margin-inline-start: 6px; }
.wstats { display: grid; gap: 3px; margin-top: 6px; }
.wstats span { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; }
.wstats small { font-size: 11px; color: #B9B0D8; }
.wstats i { display: block; height: 6px; border-radius: 4px; background: linear-gradient(90deg, #FF7A59, #FFD23F); }
.wbtns { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sk-head, .tr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sk-head b, .tr-head b { font-family: var(--display); font-size: 20px; } .sk-head small { color: #B9B0D8; flex: 1; }
.tr-head .mp-xp { flex: 1; }
.branches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .branches { grid-template-columns: 1fr; } }
.branch { padding: 10px; border-radius: 18px; background: color-mix(in srgb, var(--bc) 10%, rgba(255,255,255,.03)); border: 1px solid color-mix(in srgb, var(--bc) 50%, transparent); display: grid; gap: 8px; align-content: start; }
.branch h3 { margin: 0; font-family: var(--display); color: var(--bc); }
.skill { display: grid; gap: 3px; text-align: start; padding: 10px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.1); color: #fff; }
.skill small { color: #CFC6F0; font-size: 12px; line-height: 1.35; }
.skill.can { border-color: var(--bc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bc) 30%, transparent); }
.skill.max { opacity: .7; }
.skill .pips i.on { background: var(--bc); box-shadow: 0 0 6px var(--bc); }
.trophy { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); }
.trophy.done { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, rgba(255,255,255,.03)); }
.tico { font-size: 32px; text-align: center; } .trophy:not(.done) .tico { filter: grayscale(1); opacity: .6; }
.trophy b { font-size: 15px; } .trophy small { display: block; color: #B9B0D8; font-size: 12px; }
.tbar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; margin: 5px 0 3px; }
.tbar i { display: block; height: 100%; background: var(--tc); }
.trophy-pop { position: fixed; z-index: 30; top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -140%); display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-radius: 18px;
  background: linear-gradient(135deg, #2A1650, #120833); border: 2px solid #FFD23F; box-shadow: 0 20px 50px rgba(0,0,0,.5); color: #fff; pointer-events: none; min-width: min(360px, 92vw); }
.trophy-pop.go { animation: tpop 2.8s var(--ease) forwards; }
@keyframes tpop { 0% { transform: translate(-50%, -140%); opacity: 0; } 12%, 85% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, -140%); opacity: 0; } }
.trophy-pop:not(.go) { opacity: 0; visibility: hidden; }
.tp-ico { font-size: 38px; } .trophy-pop div { display: grid; } .trophy-pop small { font-weight: 800; font-size: 12px; } .trophy-pop b { font-family: var(--display); font-size: 20px; } .trophy-pop span { font-size: 12px; color: #CFC6F0; }
.sec-h { font-family: var(--display); margin: 14px 0 8px; font-size: 18px; } .sec-h small { font-family: var(--body); font-weight: 500; font-size: 12px; color: #B9B0D8; margin-inline-start: 6px; }
.gdesc { display: block; color: #CFC6F0; font-size: 12px; margin-top: 4px; }
.m-top { justify-content: space-between; align-items: center; }

/* ================= menu usability (phones) ================= */
.menu-a { touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: calc(12px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) calc(30px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)); }
.m-tools { display: flex; gap: 6px; }
.m-tool { display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 52px; height: 48px; padding: 0 8px; border-radius: 14px; font-size: 18px; line-height: 1;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); transition: transform .12s, background .2s; }
.m-tool small { font-size: 10px; font-weight: 700; color: #CFC6F0; white-space: nowrap; }
.m-tool:active { transform: scale(.93); } .m-tool:hover { background: rgba(255, 255, 255, .12); }
.lb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.lb-tabs button { min-width: 0; min-height: 46px; padding: 8px 4px; font-size: 14px; line-height: 1.2; transition: background .2s, color .2s; }
@media (min-width: 700px) { .lb-tabs { grid-template-columns: repeat(6, 1fr); } .lb-tabs button { font-size: 13px; } }
.lb-panel { animation: screenIn .3s var(--ease); }
.lvl-card { min-height: 120px; width: 100%; }
.lvl-card:active:not(:disabled) { transform: scale(.98); }
.lvl-go { padding: 9px 18px; font-size: 15px; }
.wbtns .btn, .hero-card .btn, .meta-row .btn { min-height: 42px; }
.skill { min-height: 64px; }
@media (max-width: 520px) {
  .m-hero { margin-top: 2vh; gap: 8px; }
  .m-title { font-size: clamp(54px, 15vw, 80px); }
  .lb-sub { font-size: 14px; padding: 0 6px; }
  .heroes { grid-template-columns: repeat(2, 1fr); }
  .hero-card img, .hero-card .ph { width: 100px; height: 100px; }
  .wcard { grid-template-columns: 44px 1fr; padding: 10px; } .wico { font-size: 32px; }
  .wbtns { justify-content: stretch; } .wbtns .btn { flex: 1; }
}

/* ================= sheets: pause · how to play · settings ================= */
.overlay { overflow-y: auto; place-content: safe center; touch-action: pan-y;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px)); }
.sheet { width: min(440px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 20px 16px 16px; border-radius: 26px; text-align: center;
  background: linear-gradient(180deg, rgba(42, 22, 80, .96), rgba(16, 8, 40, .97)); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 30px 80px -20px #000, inset 0 1px 0 rgba(255, 255, 255, .08); animation: sheetIn .32s var(--ease); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.sheet h2 { font-size: clamp(26px, 7vw, 36px); }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-grid .btn { min-height: 50px; padding: 10px 8px; font-size: 15px; }
#tutorial, #settings { z-index: 14; }

/* how to play */
.tut-sheet { width: min(520px, calc(100vw - 32px)); }
.tut-body { display: grid; gap: 10px; text-align: start; }
.tut-lead { margin: -4px 0 2px; text-align: center; color: #D9D2F0; font-size: 14px; line-height: 1.5; }
.tut-phone { position: relative; height: 150px; border-radius: 18px; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; direction: ltr;
  background: linear-gradient(180deg, #2C3550, #1B2034); border: 2px solid rgba(255, 255, 255, .22); }
.tut-zone { position: relative; display: grid; place-items: center; align-content: center; gap: 4px; padding: 8px; direction: rtl; text-align: center; font-size: 12px; font-weight: 700; color: #E6DEFF; }
.tut-zone b { font-size: 14px; color: #fff; }
.tut-zone.move { background: rgba(57, 255, 136, .08); border-right: 2px dashed rgba(255, 255, 255, .25); }
.tut-zone.look { background: rgba(34, 228, 255, .06); padding-bottom: 44px; }
.tut-stick { width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); display: grid; place-items: center; }
.tut-stick::after { content: ''; width: 22px; height: 22px; border-radius: 50%; background: #fff; animation: tutStick 2.4s ease-in-out infinite; }
@keyframes tutStick { 25% { transform: translate(12px, -10px); } 50% { transform: translate(-10px, -12px); } 75% { transform: translate(0, 12px); } }
.tut-swipe { font-size: 26px; animation: tutSwipe 2s ease-in-out infinite; }
@keyframes tutSwipe { 50% { transform: translateX(-18px) rotate(-8deg); } }
.tut-dots { position: absolute; right: 8px; bottom: 8px; width: 60px; height: 40px; }
.tut-dots i { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .7); }
.tut-dots i:nth-child(1) { width: 26px; height: 26px; right: 0; bottom: 0; background: #FF2E4D; }
.tut-dots i:nth-child(2) { width: 16px; height: 16px; right: 32px; bottom: 2px; background: #22B8E4; }
.tut-dots i:nth-child(3) { width: 16px; height: 16px; right: 4px; bottom: 30px; background: #FFD23F; }
.tut-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tut-list li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); }
.tut-list .ti { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; }
.tut-list .ti.red { background: radial-gradient(circle at 35% 30%, #FF8FA0, #FF2E4D 65%); }
.tut-list .ti.blue { background: radial-gradient(circle at 35% 30%, #CFF7FF, #22B8E4 70%); }
.tut-list .ti.gold { background: #2A0A18; box-shadow: inset 0 0 0 3px #FFD23F; }
.tut-list .ti.green { background: #0B3D22; box-shadow: inset 0 0 0 3px #39FF88; }
.tut-list .ti.goal { background: rgba(57, 255, 136, .12); color: #39FF88; font-size: 20px; }
.tut-list b { display: block; font-size: 14px; } .tut-list small { display: block; font-size: 12px; color: #CFC6F0; line-height: 1.4; }
.kbd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kbd-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); font-size: 13px; }
.kbd-row span { flex: 1; color: #E6DEFF; }
kbd { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 8px; font: 800 12px var(--body); color: #fff; direction: ltr;
  background: linear-gradient(180deg, #3A3160, #221A44); border: 1px solid rgba(255, 255, 255, .25); box-shadow: 0 3px 0 rgba(0, 0, 0, .5); }
.tut-hint { margin: 0; font-size: 12px; color: #B9B0D8; text-align: center; }
@media (max-width: 420px) { .kbd-grid { grid-template-columns: 1fr; } }
@media (orientation: landscape) and (max-height: 520px) {
  .tut-sheet { width: min(760px, calc(100vw - 32px)); padding: 14px; gap: 8px; }
  .tut-sheet h2 { font-size: 24px; }
  .tut-body.touch { grid-template-columns: 1fr 1fr; align-items: start; }
  .tut-body.touch .tut-lead { grid-column: 1 / -1; margin: 0; }
  .tut-phone { height: 100%; min-height: 150px; }
  .tut-list li { padding: 6px 10px; } .tut-list .ti { width: 38px; height: 38px; font-size: 19px; } .tut-list li { grid-template-columns: 38px 1fr; }
  .kbd-grid { grid-template-columns: repeat(3, 1fr); }
  .sheet { padding: 14px; gap: 8px; }
  .set-sheet { width: min(560px, calc(100vw - 32px)); }
  #tutOk, #setClose { position: sticky; bottom: 0; z-index: 1; padding: 12px 18px; }
  .tut-list small { line-height: 1.3; }
}

/* settings */
.set-list { display: grid; gap: 8px; text-align: start; }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); }
.set-row > .si { font-size: 22px; width: 28px; text-align: center; }
.set-row > div { flex: 1; display: grid; gap: 2px; min-width: 0; }
.set-row b { font-size: 15px; } .set-row small { font-size: 12px; color: #B9B0D8; }
.set-row.col { flex-wrap: wrap; } .set-row.col > .seg-q, .set-row.col > .range { flex-basis: 100%; }
.switch { position: relative; flex: none; width: 56px; height: 32px; border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .2); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: transform .22s var(--ease); }
.switch[aria-checked="true"] { background: #39C97A; border-color: #6CFFAE; }
.switch[aria-checked="true"]::after { transform: translateX(-24px); }
.seg-q { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .25); }
.seg-q button { min-height: 40px; border-radius: 10px; font-size: 13px; font-weight: 700; color: #CFC6F0; transition: background .2s, color .2s; }
.seg-q button.on { background: #fff; color: #0B0E24; }
.set-row > .range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; height: 32px; accent-color: #39FF88; touch-action: pan-x; }
.range output { min-width: 44px; text-align: center; font-family: var(--display); font-size: 16px; direction: ltr; }
.range small { font-size: 11px; }
