legend {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

#main {
    display: flex;
    flex-direction: column;
    margin-top: var(--header-height)
}



#pilotMainWrapper {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    padding-inline: 1rem;
}




.pilotSection {

    display: flex;
    flex-direction: column;
    gap: 2em;
}


#statsbarDiv {
    position: absolute;
    top: calc(var(--header-height) + 3.5rem);
    left: 50%;
    transform: translateX(-50%);
    height: 2rem;
    background-color: transparent;
    font-size: 1.5rem;
    z-index: 2;



}


#rankingDiv {
    right: 0px;
    left: auto;
}


#brainDiv {
    /* border: 2px inset var(--color); */
    min-height: 10rem;
    max-height: 40rem;
    overflow-y: scroll;
    overflow-x: visible;
    background-color: var(--bgcolor);
    /* padding: 0.5rem; */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* empty braindiv */

#brainDiv:empty {
    color: var(--color);

    border: 0px solid transparent;
    overflow-y: visible;

}

.brainWrapper {
    position: relative;
    padding: 0;
    /* Fjern padding så bildet fyller hele kortet */
    margin: 0.2rem;
    background-color: var(--bgcolor);
    border: 2px solid transparent;
    overflow: hidden;
    /* Sikrer at innhold ikke stikker utenfor rundingene */
    display: flex;
    flex-direction: column;
}

.brainWrapper:hover {
    cursor: pointer;
    /* make it a bit bigger */
    z-index: 10;
    border: 2px solid var(--color);

}

.brainWrapper img {
    width: 100%;
    height: auto;
    display: block;
    /* Fjerner liten glippe under bildet */
    object-fit: cover;
}

#currentBrainInfo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#currentBrain>h2 {
    display: flex;
    justify-content: center;
}

#currentBrainInfo>.brainWrapper>img {
    width: 100%;
    height: auto;
}

#currentBrainInfo>.brainWrapper>.brainInfoScore {
    font-size: x-large;
}

/* Make the image brighter when hovering over the brainDiv */
.brainWrapper:hover img {
    filter: brightness(1.5);
    transition: filter 0.2s;

}

.brainInfo {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.75);
    /* Mørk gjennomsiktig bakgrunn */
    color: white;
    padding: 0.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    backdrop-filter: blur(2px);
    /* Liten blur effekt for modernitet */
}

.brainInfoName,
.brainInfoSize,
.brainInfoScore {
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    /* Ikke bryt linjen */
    overflow: hidden;
    /* Skjul det som stikker ut */
    text-overflow: ellipsis;
    /* Legg til ... på slutten */
    text-shadow: 1px 1px 2px black;
}



.brainInfo>div {
    word-break: break-all;

}


#brainDiv img {
    width: 100%;
}

.brainInfoWrapper {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #ccc;
    /* Litt gråere for mindre viktighet */
}

.scoreBarWrapper {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.scoreBar {
    height: 6px;
    flex: 1;
    /* Fordeler plassen jevnt */
    background-color: #444;
    /* Farge for inaktive bars */
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.scoreBar.active {
    background-color: #ffd700;
    /* GUL */
    box-shadow: 0 0 4px #ffd700;
    /* Liten glød */
}

/* Justering av vekt-knappen for å ligge oppe i høyre hjørne over bildet */
.viewModelWeightsBtn {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.8);
    border: none;
    padding: 0.2rem 0.5rem;
    font-size: 1.2rem;
    border-radius: 4px;
}

.viewModelWeightsBtn:hover {
    background-color: white;
    transform: scale(1.1);
}

/* Play brain button - positioned top left corner */
.playBrainBtn {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 10;
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    border: none;
    padding: 0.2rem 0.5rem;
    font-size: 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.playBrainBtn:hover {
    background-color: #45a049;
    transform: scale(1.1);
}

.playBrainBtn:disabled {
    background-color: rgba(136, 136, 136, 0.8);
    cursor: not-allowed;
}

.pilotMutRangeWrapper {
    margin-inline: 1rem;

}

#pilotTrainMutationRange {
    width: 100%;
}

#pilotMutOutput {
    background: var(--panel-color);
    color: var(--color);
    padding: 4px 12px;
    position: absolute;
    border-radius: 4px;
    left: 50%;
    transform: translateX(-50%);
}


