* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}

body {
    background: #1a1a2e;
    color: white;
}

/* Startup loading screen */
#loadingScreen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    z-index: 20000;
}

.loadingContent {
    width: min(90%, 520px);
    text-align: center;
}

.loadingContent h1 {
    margin-bottom: 24px;
}

#loadingPercent {
    margin-bottom: 10px;
    color: #ffcc00;
    font-size: 24px;
    font-weight: bold;
}

.loadingTrack {
    width: 100%;
    height: 24px;
    overflow: hidden;
    border: 2px solid #ffcc00;
    border-radius: 12px;
    background: #222;
}

#loadingBar {
    width: 0%;
    height: 100%;
    background: #00cc66;
    transition: width 80ms linear;
}

/* Screens */
.screen {
    position: relative;
    display: none;
    padding: 20px;
    padding-top: 90px;
}

.screenCloseX {
    position: fixed;
    top: 70px;
    right: 10px;
    background: #000000aa;
    border: 2px solid #ff4444;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    z-index: 9999;
}

#mainMenu {
    display: block;
    text-align: center;
}

#selectedCarImageContainer {
    min-height: 260px;
    margin: 10px auto 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#selectedCarImage {
    display: none;
    width: min(80vw, 560px);
    height: 260px;
    object-fit: contain;
}

#selectedCarImageEmpty {
    max-width: 360px;
    color: #aaa;
    font-size: 14px;
}

h1 {
    color: #ffcc00;
    margin-bottom: 20px;
}

/* Buttons */
button {
    padding: 14px 40px;
    font-size: 22px;
    margin: 10px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: #444;
    color: white;
}

button:hover {
    background: #666;
}

button.locked {
    background: #555 !important;
    color: #999 !important;
    cursor: not-allowed !important;
}

/* Dealership Cards */
#auctionList {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.auctionToolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px auto 18px;
}

.auctionToolbar > button {
    flex: 0 0 auto;
}

.auctionSearch {
    flex: 0 1 520px;
    width: min(100%, 520px);
    margin: 0;
    padding: 12px 16px;
    border: 2px solid #66ccff;
    border-radius: 8px;
    background: #111;
    color: #fff;
    font-size: 18px;
}

.auctionSearch::placeholder {
    color: #aaa;
}

@media (max-width: 600px) {
    .auctionToolbar {
        align-items: stretch;
        flex-direction: column;
    }
}

.carCard {
    background: #222;
    padding: 15px;
    margin: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #555;
}

.carCard button {
    background: #00aa00;
}

/* Garage Cards */
.ownedCar {
    background: #333;
    padding: 15px;
    margin: 0;
    width: 100%;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #777;
}

.ownedCar button {
    background: #ffaa00;
}

.errorText {
    color: #ff5555;
    font-size: 14px;
}

@media (max-width: 900px) {
    #auctionList {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    #auctionList {
        grid-template-columns: 1fr;
    }
}


/* HUD */
#hudBar {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
}

#selectedCarHUD {
    background: #000000aa;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 18px;
    border: 2px solid #ffcc00;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
}

#selectedCarHUD:hover {
    background: #333300aa;
}

#moneyHUD {
    background: #000000aa;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 18px;
    border: 2px solid #00ff00;
}

/* PROFILE BUTTON */
#profileButton {
    position: fixed;
    top: 10px;
    left: 10px;
    background: #000000aa;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 18px;
    border: 2px solid #00ccff;
    cursor: pointer;
    z-index: 9999;
}

/* QUEST BUTTON */
#questButton {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: #000000aa;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 18px;
    border: 2px solid #ffcc00;
    cursor: pointer;
    z-index: 9999;
}

/* PROFILE POPUP */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000cc;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.popupContent {
    position: relative;
    background: #222;
    padding: 30px;
    border-radius: 12px;
    width: 300px;
    text-align: center;
    border: 2px solid #00ccff;
}

.popupCloseX {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.announcementCheckbox {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 14px 0;
    cursor: pointer;
}

#raceResultsPopup .popupContent {
    width: min(92vw, 900px);
    overflow-x: auto;
}

#raceResultsList p {
    white-space: nowrap;
    text-align: left;
    margin: 12px 0;
}

.dealershipFolderContent {
    width: min(92vw, 850px);
    max-height: 85vh;
    overflow-y: auto;
}

