@font-face {
    font-family: Fredoka;
    src: url("../assets/fonts/fredoka.ttf");
}
* {
    box-sizing: border-box;
}
html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}
body {
    font-family: Fredoka, system-ui, sans-serif;
    color: #fff;
    background: #0b1133;
}
button {
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}
button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}
.screen {
    display: none;
    position: absolute;
    inset: 0;
    background: #0b1133 url("../assets/images/space.jpg") center/cover no-repeat;
    overflow: auto;
}
.screen.active {
    display: block;
}
.top,
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 4%;
    max-width: 1400px;
    margin: auto;
}
header h2 {
    font-size: 26px;
    text-align: center;
    margin: 0;
}
.pill,
.hud-pill {
    background: #1a2158e8;
    border: 2px solid #879fef;
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #f5e4a4;
}
.eyebrow {
    font-size: 12px;
    letter-spacing: 0.13em;
    color: #a6d3ff;
    font-weight: 700;
}
.btn,
.tiny,
.level {
    border: 3px solid #ffffffaf;
    border-radius: 17px;
    font-weight: 700;
    box-shadow:
        0 6px 0 #172555,
        inset 0 4px 0 #ffffff6b,
        0 8px 18px #070b2d7a;
    transition:
        transform 0.1s,
        filter 0.1s;
}
.btn:active,
.tiny:active,
.level:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 #172555,
        inset 0 3px 0 #ffffff6b;
}
.btn:hover,
.tiny:hover {
    filter: brightness(1.1);
}
.btn {
    min-height: 54px;
    font-size: 18px;
    padding: 11px 16px;
    color: #fff;
    text-shadow: 0 2px 1px #34316775;
}
.btn span {
    float: right;
}
.tiny {
    min-width: 48px;
    min-height: 46px;
    padding: 7px 12px;
    background: linear-gradient(#e4edff, #a8c1ee);
    color: #314271;
    border-color: #7e9bdf;
    font-size: 16px;
}
.orange {
    background: linear-gradient(#ffce76, #f28e47);
    color: #563122;
    text-shadow: none;
}
.purple {
    background: linear-gradient(#dba5ff, #a774e6);
}
.blue {
    background: linear-gradient(#8bdaf5, #4da5d5);
    color: #24476f;
    text-shadow: none;
}
.green {
    background: linear-gradient(#a9e994, #6cc778);
    color: #275640;
    text-shadow: none;
}
.pink {
    background: linear-gradient(#ffaac9, #e976a4);
    color: #652e54;
    text-shadow: none;
}
.compact {
    min-height: 45px;
    font-size: 15px;
}
.home {
    width: min(1080px, 92%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 35px;
    margin: 3vh auto;
}
.home-box {
    width: 510px;
    background: #171d53ee;
    border: 3px solid #8399e8;
    border-radius: 27px;
    padding: 27px;
    box-shadow: 0 8px 0 #0a123c99;
}
.home h1 {
    font-size: clamp(52px, 6vw, 78px);
    line-height: 0.92;
    letter-spacing: -0.04em;
    margin: 14px 0 5px;
    text-shadow: 0 5px 0 #322363;
}
.home h1 em {
    font-style: normal;
    color: #ffc86e;
}
.home h2 {
    font-size: 19px;
    letter-spacing: 0.35em;
    color: #8ee3f8;
    margin: 10px 0;
}
.home p,
.panel p {
    font-size: 18px;
    line-height: 1.4;
    color: #dce8ff;
}
.home small {
    display: block;
    font-size: 11px;
    letter-spacing: 0.11em;
    color: #bfcdf7;
    text-align: center;
    margin-top: 16px;
}
.hero-image {
    width: min(40vw, 420px);
    aspect-ratio: 1;
    border: 6px solid #b9d7ff;
    border-radius: 32px;
    overflow: hidden;
    box-shadow:
        0 9px 0 #262c71,
        0 15px 40px #0008;
    transform: rotate(-2deg);
}
.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.primary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.secondary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 13px;
}
.secondary .btn {
    font-size: 15px;
    padding: 8px 4px;
}
.panel,
.load-box {
    background: #1b245bee;
    border: 3px solid #8fa9ee;
    border-radius: 24px;
    padding: 24px;
    box-shadow:
        0 7px 0 #090e34aa,
        0 10px 35px #02051a99;
}
.load-box {
    position: absolute;
    width: min(350px, 90%);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.load-box img {
    width: 100px;
    height: 130px;
    object-fit: contain;
}
.load-box h1 {
    font-size: 37px;
    margin: 8px;
}
.loadbar {
    height: 18px;
    border-radius: 20px;
    background: #101840;
    border: 2px solid #94b5ec;
    overflow: hidden;
}
.loadbar i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #62d9f4, #a5e98b, #ffd86d);
}
.load-box strong {
    display: block;
    margin-top: 8px;
}
.map,
.info,
.settings {
    width: min(840px, 94%);
    margin: 12px auto;
    text-align: center;
}
.panel h2 {
    margin: 6px;
    font-size: 30px;
}
.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 17px;
    margin: 10px;
}
.pager b {
    min-width: 150px;
}
#levelGrid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}
.level {
    min-height: 74px;
    background: linear-gradient(#9cdff3, #5cadd8);
    color: #284875;
}
.level b {
    display: block;
    font-size: 24px;
}
.level span {
    font-size: 12px;
}
.level:disabled {
    background: #747e9d;
    color: #c4cbda;
    opacity: 0.7;
}
.map p {
    font-size: 14px;
}
.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 22px 0;
}
.cards article {
    text-align: left;
    background: #121a4ae8;
    border: 2px solid #7796d6;
    border-radius: 15px;
    padding: 12px;
}
.cards article > b {
    font-size: 26px;
    color: #ffd881;
}
.cards h3 {
    margin: 5px 0;
}
.cards p {
    font-size: 14px;
    margin: 0;
}
.settings {
    max-width: 450px;
}
.settings > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #141d4d;
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
}
.screen#game {
    overflow: hidden;
    background: #060e30 url("../assets/images/space.jpg") center/cover;
}
.game-head {
    height: 62px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 5px;
    background: #101943ed;
    border-bottom: 3px solid #647fc6;
}
.game-head .tiny {
    min-height: 44px;
}
.race-name {
    text-align: center;
    min-width: 190px;
}
.race-name small {
    display: block;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #a9c7ff;
}
.race-name strong {
    font-size: 20px;
}
.hud-pill {
    font-size: 14px;
    min-width: 90px;
    text-align: center;
}
.race-area {
    position: absolute;
    inset: 62px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
canvas {
    display: block;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    touch-action: none;
}
.race-progress {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(440px, 70%);
    background: #151e50e8;
    border: 2px solid #859cdd;
    border-radius: 14px;
    padding: 8px 12px;
}
.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #d4e5ff;
}
.progress-track,
.fuelbar {
    height: 12px;
    border-radius: 12px;
    background: #0c153d;
    border: 1px solid #7ba4d6;
    overflow: hidden;
    margin-top: 5px;
}
.progress-track i,
.fuelbar i {
    height: 100%;
    width: 0;
    display: block;
    background: linear-gradient(90deg, #80d5ee, #8ff2bf, #f9e278);
    border-radius: 12px;
}
.message {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: #172454e8;
    border: 2px solid #8eaae5;
    color: #eaf4ff;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    max-width: 95%;
}
.race-bottom {
    position: relative;
    flex: none;
    align-self: center;
    width: min(620px, 100%);
    padding: 10px 15px calc(12px + env(safe-area-inset-bottom));
    background: #111a48ef;
    border: 2px solid #7b98dc;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
}
.fuel {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #cce4ff;
}
.fuelbar {
    flex: 1;
    margin: 0;
}
.fuelbar i {
    background: linear-gradient(90deg, #b685fa, #ff9b73, #ffe37b);
}
.fuel b {
    color: #ffdb84;
    min-width: 67px;
    text-align: right;
}
.steer {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 10px;
    margin-top: 8px;
}
.steer .btn {
    min-height: 50px;
}
.steer #left,
.steer #right {
    font-size: 30px;
    line-height: 1;
    padding: 5px;
}
.impact {
    display: block;
    text-align: center;
    color: #ffd39d;
    font-size: 12px;
    line-height: 1.2;
    min-height: 15px;
    margin-top: 6px;
}
.overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #05081dbf;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}
.hidden {
    display: none;
}
.modal {
    text-align: center;
    width: min(430px, 100%);
}
.modal img {
    width: 75px;
    height: 110px;
    object-fit: contain;
}
.modal h2 {
    font-size: 30px;
}
.modal #modalButtons {
    display: grid;
    gap: 10px;
}
.modal .btn {
    width: 100%;
}
#modalStars {
    margin: 8px 0 14px;
    font-size: 32px;
    color: #ffdb6b;
}
.btn:disabled {
    opacity: 0.5;
    filter: grayscale(0.3);
}
@media (max-width: 700px) and (orientation: portrait) {
    .top,
    header {
        padding: 9px 12px;
    }
    header h2 {
        font-size: 20px;
    }
    .top .pill {
        font-size: 10px;
    }
    .home {
        flex-direction: column;
        gap: 10px;
        margin: 0 auto;
    }
    .hero-image {
        width: min(47vw, 180px);
        height: 155px;
        transform: rotate(-1deg);
    }
    .home-box {
        width: min(450px, 100%);
        padding: 17px;
    }
    .home h1 {
        font-size: clamp(40px, 11vw, 55px);
        margin: 8px 0;
    }
    .home h2 {
        font-size: 13px;
    }
    .home p {
        font-size: 15px;
        margin: 9px 0;
    }
    .primary .btn {
        font-size: 15px;
    }
    .secondary .btn {
        font-size: 14px;
    }
    .home small {
        font-size: 10px;
    }
    .map,
    .info,
    .settings {
        padding: 15px;
        margin: 8px auto;
    }
    .cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin: 12px 0;
    }
    .cards p {
        font-size: 13px;
    }
    #levelGrid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .level {
        min-height: 60px;
    }
    .game-head {
        height: 56px;
        gap: 6px;
    }
    .game-head .tiny {
        min-width: 42px;
        min-height: 43px;
    }
    .race-name {
        min-width: 120px;
    }
    .race-name small {
        font-size: 9px;
    }
    .race-name strong {
        font-size: 17px;
    }
    .hud-pill {
        font-size: 12px;
        min-width: 70px;
        padding: 7px;
    }
    .race-area {
        inset: 56px 0 0;
    }
    .race-progress {
        top: 8px;
        width: calc(100% - 24px);
        padding: 6px 10px;
    }
    .progress-label {
        font-size: 11px;
    }
    .message {
        top: 58px;
        font-size: 12px;
        padding: 6px 10px;
    }
    .race-bottom {
        padding: 8px 12px calc(9px + env(safe-area-inset-bottom));
    }
    .steer .btn {
        min-height: 47px;
    }
    .impact {
        font-size: 11px;
    }
}
@media (max-width: 350px) {
    .race-name {
        min-width: 100px;
    }
    .race-name strong {
        font-size: 15px;
    }
    .message {
        white-space: normal;
        width: 90%;
    }
}
@media (max-height: 500px) and (orientation: landscape) {
    .game-head {
        height: 48px;
    }
    .game-head .tiny {
        min-height: 37px;
    }
    .race-name strong {
        font-size: 16px;
    }
    .race-name small {
        font-size: 9px;
    }
    .race-area {
        inset: 48px 0 0;
    }
    .race-progress {
        width: 290px;
        left: 12px;
        transform: none;
        top: 6px;
    }
    .message {
        top: 6px;
        left: auto;
        right: 12px;
        transform: none;
        font-size: 11px;
    }
    .race-area {
        flex-direction: row;
    }
    .race-bottom {
        align-self: flex-end;
        width: 280px;
        padding: 6px;
    }
    .steer .btn {
        min-height: 40px;
    }
    .steer {
        margin-top: 4px;
    }
    .impact {
        height: 12px;
    }
}