#pilotTrainButtonsWrapper {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#pilotTrainButtonsWrapper button {

    background-color: var(--panel-color);
    margin-top: 1rem;
    padding: 0.5rem;
    font-size: larger;
    color: var(--color);
    cursor: pointer;
    transition: background-color 0.2s;

}

#pilotTrainButtonsWrapper button:hover {
    background-color: var(--color);
    color: var(--bgcolor);
}

#trainBrainWrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;

}



#pilotTrainNTimes {
    width: 2rem;
}

#drawSettings {
    left: 1rem;
}

/* Speed radio buttons */
#speedRadioWrapper {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#speedRadioWrapper label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}




#upgradesShopWrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-block: 2rem;
}

#upgradesShopWrapper p {
    max-width: 50%;
}

#upgradesShop {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    margin-inline: auto;
    gap: 1rem;

}

.shop-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--panel-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-y: auto;
    flex-grow: 1;
}


.shop-item {
    display: flex;
    gap: 1rem;
    align-items: center;

}

.shop-item>:nth-child(2) {
    margin-left: auto;
    /* pushes this and everything after it to the right */
}

.shop-item>h3 {
    margin: 0;
}

.shop-item>button {
    background-color: transparent;
    font-size: 1.75rem;
    padding: 0;
    border-radius: var(--border-radius);
    cursor: pointer;

}

.shop-item>button:hover {
    background-color: transparent;
    transform: scale(1.4);
}

.shop-item>.level-indicator-wrapper {
    display: flex;
    gap: 0.25rem;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, .06), rgba(0, 0, 0, .12)),
        var(--panel-color);
    border: 1px solid rgba(0, 0, 0, .35);
    box-shadow: 0 3px 6px rgba(0, 0, 0, .35);
    padding: 0.35rem 0.5rem;
    border-radius: var(--border-radius);
}



.level-indicator {
    position: relative;
    width: 1rem;
    height: 2rem;
    border-radius: 0.35rem;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.55);
    background: linear-gradient(to bottom, #6b7280, #3b4452 55%, #1f2430);
    /* inactive steel look */
    box-shadow:
        inset 0 2px 2px rgba(255, 255, 255, 0.18),
        /* top bevel */
        inset 0 -3px 5px rgba(0, 0, 0, 0.45),
        /* bottom inner shadow */
        0 1px 0 rgba(255, 255, 255, 0.08),
        /* outer edge light */
        0 2px 6px rgba(0, 0, 0, 0.35);
    /* drop shadow */
    transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}

/* glossy highlight */
.level-indicator::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 45%),
        radial-gradient(100% 80% at 30% 0%, rgba(255, 255, 255, .35), transparent 60%);
    mix-blend-mode: screen;
}

/* active (green) state with subtle glow */
.level-indicator.level-active {
    background: linear-gradient(to bottom, #48f77c, #22c55e 55%, #15803d);
    border-color: #0b5d2a;
    box-shadow:
        inset 0 2px 2px rgba(255, 255, 255, 0.22),
        inset 0 -3px 6px rgba(0, 0, 0, 0.45),
        0 0 8px rgba(34, 197, 94, 0.45),
        0 2px 6px rgba(0, 0, 0, 0.35);
}


.floating-description {
    position: fixed;
    display: flex;
    box-sizing: border-box;
    background-color: var(--bgcolor);
    border: 3px outset var(--color);
    padding: 0.5rem;
    border-radius: 0.5rem;
    z-index: 1000;
    pointer-events: none;
    gap: 0.5rem;
    align-items: flex-start;
}


.floating-description-image {
    max-width: 150px;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

/* Shop stuff under this is the old shop */











#shopDiv {
    width: 100%;
    height: calc(100% - var(--header-height) - 2rem);
    background-color: transparent;
    font-size: large;
    margin-bottom: 1rem;
}

.upgradesInnerWrapper {
    display: flex;
    width: 50%;
    justify-content: space-between;
}

#shopOptionsWrapperDiv {
    display: flex;
    justify-content: space-evenly;
}

