:root {
    color-scheme: dark;
    --bg: #10111a;
    --panel: rgba(18, 18, 30, 0.86);
    --panel-strong: rgba(25, 24, 38, 0.95);
    --line: rgba(255, 242, 201, 0.18);
    --text: #fff7e8;
    --muted: #cfc4b8;
    --gold: #f3c86b;
    --ruby: #f04c55;
    --sapphire: #4cb4ff;
    --emerald: #58ca82;
    --violet: #a67bff;
    --rose: #ff78b9;
    --heart: #ff78b9;
    --shadow: rgba(0, 0, 0, 0.48);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background:
        radial-gradient(circle at 14% 8%, rgba(240, 76, 85, 0.22), transparent 26rem),
        radial-gradient(circle at 88% 12%, rgba(76, 180, 255, 0.18), transparent 24rem),
        linear-gradient(155deg, #090a11, #171323 48%, #111a1c);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

button {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

h1,
p {
    margin: 0;
}

.game-shell {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: min(100vw, 600px);
    height: 100dvh;
    min-height: 620px;
    margin: 0 auto;
    overflow: hidden;
    background: #0d0e17;
    box-shadow: 0 0 70px rgba(0, 0, 0, 0.58);
}

.game-shell.shake-light {
    animation: shake-light 190ms ease;
}

.game-shell.shake-heavy {
    animation: shake-heavy 260ms ease;
}

.game-shell.board-surge {
    animation: board-surge-flash 520ms ease;
}

.top-bar {
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 72px;
    padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(14, 14, 23, 0.98), rgba(18, 17, 28, 0.86));
}

.title-block {
    min-width: 0;
}

.title-block h1 {
    overflow: hidden;
    max-width: 270px;
    font-size: 22px;
    line-height: 1.04;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.title-block p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.title-block p span {
    margin-left: 8px;
}

.quick-stats {
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
}

.quick-stats span {
    min-width: 50px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.quick-stats b {
    display: block;
    margin-top: 2px;
    color: var(--text);
    font-size: 14px;
}

.battle-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.stage-art,
.stage-shade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.stage-art {
    object-fit: cover;
    object-position: center;
}

.stage-shade {
    background:
        linear-gradient(180deg, rgba(7, 7, 13, 0.1), rgba(7, 7, 13, 0.5) 48%, rgba(7, 7, 13, 0.82)),
        radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.18), transparent 18rem);
}

.combatants {
    position: absolute;
    z-index: 2;
    top: 8px;
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.fighter {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(78px, 1fr) auto;
    min-height: 168px;
    overflow: hidden;
    padding: 9px 9px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(9, 10, 18, 0.68);
    box-shadow: 0 12px 24px var(--shadow);
    backdrop-filter: blur(10px);
}

.fighter::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
}

.fighter.hit::after {
    animation: hit-flash 440ms ease;
}

.fighter.heal-flash::after {
    animation: heal-flash 520ms ease;
}

.fighter.power-up::after {
    animation: power-up-flash 720ms ease;
}

.fighter.hit .sprite {
    animation: sprite-hit 360ms ease;
}

.fighter-enemy.hit .sprite {
    animation: enemy-sprite-hit 360ms ease;
}

.fighter.heal-flash .sprite,
.fighter.power-up .sprite {
    animation: sprite-power 620ms ease;
}

.fighter-top,
.fighter-hp {
    position: relative;
    z-index: 5;
}

.fighter-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.fighter-copy {
    position: relative;
    min-width: 0;
    max-width: 78%;
}

.fighter-enemy .fighter-copy {
    margin-left: auto;
    text-align: right;
}

.fighter span {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.fighter b {
    display: block;
    overflow: hidden;
    margin-top: 2px;
    color: #fff0c8;
    font-size: 14px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.battle-tag {
    flex: 0 0 auto;
    max-width: 76px;
    padding: 4px 6px;
    border: 1px solid rgba(255, 242, 201, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--gold);
    font-size: 10px;
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
}

.battle-tag.danger {
    color: #ff9ba7;
}

.battle-tag.exposed {
    color: var(--emerald);
}

.fighter-portrait {
    position: relative;
    min-height: 92px;
    margin: 4px -2px 5px;
    overflow: hidden;
    border-radius: 7px;
    background:
        radial-gradient(circle at 62% 44%, rgba(255, 255, 255, 0.1), transparent 46%),
        rgba(0, 0, 0, 0.14);
}

.enemy-portrait {
    background:
        radial-gradient(circle at 36% 44%, rgba(166, 123, 255, 0.16), transparent 48%),
        rgba(0, 0, 0, 0.16);
}

.hp-bar {
    position: relative;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.52);
}

.hp-bar i {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--emerald), var(--gold));
    transition: width 220ms ease;
}

.hp-bar.enemy i {
    background: linear-gradient(90deg, var(--ruby), var(--violet));
}

.hp-text {
    position: relative;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.fighter-enemy .hp-text {
    text-align: right;
}

.sprite {
    position: absolute;
    bottom: -8px;
    width: 170px;
    height: 126px;
    background-image: url("assets/art/crystal-combatants.png");
    background-repeat: no-repeat;
    background-size: 330px 185px;
    filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

.sprite-hero {
    right: -4px;
    background-position: 0 0;
}

.sprite-enemy {
    left: -3px;
    background-position: 100% 0;
    transform: scaleX(-1);
}

.pet-squad {
    position: absolute;
    left: 6px;
    right: 88px;
    bottom: 6px;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(3, minmax(30px, 1fr));
    gap: 4px;
}

.pet-chip {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-width: 0;
    padding: 3px 2px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 7px;
    background: rgba(7, 7, 13, 0.58);
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
}

.pet-chip i {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    box-shadow: inset 0 3px 5px rgba(255, 255, 255, 0.28), 0 0 10px currentColor;
}

.pet-chip b {
    overflow: hidden;
    width: 100%;
    color: inherit;
    font-size: 8px;
    line-height: 1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pet-chip.ruby { color: var(--ruby); }
.pet-chip.sapphire { color: var(--sapphire); }
.pet-chip.emerald { color: var(--emerald); }
.pet-chip.solar { color: var(--gold); }
.pet-chip.void { color: var(--violet); }
.pet-chip.heart { color: var(--heart); }

.pet-chip.ruby i { background: radial-gradient(circle at 34% 24%, #ffd0c5, var(--ruby) 52%, #8b1223); }
.pet-chip.sapphire i { background: radial-gradient(circle at 34% 24%, #d5f4ff, var(--sapphire) 52%, #164c91); }
.pet-chip.emerald i { background: radial-gradient(circle at 34% 24%, #d9ffd8, var(--emerald) 52%, #177748); }
.pet-chip.solar i { background: radial-gradient(circle at 34% 24%, #fff3b8, var(--gold) 52%, #9b6721); }
.pet-chip.void i { background: radial-gradient(circle at 34% 24%, #f1d6ff, var(--violet) 52%, #4b248d); }
.pet-chip.heart i { background: radial-gradient(circle at 34% 24%, #ffe0ef, var(--heart) 52%, #a51c65); }

.pet-chip.active {
    animation: pet-pulse 560ms ease;
    border-color: currentColor;
    background: rgba(255, 255, 255, 0.12);
}

.enemy-minions {
    position: absolute;
    right: 6px;
    bottom: 7px;
    z-index: 4;
    display: flex;
    gap: 5px;
}

.enemy-minions span {
    width: 20px;
    height: 25px;
    border: 1px solid rgba(255, 138, 164, 0.34);
    border-radius: 8px 8px 11px 11px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 38%),
        linear-gradient(180deg, #a67bff, #4b248d);
    box-shadow: 0 0 12px rgba(166, 123, 255, 0.3);
    opacity: 0.28;
    transform: translateY(4px) scale(0.86);
}

.enemy-minions span.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.enemy-minions span.breaking {
    animation: minion-break 520ms ease forwards;
}

.board-panel {
    position: absolute;
    z-index: 3;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    gap: 8px;
    padding: 9px;
    border: 1px solid rgba(255, 242, 201, 0.2);
    border-radius: 8px;
    background: rgba(10, 10, 18, 0.78);
    box-shadow: 0 15px 34px var(--shadow);
    backdrop-filter: blur(12px);
}

.board-topline {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    align-items: center;
}

.next-token {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas:
        "label label"
        "gem name"
        "special special";
    gap: 2px 7px;
    align-items: center;
    min-width: 88px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 242, 201, 0.14);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
}

.next-token span {
    grid-area: label;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.next-token i {
    grid-area: gem;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.78);
    border-radius: 50%;
    background: var(--ruby);
    box-shadow: inset 0 4px 8px rgba(255, 255, 255, 0.32), 0 0 12px currentColor;
}

.next-token b {
    grid-area: name;
    font-size: 12px;
    white-space: nowrap;
}

.next-token em {
    grid-area: special;
    overflow: hidden;
    max-width: 76px;
    color: var(--gold);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.next-token.special-ready {
    border-color: rgba(243, 200, 107, 0.62);
    background: rgba(243, 200, 107, 0.12);
    box-shadow: 0 0 20px rgba(243, 200, 107, 0.14);
}

.battle-message {
    overflow: hidden;
    color: #fff0c8;
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.canvas-frame {
    overflow: hidden;
    border: 1px solid rgba(255, 242, 201, 0.14);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(58, 55, 88, 0.75), rgba(15, 17, 31, 0.88)),
        #151727;
}

#boardCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 7 / 6;
    touch-action: none;
}

.column-controls {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
}

.column-controls button {
    height: 34px;
    border: 1px solid rgba(255, 242, 201, 0.16);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.column-controls button:hover,
.column-controls button:focus-visible {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

.column-controls button:disabled {
    cursor: default;
    opacity: 0.45;
}

.command-strip {
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 8px 10px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid rgba(255, 242, 201, 0.12);
    background: rgba(14, 14, 24, 0.96);
}

.command-strip button,
.utility-row button {
    min-width: 0;
    border: 1px solid rgba(255, 242, 201, 0.18);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.command-strip button {
    height: 50px;
    padding: 5px;
}

.command-strip b,
.command-strip span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-strip b {
    font-size: 13px;
}

.command-strip span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.command-strip button.ready {
    border-color: rgba(243, 200, 107, 0.72);
    background: linear-gradient(180deg, rgba(243, 200, 107, 0.24), rgba(255, 255, 255, 0.05));
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.14),
        0 0 18px rgba(243, 200, 107, 0.24);
    animation: ready-pulse 1.1s ease-in-out infinite;
}

.command-strip button:disabled {
    cursor: default;
    opacity: 0.5;
}

.lower-panel {
    z-index: 4;
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
    background: rgba(12, 12, 20, 0.98);
}

.rules-line {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.quest-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid rgba(255, 242, 201, 0.16);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(243, 200, 107, 0.1), rgba(166, 123, 255, 0.08)),
        rgba(255, 255, 255, 0.045);
}

.quest-copy {
    min-width: 0;
}

.quest-copy span,
.quest-card small {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.quest-copy b {
    display: block;
    overflow: hidden;
    margin-top: 2px;
    color: #fff0c8;
    font-size: 12px;
    line-height: 1.12;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quest-card em {
    overflow: hidden;
    max-width: 96px;
    padding: 4px 6px;
    border: 1px solid rgba(243, 200, 107, 0.28);
    border-radius: 999px;
    color: var(--gold);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.quest-meter {
    grid-column: 1;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.4);
}

.quest-meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--gold), var(--rose), var(--sapphire));
    transition: width 180ms ease;
}

.quest-card small {
    justify-self: end;
}

.quest-card.complete {
    animation: quest-complete 760ms ease;
}

.log {
    min-height: 36px;
    max-height: 48px;
    overflow: hidden;
    color: #ffe9bd;
    font-size: 12px;
    line-height: 1.25;
}

.log p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.utility-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.utility-row button {
    min-height: 36px;
}

.vfx-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
}

.float-text {
    position: absolute;
    left: 50%;
    top: 50%;
    min-width: 80px;
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    background: rgba(8, 8, 14, 0.66);
    color: var(--gold);
    font-weight: 800;
    font-size: 18px;
    line-height: 1;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    transform: translate(-50%, -50%);
    animation: float-up 920ms ease-out forwards;
    will-change: transform, opacity;
}

.float-text.enemy-damage {
    color: #ffb86e;
    border-color: rgba(255, 184, 110, 0.62);
}

.float-text.player-damage {
    color: #ff7c9a;
    border-color: rgba(255, 124, 154, 0.62);
}

.float-text.heal {
    color: #86ffc2;
    border-color: rgba(134, 255, 194, 0.62);
}

.float-text.charge {
    color: #d6c1ff;
    border-color: rgba(214, 193, 255, 0.62);
}

.vfx-banner {
    position: absolute;
    left: 50%;
    top: 34%;
    width: min(86%, 480px);
    padding: 10px 14px;
    border: 1px solid rgba(255, 241, 181, 0.5);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(240, 76, 85, 0.1), rgba(243, 200, 107, 0.24), rgba(76, 180, 255, 0.1)),
        rgba(12, 11, 20, 0.74);
    box-shadow: 0 0 36px rgba(243, 200, 107, 0.24);
    color: #fff3c8;
    font-weight: 900;
    font-size: 24px;
    line-height: 1.1;
    text-align: center;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
    transform: translate(-50%, -50%) scale(0.86);
    animation: banner-pop 980ms ease forwards;
    will-change: transform, opacity;
}

.vfx-banner span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.vfx-beam {
    position: absolute;
    left: 0;
    top: 0;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
    box-shadow:
        0 0 12px currentColor,
        0 0 26px currentColor;
    opacity: 0;
    transform-origin: 0 50%;
    animation: beam-fire 420ms ease-out forwards;
}

.vfx-beam::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 22px currentColor;
    transform: translateY(-50%);
}

@keyframes shake-light {
    0%,
    100% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-3px, 1px, 0); }
    42% { transform: translate3d(3px, -1px, 0); }
    64% { transform: translate3d(-2px, -1px, 0); }
    82% { transform: translate3d(2px, 1px, 0); }
}

@keyframes shake-heavy {
    0%,
    100% { transform: translate3d(0, 0, 0); }
    16% { transform: translate3d(-6px, 2px, 0); }
    34% { transform: translate3d(6px, -2px, 0); }
    52% { transform: translate3d(-5px, -2px, 0); }
    70% { transform: translate3d(4px, 2px, 0); }
    86% { transform: translate3d(-2px, 0, 0); }
}

@keyframes board-surge-flash {
    0%,
    100% { filter: none; }
    24% { filter: brightness(1.28) saturate(1.35); }
    52% { filter: brightness(0.88) saturate(1.2); }
}

@keyframes hit-flash {
    0% { opacity: 0; background: rgba(255, 255, 255, 0); }
    18% { opacity: 1; background: rgba(255, 102, 102, 0.34); box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.24); }
    100% { opacity: 0; background: rgba(255, 255, 255, 0); }
}

@keyframes heal-flash {
    0% { opacity: 0; background: rgba(134, 255, 194, 0); }
    25% { opacity: 1; background: rgba(134, 255, 194, 0.22); box-shadow: inset 0 0 42px rgba(134, 255, 194, 0.26); }
    100% { opacity: 0; background: rgba(134, 255, 194, 0); }
}

@keyframes power-up-flash {
    0% { opacity: 0; background: rgba(243, 200, 107, 0); }
    18%,
    58% { opacity: 1; background: rgba(243, 200, 107, 0.2); box-shadow: inset 0 0 48px rgba(243, 200, 107, 0.28); }
    100% { opacity: 0; background: rgba(243, 200, 107, 0); }
}

@keyframes sprite-hit {
    0%,
    100% { transform: translateX(0) scale(1); }
    28% { transform: translateX(-7px) scale(0.96); }
    62% { transform: translateX(4px) scale(1.03); }
}

@keyframes enemy-sprite-hit {
    0%,
    100% { transform: scaleX(-1) translateX(0) scale(1); }
    28% { transform: scaleX(-1) translateX(-7px) scale(0.96); }
    62% { transform: scaleX(-1) translateX(4px) scale(1.03); }
}

@keyframes sprite-power {
    0%,
    100% { filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.5)); }
    40% { filter: drop-shadow(0 0 22px rgba(255, 237, 170, 0.72)); }
}

@keyframes pet-pulse {
    0%,
    100% { transform: translateY(0) scale(1); }
    35% { transform: translateY(-3px) scale(1.08); }
}

@keyframes minion-break {
    0% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
    100% { opacity: 0; transform: translateY(-10px) scale(0.65) rotate(18deg); filter: brightness(1.8); }
}

@keyframes ready-pulse {
    0%,
    100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

@keyframes float-up {
    0% { opacity: 0; transform: translate(-50%, -34%) scale(0.72); }
    16% { opacity: 1; transform: translate(-50%, -58%) scale(1.08); }
    100% { opacity: 0; transform: translate(-50%, -150%) scale(0.96); }
}

@keyframes banner-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.76); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
    68% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -62%) scale(0.96); }
}

@keyframes beam-fire {
    0% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--angle)) scaleX(0); }
    18% { opacity: 1; }
    76% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--angle)) scaleX(1); }
    100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--angle)) scaleX(1); }
}