.dealershipFolder {
    display: block;
    width: 100%;
    margin: 0;
    background: #355c7d;
    border: 2px solid #00ccff;
}

.affordableDot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 8px;
    border-radius: 50%;
    background: #ff3333;
    vertical-align: middle;
}

#dealershipButton .affordableDot {
    margin-left: 10px;
}

#dealershipList,
#garageList,
#dealershipFolderCars,
#garageFolderCars {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    align-items: start;
}

.dealershipFolder:hover {
    background: #447aa3;
}

/* Countdown */
#countdownOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000cc;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 120px;
    font-weight: bold;
    color: #ffcc00;
    z-index: 99999;
}

/* Track */
.track-stage {
    position: relative;
    width: 100%;
    height: 300px;
}

.track-wrapper {
    width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    border-top: 4px solid #666;
    border-bottom: 4px solid #666;
    background: #333;
}

.track-wrapper::-webkit-scrollbar {
    display: none;
}

.track {
    width: 10000px;
    height: 300px;
    position: relative;
    background: linear-gradient(to right, #333 0%, #444 100%);
}

/* Cars */
.car {
    position: absolute;
    left: 20px;
    width: 200px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 6px;
    font-size: 14px;
    font-weight: bold;
    z-index: 2;
    color: #fff;
}

#car1 {
    background: #ff3333;
    top: 10px;
    box-shadow: 0 0 15px #ff3333;
}

#car2 { background: #3366ff; top: 70px; }
#car3 { background: #33cc33; top: 130px; }
#car4 { background: #ff9900; top: 190px; }
#car5 { background: #aa00ff; top: 250px; }

/* Track Lines */
.start-line {
    position: absolute;
    left: 15px;
    top: 0;
    width: 4px;
    height: 100%;
    background: #0f0;
    z-index: 3;
}

.finish-line {
    position: absolute;
    left: 9950px;
    top: 0;
    width: 8px;
    height: 100%;
    background: repeating-linear-gradient(0deg, #000 0 10px, #fff 10px 20px);
    z-index: 3;
}

/* Distance Markers */
.marker {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: #ffffff30;
    color: #fff;
    font-size: 12px;
    padding-left: 8px;
    padding-top: 2px;
}

.m1k { left: 1000px; }
.m2k { left: 2000px; }
.m3k { left: 3000px; }
.m4k { left: 4000px; }
.m5k { left: 5000px; font-weight: bold; color: #ff0; }
.m6k { left: 6000px; }
.m7k { left: 7000px; }
.m8k { left: 8000px; }
.m9k { left: 9000px; }

/* Status Text */
.status {
    text-align: center;
    font-size: 22px;
    padding: 10px;
}

.raceProgressDot {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.offscreenIndicator {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 10;
    display: none;
    pointer-events: none;
}

.offscreenIndicatorLeft,
.offscreenIndicatorRight {
    width: 100%;
    overflow: hidden;
}

.offscreenCar {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 5px;
    width: min(70%, 420px);
    min-height: 28px;
    padding: 4px 7px;
    box-sizing: border-box;
    background: #111e;
    border: 1px solid #ffffff66;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    line-height: 16px;
}

.offscreenCar > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.offscreenIndicatorLeft .offscreenCar { left: 5px; }
.offscreenIndicatorRight .offscreenCar { right: 5px; }

.offscreenCar1 { top: 16px; }
.offscreenCar2 { top: 76px; }
.offscreenCar3 { top: 136px; }
.offscreenCar4 { top: 196px; }
.offscreenCar5 { top: 256px; }

.offscreenArrow {
    color: #fff;
    font-size: 11px;
}

.offscreenCar1 .raceProgressDot { background: #ff3333; box-shadow: 0 0 7px #ff3333; }
.offscreenCar2 .raceProgressDot { background: #3366ff; box-shadow: 0 0 7px #3366ff; }
.offscreenCar3 .raceProgressDot { background: #33cc33; box-shadow: 0 0 7px #33cc33; }
.offscreenCar4 .raceProgressDot { background: #ff9900; box-shadow: 0 0 7px #ff9900; }
.offscreenCar5 .raceProgressDot { background: #aa00ff; box-shadow: 0 0 7px #aa00ff; }

@media (max-width: 700px) {
    .offscreenIndicator {
        max-width: 48%;
    }

    .offscreenCar {
        width: min(82%, 360px);
    }
}