#shopOptionsDiv {
    padding: 1rem;
    border: 1px solid white;
    min-width: 40%;
}

#shopUpgradeDescriptionDiv {
    padding: 1rem;
    border: 1px solid white;
    width: 90%;
    font-size: medium;

}

#shopUpgradeDescriptionWrapper {
    display: flex;
    width: 50%;
    border: 1px solid white;
}

#shopUpgradeDescriptionImg {
    border: 1px solid white;
    width: 90%;
    min-height: 50%;
}

.upgradesWrapper {
    display: flex;
    justify-content: space-between;
    background-color: var(--panel-color);
    margin-top: 0.3rem;
    padding: 0.5rem;
}

#gameDiv {
    width: 95%;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    margin-inline: auto;
    position: relative;
}


#gameCanvas {
    margin-top: 1rem;
    margin-inline: auto;
    width: 100%;
    z-index: 1;
    background-image: url('../img/space.png');
    background-size: cover;
    background-repeat: no-repeat;
    box-shadow: 5px 3px 0px rgba(0, 0, 0, 0.5);
    margin-bottom: 1rem;
    border: 1px solid black;
}

#neuralCanvas {
    width: 100%;
    background-color: rgba(123, 50, 50, 0.3);
    margin-inline: auto;
    z-index: 2;
    box-shadow: 5px 3px 0px rgba(0, 0, 0, 0.5);
    margin-bottom: 1rem;
    background-image: url('../img/neuralback.png');
    background-size: cover;
    background-repeat: no-repeat;
    border: 1px solid black;

}


/* Welcome stuff */

#welcomeDiv {
    position: absolute;
    top: clamp(0.5rem, 2vh, 2rem);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bgcolor);
    z-index: 1000;
    padding: clamp(0.5rem, 2vh, 2rem);
    gap: clamp(0.25rem, 1vh, 0.75rem);
    max-height: calc(100vh - clamp(1rem, 4vh, 4rem));
    max-width: 95vw;
    overflow: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#welcomeDiv > div:last-of-type {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

#welcomeDiv > div:last-of-type button {
    background-color: var(--panel-color);
    padding: clamp(0.4rem, 1.5vh, 1rem) clamp(0.6rem, 2vw, 1.5rem);
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: var(--color);
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid var(--color);
    border-radius: var(--border-radius);
}

#welcomeDiv > div:last-of-type button:hover {
    background-color: var(--color);
    color: var(--bgcolor);
}

#welcomeDiv h1 {
    margin: 0;
    font-size: clamp(1rem, 3vw, 1.5rem);
    text-align: center;
}

#welcomeOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}


.pilotDailyCodeBtn {
    margin-top: 1rem;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    /* shiny blue */
    border: none;
    border-radius: 1em;
    padding: 0.9em 1.8em;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(0, 114, 255, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.pilotDailyCodeBtn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 114, 255, 0.6),
        inset 0 2px 6px rgba(255, 255, 255, 0.5);
}

.pilotDailyCodeBtn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 4px 8px rgba(0, 114, 255, 0.4),
        inset 0 1px 3px rgba(255, 255, 255, 0.3);
}

.viewModelWeightsBtn {
    padding: 0.01rem 0.5rem;
    background-color: rgb(192, 192, 192);
    color: black;
    border-radius: 3px;

    cursor: pointer;
}

#availableFLO {
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color);
    gap: 1rem;

}

/* Upgrades info bar shown above shop tabs */
.upgrades-info,
#upgradesInfoDiv {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--panel-color);
    color: var(--color);
    border-radius: var(--border-radius);
    border: 2px inset rgba(255, 255, 255, 0.03);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.upgrades-info-left,
.upgrades-info-right {
    display: flex;
    flex-direction: column;
}

.upgrades-info-label {
    font-size: 0.8rem;
    opacity: 0.85;
}