@keyframes quest-complete {
    0%,
    100% { box-shadow: none; transform: translateY(0); }
    30% { box-shadow: 0 0 24px rgba(243, 200, 107, 0.28); transform: translateY(-1px); }
}

@media (prefers-reduced-motion: reduce) {
    .game-shell,
    .fighter.hit::after,
    .fighter.heal-flash::after,
    .fighter.power-up::after,
    .fighter .sprite,
    .command-strip button.ready,
    .pet-chip.active,
    .enemy-minions span.breaking,
    .float-text,
    .vfx-banner,
    .vfx-beam,
    .quest-card.complete {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (max-height: 720px) {
    .game-shell {
        min-height: 540px;
    }

    .combatants {
        top: 6px;
    }

    .fighter {
        grid-template-rows: auto minmax(58px, 1fr) auto;
        min-height: 130px;
    }

    .fighter-portrait {
        min-height: 66px;
    }

    .sprite {
        width: 128px;
        height: 92px;
        background-size: 250px 140px;
    }

    .pet-squad {
        right: 66px;
        grid-template-columns: repeat(3, minmax(18px, 1fr));
        gap: 2px;
    }

    .pet-chip {
        padding: 2px 1px;
    }

    .pet-chip i {
        width: 14px;
        height: 14px;
    }

    .pet-chip b {
        display: none;
    }

    .lower-panel {
        display: none;
    }
}

@media (max-width: 440px) {
    .top-bar {
        gap: 8px;
    }

    .title-block h1 {
        max-width: 185px;
        font-size: 20px;
    }

    .quick-stats {
        gap: 5px;
    }

    .quick-stats span {
        min-width: 43px;
        padding: 6px 5px;
        font-size: 10px;
    }

    .quick-stats b {
        font-size: 12px;
    }

    .combatants {
        gap: 6px;
    }

    .fighter {
        padding: 7px;
    }

    .battle-tag {
        max-width: 58px;
        padding: 3px 5px;
        font-size: 9px;
    }

    .fighter b {
        font-size: 13px;
    }

    .sprite {
        width: 132px;
        height: 96px;
        background-size: 256px 144px;
    }

    .pet-squad {
        right: 62px;
    }
}

@media (min-width: 820px) {
    .game-shell {
        width: min(100vw, 980px);
        grid-template-columns: minmax(0, 1fr) 330px;
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .top-bar {
        grid-column: 1 / -1;
    }

    .battle-stage {
        grid-row: 2 / 4;
    }

    .command-strip,
    .lower-panel {
        grid-column: 2;
    }

    .command-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        border-left: 1px solid var(--line);
        border-top: 0;
    }

    .lower-panel {
        display: grid;
        border-left: 1px solid var(--line);
    }

    .board-panel {
        left: 7%;
        right: 7%;
        bottom: 18px;
    }

    .combatants {
        left: 18px;
        right: 18px;
        top: 14px;
    }
}
