/* Rooftop Brawl. Logical properties, so RTL and LTR share one file; the fight view stays LTR. */
:root {
    --bg: #0d0b16; --surface: #1a1526; --surface2: #241d36; --border: #3a2f55; --text: #f6f1ff; --muted: #b3a8cc;
    --accent: #ff8a3d; --accent2: #ffd166; --hot: #ff4f6d; --ok: #4ade80; --fury: #7af5ff; --ink: #0b0d18;
    --font: system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
#game:focus { outline: none; }
[hidden] { display: none !important; }

.game { max-inline-size: 1040px; margin-inline: auto; padding: 8px; }

/* ---------- menu and end card, over a live skyline ---------- */
.screen { position: relative; overflow: hidden; display: grid; border-radius: 18px; border: 1px solid var(--border); background: #120e1e; min-block-size: 480px; }
.backdrop { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; }
.screen::before {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: linear-gradient(180deg, rgba(13, 11, 22, .62), rgba(13, 11, 22, .2) 40%, rgba(13, 11, 22, .8));
}
.panel {
    position: relative; z-index: 2; display: grid; align-content: center; align-items: center;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-areas: "head head" "main col";
    gap: 12px 18px; padding: 18px 20px 20px;
}
.head { grid-area: head; text-align: center; }
.logo {
    margin: 0; font-size: clamp(1.9rem, 5.2vw, 3.1rem); font-weight: 900; line-height: 1.08; letter-spacing: .02em;
    text-transform: uppercase; font-style: italic; color: var(--accent2);
    background: linear-gradient(180deg, #fff3c4 12%, var(--accent2) 44%, var(--accent) 74%, #e2452f);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 3px 0 #1a0d0a) drop-shadow(0 0 18px rgba(255, 138, 61, .45));
}
.logo.lose { background-image: linear-gradient(180deg, #fff, #cfc6e4 50%, #7d7399); filter: drop-shadow(0 3px 0 #0b0812); }
.tag { margin: 4px 0 0; color: #e0d6f2; font-size: .95rem; text-shadow: 0 1px 3px #000; }

.heroes { grid-area: main; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hero {
    position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px 10px;
    border-radius: 16px; border: 2px solid rgba(255, 255, 255, .14); cursor: pointer; text-align: center;
    background: linear-gradient(180deg, rgba(36, 29, 54, .78), rgba(18, 14, 30, .93));
    transition: transform .16s, border-color .16s, box-shadow .16s;
}
.hero::before {
    content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .2s;
    background: radial-gradient(75% 48% at 50% 46%, rgba(255, 170, 80, .3), transparent 72%);
    background: radial-gradient(75% 48% at 50% 46%, color-mix(in srgb, var(--fx) 34%, transparent), transparent 72%);
}
.hero > * { position: relative; }
.hero canvas { inline-size: 100%; max-inline-size: 172px; aspect-ratio: 1; display: block; }
.hero b { font-size: 1.1rem; line-height: 1.2; }
.hero small { color: var(--muted); font-size: .76rem; }
.hero:hover { border-color: rgba(255, 255, 255, .4); }
.hero[aria-pressed="true"] {
    border-color: var(--fx); transform: translateY(-4px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .5), 0 0 26px -4px var(--fx);
}
.hero[aria-pressed="true"]::before { opacity: 1; }
.bars { inline-size: 100%; display: grid; gap: 3px; margin-block-start: 6px; }
.bar { display: grid; grid-template-columns: 4.4em minmax(0, 1fr); align-items: center; gap: 6px; font-size: .68rem; color: var(--muted); text-align: start; }
.bar i { block-size: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--fx) calc(var(--v) * 20%), rgba(255, 255, 255, .13) calc(var(--v) * 20%)); }
html[dir="rtl"] .bar i { transform: scaleX(-1); }

.col {
    grid-area: col; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; align-content: center; min-inline-size: 0; padding: 12px 14px 14px; text-align: start;
    border-radius: 16px; border: 1px solid rgba(255, 255, 255, .1); background: rgba(13, 11, 22, .78);
}
.desc { margin: 0; color: #e6dcf7; font-size: .86rem; line-height: 1.45; min-block-size: 2.9em; }
.spn { color: var(--fury); }
.col h3 { margin: 2px 0 -3px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pick {
    display: grid; gap: 4px; padding: 0; overflow: hidden; cursor: pointer; text-align: center;
    border-radius: 12px; border: 2px solid rgba(255, 255, 255, .13); background: var(--surface);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.sw { display: block; block-size: 30px; background: linear-gradient(180deg, #4b2a6a, #d9603f 62%, #ffc46b); }
.pick.neon .sw { background: linear-gradient(180deg, #0c1238, #5a2a9c 60%, #ff4fd8); }
.pick.storm .sw { background: linear-gradient(180deg, #0b1424, #2c4468 62%, #9ab8dc); }
.nm { display: grid; justify-items: center; gap: 2px; padding: 0 4px 6px; }
.nm b { font-size: .74rem; line-height: 1.25; }
.stars { display: inline-flex; gap: 1px; }
.stars i { inline-size: 14px; block-size: 14px; color: rgba(255, 255, 255, .2); }
.stars i.on { color: var(--accent2); filter: drop-shadow(0 0 4px rgba(255, 209, 102, .6)); }
.stars svg, .lock svg { inline-size: 100%; block-size: 100%; }
.lock { display: block; inline-size: 14px; block-size: 14px; color: var(--muted); }
.pick:hover { border-color: rgba(255, 255, 255, .4); }
.pick[aria-pressed="true"] { border-color: var(--accent2); box-shadow: 0 0 18px -4px var(--accent2); }
.pick[aria-disabled="true"] { cursor: not-allowed; }
.pick[aria-disabled="true"] .sw { filter: grayscale(.8) brightness(.55); }
.pick[aria-disabled="true"] .nm b { color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05); }
.seg button { border: 0; background: none; padding: 6px 4px; min-block-size: 38px; font-weight: 700; font-size: .86rem; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, #4a3a70, #33284f); color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }

.btn {
    appearance: none; border: 0; border-radius: 14px; padding: .65em 1.2em; min-block-size: 44px; cursor: pointer;
    font-weight: 900; font-size: 1rem; color: #2a1200; text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
    background: linear-gradient(180deg, #ffd166, var(--accent) 70%, #e2632a);
    box-shadow: 0 4px 0 #9c3d12, 0 8px 18px rgba(0, 0, 0, .4); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9c3d12, 0 3px 8px rgba(0, 0, 0, .4); }
.btn.ghost { background: rgba(255, 255, 255, .08); color: var(--text); text-shadow: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24); }
.btn.big { font-size: 1.3rem; letter-spacing: .04em; text-transform: uppercase; animation: rb-breathe 1.8s ease-in-out infinite; }

.prog { display: flex; align-items: center; gap: 10px; }
.tot { display: inline-flex; align-items: center; gap: 4px; color: var(--accent2); font-weight: 800; font-size: .9rem; }
.tot svg { inline-size: 18px; block-size: 18px; }
.medals { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; justify-content: flex-end; }
.medal {
    inline-size: 28px; block-size: 28px; padding: 4px; display: grid; place-items: center; cursor: pointer;
    border-radius: 50%; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05); color: rgba(255, 255, 255, .26);
}
.medal svg { inline-size: 100%; block-size: 100%; }
.medal.on { color: #2a1a00; background: radial-gradient(circle at 35% 30%, #fff3c4, var(--accent2) 45%, #d98e1f); border-color: #ffe9a8; box-shadow: 0 0 10px rgba(255, 209, 102, .45); }
.note { margin: 0; min-block-size: 1.35em; font-size: .8rem; line-height: 1.35; color: var(--muted); text-align: center; }
.note b { color: var(--text); }

/* end card */
.result { grid-area: main; display: grid; justify-items: center; gap: 12px; }
.rank {
    inline-size: 150px; aspect-ratio: 1; display: grid; place-content: center; justify-items: center; color: var(--accent2);
    border-radius: 50%; border: 5px solid currentColor; background: radial-gradient(circle, rgba(0, 0, 0, .62), rgba(0, 0, 0, .34));
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .4), 0 0 30px -6px currentColor; opacity: 0; transform: scale(2.2) rotate(-18deg);
}
.rank.in { opacity: 1; transform: rotate(-8deg); transition: transform .28s cubic-bezier(.2, 1.6, .4, 1), opacity .12s; }
.rank small { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: #fff; opacity: .85; }
.rank b { font-size: 4.2rem; line-height: .95; font-weight: 900; text-shadow: 0 4px 0 rgba(0, 0, 0, .5); }
.rank span { font-size: .78rem; font-weight: 800; color: #fff; }
.rank.rA { color: var(--fury); }
.rank.rB { color: #7cff9a; }
.rank.rC { color: #ffb86b; }
.rank.rD { color: #c9bfe0; }
.pts { text-align: center; }
.big { font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 4px 0 rgba(0, 0, 0, .5); }
.big.landed { animation: rb-land .35s; }
.badge { display: inline-block; margin-block-start: 8px; padding: 4px 14px; border-radius: 999px; background: linear-gradient(180deg, #fff3c4, var(--accent2)); color: #2a1a00; font-weight: 900; font-size: .85rem; animation: rb-badge 1s ease-in-out infinite alternate; }
.bestline { margin: 8px 0 0; color: #e0d6f2; font-size: .9rem; text-shadow: 0 1px 3px #000; }
.bestline b { color: #fff; }
.runstars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.st { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; background: rgba(255, 255, 255, .06); border-block-start: 3px solid var(--accent); }
.st.neon { border-color: #ff4fd8; }
.st.storm { border-color: #6aa8ff; }
.st small { font-size: .7rem; color: var(--muted); font-weight: 800; }
.grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .9rem; }
.grid span { color: var(--muted); }
.grid b { text-align: end; font-variant-numeric: tabular-nums; }
.gots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.got { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 12px; background: linear-gradient(90deg, rgba(255, 209, 102, .22), rgba(255, 209, 102, .05)); border: 1px solid rgba(255, 209, 102, .45); }
.got svg { inline-size: 26px; block-size: 26px; flex: none; color: var(--accent2); }
.got small, .toast small { display: block; font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent2); }
.got b { font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.actions .btn { flex: 1 1 auto; }
.confetti { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; inset-block-start: -14px; inline-size: 8px; block-size: 14px; border-radius: 2px; animation: rb-fall linear forwards; }

/* ---------- the fight ---------- */
.play-area { display: grid; gap: 8px; }
.stage {
    position: relative; aspect-ratio: 16 / 9; overflow: hidden; direction: ltr; touch-action: none; container-type: inline-size;
    border-radius: 16px; border: 1px solid var(--border); background: #000;
}
#view { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; }
/* everything drawn over the fight is sized in em, and the em follows the width of the stage */
.stage > :not(canvas) { font-size: 13px; font-size: clamp(10.5px, 1.5cqw, 16.5px); }
/* wide black bars for a boss walking in or going down */
.stage::before, .stage::after { content: ""; position: absolute; inset-inline: 0; z-index: 2; block-size: 9%; background: #000; pointer-events: none; transition: transform .35s ease; }
.stage::before { inset-block-start: 0; transform: translateY(-101%); }
.stage::after { inset-block-end: 0; transform: translateY(101%); }
.stage.cine::before, .stage.cine::after { transform: none; }

.hud {
    position: absolute; inset-inline: 0; inset-block-start: 0; z-index: 3; pointer-events: none;
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 1em; padding: .8em 1em 2.4em;
    background: linear-gradient(180deg, rgba(8, 6, 16, .74), rgba(8, 6, 16, .36) 55%, transparent); transition: opacity .3s;
}
.stage.cine .hud { opacity: 0; }
.me { display: flex; align-items: center; gap: .7em; min-inline-size: 0; }
.face { inline-size: 3.9em; block-size: 3.9em; flex: none; border-radius: 50%; border: .18em solid var(--accent2); background: var(--surface); box-shadow: 0 .2em .6em rgba(0, 0, 0, .5); }
.me.hurt .face { animation: rb-hurt .35s; }
.vitals { display: grid; gap: .32em; flex: 0 1 17em; min-inline-size: 0; }
.vitals b { font-size: 1em; line-height: 1.15; font-weight: 800; text-shadow: 0 1px 2px #000; }
.hp { position: relative; block-size: 1em; overflow: hidden; border-radius: .3em; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .28); transform: skewX(-12deg); }
.hp i, .track2 i { position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 100%; }
#hpBack, #bossBack { background: #fff; opacity: .9; transition: inline-size .6s .25s ease-out; }
#hp { background: linear-gradient(180deg, #b6ff8a, var(--ok) 45%, #1f9d55); transition: inline-size .12s; }
.me.low #hp { background: linear-gradient(180deg, #ff9aa8, var(--hot) 45%, #b3122e); animation: rb-low .5s infinite alternate; }
.fury { display: grid; grid-template-columns: repeat(3, 1fr); gap: .28em; }
.fury i { block-size: .5em; border-radius: .2em; transform: skewX(-12deg); background: linear-gradient(90deg, var(--fury) var(--f, 0%), rgba(255, 255, 255, .17) var(--f, 0%)); }
.fury i.full { box-shadow: 0 0 .6em var(--fury); }
.fury.ready i.full { animation: rb-glow .7s infinite alternate; }
.wpn { display: grid; justify-items: center; gap: .2em; color: #d7dde8; }
.wpn svg { inline-size: 1.9em; block-size: 1.9em; filter: drop-shadow(0 1px 2px #000); }
.wpn i { display: block; inline-size: 2.4em; block-size: .34em; overflow: hidden; border-radius: .2em; background: rgba(0, 0, 0, .6); }
.wpn u { display: block; block-size: 100%; background: var(--accent2); }

.mid { display: grid; justify-items: center; gap: .4em; }
.sc { display: grid; justify-items: center; line-height: 1; }
.k { font-size: .68em; letter-spacing: .12em; text-transform: uppercase; color: #d2c8e8; font-weight: 800; text-shadow: 0 1px 2px #000; }
#score { font-size: 1.9em; font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 .1em 0 rgba(0, 0, 0, .6); }
#score.bump { animation: rb-bump .3s; }
.track { position: relative; inline-size: 15em; block-size: .44em; margin-inline-end: 1.3em; border-radius: .3em; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .22); }
.track i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.track s { position: absolute; inset-block: -.22em; inline-size: 2px; margin-inline-start: -1px; background: rgba(255, 255, 255, .6); }
.track em { position: absolute; inset-block-start: 50%; inline-size: .9em; block-size: .9em; border-radius: 50%; background: #fff; border: .16em solid var(--accent); transform: translate(-50%, -50%); box-shadow: 0 0 .5em rgba(255, 209, 102, .8); }
.skull { position: absolute; inset-inline-start: 100%; inset-block-start: 50%; inline-size: 1.5em; block-size: 1.5em; transform: translate(.15em, -50%); color: #c9bfe0; filter: drop-shadow(0 1px 2px #000); }
.track.boss .skull { color: var(--hot); animation: rb-skull .5s infinite alternate; }

.side-r { display: flex; justify-content: flex-end; align-items: flex-start; gap: .45em; }
.lv { display: grid; justify-items: end; gap: .1em; margin-inline-end: .3em; line-height: 1.15; }
.hearts { color: var(--hot); font-size: 1.35em; letter-spacing: .08em; text-shadow: 0 1px 2px #000; }
.hearts.lost { animation: rb-shake .4s; }
.icon {
    pointer-events: auto; inline-size: 2.6em; block-size: 2.6em; min-inline-size: 34px; min-block-size: 34px; padding: 0; display: grid; place-items: center; cursor: pointer;
    border-radius: 50%; border: 1px solid rgba(255, 255, 255, .24); background: rgba(13, 11, 22, .62); color: #fff;
}
.icon svg { inline-size: 56%; block-size: 56%; }
.icon[aria-pressed="false"] { color: var(--muted); }

.combo {
    position: absolute; inset-inline-start: 1.2em; inset-block-start: 6.4em; z-index: 3; pointer-events: none;
    display: grid; grid-template-columns: auto auto; justify-content: start; align-items: end; column-gap: .4em;
    opacity: 0; transform: translateX(-1em); transition: opacity .25s, transform .25s; text-shadow: 0 .12em 0 rgba(0, 0, 0, .6);
}
.combo.on { opacity: 1; transform: none; }
.combo b { display: inline-block; font-size: 3.4em; font-weight: 900; font-style: italic; line-height: .9; color: var(--accent2); }
.combo b.pop { animation: rb-pop .22s; }
.combo span { font-size: .85em; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; padding-block-end: .3em; }
.ct { grid-column: 1 / -1; display: block; inline-size: 6.5em; block-size: .36em; margin-block-start: .35em; overflow: hidden; border-radius: .2em; background: rgba(0, 0, 0, .55); }
.ct u { display: block; block-size: 100%; background: linear-gradient(90deg, var(--hot), var(--accent2)); }
.combo em { grid-column: 1 / -1; min-block-size: 1.3em; margin-block-start: .25em; font-size: 1.35em; font-weight: 900; font-style: italic; color: #fff; transform-origin: 0 50%; }
.combo em.pop { animation: rb-word .5s; }

.toast {
    position: absolute; right: 1em; inset-block-start: 6.4em; z-index: 4; pointer-events: none;
    display: flex; align-items: center; gap: .6em; padding: .5em .9em; border-radius: .9em; color: #fff;
    background: linear-gradient(90deg, rgba(42, 26, 0, .94), rgba(64, 42, 6, .94)); border: 1px solid var(--accent2);
    opacity: 0; transform: translateX(110%); transition: opacity .3s, transform .3s cubic-bezier(.2, 1.3, .4, 1);
}
.toast.on { opacity: 1; transform: none; }
.toast svg { inline-size: 2em; block-size: 2em; flex: none; color: var(--accent2); }
.toast small { font-size: .68em; }
.toast b { font-size: .95em; }

.go { position: absolute; inset-inline-end: 1.4em; inset-block-start: 36%; z-index: 3; display: flex; align-items: center; gap: .3em; color: var(--accent2); opacity: 0; pointer-events: none; }
.go span { font-size: 2.3em; font-weight: 900; font-style: italic; text-shadow: 0 .1em 0 #000; }
.go svg { inline-size: 3em; block-size: 3em; filter: drop-shadow(0 .15em 0 #000); }
.go.on { animation: rb-go .7s infinite; }

.banner {
    position: absolute; inset-inline: 0; inset-block-start: 29%; z-index: 4; pointer-events: none;
    display: grid; justify-items: center; gap: .15em; padding: .7em 1em; text-align: center;
    background: linear-gradient(90deg, transparent, rgba(8, 6, 16, .8) 24%, rgba(8, 6, 16, .8) 76%, transparent);
    opacity: 0; transform: scaleY(.5); transition: opacity .22s, transform .22s;
}
.banner.on { opacity: 1; transform: none; }
.banner b { font-size: 2.5em; line-height: 1.12; font-weight: 900; font-style: italic; letter-spacing: .02em; text-transform: uppercase; color: #fff; text-shadow: 0 .07em 0 var(--accent), 0 .15em 0 rgba(0, 0, 0, .6); }
.banner.on b { animation: rb-slam .35s; }
.banner small { font-size: 1.05em; font-weight: 700; letter-spacing: .05em; color: var(--accent2); }
.banner.boss { background: linear-gradient(90deg, transparent, rgba(60, 6, 18, .86) 24%, rgba(60, 6, 18, .86) 76%, transparent); }
.banner.boss b { text-shadow: 0 .07em 0 var(--hot), 0 .15em 0 rgba(0, 0, 0, .6); }
.banner.ok b { color: var(--accent2); text-shadow: 0 .07em 0 #b3640f, 0 .15em 0 rgba(0, 0, 0, .6); }

.coach {
    position: absolute; left: 50%; inset-block-start: 18.5%; z-index: 3; pointer-events: none;
    inline-size: max-content; max-inline-size: min(82%, 36em); padding: .5em 1.1em; text-align: center; line-height: 1.5; font-weight: 600; color: #fff;
    border-radius: 1.4em; border: 1px solid rgba(122, 245, 255, .6); background: rgba(13, 11, 22, .88); box-shadow: 0 .3em 1em rgba(0, 0, 0, .45);
    opacity: 0; transform: translate(-50%, -.6em); transition: opacity .3s, transform .3s;
}
.coach.on { opacity: 1; transform: translate(-50%, 0); animation: rb-coach 1.6s .4s ease-in-out infinite alternate; }
.coach b { color: var(--accent2); }
kbd {
    display: inline-block; min-inline-size: 1.7em; padding: .08em .4em; margin-inline: .12em; text-align: center; direction: ltr;
    border-radius: .35em; background: #fff; color: #1a1526; font: 800 .86em/1.35 var(--font); box-shadow: 0 .15em 0 #9d93b8;
}

.bossbar {
    position: absolute; left: 50%; inset-block-end: 3.5%; z-index: 3; pointer-events: none;
    inline-size: min(54%, 34em); display: grid; justify-items: center; gap: .25em;
    opacity: 0; transform: translate(-50%, 1em); transition: opacity .3s, transform .3s;
}
.bossbar.on { opacity: 1; transform: translate(-50%, 0); }
.bossbar span { font-size: 1.05em; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 0 #000, 0 0 .6em var(--hot); }
.track2 { position: relative; inline-size: 100%; block-size: 1.05em; overflow: hidden; border-radius: .3em; background: rgba(0, 0, 0, .68); border: 1px solid rgba(255, 255, 255, .32); transform: skewX(-14deg); }
#bossHp { background: linear-gradient(180deg, #ff9aa8, var(--hot) 45%, #a3122e); transition: inline-size .12s; }
.bossbar.rage #bossHp { background: linear-gradient(180deg, #ffd166, #ff6a2b 45%, #c41e1e); animation: rb-low .35s infinite alternate; }
.bossbar.rage span { color: var(--accent2); }

.overlay { position: absolute; inset: 0; z-index: 6; display: none; place-items: center; padding: 1em; background: rgba(8, 6, 16, .74); }
.overlay.on { display: grid; }
.box {
    inline-size: min(100%, 31em); max-block-size: 100%; overflow: auto; padding: 1.1em 1.4em 1.3em; text-align: center;
    border-radius: 1.2em; border: 1px solid var(--border); background: linear-gradient(180deg, #2a2140, #171226); box-shadow: 0 1em 3em rgba(0, 0, 0, .6);
    animation: rb-box .25s;
}
.box h2 { margin: 0 0 .5em; font-size: 1.7em; font-weight: 900; }
.box.clear h2 { color: var(--accent2); }
.box .btn { font-size: 1em; border-radius: .9em; min-block-size: 2.9em; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: .3em 1.2em; margin-block-end: .8em; font-size: .95em; color: var(--muted); }
.row b { color: var(--text); }
.ctl { display: grid; grid-template-columns: auto 1fr; gap: .45em 1em; margin: 0 0 1em; text-align: start; font-size: .92em; }
.ctl dt { color: var(--muted); font-weight: 700; }
.ctl dd { margin: 0; }
.tipsl { display: grid; gap: .35em; margin: 0 0 1em; padding: 0; list-style: none; font-size: .95em; color: #e6dcf7; }
.stars3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5em; margin-block-end: .9em; }
.stars3 span { display: grid; justify-items: center; gap: .2em; color: rgba(255, 255, 255, .18); opacity: 0; transform: scale(.4); }
.stars3 span.in { opacity: 1; transform: none; transition: transform .3s cubic-bezier(.2, 1.7, .4, 1), opacity .15s; }
.stars3 span.won { color: var(--accent2); }
.stars3 span.won svg { filter: drop-shadow(0 0 .5em rgba(255, 209, 102, .8)); }
.stars3 svg { inline-size: 3.4em; block-size: 3.4em; }
.stars3 small { font-size: .74em; line-height: 1.25; color: var(--muted); }
.stars3 .won small { color: #fff; }
.tally { display: grid; grid-template-columns: 1fr auto; gap: .3em 0; text-align: start; }
.tally span, .tally b { opacity: 0; transform: translateY(.4em); transition: opacity .25s, transform .25s; }
.tally .on { opacity: 1; transform: none; }
.tally span { color: var(--muted); }
.tally b { padding-inline-start: 1em; text-align: end; font-variant-numeric: tabular-nums; }
.tally .total { margin-block-start: .2em; padding-block-start: .3em; border-block-start: 1px solid var(--border); color: var(--accent2); font-size: 1.25em; font-weight: 900; }

/* ---------- touch controls: a stick that appears under the left thumb, four buttons on the right ---------- */
.pad { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; block-size: 200px; direction: ltr; touch-action: none; --pb: 78px; }
.stickzone { position: relative; border-radius: 16px; border: 1px dashed rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .03); touch-action: none; }
.stick {
    position: absolute; left: calc(50% - 62px); top: calc(50% - 62px); inline-size: 124px; block-size: 124px; pointer-events: none;
    border-radius: 50%; border: 2px solid rgba(255, 255, 255, .3); background: radial-gradient(circle, rgba(255, 255, 255, .12), rgba(255, 255, 255, .03));
    transition: opacity .2s, border-color .2s;
}
.stick i { position: absolute; inset: 27%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #c9bfe0 55%, #8f84ad); box-shadow: 0 4px 10px rgba(0, 0, 0, .5); }
.stick.held { border-color: var(--accent2); }
.acts { display: grid; grid-template-columns: repeat(2, var(--pb)); grid-template-rows: repeat(2, var(--pb)); grid-template-areas: "sp jp" "dg at"; gap: 12px; align-content: center; padding-inline: 6px; }
.pb {
    display: grid; place-content: center; justify-items: center; gap: 1px; padding: 0; touch-action: none; color: #fff;
    border-radius: 50%; border: 2px solid rgba(255, 255, 255, .34); background: rgba(26, 21, 38, .7);
    font-size: .66rem; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); transition: transform .06s, filter .06s, opacity .2s;
}
.pb svg { inline-size: 26px; block-size: 26px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5)); }
.pb.at { grid-area: at; transform: scale(1.1); border-color: #ffd9b8; background: radial-gradient(circle at 35% 30%, rgba(255, 178, 122, .95), rgba(255, 138, 61, .9) 55%, rgba(194, 82, 26, .9)); }
.pb.jp { grid-area: jp; }
.pb.dg { grid-area: dg; }
.pb.sp { grid-area: sp; opacity: .5; border-color: rgba(122, 245, 255, .6); }
.pb.sp.ready { opacity: 1; color: #04222a; text-shadow: none; background: radial-gradient(circle at 35% 30%, #e6fdff, var(--fury) 55%, #2aa9bd); animation: rb-glow .7s infinite alternate; }
.pb.dg.wait { opacity: .42; }
.pb.down { transform: scale(.92); filter: brightness(1.35); }
.pb.at.down { transform: scale(1.01); }
.keys { margin: 0; text-align: center; color: var(--muted); font-size: .8rem; line-height: 2; }

/* a small stage (a phone held upright outside the site's play screen): only the essentials stay in the HUD */
@container (max-width: 560px) {
    .hud { gap: .5em; padding-inline: .6em; }
    .track, .lv .k, .wpn i { display: none; }
    .icon { min-inline-size: 30px; min-block-size: 30px; }
    .face { inline-size: 3.2em; block-size: 3.2em; }
    .coach { inset-block-start: 27%; }
    .combo { inset-block-start: 5.4em; }
    .combo b { font-size: 2.6em; }
}

/* ---------- narrow pages ---------- */
@media (max-width: 720px) {
    .game:not(.side) .panel { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "col"; padding: 14px 12px 16px; }
    .game:not(.side) .hero { padding: 4px 4px 8px; }
    .game:not(.side) .bar { grid-template-columns: minmax(0, 1fr); gap: 1px; }
    .track { inline-size: 11em; }
}

/* ---------- a phone held sideways: the fight fills the screen, the pad sits over it ---------- */
.game.side { max-inline-size: none; padding: 0; }
.game.side .screen { min-block-size: var(--ah); border: 0; border-radius: 0; }
.game.side .panel { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 6px 14px; padding: 8px 14px 10px; }
.game.side .logo { font-size: 1.75rem; }
.game.side .tag { display: none; }
.game.side .hero { padding: 2px 6px 6px; }
.game.side .hero canvas { max-inline-size: 118px; }
.game.side .hero b { font-size: .98rem; }
.game.side .bars { margin-block-start: 3px; gap: 2px; }
.game.side .col { gap: 6px; padding: 8px 12px 10px; }
.game.side .desc { font-size: .78rem; min-block-size: 0; }
.game.side .sw { block-size: 18px; }
.game.side .btn.big { font-size: 1.1rem; min-block-size: 40px; padding-block: .45em; }
.game.side .col h3 { font-size: .66rem; margin-block: 0 -2px; }
.game.side .nm { padding-block-end: 4px; }
.game.side .nm b { font-size: .68rem; }
.game.side .seg button { min-block-size: 32px; padding-block: 4px; font-size: .8rem; }
.game.side .medals { gap: 2px; }
.game.side .medal { inline-size: 21px; block-size: 21px; padding: 3px; }
.game.side .tot { font-size: .8rem; }
.game.side .note { min-block-size: 0; font-size: .74rem; }
.game.side .note:empty { display: none; }
.game.side .runstars .st { padding-block: 3px; }
.game.side .actions .btn { min-block-size: 38px; font-size: .9rem; }
.game.side .rank { inline-size: 112px; }
.game.side .rank b { font-size: 3.1rem; }
.game.side .big { font-size: 2.3rem; }
.game.side .grid { font-size: .8rem; gap: 2px 12px; }
.game.side .play-area { position: relative; display: block; block-size: var(--ah); }
.game.side .stage { block-size: 100%; aspect-ratio: auto; border: 0; border-radius: 0; }
.game.side .pad { position: absolute; inset: 0; z-index: 5; display: block; block-size: auto; pointer-events: none; --pb: clamp(58px, calc(var(--ah) * .19), 80px); }
.game.side .stickzone { position: absolute; inset-inline-start: 0; inset-block: 24% 0; inline-size: 46%; border: 0; border-radius: 0; background: none; pointer-events: auto; }
.game.side .stick { left: 26px; top: auto; bottom: 20px; inline-size: 112px; block-size: 112px; opacity: .5; }
.game.side .stick.held { opacity: 1; }
.game.side .acts { position: absolute; inset-inline-end: 16px; inset-block-end: 14px; gap: 10px; padding: 0; pointer-events: auto; }
.game.side .keys { display: none; }
.game.side .coach { inset-block-start: 22%; }
.game.side .pb:not(.at):not(.ready) { background: rgba(26, 21, 38, .52); }
.game.side .acts, .game.side .stick { transition: opacity .25s; }
.game.side.near-pad .acts { opacity: .45; }
.game.side.near-stick .stick:not(.held) { opacity: .22; }
.game.modal .pad, .game.modal .pad * { pointer-events: none !important; }

/* ---------- Arabic: the fight keeps its direction, the words read right to left ---------- */
html[dir="rtl"] .logo, html[dir="rtl"] .banner b, html[dir="rtl"] .combo b, html[dir="rtl"] .combo em, html[dir="rtl"] .go span { font-style: normal; letter-spacing: 0; }
html[dir="rtl"] .logo { line-height: 1.4; }
html[dir="rtl"] .k, html[dir="rtl"] .col h3, html[dir="rtl"] .rank small, html[dir="rtl"] .got small, html[dir="rtl"] .toast small, html[dir="rtl"] .combo span, html[dir="rtl"] .bossbar span, html[dir="rtl"] .banner small { letter-spacing: 0; }
html[dir="rtl"] .banner, html[dir="rtl"] .coach, html[dir="rtl"] .toast, html[dir="rtl"] .overlay, html[dir="rtl"] .bossbar span, html[dir="rtl"] .lv .k { direction: rtl; }

@keyframes rb-breathe { 50% { filter: brightness(1.14); transform: scale(1.02); } }
@keyframes rb-land { 0% { transform: scale(1.3); } 60% { transform: scale(.95); } 100% { transform: none; } }
@keyframes rb-badge { to { transform: scale(1.08); box-shadow: 0 0 18px rgba(255, 209, 102, .7); } }
@keyframes rb-fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes rb-hurt { 0% { transform: translateX(0); filter: brightness(2.2); } 25% { transform: translateX(-.3em); } 50% { transform: translateX(.3em); } 75% { transform: translateX(-.15em); } 100% { transform: none; filter: none; } }
@keyframes rb-low { to { filter: brightness(1.5); } }
@keyframes rb-glow { to { filter: brightness(1.35); box-shadow: 0 0 1em var(--fury); } }
@keyframes rb-bump { 40% { transform: scale(1.22); color: var(--accent2); } }
@keyframes rb-skull { to { transform: translate(.15em, -50%) scale(1.25); } }
@keyframes rb-shake { 20% { transform: translateX(-.25em); } 40% { transform: translateX(.25em); } 60% { transform: translateX(-.15em); } 80% { transform: translateX(.15em); } }
@keyframes rb-pop { 0% { transform: scale(1.5); color: #fff; } 100% { transform: none; } }
@keyframes rb-word { 0% { transform: scale(1.8) rotate(-6deg); color: var(--accent2); } 60% { transform: scale(.95); } 100% { transform: none; } }
@keyframes rb-go { 0%, 100% { opacity: 1; transform: none; } 50% { opacity: .35; transform: translateX(.7em); } }
@keyframes rb-slam { 0% { transform: scale(1.7); opacity: 0; } 70% { transform: scale(.96); opacity: 1; } 100% { transform: none; } }
@keyframes rb-coach { to { border-color: var(--fury); box-shadow: 0 .3em 1em rgba(0, 0, 0, .45), 0 0 1.1em rgba(122, 245, 255, .45); } }
@keyframes rb-box { from { opacity: 0; transform: translateY(.8em) scale(.96); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .btn.big, .badge, .go.on, .coach.on { animation: none; }
    .go.on { opacity: 1; }
}