.upgrades-info-value {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.06));
    padding: 0.25rem 0.5rem;
    border-radius: 0.35rem;
    margin-top: 0.25rem;
}

@media (max-width: 900px) {

    .upgrades-info,
    #upgradesInfoDiv {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .upgrades-info-left,
    .upgrades-info-right {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* Persistent finished message shown when simulation/training stops */
#finishedMessageDiv,
.finished-message {
    position: absolute;
    left: 50%;
    top: calc(var(--header-height) + 2rem);
    transform: translateX(-50%);
    background-color: var(--bgcolor);
    color: var(--color);
    padding: 0.75rem 1.25rem;
    border: 2px outset var(--color);
    border-radius: var(--border-radius);
    z-index: 1200;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}



.upgrades-info-value {
    font-weight: 700;
    font-size: 1.15em;
    color: rgb(245, 245, 245);
    background-color: rgba(0, 0, 0, 0.15);
    padding: 2px 6px;
}









@media (max-width: 600px) {

    #finishedMessageDiv,
    .finished-message {
        left: 50%;
        top: calc(var(--header-height) + 1rem);
        transform: translateX(-50%);
        width: calc(100% - 2rem);
        box-sizing: border-box;
        text-align: center;
    }
}

/* === LEADERBOARD STYLES === */

#leaderboardSection {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--panel-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 2px inset rgba(255, 255, 255, 0.03);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#leaderboardHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

#leaderboardHeader h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#leaderboardMonth {
    font-size: 0.8rem;
    opacity: 0.7;
    font-style: italic;
}

#leaderboardUserPosition {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
    padding: 0.5rem 0.75rem;
    border-radius: 0.35rem;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

#userPositionValue {
    font-weight: 700;
    font-size: 1.1rem;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

#leaderboardList {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#leaderboardLoading {
    text-align: center;
    padding: 1rem;
    opacity: 0.7;
    font-style: italic;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 0.25rem;
    border-left: 3px solid transparent;
    transition: background-color 0.2s;
}

.leaderboard-entry:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.leaderboard-rank {
    font-weight: 700;
    text-align: center;
    font-size: 0.9rem;
}

/* Top 3 styling */
.leaderboard-entry[data-rank="1"] .leaderboard-rank {
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}

.leaderboard-entry[data-rank="2"] .leaderboard-rank {
    color: #c0c0c0;
    text-shadow: 0 0 6px rgba(192, 192, 192, 0.6);
}

.leaderboard-entry[data-rank="3"] .leaderboard-rank {
    color: #cd7f32;
    text-shadow: 0 0 6px rgba(205, 127, 50, 0.6);
}

.leaderboard-entry[data-rank="1"] {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), transparent);
    border-left: 3px solid #ffd700;
}

.leaderboard-entry[data-rank="2"] {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.15), transparent);
    border-left: 3px solid #c0c0c0;
}

.leaderboard-entry[data-rank="3"] {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.15), transparent);
    border-left: 3px solid #cd7f32;
}

.leaderboard-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-score {
    font-weight: 600;
    font-size: 0.85rem;
    color: #90ee90;
    text-align: right;
}

#refreshLeaderboardBtn {
    align-self: flex-end;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background-color: var(--bgcolor);
    color: var(--color);
    border: 1px solid var(--color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
}

#refreshLeaderboardBtn:hover {
    background-color: var(--color);
    color: var(--bgcolor);
}

#refreshLeaderboardBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* User's own entry highlight */
.leaderboard-entry.user-entry {
    background: linear-gradient(90deg, rgba(100, 149, 237, 0.2), transparent);
    border-left: 3px solid cornflowerblue;
}

.leaderboard-entry.user-entry .leaderboard-name::after {
    content: " (deg)";
    opacity: 0.7;
    font-size: 0.75rem;
}

.leaderboard-separator {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.25rem 0;
    font-size: 1.2rem;
    letter-spacing: 0.3rem;
}

/* ============================= */
/* === RESPONSIVE / MOBILE  === */
/* ============================= */