.yellow {
    background: linear-gradient(#ffe58e, #f4b650);
    color: #65421e;
    text-shadow: none;
}
.garage-button {
    width: 100%;
    margin-top: 12px;
    min-height: 48px;
    font-size: 16px;
}
.garage {
    width: min(700px, 94%);
    margin: 12px auto;
    text-align: center;
}
.ships {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
}
.ship {
    background: linear-gradient(#404c8c, #232d69);
    border: 3px solid #a3b5ef;
    border-radius: 18px;
    color: #fff;
    padding: 12px;
    box-shadow: 0 5px 0 #101842;
    font-weight: 700;
    min-width: 0;
}
.ship img {
    width: 100%;
    height: 170px;
    object-fit: contain;
    display: block;
}
.ship b {
    font-size: 16px;
}
.ship.selected {
    border-color: #ffe078;
    background: linear-gradient(#6c65af, #3a407a);
    box-shadow:
        0 5px 0 #58468a,
        0 0 0 3px #fff6b1;
}
.ship:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}
@media (max-width: 700px) and (orientation: portrait) {
    .garage-button {
        margin-top: 8px;
        min-height: 45px;
        font-size: 14px;
    }
    .garage {
        padding: 15px;
        margin: 8px auto;
    }
    .ships {
        gap: 8px;
        margin: 12px 0;
    }
    .ship {
        padding: 6px;
    }
    .ship img {
        height: 110px;
    }
    .ship b {
        font-size: 13px;
    }
}

/* Racing polish */
.countdown {
    position: absolute;
    left: 50%;
    top: 37%;
    transform: translate(-50%, -50%);
    font-size: clamp(80px, 15vw, 150px);
    line-height: 1;
    font-weight: 800;
    color: #ffe17a;
    text-shadow:
        0 5px 0 #b65f28,
        0 9px 0 #3f2564,
        0 0 30px #9edcff;
    pointer-events: none;
}
.countdown.hidden {
    display: none;
}
.hud-pill {
    background: linear-gradient(#344b99, #212861);
    box-shadow:
        inset 0 3px 0 #ffffff35,
        0 3px 0 #0b1037;
}
.race-progress {
    box-shadow:
        inset 0 2px 0 #ffffff27,
        0 5px 15px #050a2c80;
}
.race-bottom {
    box-shadow:
        inset 0 3px 0 #ffffff25,
        0 -6px 20px #050a2b70;
}
.steer .btn {
    border-radius: 15px;
}
.steer #boost:not(:disabled) {
    box-shadow:
        0 6px 0 #9d4f25,
        inset 0 4px 0 #ffffff85,
        0 0 19px #ffbf6780;
}

/* ---------- Polish: icons, feedback, motion ---------- */
.ic {
    width: 1.1em;
    height: 1.1em;
    fill: currentColor;
    vertical-align: -0.17em;
    flex: none;
}
.tiny .ic {
    width: 1.2em;
    height: 1.2em;
}
.btn span .ic {
    width: 1em;
    height: 1em;
}
.level span .ic {
    width: 1.5em;
    height: 1.5em;
    margin: 0 1px;
    color: #ffc93a;
}
.level:disabled span .ic {
    width: 1.2em;
    height: 1.2em;
    color: #c4cbda;
}
.pill .ic {
    color: #ffd75a;
}
#modalStars {
    margin: 8px 0 14px;
    display: flex;
    justify-content: center;
    gap: 6px;
    color: #ffd75a;
    font-size: 34px;
    min-height: 0;
}
#modalStars .ic {
    width: 1em;
    height: 1em;
    animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
#modalStars .ic:nth-child(2) {
    animation-delay: 0.15s;
}
#modalStars .ic:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes pop {
    from {
        transform: scale(0) rotate(-40deg);
    }
    to {
        transform: scale(1) rotate(0);
    }
}
.screen.active {
    animation: screen-in 0.28s ease-out;
}
@keyframes screen-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.overlay:not(.hidden) .modal {
    animation: modal-pop 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.86);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.hero-image img {
    transition: transform 0.35s;
}
.hero-image:hover img {
    transform: scale(1.03) rotate(-0.6deg);
}
.level:not(:disabled):hover {
    transform: translateY(-3px);
    filter: brightness(1.12);
}
.ship {
    transition:
        transform 0.15s,
        box-shadow 0.15s;
}
.ship:hover {
    transform: translateY(-4px);
}
.ship.selected img {
    animation: hover-ship 1.8s ease-in-out infinite;
}
@keyframes hover-ship {
    50% {
        transform: translateY(-6px);
    }
}
#boost:not(:disabled) {
    animation: boost-ready 1.2s ease-in-out infinite;
}
@keyframes boost-ready {
    50% {
        filter: brightness(1.2);
        box-shadow:
            0 6px 0 #172555,
            inset 0 4px 0 #ffffff6b,
            0 0 22px #ffb64aaa;
    }
}
.btn:disabled {
    filter: saturate(0.5) brightness(0.85);
    cursor: default;
}
.load-box img {
    animation: hover-ship 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- Art direction v2: icons, illustration, feedback ---------- */
.ic {
    filter: drop-shadow(0 2px 0 #0b1236aa);
}
.pill .ic,
.hud-pill .ic,
.tiny .ic,
.fuel .ic,
.ic.row {
    filter: none;
}
.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 0.2px;
}
.btn em {
    font-style: normal;
    flex: 1;
    text-align: center;
}
.btn .ic.lead {
    width: 30px;
    height: 30px;
}
.btn .ic.tail {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}
.btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(100deg, transparent, #ffffff66, transparent);
    transform: skewX(-20deg);
    transition: left 0.5s;
    pointer-events: none;
}
.btn:hover::after {
    left: 130%;
}
.btn:hover:not(:disabled) {
    transform: translateY(-2px);
}
.btn:active:not(:disabled) {
    transform: translateY(4px);
}
.btn.stack {
    flex-direction: column;
    gap: 2px;
    padding: 8px 4px 9px;
}
.btn.stack em {
    flex: none;
}
.btn.stack .ic.big {
    width: 34px;
    height: 34px;
}
.garage-button .ic.lead {
    width: 28px;
    height: 28px;
}
.top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.brand-pill .ic {
    width: 20px;
    height: 20px;
}
.pill .ic {
    width: 18px;
    height: 18px;
    vertical-align: -4px;
}
.tiny .ic {
    width: 24px;
    height: 24px;
}
.tiny.back .ic {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
}
/* menu scenery */
.deco {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.deco .planet {
    position: absolute;
    filter: drop-shadow(0 6px 14px #0008);
    animation: drift 9s ease-in-out infinite;
}
.deco .p-a {
    width: 92px;
    left: 4%;
    top: 14%;
}
.deco .p-b {
    width: 70px;
    right: 5%;
    bottom: 12%;
    animation-delay: -3s;
}
.deco .p-c {
    width: 62px;
    left: 9%;
    bottom: 9%;
    animation-delay: -6s;
}
@keyframes drift {
    50% {
        transform: translateY(-14px) rotate(4deg);
    }
}
.shoot {
    position: absolute;
    width: 120px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, #fff);
    opacity: 0;
    transform: rotate(28deg);
    animation: shoot 7s linear infinite;
}
.shoot.s1 {
    left: 55%;
    top: 8%;
}
.shoot.s2 {
    left: 15%;
    top: 40%;
    animation-delay: 3.5s;
}
@keyframes shoot {
    0% {
        opacity: 0;
        translate: 0 0;
    }
    4% {
        opacity: 1;
    }
    12% {
        opacity: 0;
        translate: 220px 120px;
    }
    100% {
        opacity: 0;
    }
}
.home,
#menu .top {
    position: relative;
    z-index: 1;
}
.hero-image {
    animation: bob 5s ease-in-out infinite;
    position: relative;
}
.hero-image::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 26px;
    background: linear-gradient(120deg, transparent 40%, #ffffff33 50%, transparent 60%);
    background-size: 250% 100%;
    animation: sheen 5s ease-in-out infinite;
}
@keyframes bob {
    50% {
        transform: rotate(-2deg) translateY(-8px);
    }
}
@keyframes sheen {
    from {
        background-position: 130% 0;
    }
    to {
        background-position: -60% 0;
    }
}
.home-box {
    position: relative;
    backdrop-filter: blur(6px);
}
.home-box::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 22px;
    border: 1px dashed #8399e855;
    pointer-events: none;
}
/* race map */
.world-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.world-badge .ic {
    width: 52px;
    height: 52px;
    animation: drift 6s ease-in-out infinite;
}
#levelGrid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 12px 0;
}
.level {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(#7de0ff, #3f8fe6);
    color: #fff;
    text-shadow: 0 2px 0 #1d3f8a;
}
.level b {
    font-size: 22px;
}
.level span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
}
.level span .ic {
    width: 20px;
    height: 20px;
    margin: 0 -1px;
    filter: none;
}
.level:disabled {
    background: linear-gradient(#59679c, #3a4478);
    color: #b4bfe6;
    text-shadow: none;
    opacity: 1;
    filter: none;
    cursor: not-allowed;
}
.level:disabled span .ic {
    width: 22px;
    height: 22px;
}
.level.current {
    background: linear-gradient(#ffd56e, #ff9740);
    color: #5a2f10;
    text-shadow: none;
    animation: pulse-ring 1.6s ease-in-out infinite;
}
@keyframes pulse-ring {
    0%,
    100% {
        box-shadow:
            0 6px 0 #172555,
            inset 0 4px 0 #ffffff6b,
            0 0 0 0 #ffd56e99;
    }
    50% {
        box-shadow:
            0 6px 0 #172555,
            inset 0 4px 0 #ffffff6b,
            0 0 0 9px #ffd56e00;
    }
}
#levels[data-world="2"] .level:not(:disabled):not(.current) {
    background: linear-gradient(#ffb98a, #e0663a);
    text-shadow: 0 2px 0 #7a2a12;
}
#levels[data-world="3"] .level:not(:disabled):not(.current) {
    background: linear-gradient(#ffe483, #e4a21b);
    text-shadow: 0 2px 0 #8a5a0b;
}
#levels[data-world="4"] .level:not(:disabled):not(.current) {
    background: linear-gradient(#8ff2c6, #1fa08c);
    text-shadow: 0 2px 0 #0a5a50;
}
#levels[data-world="5"] .level:not(:disabled):not(.current) {
    background: linear-gradient(#ff9fb8, #cf2f6b);
    text-shadow: 0 2px 0 #5a0c30;
}
#levels[data-world="1"] .level:not(:disabled):not(.current) {
    background: linear-gradient(#b9a6ff, #6c54e6);
    text-shadow: 0 2px 0 #2a1f86;
}
/* how to play */
.cards article {
    position: relative;
    text-align: center;
    padding: 16px 12px 12px;
    transition:
        transform 0.2s,
        border-color 0.2s;
}
.cards article:hover {
    transform: translateY(-4px);
    border-color: #ffe078;
}
.tile {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    margin: 0 auto 6px;
    border-radius: 20px;
    border: 3px solid #ffffff99;
    box-shadow:
        0 5px 0 #0b1236,
        inset 0 3px 0 #ffffff66;
}
.tile .ic {
    width: 38px;
    height: 38px;
}
.tile.t1 {
    background: linear-gradient(#7de0ff, #2f7bff);
}
.tile.t2 {
    background: linear-gradient(#c7b3ff, #7a4dff);
}
.tile.t3 {
    background: linear-gradient(#ffe98a, #ff9f1c);
}
.tile.t4 {
    background: linear-gradient(#b5f56b, #2fb85a);
}
.cards article:hover .tile .ic {
    animation: wiggle 0.5s;
}
@keyframes wiggle {
    25% {
        transform: rotate(-10deg) scale(1.1);
    }
    75% {
        transform: rotate(10deg) scale(1.1);
    }
}
/* garage */
.ship {
    position: relative;
    overflow: hidden;
}
.ship .pad {
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: 34px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(#9fd6ff99, #9fd6ff00 70%);
    border: 2px solid #9fd6ff55;
}
.ship img {
    position: relative;
    transition: transform 0.25s;
}
.ship:hover img {
    transform: translateY(-6px) scale(1.05);
}
.ship[data-ship="rival"] .pad {
    background: radial-gradient(#ff9ad599, #ff9ad500 70%);
    border-color: #ff9ad566;
}
.ship[data-ship="rival2"] .pad {
    background: radial-gradient(#b5f56b99, #b5f56b00 70%);
    border-color: #b5f56b66;
}
.ship.selected::after {
    content: "EQUIPPED";
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 9px;
    border-radius: 12px;
    background: linear-gradient(#ffe078, #ffab2e);
    color: #5a2f10;
    font-size: 10px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 0 #7a4a10;
}
/* settings */
.settings > div strong {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ic.row {
    width: 28px;
    height: 28px;
}
.settings .btn .ic {
    width: 20px;
    height: 20px;
}
/* HUD */
.hud-pill {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.hud-pill .ic {
    width: 20px;
    height: 20px;
}
#starPill {
    min-width: 0;
    padding: 6px 10px;
}
.fuel .ic {
    width: 18px;
    height: 18px;
    vertical-align: -4px;
}
.progress-track,
.fuelbar {
    position: relative;
}
.progress-track i,
.fuelbar i {
    position: relative;
    transition: width 0.2s;
}
.progress-track i::after {
    content: "";
    position: absolute;
    right: -2px;
    top: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(#fff, #ffe17a 60%, #ff9f1c);
    box-shadow: 0 0 10px #ffe17a;
}
.fuelbar i::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, #ffffff66 50%, transparent 70%);
    background-size: 200% 100%;
}
.steer #left,
.steer #right {
    font-size: 0;
}
.steer #left .ic,
.steer #right .ic {
    width: 34px;
    height: 34px;
}
.steer #boost .ic {
    width: 26px;
    height: 26px;
}
.countdown {
    animation: count-pop 1s ease-out infinite;
}
@keyframes count-pop {
    from {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.2;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0.8;
    }
}
.speedlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    background: repeating-conic-gradient(
        from 0deg at 50% 62%,
        transparent 0 5deg,
        #bfe9ff30 5deg 5.6deg,
        transparent 5.6deg 12deg
    );
    -webkit-mask: radial-gradient(circle at 50% 62%, transparent 22%, #000 78%);
    mask: radial-gradient(circle at 50% 62%, transparent 22%, #000 78%);
}
.speedlines.on {
    opacity: 1;
}
@keyframes rush {
    to {
        transform: scale(1.12);
    }
}
.hitflash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    box-shadow: inset 0 0 90px 24px #ff3b5c;
}
.hitflash.on {
    animation: flash 0.6s ease-out;
}
@keyframes flash {
    from {
        opacity: 0.9;
    }
    to {
        opacity: 0;
    }
}
.race-area.shake {
    animation: shake 0.4s;
}
@keyframes shake {
    20% {
        transform: translate(-7px, 3px);
    }
    40% {
        transform: translate(6px, -4px);
    }
    60% {
        transform: translate(-4px, 2px);
    }
    80% {
        transform: translate(3px, -1px);
    }
}
.popup {
    position: absolute;
    left: 50%;
    top: 46%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    background: #1a2158ee;
    border: 2px solid #ffe078;
    color: #ffe078;
    font-weight: 800;
    pointer-events: none;
    animation: float-up 1.1s ease-out forwards;
}
.popup .ic {
    width: 20px;
    height: 20px;
}
@keyframes float-up {
    from {
        transform: translate(-50%, 0) scale(0.7);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -10px) scale(1.1);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -70px);
        opacity: 0;
    }
}
/* dialogs */
.modal {
    position: relative;
    z-index: 1;
    overflow: hidden;
}
.modal-art.medal .ic {
    width: 92px;
    height: 92px;
    animation: medal-in 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
@keyframes medal-in {
    from {
        transform: scale(0) rotate(-90deg);
    }
    to {
        transform: none;
    }
}
.confetti {
    z-index: 0;
    position: absolute;
    top: -12px;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    pointer-events: none;
    animation: fall 2.4s linear forwards;
}
@keyframes fall {
    to {
        transform: translate(var(--drift), 105vh) rotate(720deg);
    }
}
.overlay {
    overflow: hidden;
}
#modalStars .ic {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 3px 0 #0b1236aa);
}
.load-box img {
    animation: hover-ship 1.6s ease-in-out infinite;
}

/* ---------- Fit every menu on one screen (short screens and phones) ---------- */
@media (max-height: 520px),
    (max-height: 640px) and (min-width: 700px),
    (max-width: 699px) and (orientation: landscape) and (max-height: 640px) {
    .top,
    header {
        padding: 6px 3%;
    }
    header h2 {
        font-size: 17px;
    }
    .home {
        gap: 18px;
        margin: 0 auto;
    }
    .hero-image {
        width: min(34vh, 40vw);
        border-width: 4px;
        border-radius: 22px;
    }
    .home-box {
        width: min(480px, 58vw);
        padding: 12px 16px;
        border-radius: 20px;
    }
    .home h1 {
        font-size: clamp(30px, 11vh, 44px);
    }
    .home h2 {
        font-size: 13px;
        margin: 2px 0;
    }
    .home p {
        display: none;
    }
    .home small {
        display: none;
    }
    .home .btn {
        min-height: 38px;
        padding: 6px 8px;
        font-size: 14px;
    }
    .garage-button {
        margin-top: 8px;
        min-height: 38px;
    }
    .secondary {
        margin-top: 8px;
        gap: 8px;
    }
    .panel {
        padding: 10px 14px;
        border-radius: 18px;
    }
    .map,
    .info,
    .settings,
    .garage {
        margin: 4px auto;
    }
    .panel h2 {
        font-size: 20px;
        margin: 2px;
    }
    .panel p {
        margin: 3px 0;
        font-size: 12px;
    }
    .cards {
        margin: 8px 0;
        gap: 8px;
    }
    .cards article {
        padding: 6px 8px;
    }
    .cards article > b {
        font-size: 18px;
    }
    .cards h3 {
        margin: 1px 0;
        font-size: 14px;
    }
    .cards p {
        font-size: 11px;
        line-height: 1.2;
    }
    .level {
        min-height: 44px;
    }
    .level b {
        font-size: 18px;
    }
    .level span .ic {
        width: 1.2em;
        height: 1.2em;
    }
    .ships {
        margin: 8px 0;
        gap: 8px;
    }
    .ship {
        padding: 6px;
    }
    .ship img {
        height: min(26vh, 110px);
    }
    .ship b {
        font-size: 13px;
    }
    .settings .btn {
        min-height: 40px;
    }
}
@media (max-width: 380px) and (orientation: portrait),
    (max-width: 699px) and (orientation: portrait) and (max-height: 700px) {
    .home-box {
        padding: 16px 14px;
    }
    .home h1 {
        font-size: 46px;
    }
    .home p {
        margin: 4px 0 8px;
        font-size: 13px;
    }
    .home .hero-image {
        width: min(40vw, 17vh);
        height: min(40vw, 17vh);
        aspect-ratio: auto;
        border-width: 4px;
    }
    .home small {
        display: none;
    }
    .home p {
        display: none;
    }
    .home h1 {
        font-size: 40px;
    }
    .home .btn {
        min-height: 42px;
    }
    .home {
        margin: 1vh auto;
        gap: 14px;
    }
    .cards {
        grid-template-columns: repeat(2, 1fr);
        margin: 10px 0;
    }
    .cards article {
        padding: 6px 8px;
    }
    .cards article > b {
        font-size: 20px;
    }
    .cards p {
        font-size: 11px;
        line-height: 1.25;
    }
    .panel {
        padding: 10px 12px;
    }
    .panel h2 {
        font-size: 24px;
    }
    .level {
        min-height: 54px;
    }
}
@media (max-height: 360px) {
    header h2 {
        font-size: 15px;
    }
    .panel {
        padding: 6px 10px;
    }
    .panel h2 {
        font-size: 17px;
    }
    .cards {
        margin: 4px 0;
    }
    .cards article {
        padding: 4px 6px;
    }
    .cards p {
        font-size: 10px;
    }
    .btn,
    .tiny {
        min-height: 34px;
    }
    .level {
        min-height: 36px;
    }
    .ship img {
        height: 22vh;
    }
    .home-box {
        padding: 8px 14px;
    }
}
@media (max-width: 520px) {
    .brand-pill {
        display: none;
    }
    .top {
        justify-content: flex-end;
    }
}
@media (max-height: 520px) {
    .btn.stack {
        flex-direction: row;
        gap: 6px;
    }
    .btn.stack .ic.big {
        width: 22px;
        height: 22px;
    }
    .btn .ic.lead {
        width: 22px;
        height: 22px;
    }
    .tile {
        width: 40px;
        height: 40px;
        margin-bottom: 2px;
        border-radius: 14px;
    }
    .tile .ic {
        width: 26px;
        height: 26px;
    }
    .cards article {
        padding: 6px 8px;
    }
    .world-badge .ic {
        width: 34px;
        height: 34px;
    }
    .level b {
        font-size: 16px;
    }
    .level span {
        min-height: 16px;
    }
    .level span .ic {
        width: 15px;
        height: 15px;
    }
    .level:disabled span .ic {
        width: 15px;
        height: 15px;
    }
    #levelGrid {
        gap: 8px;
        margin: 6px 0;
    }
    .pager {
        margin: 4px;
    }
    .deco .planet {
        display: none;
    }
    .ship .pad {
        bottom: 22px;
        height: 14px;
    }
}
@media (max-width: 380px) and (orientation: portrait) {
    .tile {
        width: 44px;
        height: 44px;
        margin-bottom: 2px;
    }
    .tile .ic {
        width: 28px;
        height: 28px;
    }
    .cards h3 {
        font-size: 15px;
    }
    .btn.stack .ic.big {
        width: 26px;
        height: 26px;
    }
}
@media (max-height: 740px) and (min-width: 700px) {
    .home {
        margin: 1.5vh auto;
    }
    .home .hero-image {
        width: min(40vw, 46vh);
    }
    .home-box {
        padding: 18px 22px;
    }
    .home h1 {
        font-size: clamp(40px, 8.5vh, 70px);
    }
    .home p {
        margin: 4px 0 10px;
    }
    .home .btn {
        min-height: 46px;
        padding-top: 7px;
        padding-bottom: 7px;
    }
    .garage-button {
        margin-top: 8px;
    }
}
/* The menu fills the screen as a column, so nothing sticks out and nothing is cut. */
#menu.active {
    display: flex;
    flex-direction: column;
}
#menu .home {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0;
    margin-bottom: 0;
}
@media (max-width: 699px) and (orientation: portrait) and (max-height: 520px) {
    .home .hero-image {
        display: none;
    }
}
/* End of style.css */


/* ================= v1.1 art direction pass: race HUD ================= */
.game-head {
    background: linear-gradient(#1b2870f2, #0e1650f2);
    border-bottom: 0;
    box-shadow:
        0 3px 0 #6d8ae0,
        0 6px 22px #4fb6ff55;
    position: relative;
    z-index: 3;
}
.hud-pill {
    border: 2px solid #8fb0ff;
    border-radius: 999px;
    background: linear-gradient(#3a55b8, #1d2a78);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow:
        inset 0 3px 0 #ffffff40,
        0 3px 0 #0b1037,
        0 0 14px #5fa8ff40;
}
.race-progress {
    background: linear-gradient(#1c2a7af0, #0f1850f0);
    border: 2px solid #8fb0ff;
    box-shadow:
        inset 0 2px 0 #ffffff30,
        0 6px 18px #050a2c90,
        0 0 18px #4fb6ff40;
}
.race-progress .progress-track {
    margin-top: 10px;
    overflow: visible;
    position: relative;
    height: 14px;
    background: repeating-linear-gradient(90deg, #0a1238 0 10%, #101a4c 10% 20%);
}
.race-progress .progress-track::after {
    content: "";
    position: absolute;
    right: -2px;
    top: -5px;
    width: 14px;
    height: 22px;
    background: url("../assets/images/finish-flag.svg") center/contain no-repeat;
}
#progressFill {
    position: relative;
    background: linear-gradient(90deg, #5fd4ff, #8ff2bf, #ffe27a);
    box-shadow: 0 0 10px #8ff2bf90;
}
#progressFill::after {
    content: "";
    position: absolute;
    right: -15px;
    top: -9px;
    width: 30px;
    height: 30px;
    background: url("../assets/images/rocket.png") center/contain no-repeat;
    transform: rotate(90deg);
    filter: drop-shadow(0 2px 3px #0008);
}
.message {
    background: linear-gradient(#233a8cf0, #172062f0);
    border: 2px solid #9db8ff;
    box-shadow:
        inset 0 2px 0 #ffffff30,
        0 4px 14px #050a2c80;
}
.race-bottom {
    background: linear-gradient(#18246cf5, #0d1448f8);
    border: 2px solid #8fb0ff;
    border-bottom: 0;
    box-shadow:
        inset 0 3px 0 #ffffff30,
        0 -8px 26px #4fb6ff40;
}
.fuelbar {
    position: relative;
    height: 14px;
    background: #090f33;
    border-color: #8fb0ff;
}
.fuelbar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 2px), #090f33 calc(25% - 2px) 25%);
    pointer-events: none;
}
.fuelbar i {
    box-shadow: 0 0 12px #ffb36b99;
    transition: width 0.25s ease-out;
}
.steer .btn {
    transition:
        transform 0.12s,
        box-shadow 0.12s,
        filter 0.12s;
}
.steer .btn:not(:disabled):hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
}
.steer .btn:not(:disabled):active {
    transform: translateY(3px);
}
.steer #boost:not(:disabled) {
    animation: boostPulse 1.1s ease-in-out infinite;
}
@keyframes boostPulse {
    50% {
        box-shadow:
            0 6px 0 #9d4f25,
            inset 0 4px 0 #ffffff85,
            0 0 34px #ffd27acc;
    }
}
.countdown {
    display: grid;
    place-items: center;
    width: clamp(120px, 20vw, 190px);
    height: clamp(120px, 20vw, 190px);
    border-radius: 50%;
    font-size: clamp(60px, 10vw, 100px);
    color: #fff;
    background: radial-gradient(circle at 35% 30%, #4b63d6, #141c6a 70%);
    border: 7px solid #ffd75a;
    text-shadow:
        0 4px 0 #1a1f6e,
        0 0 18px #9edcff;
    box-shadow:
        0 0 0 6px #ffffff30,
        0 0 40px #6bc4ff99,
        inset 0 6px 0 #ffffff30;
    animation: cdPop 0.9s ease-out infinite;
}
@keyframes cdPop {
    0% {
        scale: 0.7;
        opacity: 0.2;
    }
    25% {
        scale: 1.08;
        opacity: 1;
    }
    100% {
        scale: 1;
    }
}
@media (max-width: 700px) {
    .race-progress .progress-track::after {
        display: none;
    }
}

#game.endless-mode .race-progress .progress-track::after {
    display: none;
}
