@font-face {
    font-family: "Fredoka";
    src: url("../assets/fonts/fredoka.ttf") format("truetype");
    font-weight: 300 700;
    font-display: swap;
}
:root {
    --ink: #141c4a;
    --navy: #1d2a78;
    --navy2: #2c3c9c;
    --gold: #ffc83d;
    --gold2: #ff9d1f;
    --cream: #fff4d6;
    --red: #ff4d5a;
    --green: #34c76a;
    --blue: #3d9bff;
    --tx: #fff7e0;
    --mu: #b8c4ff;
}
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #141c4a;
    font-family: "Fredoka", "Trebuchet MS", sans-serif;
    color: var(--tx);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
canvas#gl {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.grade {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(18, 10, 60, 0.38) 100%),
        linear-gradient(180deg, rgba(255, 214, 140, 0.1), transparent 38%, rgba(40, 20, 90, 0.1));
}
.hitflash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 35%, #ff1f4aaa 100%);
}
.hitflash.on {
    animation: hit 0.55s ease-out;
}
@keyframes hit {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
.speedfx {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    background: repeating-conic-gradient(from 0deg at 50% 52%, #ffffff55 0 0.8deg, transparent 0.8deg 5deg);
    -webkit-mask: radial-gradient(circle at 50% 52%, transparent 34%, #000 88%);
    mask: radial-gradient(circle at 50% 52%, transparent 34%, #000 88%);
}
.speedfx.on {
    opacity: 0.6;
}
.ic {
    width: 30px;
    height: 30px;
    flex: none;
    display: block;
}
.ic.s {
    width: 22px;
    height: 22px;
}
.ic.xl {
    width: 54px;
    height: 54px;
}
.screen {
    position: fixed;
    inset: 0;
    display: none;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
        max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.screen.active {
    display: flex;
}
#loader {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: radial-gradient(ellipse at 50% 38%, #4a63e8, #1d2a78 62%, #101840);
    z-index: 30;
}
.loadbar {
    width: min(320px, 70vw);
    height: 22px;
    border-radius: 99px;
    background: #101840;
    border: 3px solid var(--gold);
    overflow: hidden;
    box-shadow: 0 0 18px #ffc83d66;
}
.loadbar i {
    display: block;
    height: 100%;
    width: 0;
    background: repeating-linear-gradient(-45deg, #ffc83d 0 12px, #ff9d1f 12px 24px);
    transition: width 0.25s;
}
.muted {
    color: var(--mu);
    margin: 0;
    font-weight: 500;
}
.small {
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}
.tag {
    margin: 4px 0 0;
    text-align: center;
    font-weight: 700;
    color: #fff;
    font-size: clamp(14px, 2.1vw, 19px);
    letter-spacing: 0.3px;
    text-shadow:
        0 2px 0 var(--ink),
        0 0 12px #1d2a78;
}
/* panels: indigo plates with a brass rim and rivets */
.panel,
.card {
    background: linear-gradient(180deg, #34479f, #1f2c7a 55%, #18205f);
    border: 4px solid var(--gold);
    border-radius: 26px;
    box-shadow:
        0 0 0 3px var(--ink),
        0 14px 0 -2px #0c1236,
        0 22px 40px #0008,
        inset 0 3px 0 #ffffff40,
        inset 0 0 0 4px #141c4a55;
    position: relative;
}
.panel::before,
.card::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 19px;
    border: 2px dashed #ffc83d55;
    pointer-events: none;
}
.btn {
    position: relative;
    top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 4px solid var(--ink);
    border-radius: 18px;
    padding: 10px 20px;
    font:
        700 clamp(17px, 2.4vw, 22px) "Fredoka",
        sans-serif;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(#7eb7ff, #2f6df0);
    text-shadow: 0 2px 0 #0c2a7a;
    box-shadow:
        0 6px 0 #0c1236,
        0 10px 14px #0006,
        inset 0 3px 0 #ffffffaa,
        inset 0 -4px 0 #00000026;
    transition:
        top 0.08s,
        box-shadow 0.08s,
        filter 0.12s;
}
.btn::after {
    content: "";
    position: absolute;
    left: 10%;
    right: 10%;
    top: 4px;
    height: 34%;
    border-radius: 12px;
    background: linear-gradient(#ffffff77, #ffffff00);
    pointer-events: none;
}
.btn:hover {
    filter: brightness(1.1);
    top: -2px;
    box-shadow:
        0 8px 0 #0c1236,
        0 12px 16px #0006,
        inset 0 3px 0 #ffffffaa,
        inset 0 -4px 0 #00000026;
}
.btn:active,
.btn.press {
    top: 5px;
    box-shadow:
        0 1px 0 #0c1236,
        0 3px 6px #0006,
        inset 0 3px 0 #ffffffaa;
}
.btn:focus-visible {
    outline: 4px solid var(--gold);
    outline-offset: 3px;
}
.btn.green {
    background: linear-gradient(#8bf0a4, #1fa94f);
    text-shadow: 0 2px 0 #0a5a2a;
}
.btn.mustard {
    background: linear-gradient(#ffe27a, #ff9d1f);
    text-shadow: 0 2px 0 #9a4a00;
}
.btn.blue {
    background: linear-gradient(#8fd0ff, #2f6df0);
}
.btn.red {
    background: linear-gradient(#ff9ca4, #e0303f);
    text-shadow: 0 2px 0 #7a0a18;
}
.btn.big {
    font-size: clamp(26px, 4vw, 38px);
    padding: 14px 36px;
    border-radius: 26px;
    letter-spacing: 1px;
}
.btn.round {
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
}
.btn.round.sm {
    width: 48px;
    height: 48px;
}
.btn.round::after {
    left: 18%;
    right: 18%;
    border-radius: 50%;
}
.btn.back {
    background: linear-gradient(#ffb0b6, #e0303f);
}
.chip,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    border-radius: 99px;
    font-weight: 700;
    background: linear-gradient(#2c3c9c, #18205f);
    border: 3px solid var(--gold);
    color: #fff;
    box-shadow:
        0 4px 0 #0c1236,
        0 6px 12px #0005,
        inset 0 2px 0 #ffffff33;
}
.chip b,
.pill b {
    color: var(--gold);
}
/* menu: logo up top, brass-plated buttons at the bottom, the train scene stays visible */
#menu {
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(
        180deg,
        rgba(14, 20, 70, 0.55),
        rgba(14, 20, 70, 0) 34%,
        rgba(14, 20, 70, 0) 58%,
        rgba(14, 20, 70, 0.62)
    );
}
.menu-wrap {
    display: contents;
}
#menu .logo-img {
    height: clamp(86px, 25vh, 210px);
    margin-top: clamp(0px, 1.5vh, 14px);
    filter: drop-shadow(0 8px 14px #0007);
}
#menu .tag {
    position: absolute;
    top: calc(clamp(86px, 25vh, 210px) + max(14px, env(safe-area-inset-top)) + 6px);
    left: 0;
    right: 0;
}
.menu-btns {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(10px, 2vw, 22px);
    width: 100%;
    max-width: 760px;
}
.row2 {
    display: contents;
}
.menu-btns .btn.big {
    order: 2;
    flex: 1.5;
    min-width: 0;
}
.menu-btns #btnEndless {
    order: 1;
    flex: 1;
}
.menu-btns #btnLevels {
    order: 3;
    flex: 1;
}
.menu-btns .btn:not(.big) {
    padding: 14px 12px;
    font-size: clamp(17px, 2.4vw, 23px);
}
.chips {
    position: absolute;
    left: max(14px, env(safe-area-inset-left));
    top: max(14px, env(safe-area-inset-top));
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}
.menu-bottom {
    width: 100%;
}
.corner {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    top: max(14px, env(safe-area-inset-top));
    display: flex;
    gap: 12px;
}
@media (max-aspect-ratio: 1/1) {
    .menu-btns {
        flex-wrap: wrap;
    }
    .menu-btns .btn.big {
        order: 0;
        flex: 1 1 100%;
    }
    .menu-btns #btnEndless,
    .menu-btns #btnLevels {
        order: 1;
    }
}
@media (max-height: 480px) {
    #menu .tag {
        display: none;
    }
    .menu-btns .btn.big {
        padding: 8px 20px;
    }
    .menu-btns .btn:not(.big) {
        padding: 9px 10px;
    }
}
/* panels screens */
.screen#levels,
.screen#how,
.screen#settings {
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(20, 28, 74, 0.35), rgba(20, 28, 74, 0.78));
}
.panel {
    width: min(760px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 16px 18px 18px;
}
.panel.narrow {
    width: min(460px, 100%);
}
.phead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}
.phead h2 {
    margin: 0;
    font-size: clamp(22px, 4vw, 32px);
    color: var(--gold);
    text-shadow:
        0 3px 0 var(--ink),
        0 0 14px #ffc83d66;
    letter-spacing: 0.5px;
}
.tabs {
    display: flex;
    gap: 8px;
    padding: 4px 2px 10px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}
.tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 6px;
    border-radius: 14px;
    border: 3px solid var(--ink);
    font:
        700 15px "Fredoka",
        sans-serif;
    color: var(--ink);
    cursor: pointer;
    background: linear-gradient(var(--c1), var(--c2));
    opacity: 0.6;
    box-shadow: 0 4px 0 #0c1236;
    position: relative;
    top: 0;
    transition:
        top 0.08s,
        opacity 0.15s;
}
.tab:hover {
    opacity: 0.9;
}
.tab.on {
    opacity: 1;
    top: -2px;
    box-shadow:
        0 6px 0 #0c1236,
        0 0 0 3px var(--gold);
}
.grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    padding: 4px 4px 8px;
    position: relative;
    z-index: 1;
}
.lv {
    position: relative;
    top: 0;
    aspect-ratio: 1/1;
    min-height: 64px;
    border-radius: 18px;
    border: 3px solid var(--ink);
    background: linear-gradient(var(--c1), var(--c2));
    font:
        700 clamp(20px, 3.6vw, 30px) "Fredoka",
        sans-serif;
    color: #fff;
    text-shadow: 0 2px 0 #0008;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow:
        0 5px 0 #0c1236,
        inset 0 3px 0 #ffffffaa,
        inset 0 -4px 0 #00000022;
    transition:
        top 0.08s,
        box-shadow 0.08s,
        filter 0.12s;
}
.lv:hover {
    top: -2px;
    filter: brightness(1.1);
    box-shadow:
        0 7px 0 #0c1236,
        inset 0 3px 0 #ffffffaa;
}
.lv:active {
    top: 3px;
    box-shadow: 0 2px 0 #0c1236;
}
.lv.cur {
    box-shadow:
        0 5px 0 #0c1236,
        0 0 0 4px var(--gold),
        0 0 18px #ffc83d;
}
.lv .st {
    display: flex;
    gap: 1px;
}
.lv .st .ic {
    width: 15px;
    height: 15px;
}
.lv.locked {
    background: linear-gradient(#5a6296, #3b4175);
    cursor: default;
    opacity: 0.92;
}
.lv.locked:hover {
    top: 0;
    filter: none;
    box-shadow:
        0 5px 0 #0c1236,
        inset 0 3px 0 #ffffff55;
}
.lv.locked .ic {
    width: 30px;
    height: 30px;
}
.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    position: relative;
    z-index: 1;
}
.cards article {
    background: #10185a99;
    border: 3px solid #ffc83d88;
    border-radius: 18px;
    padding: 10px 14px;
}
.cards h3 {
    margin: 8px 0 4px;
    color: var(--gold);
    font-size: 19px;
}
.cards p {
    margin: 0;
    color: #e4e9ff;
    font-weight: 500;
    font-size: 15px;
    line-height: 1.35;
}
.art {
    height: 74px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(#52b7ff, #2c7fe0);
    border: 3px solid var(--ink);
}
.art.a2 {
    background: linear-gradient(#ffb066, #e5484d);
}
.art.a3 {
    background: linear-gradient(#b48bff, #6a3fd6);
}
.art.a4 {
    background: linear-gradient(#5be07f, #1b9a55);
}
.crate {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: repeating-linear-gradient(90deg, #c98a4b 0 9px, #a9703a 9px 11px);
    border: 3px solid var(--ink);
}
.setlist {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 1;
}
.setrow {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: 18px;
    border: 3px solid var(--ink);
    background: linear-gradient(#fff7e0, #ffe0a0);
    color: var(--ink);
    font:
        700 20px "Fredoka",
        sans-serif;
    cursor: pointer;
    position: relative;
    top: 0;
    box-shadow:
        0 5px 0 #0c1236,
        inset 0 3px 0 #fff;
    transition:
        top 0.08s,
        box-shadow 0.08s;
}
.setrow:hover {
    top: -2px;
    box-shadow:
        0 7px 0 #0c1236,
        inset 0 3px 0 #fff;
}
.setrow:active {
    top: 3px;
    box-shadow: 0 2px 0 #0c1236;
}
.setrow span {
    flex: 1;
    text-align: left;
}
.setrow em {
    font-style: normal;
    color: #d1303d;
}
.setrow.danger {
    background: linear-gradient(#ffc2c4, #ff7b80);
}
.sw {
    width: 54px;
    height: 30px;
    border-radius: 99px;
    background: #9aa0c8;
    border: 3px solid var(--ink);
    position: relative;
    flex: none;
}
.sw::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--ink);
    transition: left 0.15s;
}
.sw.on {
    background: #3fd16a;
}
.sw.on::after {
    left: 26px;
}
/* HUD */
#game {
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}
#game .btn,
.modal {
    pointer-events: auto;
}
.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    max-width: 760px;
}
.hud .dist {
    display: none;
}
.hearts {
    display: flex;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 99px;
    background: linear-gradient(#2c3c9c, #18205f);
    border: 3px solid var(--gold);
    box-shadow:
        0 4px 0 #0c1236,
        0 6px 12px #0005,
        inset 0 2px 0 #ffffff33;
}
.hearts .ic {
    width: 28px;
    height: 28px;
}
.progress {
    position: relative;
    width: min(560px, 100%);
    height: 22px;
    margin-top: 14px;
    border-radius: 99px;
    background: #101840cc;
    border: 3px solid var(--gold);
    box-shadow:
        0 4px 0 #0c1236,
        0 6px 12px #0005;
}
.progress i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 99px;
    background: repeating-linear-gradient(-45deg, #ff9d1f 0 10px, #ffc83d 10px 20px);
}
.progress i::after {
    content: "";
    position: absolute;
    right: -17px;
    top: -13px;
    width: 34px;
    height: 34px;
    background: url(../assets/icons/train.png) center/contain no-repeat;
    filter: drop-shadow(0 2px 0 #0c1236);
}
.progress span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    text-shadow:
        0 1px 0 #0c1236,
        0 0 6px #0c1236;
}
.msg {
    margin-top: 16px;
    min-height: 40px;
    padding: 6px 22px;
    border-radius: 99px;
    background: linear-gradient(#ffe27a, #ff9d1f);
    border: 3px solid var(--ink);
    font-weight: 700;
    font-size: 20px;
    color: var(--ink);
    opacity: 0;
    transition: opacity 0.25s;
    box-shadow: 0 4px 0 #0c1236;
}
.msg.on {
    opacity: 1;
}
.count {
    position: absolute;
    left: 50%;
    top: 40%;
    margin-left: -80px;
    margin-top: -80px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 92px;
    font-weight: 700;
    color: #fff;
    -webkit-text-stroke: 8px var(--ink);
    paint-order: stroke fill;
    background: radial-gradient(circle at 35% 30%, #ffd86a, #ff8a1f 70%);
    border: 7px solid var(--ink);
    box-shadow:
        0 0 0 5px var(--gold),
        0 8px 0 #0c1236,
        0 0 40px #ffc83daa;
}
.count.on {
    display: flex;
    animation: pop 0.9s ease-out infinite;
}
@keyframes pop {
    0% {
        opacity: 0.2;
    }
    25% {
        opacity: 1;
    }
    100% {
        opacity: 1;
    }
}
.pads {
    position: absolute;
    left: 0;
    right: 0;
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    padding: 0 max(16px, env(safe-area-inset-left));
    pointer-events: none;
}
.pad {
    width: clamp(76px, 16vw, 110px);
    height: clamp(76px, 16vw, 110px);
    border-radius: 50%;
    background: #1d2a78aa;
    border: 4px solid #ffc83dcc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.08s;
    box-shadow: inset 0 3px 0 #ffffff44;
}
.pad.on {
    background: #ff9d1fee;
    border-color: #fff;
}
.tutorial {
    position: absolute;
    left: 0;
    right: 0;
    top: 36%;
    display: none;
    justify-content: center;
}
.tutorial.on {
    display: flex;
}
.tutorial div {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 22px;
    border-radius: 99px;
    background: linear-gradient(#2c3c9c, #18205f);
    border: 3px solid var(--gold);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    box-shadow:
        0 5px 0 #0c1236,
        0 0 20px #0006;
}
.tutorial .ic {
    width: 36px;
    height: 36px;
}
@media (pointer: fine) {
    .pads {
        display: none;
    }
}
/* modal */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 14, 50, 0.7);
    z-index: 20;
}
.modal.hidden {
    display: none;
}
.card {
    width: min(440px, 100%);
    max-height: 100%;
    overflow: hidden;
    text-align: center;
    border-radius: 30px;
    padding: clamp(12px, 2.4vh, 22px) 22px clamp(12px, 2.2vh, 20px);
    animation: cardin 0.3s ease-out;
}
@keyframes cardin {
    from {
        transform: translateY(26px);
        opacity: 0;
    }
}
.card h2 {
    margin: 6px 0 2px;
    font-size: clamp(26px, 4.8vh, 42px);
    color: var(--gold);
    text-shadow:
        0 3px 0 var(--ink),
        0 0 16px #ffc83d77;
    position: relative;
    z-index: 1;
}
.card #mSub,
.card .stars,
.card .stats,
.card .mbtns,
.card .medal {
    position: relative;
    z-index: 1;
}
.medal {
    width: clamp(50px, 9vh, 78px);
    height: clamp(50px, 9vh, 78px);
    margin: -10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(#ffe27a, #ff9d1f);
    border: 4px solid var(--ink);
    box-shadow:
        0 5px 0 #0c1236,
        0 0 22px #ffc83d;
}
.medal .ic {
    width: 66%;
    height: 66%;
}
.stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: clamp(4px, 1.2vh, 12px) 0 clamp(4px, 0.8vh, 8px);
}
.stars .ic {
    width: clamp(34px, 6.4vh, 58px);
    height: clamp(34px, 6.4vh, 58px);
    filter: drop-shadow(0 3px 0 #0c1236);
}
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: clamp(6px, 1vh, 10px) 0 clamp(8px, 1.6vh, 16px);
}
.stats div {
    padding: clamp(4px, 0.9vh, 8px);
    border-radius: 14px;
    background: #10185a99;
    border: 2px solid #ffc83d66;
    font-weight: 600;
    color: var(--mu);
    font-size: 14px;
}
.stats b {
    display: block;
    font-size: clamp(17px, 2.8vh, 24px);
    color: #fff;
}
.mbtns {
    display: flex;
    flex-direction: column;
    gap: clamp(7px, 1.3vh, 12px);
}
.mbtns .btn {
    width: 100%;
    padding-top: clamp(7px, 1.3vh, 12px);
    padding-bottom: clamp(7px, 1.3vh, 12px);
}
#confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 25;
}
#confetti i {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    animation: fall 2.4s ease-in forwards;
}
@keyframes fall {
    to {
        transform: translateY(110vh) rotate(700deg);
    }
}
.logo-img {
    display: block;
    width: auto;
    max-width: 100%;
    height: clamp(60px, 17vh, 140px);
    object-fit: contain;
    margin: 0 auto;
}
.logo-img.big {
    max-width: 90vw;
    height: clamp(80px, 24vh, 200px);
}
@media (max-width: 380px) {
    .grid {
        gap: 6px;
    }
    .lv {
        min-height: 0;
        font-size: 18px;
        border-radius: 12px;
    }
    .lv .st .ic {
        width: 10px;
        height: 10px;
    }
    .lv.locked .ic {
        width: 22px;
        height: 22px;
    }
    .panel {
        padding: 10px;
    }
    .phead h2 {
        font-size: 20px;
    }
}
@media (max-width: 520px) {
    .grid {
        gap: 8px;
    }
    .hud .pill {
        padding: 4px 10px;
    }
    .btn {
        padding: 10px 14px;
    }
    .panel {
        padding: 12px;
    }
    .lv {
        min-height: 0;
    }
    .tabs {
        gap: 5px;
        padding-bottom: 8px;
    }
    .tab {
        padding: 5px 2px;
        font-size: 11.5px;
        line-height: 1.05;
        border-width: 2px;
        border-radius: 10px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    .cards {
        gap: 8px;
    }
    .cards article {
        padding: 8px 8px 9px;
        border-radius: 14px;
    }
    .art {
        height: clamp(40px, 7.5vh, 60px);
        gap: 8px;
    }
    .art .ic.xl {
        width: clamp(26px, 5vh, 40px);
        height: clamp(26px, 5vh, 40px);
    }
    .crate {
        width: clamp(28px, 5vh, 40px);
        height: clamp(28px, 5vh, 40px);
    }
    .cards h3 {
        font-size: 14px;
        margin: 6px 0 3px;
        line-height: 1.1;
    }
    .cards p {
        font-size: 11.5px;
        line-height: 1.28;
    }
    .phead {
        margin-bottom: 8px;
    }
}
@media (max-height: 640px) and (max-width: 520px) {
    .cards p {
        font-size: 11px;
        line-height: 1.22;
    }
    .cards h3 {
        font-size: 13px;
    }
    .art {
        height: 36px;
    }
}
@media (max-height: 520px) {
    #mSub {
        display: none;
    }
    .card h2 {
        margin: 2px 0;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .panel {
        padding: 10px 14px;
    }
    .cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }
    .cards article {
        padding: 8px;
        min-width: 0;
    }
    .cards p {
        overflow-wrap: anywhere;
        font-size: 12.5px;
    }
    .cards h3 {
        font-size: 15px;
    }
    .art {
        height: 50px;
    }
    .grid {
        gap: 8px;
    }
    .lv {
        min-height: 0;
        aspect-ratio: auto;
        height: 54px;
    }
    .lv .st .ic {
        width: 12px;
        height: 12px;
    }
    .card {
        padding: 12px 18px;
    }
    .stats {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-height: 380px) {
    .medal {
        display: none;
    }
    .cards .art {
        display: none;
    }
    .cards p {
        font-size: 11.5px;
    }
    .cards h3 {
        margin-top: 0;
    }
    .stars {
        margin: 2px 0;
    }
    .card {
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .mbtns .btn {
        padding-top: 6px;
        padding-bottom: 6px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .count.on {
        animation: none;
    }
    .hitflash.on {
        animation: none;
        opacity: 0.5;
    }
}
@media (max-height: 520px) {
    .setlist {
        gap: 8px;
    }
    .setrow {
        padding: 7px 12px;
        font-size: 17px;
        gap: 10px;
        box-shadow: 0 4px 0 #0c1236;
    }
    .setrow .ic {
        width: 24px;
        height: 24px;
    }
    .small {
        display: none;
    }
    .panel.narrow {
        padding: 10px 14px;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .panel.narrow {
        width: min(640px, 100%);
    }
    .setlist {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .phead {
        margin-bottom: 8px;
    }
    .phead h2 {
        font-size: 22px;
    }
}
@media (max-height: 420px) and (orientation: landscape) {
    .card {
        width: min(560px, 100%);
    }
    .mbtns {
        flex-direction: row;
    }
    .mbtns .btn {
        font-size: 16px;
        padding: 7px 8px;
        gap: 6px;
    }
    .stats {
        display: none;
    }
}
@media (max-width: 360px) {
    .hud {
        gap: 6px;
    }
    .hearts {
        padding: 4px 8px;
        gap: 2px;
    }
    .hearts .ic {
        width: 22px;
        height: 22px;
    }
    .pill {
        padding: 3px 8px;
        font-size: 14px;
    }
    .btn.round.sm {
        width: 42px;
        height: 42px;
    }
}
@media (max-aspect-ratio: 1/1) {
    #menu {
        padding-top: max(74px, calc(env(safe-area-inset-top) + 62px));
    }
    #menu .tag {
        top: calc(clamp(86px, 25vh, 210px) + max(74px, calc(env(safe-area-inset-top) + 62px)) + 6px);
    }
    .chips {
        top: auto;
        left: 0;
        right: 0;
        bottom: calc(max(14px, env(safe-area-inset-bottom)) + 178px);
        flex-direction: row;
        justify-content: center;
    }
}
/* v1.2: steam meter, mission card, garage */
.steam {
    position: absolute;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: min(240px, 42vw);
}
.steam .boost {
    pointer-events: auto;
    width: 100%;
    padding: 8px 10px;
    font-size: clamp(17px, 3.2vw, 22px);
    letter-spacing: 1px;
    filter: grayscale(0.85) brightness(0.8);
}
.steam .boost.ready {
    filter: none;
    animation: ready 0.6s ease-in-out infinite alternate;
}
.steam .boost.live {
    filter: none;
    background: linear-gradient(#ff9ca4, #e0303f);
    text-shadow: 0 2px 0 #7a0a18;
}
@keyframes ready {
    to {
        box-shadow:
            0 6px 0 #0c1236,
            0 0 26px #ffc83d,
            inset 0 3px 0 #ffffffaa;
    }
}
.steambar {
    width: 100%;
    height: 16px;
    border-radius: 99px;
    background: #101840cc;
    border: 3px solid var(--gold);
    overflow: hidden;
    box-shadow: 0 3px 0 #0c1236;
}
.steambar i {
    display: block;
    height: 100%;
    width: 0;
    background: repeating-linear-gradient(-45deg, #3a3a52 0 8px, #ff7a1f 8px 16px);
    transition: width 0.15s;
}
.steambar.full i {
    background: repeating-linear-gradient(-45deg, #ff9d1f 0 8px, #ffe27a 8px 16px);
}
.combo {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translateX(-50%);
    font-weight: 700;
    font-size: clamp(22px, 5vh, 38px);
    color: #fff;
    -webkit-text-stroke: 5px var(--ink);
    paint-order: stroke fill;
    text-shadow: 0 0 14px #ff9d1f;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
}
.combo.on {
    animation: combo 0.8s ease-out;
}
@keyframes combo {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.6);
    }
    20% {
        opacity: 1;
        transform: translateX(-50%) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-24px) scale(1);
    }
}
.goals {
    position: absolute;
    left: 50%;
    top: clamp(120px, 24vh, 200px);
    transform: translateX(-50%);
    width: min(380px, 92vw);
    display: none;
    flex-direction: column;
    gap: 7px;
    padding: 12px 14px;
    border-radius: 22px;
    background: linear-gradient(#34479f, #1f2c7a);
    border: 4px solid var(--gold);
    box-shadow:
        0 0 0 3px var(--ink),
        0 10px 0 -2px #0c1236,
        0 16px 30px #0007;
    font-weight: 600;
    font-size: clamp(13px, 2.6vw, 16px);
    pointer-events: none;
}
.goals.on {
    display: flex;
    animation: cardin 0.3s ease-out;
}
.goals h4 {
    margin: 0 0 2px;
    text-align: center;
    color: var(--gold);
    font-size: clamp(15px, 3vw, 19px);
    text-shadow: 0 2px 0 var(--ink);
}
.goals div {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 8px;
    border-radius: 12px;
    background: #10185a99;
}
.goals .ic {
    width: 22px;
    height: 22px;
}
.goals small {
    display: block;
    color: var(--mu);
    font-weight: 500;
    font-size: 0.85em;
}
.goals .tip {
    background: linear-gradient(#ffe27a, #ff9d1f);
    color: var(--ink);
}
.tab[data-t] {
    flex: 1;
}
.gbody {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
}
.skins {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    height: 100%;
}
.skin {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 6px;
    border-radius: 16px;
    border: 3px solid var(--ink);
    background: linear-gradient(#fff7e0, #ffe0a0);
    color: var(--ink);
    font-weight: 700;
    font-size: clamp(11px, 2.2vw, 15px);
    box-shadow: 0 5px 0 #0c1236;
    min-height: 0;
}
.skin.on {
    box-shadow:
        0 5px 0 #0c1236,
        0 0 0 4px var(--gold),
        0 0 16px #ffc83d;
}
.skin .sw2 {
    width: 100%;
    flex: 1;
    min-height: 30px;
    border-radius: 12px;
    border: 3px solid var(--ink);
    position: relative;
    overflow: hidden;
}
.skin .sw2::before {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: 30%;
    height: 42%;
    border-radius: 10px;
    background: var(--b);
    border: 3px solid var(--ink);
}
.skin .sw2::after {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: 66%;
    height: 10%;
    background: var(--a);
    border-radius: 5px;
}
.skin .btn {
    width: 100%;
    padding: 4px 6px;
    font-size: clamp(12px, 2.2vw, 15px);
    border-radius: 12px;
    border-width: 3px;
    box-shadow: 0 4px 0 #0c1236;
    gap: 5px;
}
.skin .btn .ic {
    width: 16px;
    height: 16px;
}
.ups {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
}
.up {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    border-radius: 16px;
    border: 3px solid var(--ink);
    background: linear-gradient(#fff7e0, #ffe0a0);
    color: var(--ink);
    box-shadow: 0 5px 0 #0c1236;
}
.up > .ic {
    width: 38px;
    height: 38px;
}
.up .tx {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: clamp(14px, 2.6vw, 18px);
    line-height: 1.15;
}
.up .tx small {
    display: block;
    font-weight: 500;
    font-size: 0.78em;
    opacity: 0.8;
}
.pips {
    display: flex;
    gap: 4px;
    margin-top: 3px;
}
.pips i {
    width: 14px;
    height: 8px;
    border-radius: 4px;
    background: #c9b48a;
    border: 2px solid var(--ink);
}
.pips i.f {
    background: #ff9d1f;
}
.up .btn {
    padding: 6px 12px;
    font-size: clamp(13px, 2.4vw, 17px);
    border-radius: 12px;
    border-width: 3px;
    box-shadow: 0 4px 0 #0c1236;
    white-space: nowrap;
}
.up .btn .ic {
    width: 18px;
    height: 18px;
}
.btn.off {
    filter: grayscale(0.9) brightness(0.85);
    pointer-events: none;
}
.need {
    margin: 0 0 6px;
    text-align: center;
    color: #ffe27a;
    font-weight: 700;
    position: relative;
    z-index: 1;
}
@media (max-width: 520px) {
    .skins {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: auto;
    }
    .steam {
        width: min(220px, 56vw);
    }
    .up {
        padding: 5px 8px;
        gap: 8px;
    }
    .up > .ic {
        width: 30px;
        height: 30px;
    }
    .goals {
        top: clamp(104px, 20vh, 170px);
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .skins {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 6px;
    }
    .skin {
        padding: 5px 4px;
        font-size: 11px;
    }
    .skin .sw2 {
        min-height: 20px;
    }
    .ups {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .goals {
        top: 90px;
        padding: 8px 10px;
        gap: 4px;
        font-size: 12px;
    }
    .goals div {
        padding: 3px 6px;
    }
    .steam {
        width: 200px;
        gap: 4px;
    }
    .steam .boost {
        padding: 5px 8px;
        font-size: 15px;
    }
}
.stats .row {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
    color: #fff;
    font-size: clamp(12px, 2.1vh + 0.4vw, 15px);
    padding: 4px 8px;
}
.stats .row span {
    flex: 1;
    min-width: 0;
}
.skin .thumb {
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: cover;
    border-radius: 12px;
    border: 3px solid var(--ink);
    background: #bfe6ff;
}
.goals {
    left: 0 !important;
    right: 0;
    margin: 0 auto;
    transform: none !important;
}
.chips {
    flex-wrap: wrap;
}
@media (max-width: 420px) {
    .chips {
        gap: 5px;
    }
    .chips .chip {
        padding: 3px 9px;
        font-size: 13px;
    }
}
@media (max-height: 560px) {
    .medal {
        display: none;
    }
    .stats {
        gap: 4px;
        margin: 4px 0 8px;
    }
    .stats .row {
        padding: 2px 6px;
        font-size: 12px;
    }
    .stats div {
        padding: 3px;
    }
    .card {
        padding: 10px 14px;
    }
    .card h2 {
        font-size: 24px;
    }
    .mbtns {
        gap: 6px;
    }
    .mbtns .btn {
        padding-top: 6px;
        padding-bottom: 6px;
        font-size: 16px;
    }
    .stars .ic {
        width: 32px;
        height: 32px;
    }
}
@media (min-height: 1px) {
    .count {
        top: auto;
        bottom: clamp(96px, 24vh, 220px);
        margin-top: 0;
        width: clamp(64px, 11vh, 110px);
        height: clamp(64px, 11vh, 110px);
        margin-left: calc(clamp(64px, 11vh, 110px) / -2);
        font-size: clamp(38px, 6.6vh, 66px);
        border-width: 4px;
        -webkit-text-stroke: 4px var(--ink);
    }
}
@media (max-height: 900px) {
    .goals {
        top: clamp(92px, 17vh, 150px);
        gap: 4px;
        padding: 8px 12px;
    }
    .goals div {
        padding: 3px 8px;
    }
}
@media (max-height: 420px) and (orientation: landscape) {
    .count {
        left: auto;
        right: 10px;
        margin-left: 0;
        top: 96px;
        bottom: auto;
        width: 60px;
        height: 60px;
        font-size: 34px;
    }
}
@media (max-height: 420px) and (orientation: landscape) {
    .goals {
        top: 98px;
    }
    .goals .tip {
        display: none;
    }
}
@media (max-height: 700px) {
    .medal {
        display: none;
    }
    .card {
        padding: 10px 16px;
    }
    .card h2 {
        font-size: 26px;
    }
    .stars .ic {
        width: 36px;
        height: 36px;
    }
    .stats {
        gap: 4px;
        margin: 4px 0 8px;
    }
    .stats .row {
        padding: 2px 6px;
        font-size: 12.5px;
    }
    .mbtns {
        gap: 6px;
    }
    .mbtns .btn {
        padding-top: 6px;
        padding-bottom: 6px;
        font-size: 17px;
    }
}
#btnPlay span {
    white-space: nowrap;
}