/* Tablet breakpoint */
@media (max-width: 1024px) {
    #pilotMainWrapper {
        grid-template-columns: 1fr 2fr 1fr;
        padding-inline: 0.5rem;
    }
    
    #brainDiv {
        grid-template-columns: 1fr;
    }
    
    .brainInfoName,
    .brainInfoSize,
    .brainInfoScore {
        font-size: 0.8rem;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    #pilotMainWrapper {
        display: flex;
        flex-direction: column;
        padding-inline: 0.5rem;
        gap: 1rem;
    }
    
    .pilotSection {
        width: 100%;
        gap: 1rem;
    }
    
    /* Reorder sections: game first, then current brain, then brains list, then shop/leaderboard */
    #pilotMainWrapper > .pilotSection:nth-child(1) { order: 2; } /* Left section (current brain) */
    #pilotMainWrapper > .pilotSection:nth-child(2) { order: 1; } /* Middle section (game) */
    #pilotMainWrapper > .pilotSection:nth-child(3) { order: 3; } /* Right section (shop/leaderboard) */
    
    #gameDiv {
        width: 100%;
    }
    
    #gameCanvas,
    #neuralCanvas {
        width: 100%;
        max-width: 100%;
    }
    
    /* Current brain section - keep it large */
    #currentBrain {
        width: 100%;
    }
    
    #currentBrainInfo {
        flex-direction: column;
    }
    
    #currentBrainInfo > .brainWrapper {
        max-width: 250px;
        margin-inline: auto;
    }
    
    #currentBrainInfo > .brainWrapper img {
        max-height: none;
    }
    
    #currentBrainInfo .brainInfo {
        padding: 0.5rem;
    }
    
    #currentBrainInfo .brainInfoName,
    #currentBrainInfo .brainInfoSize,
    #currentBrainInfo .brainInfoScore {
        font-size: 0.9rem;
    }
    
    /* Hide unused rankingDiv on mobile */
    #rankingDiv {
        display: none;
    }
    
    /* Brain cards grid - 2 columns on mobile, smaller cards (only in brainDiv) */
    #brainDiv {
        grid-template-columns: repeat(2, 1fr);
        max-height: 12rem;
        min-height: auto;
        gap: 0.25rem;
    }
    
    #brainDiv .brainWrapper {
        margin: 0;
        max-width: 100%;
    }
    
    #brainDiv .brainWrapper img {
        max-height: 80px;
        object-fit: cover;
    }
    
    #brainDiv .brainInfo {
        padding: 0.2rem;
    }
    
    #brainDiv .brainInfoName,
    #brainDiv .brainInfoSize,
    #brainDiv .brainInfoScore {
        font-size: 0.65rem;
    }
    
    #brainDiv .brainInfoWrapper {
        font-size: 0.55rem;
    }
    
    #brainDiv .scoreBar {
        height: 4px;
    }
    
    /* Play and view buttons smaller in brainDiv */
    #brainDiv .playBrainBtn,
    #brainDiv .viewModelWeightsBtn {
        padding: 0.1rem 0.3rem;
        font-size: 0.9rem;
    }
    
    /* Stats bar positioning */
    #statsbarDiv {
        top: calc(var(--header-height) + 1rem);
        font-size: 1.1rem;
        width: 90%;
    }
    
    /* Shop/Upgrades section */
    #upgradesShop {
        width: 100%;
        max-width: 100%;
    }
    
    .shop-tab {
        padding: 0.5rem;
    }
    
    .shop-item {
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.85rem;
    }
    
    .shop-item > h3 {
        font-size: 0.9rem;
        flex: 1 1 auto;
        min-width: 100px;
    }
    
    .shop-item > p {
        font-size: 0.75rem;
    }
    
    .shop-item > button {
        font-size: 1.3rem;
    }
    
    .level-indicator {
        width: 0.7rem;
        height: 1.4rem;
    }
    
    .level-indicator-wrapper {
        padding: 0.2rem 0.3rem;
    }
    
    /* Floating description images */
    .floating-description {
        max-width: 250px !important;
        font-size: 0.85rem;
    }
    
    .floating-description-image {
        max-width: 60px;
        height: auto;
        object-fit: contain;
        flex-shrink: 0;
    }
    
    /* Training wrapper */
    #trainBrainWrapper {
        padding: 0.75rem;
    }
    
    #trainBrainWrapper h3 {
        font-size: 1rem;
    }
    
    .trainingInputs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .trainingInputs input {
        width: 100%;
    }
    
    #trainButton {
        width: 100%;
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    /* Speed radio buttons */
    #speedRadioWrapper {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
        font-size: 0.85rem;
    }
    
    #speedRadioWrapper label {
        display: flex;
        align-items: center;
        gap: 0.2rem;
    }
    
    /* Welcome dialog - fixed position at top of viewport on mobile */
    #welcomeDiv {
        position: fixed;
        width: 95%;
        padding: 1rem;
        top: calc(var(--header-height) + 0.5rem);
        left: 50%;
        transform: translateX(-50%);
        max-height: 85vh;
        overflow-y: auto;
    }
    
    #welcomeOverlay {
        position: fixed;
    }
    
    #welcomeDiv h1 {
        font-size: 1.3rem;
    }
    
    #welcomeDiv button {
        padding: 0.7rem;
        font-size: 1rem;
        margin-inline: 0.3rem;
    }
    
    .pilotDailyCodeBtn {
        font-size: 1rem;
        padding: 0.7rem 1.2rem;
    }
    
    /* Leaderboard */
    #leaderboardSection {
        padding: 0.75rem;
    }
    
    #leaderboardHeader h3 {
        font-size: 0.95rem;
    }
    
    #leaderboardList {
        max-height: 200px;
    }
    
    .leaderboard-entry {
        grid-template-columns: 2rem 1fr auto;
        padding: 0.3rem 0.5rem;
    }
    
    .leaderboard-rank {
        font-size: 0.8rem;
    }
    
    .leaderboard-name,
    .leaderboard-score {
        font-size: 0.75rem;
    }
    
    /* Upgrades info */
    .upgrades-info,
    #upgradesInfoDiv {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Level indicators */
    .level-indicator {
        font-size: 0.65rem;
    }
    
    /* Floating descriptions */
    .floatingDescription {
        font-size: 0.8rem;
        max-width: 200px;
    }
    
    /* View model weights button */
    .viewModelWeightsBtn {
        font-size: 0.7rem;
        padding: 0.01rem 0.3rem;
    }
    
    /* Available FLO display */
    #availableFLO {
        font-size: 1rem;
    }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
    #pilotMainWrapper {
        padding-inline: 0.25rem;
    }
    
    /* Keep 2 columns for brainDiv even on small phones */
    #brainDiv {
        grid-template-columns: repeat(2, 1fr);
        max-height: 10rem;
    }
    
    #brainDiv .brainWrapper {
        margin: 0;
    }
    
    #brainDiv .brainWrapper img {
        max-height: 60px;
    }
    
    #brainDiv .brainInfo {
        padding: 0.15rem;
    }
    
    #brainDiv .brainInfoName,
    #brainDiv .brainInfoScore {
        font-size: 0.6rem;
    }
    
    #statsbarDiv {
        font-size: 0.9rem;
    }
    
    #welcomeDiv {
        width: 98%;
        padding: 0.75rem;
    }
    
    #welcomeDiv h1 {
        font-size: 1.1rem;
    }
    
    #welcomeDiv > div:last-of-type button {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Shop on small phones */
    .shop-tab {
        padding: 0.3rem;
    }
    
    /* Keep 2 columns even on small phones */
    #brainDiv {
        grid-template-columns: repeat(2, 1fr);
        max-height: 10rem;
    }
    
    .brainWrapper img {
        max-height: 60px;
    }
    
    .shop-item {
        gap: 0.3rem;
    }
    
    .shop-item > h3 {
        font-size: 0.8rem;
    }
    
    .shop-item > button {
        font-size: 1.1rem;
    }
    
    .level-indicator {
        width: 0.6rem;
        height: 1.2rem;
    }
    
    .pilotDailyCodeBtn {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }
    
    /* Leaderboard smaller */
    .leaderboard-entry {
        grid-template-columns: 1.5rem 1fr auto;
    }
    
    .leaderboard-rank,
    .leaderboard-name,
    .leaderboard-score {
        font-size: 0.7rem;
    }
}

/* ====================================
   TUTORIAL CAROUSEL STYLES
   ==================================== */

#tutorialCarousel {
    width: 100%;
    max-width: min(600px, 90vw);
    display: flex;
    flex-direction: column;
}

.carousel-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius);
    background-color: var(--panel-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Image wrapper - positioned relative for arrows */
.slide-image-wrapper {
    position: relative;
    width: 100%;
    background-color: #000;
}

.carousel-slides {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}

@media (max-height: 500px) {
    .carousel-slides {
        aspect-ratio: 21 / 9;
    }
}

.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
}

.carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.slide-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
}

.slide-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Text content container */
.carousel-text-container {
    position: relative;
    flex: 0 0 auto;
}

.slide-content {
    padding: clamp(0.3rem, 1vh, 0.6rem) clamp(0.5rem, 2vw, 1rem);
    text-align: center;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.slide-content.active {
    opacity: 1;
    position: relative;
    pointer-events: auto;
}

.slide-content h3 {
    margin: 0 0 0.2em 0;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: var(--color);
    font-weight: bold;
}

.slide-content p {
    margin: 0;
    font-size: clamp(0.8rem, 2vw, 1rem);
    line-height: 1.35;
    color: var(--color);
}

/* Carousel Navigation Arrows */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-family: system-ui, sans-serif;
    line-height: 1;
}

.carousel-arrow:hover {
    background-color: var(--emphasis-color);
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
    left: 0.5rem;
}

.carousel-next {
    right: 0.5rem;
}

/* Mobile arrows */
@media (max-width: 480px) {
    .carousel-arrow {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* Carousel Dots */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: clamp(0.3rem, 1vw, 0.5rem);
    padding: clamp(0.2rem, 0.5vh, 0.4rem) 0;
    margin-top: 0.5rem;
}

.carousel-dot {
    width: clamp(6px, 1.5vw, 10px);
    height: clamp(6px, 1.5vw, 10px);
    border-radius: 50%;
    border: 2px solid var(--color);
    background-color: transparent;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
    padding: 0;
}

.carousel-dot:hover {
    transform: scale(1.2);
    border-color: var(--emphasis-color);
}

.carousel-dot.active {
    background-color: var(--emphasis-color);
    border-color: var(--emphasis-color);
}

.shop-item details { text-align: left; overflow-wrap: anywhere; }
.shop-item summary { cursor: pointer; padding-block: 0.5rem; }
.shop-item details img { max-width: 100%; height: auto; }
#pilotTrainNTimes { max-width: 7rem; font: inherit; }
#welcomeDiv { box-sizing: border-box; position: fixed; inset: 0; transform: none; margin: auto; width: min(50rem, calc(100% - 1rem)); max-width: calc(100% - 1rem); max-height: calc(100dvh - 1rem); color: var(--color); border: 1px solid var(--color); }
#welcomeDiv:not([open]), #welcomeOverlay { display: none; }
#welcomeDiv::backdrop { background: rgb(0 0 0 / 45%); }
#showPilotIntro {
    position: fixed;
    top: calc(var(--header-height) + 0.6rem);
    right: 0.75rem;
    z-index: 50;
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--color);
    background-color: color-mix(in srgb, var(--panel-color) 90%, transparent);
    border: 1px solid color-mix(in srgb, var(--color) 45%, transparent);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgb(0 0 0 / 20%);
    font: 700 1rem/1 var(--font-family);
    cursor: pointer;
}
#showPilotIntro:hover { background-color: var(--hover-bg-color); }
@media (prefers-reduced-motion: reduce) {
    .carousel-slide, .carousel-dot { transition: none; }
}
