:root {
    --ui-bg: rgba(8, 12, 18, 0.72);
    --ui-bg-strong: rgba(7, 10, 15, 0.9);
    --ui-border: rgba(255, 255, 255, 0.22);
    --ui-border-strong: rgba(255, 255, 255, 0.4);
    --ui-line: rgba(95, 226, 255, 0.5);
    --ui-text: #f7fbff;
    --ui-muted: rgba(230, 240, 248, 0.68);
    --ui-accent: #5fe2ff;
    --ui-accent-2: #ffd447;
    --ui-danger: #ff4f5f;
    --ui-green: #68ff9a;
    --ui-shadow: rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    overflow: hidden;
    color: var(--ui-text);
    font-family: "Arial Narrow", "Aptos", "Arial", sans-serif;
    background: #05070b;
}

canvas {
    display: block;
}

button,
select {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

.hud,
.screenOverlay,
#mobileControls,
.cameraTuner {
    position: fixed;
    z-index: 10;
}

.hud {
    top: 16px;
    left: 16px;
    display: none;
    pointer-events: none;
}

.fpsCounter {
    position: fixed;
    top: 16px;
    right: 84px;
    z-index: 13;
    min-width: 72px;
    padding: 8px 10px;
    pointer-events: none;
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    border-left: 4px solid var(--ui-green);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(104, 255, 154, 0.16), transparent 42%),
        var(--ui-bg);
    box-shadow: 0 12px 30px var(--ui-shadow);
    backdrop-filter: blur(16px) saturate(1.25);
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

.hudTelemetry {
    position: relative;
    display: grid;
    grid-template-columns: auto auto auto auto;
    align-items: end;
    gap: 12px;
    min-width: 318px;
    padding: 12px 14px 13px;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-left: 4px solid var(--ui-accent);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(95, 226, 255, 0.14), transparent 34%),
        var(--ui-bg);
    box-shadow: 0 16px 42px var(--ui-shadow);
    backdrop-filter: blur(18px) saturate(1.35);
}

.hudTelemetry::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 54%);
}

body.trackOverviewActive .hudTelemetry {
    opacity: 0;
    transform: translateY(-14px);
}

body.trackOverviewActive .fpsCounter,
body.trackOverviewActive #mobileControls {
    display: none !important;
}

.hudBrand {
    align-self: center;
    padding: 6px 9px;
    border-radius: 6px;
    color: #071017;
    background: var(--ui-accent-2);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
}

.metric {
    display: grid;
    gap: 3px;
    min-width: 72px;
}

.metricSpeed {
    min-width: 116px;
}

.metricSector {
    min-width: 148px;
}

.metricLabel {
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.metricReadout {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

#speedValue,
#timerValue {
    font-size: 32px;
    font-weight: 900;
    line-height: 0.9;
    text-shadow: 0 3px 16px rgba(95, 226, 255, 0.35);
}

#sectorValue {
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 3px 16px rgba(95, 226, 255, 0.35);
}

.metricSubline {
    display: block;
    min-height: 11px;
    overflow: hidden;
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metricUnit {
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.hudRule {
    width: 1px;
    height: 38px;
    background: linear-gradient(180deg, transparent, var(--ui-border-strong), transparent);
}

.settingsHud {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 12;
    display: grid;
    justify-items: end;
    gap: 10px;
    pointer-events: none;
}

.hudButtonStack {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.iconButton {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    pointer-events: all;
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 44%),
        var(--ui-bg);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(16px) saturate(1.25);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.iconButton[data-active="true"] {
    border-color: rgba(95, 226, 255, 0.62);
    background:
        linear-gradient(145deg, rgba(95, 226, 255, 0.22), transparent 44%),
        var(--ui-bg-strong);
}

.iconButton:hover,
.settingsAction:hover {
    transform: translateY(-1px);
    border-color: var(--ui-accent);
}

.iconButton svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.iconButtonSmall {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

.iconButtonSmall svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2.4;
}

.iconButton:disabled {
    cursor: default;
    opacity: 0.4;
}

.settingsPanel {
    position: relative;
    width: min(280px, calc(100vw - 32px));
    padding: 12px;
    pointer-events: all;
    border: 1px solid var(--ui-border);
    border-left: 4px solid var(--ui-accent);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(95, 226, 255, 0.12), transparent 42%),
        var(--ui-bg-strong);
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.56);
    backdrop-filter: blur(22px) saturate(1.35);
}

.cameraTuner {
    left: 16px;
    bottom: 16px;
    z-index: 13;
    width: min(430px, calc(100vw - 32px));
    padding: 12px;
    pointer-events: none;
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    border-left: 4px solid var(--ui-accent);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(95, 226, 255, 0.15), transparent 38%),
        rgba(7, 12, 18, 0.78);
    box-shadow: 0 16px 42px var(--ui-shadow);
    backdrop-filter: blur(18px) saturate(1.28);
}

.cameraTunerHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.cameraTunerHeader strong {
    color: var(--ui-accent-2);
    font-size: 12px;
}

.cameraTunerValues {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 10px;
    font-variant-numeric: tabular-nums;
}

.cameraTunerValue {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 7px 8px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}

.cameraTunerValue span {
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.cameraTunerValue strong {
    color: var(--ui-text);
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.cameraTunerKeys {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 10px;
    margin-top: 11px;
    color: rgba(235, 245, 255, 0.72);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.35;
    text-transform: uppercase;
}

.cameraTunerKeys span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cameraTunerKeys kbd {
    min-width: 18px;
    padding: 3px 5px;
    color: #061016;
    border-radius: 4px;
    background: var(--ui-accent);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
}

.settingsPanelHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.settingsAction {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 50px;
    margin-top: 8px;
    padding: 8px 10px;
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 15px;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.settingsIcon {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: #061016;
    border-radius: 6px;
    background: var(--ui-accent-2);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.settingsAction[data-active="true"] .settingsIcon {
    background: var(--ui-green);
}

.settingsAction[data-warning="true"] .settingsIcon {
    background: var(--ui-danger);
    color: var(--ui-text);
}

.screenOverlay {
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, rgba(3, 7, 12, 0.3), rgba(3, 7, 12, 0.64));
}

.menuPanel {
    position: relative;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 16px;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(95, 226, 255, 0.12), transparent 38%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 28%),
        var(--ui-bg-strong);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.64);
    backdrop-filter: blur(22px) saturate(1.35);
}

.menuPanel::before {
    content: "";
    position: absolute;
    inset: 8px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.endPanel {
    width: min(500px, calc(100vw - 32px));
}

.garageMenuPanel {
    width: min(1120px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
    gap: 18px;
}

.menuIntro,
.garageSelect {
    position: relative;
    z-index: 1;
}

.gameLogo {
    position: relative;
    width: 100%;
    height: 220px;
    margin: 0 0 18px;
    overflow: hidden;
    border-radius: 8px;
    background: #10141b;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 34px rgba(0, 0, 0, 0.4);
}

.compactLogo {
    height: 150px;
}

.gameLogo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center top;
    filter: saturate(1.1) contrast(1.03);
}

.gameLogo::after {
    content: "";
    position: absolute;
    inset: 34% 0 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(2, 5, 10, 0.9));
}

.gameLogoTitle {
    position: absolute;
    right: 18px;
    bottom: 16px;
    left: 18px;
    z-index: 1;
    color: #ffffff;
    font-size: 48px;
    font-weight: 900;
    line-height: 0.92;
    text-transform: uppercase;
    text-shadow: 0 4px 0 #000000, 0 12px 28px rgba(0, 0, 0, 0.9);
    white-space: nowrap;
}

.compactLogo .gameLogoTitle {
    font-size: 38px;
}

.gameLogoTitle span {
    color: var(--ui-accent-2);
}

.menuCopy {
    position: relative;
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0;
    color: var(--ui-accent);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.menuCopy h1 {
    margin: 0;
    font-size: 36px;
    line-height: 1;
    text-transform: uppercase;
}

.menuCopy p {
    margin: 0;
    color: var(--ui-muted);
    font-size: 15px;
    font-weight: 700;
}

.selectLabel {
    display: block;
    margin: 0 0 8px;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.selectShell {
    position: relative;
    margin-bottom: 14px;
}

.selectShell::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 16px;
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--ui-accent);
    border-bottom: 2px solid var(--ui-accent);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

select {
    width: 100%;
    min-height: 54px;
    padding: 0 44px 0 16px;
    appearance: none;
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 20px;
    font-weight: 900;
    text-transform: uppercase;
}

select:focus,
button:focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 3px;
}

.modeSelect {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.055);
}

.binaryModeSelect {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modeOption {
    position: relative;
    min-height: 48px;
    padding: 0 10px;
    overflow: hidden;
    color: var(--ui-muted);
    border: 1px solid transparent;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    transition: transform 140ms ease, color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.modeOption::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(95, 226, 255, 0.16), transparent 48%, rgba(255, 212, 71, 0.12));
    opacity: 0;
    transition: opacity 140ms ease;
}

.modeOption:hover,
.modeOption.isSelected {
    color: var(--ui-text);
    border-color: rgba(95, 226, 255, 0.64);
    background: rgba(95, 226, 255, 0.12);
    transform: translateY(-1px);
}

.modeOption.isSelected {
    color: #061016;
    background: linear-gradient(135deg, var(--ui-accent), var(--ui-green));
    box-shadow: 0 10px 24px rgba(95, 226, 255, 0.22);
}

.modeOption.isSelected::before {
    opacity: 1;
}

.garageSelect {
    display: grid;
    align-content: start;
    gap: 14px;
    min-height: 100%;
    padding: 4px 0 0;
}

.garageHeader {
    position: relative;
    min-height: 108px;
    padding: 14px 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-left: 4px solid var(--ui-accent-2);
    border-radius: 8px;
    background:
        linear-gradient(125deg, rgba(255, 212, 71, 0.16), transparent 44%),
        rgba(255, 255, 255, 0.07);
}

.garageHeader::after {
    content: "";
    position: absolute;
    right: -26px;
    bottom: -32px;
    width: 180px;
    height: 80px;
    border-top: 2px solid rgba(255, 255, 255, 0.18);
    transform: skewX(-28deg);
}

.garageHeader h2 {
    position: relative;
    margin: 6px 0 4px;
    font-size: 52px;
    font-weight: 900;
    line-height: 0.86;
    text-transform: uppercase;
    text-shadow: 0 4px 0 #000000, 0 16px 32px rgba(0, 0, 0, 0.64);
}

.garageHeader span {
    position: relative;
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.garagePreview {
    position: relative;
    height: 252px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(95, 226, 255, 0.18), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 56px),
        #071018;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 18px 44px rgba(0, 0, 0, 0.32);
}

.garagePreview::before,
.garagePreview::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.garagePreview::before {
    right: -12%;
    bottom: -40%;
    left: -12%;
    height: 70%;
    border-top: 1px solid rgba(95, 226, 255, 0.28);
    background:
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(95, 226, 255, 0.18) 46px 47px),
        linear-gradient(180deg, rgba(95, 226, 255, 0.14), rgba(95, 226, 255, 0));
    transform: perspective(420px) rotateX(62deg);
    transform-origin: top;
}

.garagePreview::after {
    top: 16px;
    right: 18px;
    left: 18px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--ui-accent), transparent);
    box-shadow: 0 0 22px rgba(95, 226, 255, 0.55);
}

.garagePreview canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.garagePreviewFallback {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: #070a0d;
}

.garagePreviewMeta {
    position: absolute;
    right: 14px;
    bottom: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    color: var(--ui-muted);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    background: rgba(5, 8, 12, 0.62);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
    backdrop-filter: blur(12px);
}

.garagePreviewSignal {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ui-green);
    box-shadow: 0 0 14px rgba(104, 255, 154, 0.7);
}

.garageGrid {
    display: grid;
    gap: 10px;
}

.garageCar {
    position: relative;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) minmax(76px, 112px);
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 12px 14px;
    overflow: hidden;
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 44%),
        rgba(255, 255, 255, 0.06);
    text-align: left;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.garageCar::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--car-accent, var(--ui-accent));
    opacity: 0;
    transition: opacity 140ms ease;
}

.garageCar:hover,
.garageCar.isSelected {
    transform: translateY(-1px);
    border-color: var(--car-accent, var(--ui-accent));
    background:
        linear-gradient(145deg, rgba(95, 226, 255, 0.16), transparent 44%),
        rgba(255, 255, 255, 0.1);
}

.garageCar.isSelected::before {
    opacity: 1;
}

.garageCarPaint {
    width: 14px;
    height: 42px;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26), 0 0 18px rgba(255, 255, 255, 0.12);
}

.garageCarCopy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.garageCarCopy strong {
    overflow: hidden;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.garageCarCopy span {
    overflow: hidden;
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 900;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.garageCarMeter,
.garageStatTrack {
    display: block;
    height: 8px;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
}

.garageCarMeter span,
.garageStatTrack span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ui-accent), var(--ui-green));
    box-shadow: 0 0 18px rgba(95, 226, 255, 0.42);
}

.garageTelemetry {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding-top: 2px;
}

.garageStat {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.garageStat > span:first-child {
    overflow: hidden;
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 900;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.menuActions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.primaryButton,
.secondaryButton {
    position: relative;
    min-height: 56px;
    padding: 0 18px;
    overflow: hidden;
    border-radius: 8px;
    font-size: 17px;
    font-weight: 900;
    text-transform: uppercase;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primaryButton {
    width: 100%;
    color: #061016;
    background: linear-gradient(135deg, var(--ui-accent), var(--ui-green));
    box-shadow: 0 16px 36px rgba(95, 226, 255, 0.28);
}

.secondaryButton {
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    background: rgba(255, 255, 255, 0.08);
}

.primaryButton::after,
.secondaryButton::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transform: translateX(-120%);
    transition: transform 240ms ease;
}

.primaryButton:hover,
.secondaryButton:hover,
.controlButton:hover {
    transform: translateY(-1px);
}

.primaryButton:disabled,
.secondaryButton:disabled {
    cursor: wait;
    opacity: 0.74;
    transform: none;
}

.primaryButton:hover::after,
.secondaryButton:hover::after {
    transform: translateX(120%);
}

.finalTime {
    display: inline-flex;
    width: fit-content;
    padding: 8px 12px;
    color: #051018 !important;
    border-radius: 6px;
    background: var(--ui-accent-2);
    font-size: 26px !important;
    font-weight: 900 !important;
    font-variant-numeric: tabular-nums;
}

.scoreboard {
    position: relative;
    margin: 0 0 14px;
    padding: 13px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.scoreboard h2 {
    margin: 0 0 10px;
    color: var(--ui-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.scoreboard ol {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.scoreboard li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.22);
    font-variant-numeric: tabular-nums;
}

.scoreboard span {
    color: var(--ui-accent);
    font-size: 12px;
    font-weight: 900;
}

.scoreboard strong {
    font-size: 14px;
}

.loadingOverlay {
    z-index: 14;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 62%, rgba(255, 212, 71, 0.16), transparent 18%),
        linear-gradient(180deg, rgba(3, 7, 12, 0.54), rgba(3, 7, 12, 0.86));
}

.loadingOverlay::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.48;
    background:
        linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.08) 1px, transparent 2px),
        linear-gradient(0deg, transparent 0, rgba(95, 226, 255, 0.06) 1px, transparent 2px);
    background-size: 64px 64px, 100% 34px;
    mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.loadingPanel {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    padding: 18px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-left: 4px solid var(--ui-accent-2);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(95, 226, 255, 0.18), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 28%),
        rgba(5, 8, 13, 0.88);
    box-shadow:
        0 28px 88px rgba(0, 0, 0, 0.72),
        0 0 42px rgba(95, 226, 255, 0.16);
    backdrop-filter: blur(24px) saturate(1.45);
}

.loadingPanel::before {
    content: "";
    position: absolute;
    inset: 8px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.loadingScanner {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 0%, rgba(95, 226, 255, 0.18) 48%, transparent 58%);
    transform: translateX(-130%);
    animation: loading-scan 1.8s ease-in-out infinite;
}

.loadingTopline,
.loadingMeta {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.loadingTopline {
    align-items: center;
    margin-bottom: 14px;
}

.loadingSignal {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ui-green);
    box-shadow: 0 0 18px rgba(104, 255, 154, 0.84);
    animation: loading-pulse 900ms ease-in-out infinite alternate;
}

.loadingTitle {
    position: relative;
    margin-bottom: 8px;
    font-size: 56px;
    font-weight: 900;
    line-height: 0.88;
    text-transform: uppercase;
    text-shadow: 0 4px 0 #000000, 0 16px 34px rgba(0, 0, 0, 0.72);
}

.loadingCopy {
    position: relative;
    margin-bottom: 18px;
    color: var(--ui-text);
    font-size: 16px;
    font-weight: 800;
}

.loadingTrack {
    position: relative;
    height: 16px;
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.34);
}

#loadingProgressBar {
    width: 0%;
    height: 100%;
    border-radius: 8px;
    background:
        linear-gradient(90deg, var(--ui-accent), var(--ui-green) 58%, var(--ui-accent-2)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 8px, transparent 8px 16px);
    box-shadow: 0 0 24px rgba(95, 226, 255, 0.45);
    transition: width 180ms ease;
}

.loadingMeta {
    font-variant-numeric: tabular-nums;
}

#loadingPercent {
    color: var(--ui-accent-2);
}

#loadingAssetName {
    color: var(--ui-accent);
    text-align: right;
}

@keyframes loading-scan {
    0% {
        transform: translateX(-130%);
    }

    52%,
    100% {
        transform: translateX(130%);
    }
}

@keyframes loading-pulse {
    from {
        transform: scale(0.82);
        opacity: 0.68;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

#mobileControls {
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    pointer-events: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.pedalControls,
.steerControls {
    position: absolute;
    bottom: 18px;
    display: flex;
    gap: 10px;
}

.pedalControls {
    left: 18px;
    flex-direction: column;
}

.steerControls {
    right: 18px;
}

.controlButton {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    min-width: 128px;
    min-height: 58px;
    padding: 10px 14px;
    pointer-events: all;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background: rgba(6, 12, 18, 0.86);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(16px) saturate(1.25);
    font-size: 16px;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.controlButton * {
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.controlButton:active {
    transform: translateY(2px) scale(0.98);
    border-color: var(--ui-accent);
    background:
        linear-gradient(145deg, rgba(95, 226, 255, 0.22), transparent 44%),
        rgba(6, 12, 18, 0.86);
}

.controlButton.isLatched,
.controlButton[aria-pressed="true"] {
    border-color: var(--ui-green);
    background:
        linear-gradient(145deg, rgba(104, 255, 154, 0.24), rgba(6, 12, 18, 0.9));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.controlButtonPrimary {
    border-color: rgba(104, 255, 154, 0.48);
}

.controlKey {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: #061016;
    border-radius: 6px;
    background: var(--ui-accent);
    font-size: 12px;
    font-weight: 900;
}

.controlButtonPrimary .controlKey {
    background: var(--ui-green);
}

@media (max-width: 720px) {
    .hud {
        top: 10px;
        left: 10px;
    }

    .settingsHud {
        top: 10px;
        right: 10px;
    }

    .hudButtonStack {
        gap: 8px;
    }

    .iconButton {
        width: 44px;
        height: 44px;
    }

    .settingsPanel {
        width: min(280px, calc(100vw - 20px));
        padding: 10px;
    }

    .cameraTuner {
        left: 10px;
        bottom: 10px;
        width: min(360px, calc(100vw - 20px));
        padding: 10px;
    }

    .cameraTunerValues {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hudTelemetry {
        grid-template-columns: auto auto auto;
        gap: 9px;
        min-width: 0;
        padding: 10px 11px;
    }

    .hudBrand {
        display: none;
    }

    .metricSpeed {
        min-width: 94px;
    }

    #speedValue,
    #timerValue {
        font-size: 26px;
    }

    .screenOverlay {
        padding: 12px;
        place-items: start center;
        overflow: auto;
    }

    .menuPanel,
    .endPanel {
        width: min(390px, calc(100vw - 20px));
        margin-top: 12px;
        padding: 12px;
    }

    .garageMenuPanel {
        width: min(430px, calc(100vw - 20px));
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .gameLogo {
        height: 176px;
    }

    .compactLogo {
        height: 126px;
    }

    .gameLogoTitle {
        right: 12px;
        bottom: 12px;
        left: 12px;
        font-size: 34px;
    }

    .compactLogo .gameLogoTitle {
        font-size: 30px;
    }

    .garageHeader {
        min-height: 92px;
        padding: 12px;
    }

    .garageHeader h2 {
        font-size: 38px;
    }

    .garagePreview {
        height: 198px;
    }

    .garageCar {
        grid-template-columns: 12px minmax(0, 1fr) minmax(56px, 80px);
        min-height: 66px;
        gap: 10px;
        padding: 10px 12px;
    }

    .modeSelect {
        gap: 6px;
    }

    .modeOption {
        min-height: 44px;
        padding: 0 6px;
        font-size: 11px;
    }

    .garageTelemetry {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .menuCopy h1 {
        font-size: 28px;
    }

    .menuActions {
        grid-template-columns: 1fr;
    }

    .loadingPanel {
        width: min(390px, calc(100vw - 20px));
        margin-top: 18px;
        padding: 14px;
    }

    .loadingTopline,
    .loadingMeta {
        font-size: 11px;
    }

    .loadingTitle {
        font-size: 40px;
    }

    #mobileControls {
        display: block;
    }

    .pedalControls,
    .steerControls {
        bottom: 14px;
        gap: 8px;
    }

    .pedalControls {
        left: 10px;
    }

    .steerControls {
        right: 10px;
    }

    .controlButton {
        min-width: 92px;
        min-height: 54px;
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 8px 10px;
        font-size: 13px;
        text-align: center;
    }

    .controlKey {
        width: 28px;
        height: 24px;
        justify-self: center;
    }
}

@media (max-width: 420px) {
    .hudTelemetry {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .hudRule {
        display: none;
    }

    .metric {
        min-width: 0;
    }

    .pedalControls,
    .steerControls {
        position: static;
    }

    #mobileControls {
        right: 10px;
        bottom: 10px;
        left: 10px;
        display: none;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    #mobileControls[style*="block"] {
        display: grid !important;
    }

    .pedalControls,
    .steerControls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .controlButton {
        min-width: 0;
    }
}

/* Reference-inspired start screen */
#startScreen {
    display: grid;
    place-items: stretch;
    overflow: auto;
    padding: 14px;
    background: #020306;
}

#startScreen::before,
#startScreen::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

#startScreen::before {
    z-index: -2;
    background:
        radial-gradient(circle at 72% 42%, rgba(255, 86, 48, 0.4), transparent 24%),
        radial-gradient(circle at 48% 42%, rgba(255, 207, 99, 0.28), transparent 22%),
        linear-gradient(135deg, #101a29 0%, #07090e 48%, #020305 100%);
}

#startScreen::after {
    z-index: -1;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.22) 34%, rgba(0, 0, 0, 0.2) 64%, rgba(0, 0, 0, 0.66)),
        linear-gradient(180deg, rgba(0, 0, 0, 0.24), rgba(0, 0, 0, 0.88));
}

body[data-menu-stage="scotland"] #startScreen::before {
    background:
        radial-gradient(circle at 72% 26%, rgba(117, 178, 94, 0.42), transparent 23%),
        linear-gradient(150deg, rgba(47, 77, 61, 0.75), transparent 44%),
        repeating-linear-gradient(170deg, rgba(186, 140, 82, 0.2) 0 36px, rgba(104, 148, 83, 0.22) 36px 72px),
        linear-gradient(135deg, #101b22, #090c10 58%, #020304);
}

body[data-menu-stage="desert"] #startScreen::before {
    background:
        radial-gradient(circle at 54% 34%, rgba(255, 185, 94, 0.56), transparent 22%),
        linear-gradient(170deg, rgba(172, 82, 45, 0.6), transparent 48%),
        repeating-linear-gradient(8deg, rgba(232, 156, 76, 0.22) 0 42px, rgba(91, 54, 36, 0.18) 42px 96px),
        linear-gradient(135deg, #31231c, #100b0a 58%, #030202);
}

body[data-menu-stage="alpine"] #startScreen::before {
    background:
        radial-gradient(circle at 70% 28%, rgba(193, 230, 255, 0.46), transparent 24%),
        linear-gradient(150deg, rgba(97, 136, 159, 0.62), transparent 46%),
        repeating-linear-gradient(166deg, rgba(240, 250, 255, 0.22) 0 32px, rgba(50, 67, 82, 0.24) 32px 78px),
        linear-gradient(135deg, #12202c, #070b12 58%, #020306);
}

body[data-menu-stage="city"] #startScreen::before {
    background:
        radial-gradient(circle at 70% 30%, rgba(255, 63, 151, 0.34), transparent 18%),
        radial-gradient(circle at 48% 34%, rgba(66, 228, 255, 0.26), transparent 20%),
        repeating-linear-gradient(90deg, rgba(126, 179, 210, 0.14) 0 12px, rgba(2, 7, 14, 0.18) 12px 42px),
        linear-gradient(135deg, #132233, #06080f 58%, #020305);
}

body[data-menu-stage="lakes"] #startScreen::before {
    background:
        radial-gradient(circle at 60% 34%, rgba(78, 178, 202, 0.4), transparent 24%),
        linear-gradient(160deg, rgba(45, 94, 61, 0.72), transparent 48%),
        repeating-linear-gradient(168deg, rgba(44, 96, 90, 0.2) 0 42px, rgba(26, 46, 35, 0.22) 42px 86px),
        linear-gradient(135deg, #0c1c23, #060b0e 58%, #020303);
}

body[data-menu-stage="jungle"] #startScreen::before {
    background:
        radial-gradient(circle at 64% 32%, rgba(71, 202, 113, 0.34), transparent 21%),
        linear-gradient(155deg, rgba(23, 74, 39, 0.82), transparent 48%),
        repeating-linear-gradient(78deg, rgba(45, 105, 57, 0.24) 0 34px, rgba(8, 23, 17, 0.28) 34px 68px),
        linear-gradient(135deg, #0b1d17, #040807 58%, #010202);
}

body[data-menu-stage="coastal"] #startScreen::before {
    background:
        radial-gradient(circle at 68% 30%, rgba(66, 196, 218, 0.44), transparent 22%),
        radial-gradient(circle at 46% 38%, rgba(255, 221, 135, 0.28), transparent 19%),
        linear-gradient(165deg, rgba(75, 113, 76, 0.52), transparent 46%),
        repeating-linear-gradient(172deg, rgba(228, 214, 161, 0.18) 0 36px, rgba(52, 111, 131, 0.16) 36px 80px),
        linear-gradient(135deg, #0e2530, #061014 58%, #020304);
}

body[data-menu-stage="valleverde"] #startScreen::before {
    background:
        radial-gradient(circle at 68% 28%, rgba(236, 240, 226, 0.28), transparent 20%),
        radial-gradient(circle at 42% 40%, rgba(203, 38, 44, 0.24), transparent 17%),
        repeating-linear-gradient(90deg, rgba(245, 245, 235, 0.12) 0 18px, rgba(13, 16, 18, 0.18) 18px 42px),
        linear-gradient(150deg, rgba(94, 127, 70, 0.56), transparent 48%),
        linear-gradient(135deg, #18201d, #090b0c 58%, #020303);
}

body[data-menu-stage="valleverde"] .stageHeroPanel {
    --stage-hero-image:
        radial-gradient(ellipse at 72% 42%, rgba(245, 245, 235, 0.24), transparent 26%),
        repeating-linear-gradient(82deg, rgba(245, 245, 235, 0.16) 0 16px, rgba(196, 37, 44, 0.18) 16px 28px, rgba(15, 18, 19, 0.18) 28px 52px),
        linear-gradient(135deg, #587344, #101315);
}

.raceMenuShell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    min-height: calc(100vh - 28px);
    color: var(--ui-text);
}

.raceMenuTop {
    display: grid;
    grid-template-columns: 58px minmax(180px, 1fr);
    align-items: center;
    gap: 16px;
}

.menuIconButton {
    display: grid;
    place-content: center;
    gap: 7px;
    width: 58px;
    height: 58px;
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.42);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.42);
}

.menuIconButton span {
    display: block;
    width: 24px;
    height: 3px;
    border-radius: 3px;
    background: currentColor;
}

.raceMenuBrand {
    display: block;
    align-content: center;
    width: fit-content;
    min-width: 280px;
    white-space: nowrap;
    text-transform: uppercase;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.7));
}

.raceMenuBrand strong,
.raceMenuBrand span {
    display: inline-block;
    color: #ffffff;
    font-size: clamp(38px, 4.4vw, 62px);
    font-style: italic;
    font-weight: 900;
    line-height: 0.78;
    letter-spacing: 0;
}

.raceMenuBrand span {
    margin-left: 4px;
    color: #e71921;
}

.raceMenuBrand small {
    display: block;
    margin: 7px 0 0 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-style: italic;
    font-weight: 800;
    letter-spacing: 5px;
    white-space: normal;
}

.raceMenuGrid {
    display: grid;
    grid-template-columns: minmax(280px, 330px) minmax(390px, 1fr) minmax(320px, 380px);
    grid-template-rows: minmax(248px, 0.74fr) minmax(0, auto);
    gap: 14px;
    min-height: 0;
}

.glassPanel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.025) 44%, rgba(0, 0, 0, 0.32)),
        rgba(4, 6, 10, 0.68);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 20px 58px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px) saturate(1.25);
}

.panelTitle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    color: #f8fbff;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.panelPin,
.panelCar {
    position: relative;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.panelPin::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 1px;
    width: 10px;
    height: 10px;
    border: 3px solid currentColor;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
}

.panelCar::before {
    content: "";
    position: absolute;
    left: 1px;
    right: 1px;
    top: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-radius: 8px 8px 3px 3px;
}

.panelCar::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 1px;
    height: 5px;
    border-radius: 4px;
    box-shadow: 0 0 0 2px currentColor, 12px 0 0 2px currentColor;
}

.stageSelectPanel {
    grid-row: 1 / 3;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    padding: 12px;
}

.nativeStageLabel,
.nativeStageSelect {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.stageCardSelect {
    display: grid;
    align-content: start;
    gap: 6px;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
}

.stageCard {
    position: relative;
    min-height: 76px;
    overflow: hidden;
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    background: #0a0e14;
    text-align: left;
    text-transform: uppercase;
}

.stageCardImage {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2)),
        linear-gradient(135deg, #22384a, #0a1018);
    filter: saturate(1.16) contrast(1.08);
}

.stageCard[data-stage-id="scotland"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.24)),
        repeating-linear-gradient(165deg, rgba(119, 165, 79, 0.62) 0 22px, rgba(151, 109, 71, 0.45) 22px 46px),
        linear-gradient(135deg, #425d44, #0a1110);
}

.stageCard[data-stage-id="desert"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.76), rgba(0, 0, 0, 0.2)),
        repeating-linear-gradient(8deg, rgba(232, 154, 74, 0.75) 0 18px, rgba(128, 64, 42, 0.48) 18px 44px),
        linear-gradient(135deg, #c07a3d, #23110c);
}

.stageCard[data-stage-id="alpine"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.22)),
        repeating-linear-gradient(158deg, rgba(241, 250, 255, 0.82) 0 18px, rgba(56, 74, 91, 0.62) 18px 46px),
        linear-gradient(135deg, #688499, #080d13);
}

.stageCard[data-stage-id="city"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2)),
        repeating-linear-gradient(90deg, rgba(37, 55, 76, 0.92) 0 18px, rgba(4, 8, 15, 0.95) 18px 42px),
        radial-gradient(circle at 72% 38%, rgba(255, 66, 156, 0.62), transparent 20%),
        linear-gradient(135deg, #0a1826, #03050a);
}

.stageCard[data-stage-id="lakes"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2)),
        radial-gradient(circle at 68% 58%, rgba(78, 183, 209, 0.78), transparent 26%),
        repeating-linear-gradient(160deg, rgba(54, 104, 65, 0.72) 0 22px, rgba(26, 43, 39, 0.52) 22px 48px),
        linear-gradient(135deg, #17362f, #030809);
}

.stageCard[data-stage-id="jungle"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2)),
        repeating-linear-gradient(82deg, rgba(45, 117, 59, 0.76) 0 18px, rgba(6, 24, 16, 0.86) 18px 40px),
        linear-gradient(135deg, #133920, #020604);
}

.stageCard[data-stage-id="coastal"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2)),
        radial-gradient(circle at 72% 58%, rgba(66, 196, 218, 0.82), transparent 28%),
        repeating-linear-gradient(160deg, rgba(217, 203, 150, 0.66) 0 20px, rgba(67, 115, 74, 0.44) 20px 46px),
        linear-gradient(135deg, #226675, #060d10);
}

.stageCard[data-stage-id] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.2) 62%, rgba(0, 0, 0, 0.38)),
        var(--stage-card-image, linear-gradient(135deg, #22384a, #0a1018));
    background-position: center;
    background-size: cover;
}

.stageCard[data-stage-id="valleverde"] .stageCardImage {
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.22)),
        repeating-linear-gradient(90deg, rgba(242, 242, 232, 0.72) 0 9px, rgba(195, 37, 44, 0.72) 9px 18px, rgba(16, 18, 20, 0.6) 18px 30px),
        linear-gradient(135deg, #5f7847, #111416);
}

.stageCard::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.32));
}

.stageCardCopy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 4px;
    padding: 18px 44px 12px 14px;
}

.stageCardCopy strong {
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.stageCardCopy span {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    font-weight: 800;
}

.stageCardCheck {
    position: absolute;
    right: 14px;
    bottom: 16px;
    z-index: 1;
    width: 18px;
    height: 10px;
    border-bottom: 4px solid var(--ui-accent-2);
    border-left: 4px solid var(--ui-accent-2);
    opacity: 0;
    transform: rotate(-45deg);
}

.stageCard.isSelected {
    border-color: var(--ui-accent-2);
    box-shadow:
        inset 0 0 0 1px var(--ui-accent-2),
        0 0 22px rgba(255, 212, 71, 0.22);
}

.stageCard.isSelected .stageCardCheck {
    opacity: 1;
}

.stageHeroPanel {
    grid-column: 2;
    position: relative;
    min-height: 286px;
    overflow: hidden;
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.46) 34%, rgba(0, 0, 0, 0.16) 66%, rgba(0, 0, 0, 0.24)),
        var(--stage-hero-image, linear-gradient(135deg, #102133, #05070c));
    background-position: center;
    background-size: cover;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.stageHeroPanel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 72% 64%, rgba(255, 255, 255, 0.13), transparent 32%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.64), transparent 48%),
        linear-gradient(180deg, transparent 52%, rgba(0, 0, 0, 0.56));
}

.stageHeroCopy {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 500px);
    grid-template-areas:
        "title"
        "subtitle"
        "copy"
        "facts";
    align-content: center;
    align-items: center;
    justify-items: start;
    max-width: 560px;
    min-height: 100%;
    padding: 22px 24px;
    text-transform: uppercase;
}

.stageHeroCopy h1,
.stageHeroCopy h2,
.stageHeroCopy p {
    margin: 0;
}

.stageHeroCopy h1 {
    grid-area: title;
    font-size: clamp(34px, 3.8vw, 54px);
    font-style: italic;
    font-weight: 900;
    line-height: 0.86;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.9);
}

.stageHeroCopy h2 {
    grid-area: subtitle;
    margin-top: 8px;
    font-size: clamp(20px, 2vw, 28px);
    font-style: italic;
    font-weight: 900;
    line-height: 1;
}

.stageHeroCopy p {
    grid-area: copy;
    max-width: 360px;
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.86);
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.38;
    text-transform: none;
}

.stageFacts {
    grid-area: facts;
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 18px;
    margin: 10px 0 0;
}

.stageFacts div {
    display: grid;
    gap: 3px;
}

.stageFacts dt,
.stageFacts dd {
    margin: 0;
}

.stageFacts dt {
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 900;
}

.stageFacts dd {
    color: #ffffff;
    font-size: 19px;
    font-weight: 900;
}

.garageSelect {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    gap: 8px;
    padding: 9px;
}

.garageFeature {
    display: grid;
    grid-template-columns: 0.52fr 1fr;
    gap: 10px;
    min-height: 164px;
}

.garageHeader {
    min-height: 0;
    padding: 10px 12px;
    border-left: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.22));
}

.garageHeader h2 {
    font-size: clamp(26px, 2.5vw, 38px);
    line-height: 0.9;
}

.garagePreview {
    height: 164px;
    border-radius: 6px;
    background:
        radial-gradient(ellipse at 58% 54%, rgba(255, 255, 255, 0.16), transparent 36%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 42%),
        #090c11;
}

.garageGrid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(112px, 1fr);
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.garageCar {
    grid-template-columns: 1fr;
    grid-template-rows: 58px auto;
    gap: 6px;
    min-height: 108px;
    padding: 6px;
    border-radius: 5px;
}

.garageCarThumb {
    position: relative;
    display: block;
    min-height: 58px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    background:
        radial-gradient(ellipse at 50% 78%, rgba(255, 255, 255, 0.18), transparent 46%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03)),
        rgba(0, 0, 0, 0.42);
}

.garageCarImage {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.garageCarImage + .garageCarSilhouette {
    display: none;
}

.garageCarSilhouette {
    position: absolute;
    right: 11px;
    bottom: 12px;
    left: 11px;
    height: 20px;
    border-radius: 16px 22px 8px 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 38%),
        var(--car-body, var(--ui-accent));
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
}

.garageCarSilhouette::before {
    content: "";
    position: absolute;
    left: 21%;
    top: -12px;
    width: 42%;
    height: 16px;
    border-radius: 18px 20px 4px 4px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(6, 11, 16, 0.7));
}

.garageCarSilhouette::after {
    content: "";
    position: absolute;
    left: 13%;
    right: 13%;
    bottom: -6px;
    height: 10px;
    border-radius: 10px;
    box-shadow: 0 0 0 6px #020305, 58px 0 0 6px #020305;
}

.garageCarCopy {
    min-width: 0;
    padding: 0 2px;
}

.garageCarCopy strong {
    font-size: 13px;
}

.garageCarCopy span {
    font-size: 10px;
}

.garageCarRank {
    position: absolute;
    top: 9px;
    left: 9px;
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 20px;
    color: #ffffff;
    border: 1px solid rgba(255, 212, 71, 0.7);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.68);
    font-size: 11px;
}

.garageTelemetry {
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    gap: 6px;
}

.setupColumn {
    grid-column: 3;
    grid-row: 1 / 3;
    display: grid;
    gap: 8px;
    align-content: start;
}

.setupPanel {
    min-height: 100px;
    padding: 8px 10px;
}

.setupPanel .panelTitle {
    min-height: 18px;
    margin-bottom: 5px;
    font-size: 14px;
}

.modeSelect {
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.difficultyModeSelect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.assistModeSelect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.raceTypeModeSelect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tileModeSelect {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#weatherSelect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#timeOfDaySelect {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modeOption {
    display: grid;
    grid-template-rows: 26px min-content;
    place-items: center;
    gap: 5px;
    min-height: 58px;
    padding: 5px 7px;
    overflow: visible;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 3px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.24)),
        rgba(3, 5, 9, 0.55);
    color: rgba(255, 255, 255, 0.76);
}

.modeOption:hover,
.modeOption.isSelected {
    border-color: var(--ui-accent-2);
    color: #ffffff;
    background:
        linear-gradient(145deg, rgba(255, 212, 71, 0.18), rgba(0, 0, 0, 0.28)),
        rgba(3, 5, 9, 0.62);
    box-shadow:
        inset 0 0 0 1px rgba(255, 212, 71, 0.55),
        0 0 18px rgba(255, 212, 71, 0.22);
}

.difficultyModeSelect .modeOption.isSelected {
    border-color: #ff2d24;
    background:
        linear-gradient(145deg, rgba(255, 38, 31, 0.58), rgba(80, 0, 0, 0.72)),
        #450506;
    box-shadow:
        inset 0 0 0 1px rgba(255, 70, 55, 0.8),
        0 0 18px rgba(255, 34, 30, 0.34);
}

.modeGlyph {
    position: relative;
    display: block;
    width: 26px;
    height: 26px;
    color: currentColor;
}

.difficultyModeSelect .modeGlyph,
.assistModeSelect .modeGlyph,
.raceTypeModeSelect .modeGlyph {
    display: grid;
    place-items: center;
    width: 32px;
    height: 24px;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 900;
}

.difficultyModeSelect .modeGlyph::before,
.assistModeSelect .modeGlyph::before,
.raceTypeModeSelect .modeGlyph::before {
    content: attr(data-short);
}

.modeGlyph-day::before,
.modeGlyph-off::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow:
        0 -10px 0 -6px currentColor,
        0 10px 0 -6px currentColor,
        10px 0 0 -6px currentColor,
        -10px 0 0 -6px currentColor,
        7px 7px 0 -6px currentColor,
        -7px -7px 0 -6px currentColor,
        7px -7px 0 -6px currentColor,
        -7px 7px 0 -6px currentColor;
}

.modeGlyph-night::before {
    content: "";
    position: absolute;
    inset: 4px 7px 4px 3px;
    border-radius: 50%;
    background: currentColor;
}

.modeGlyph-night::after {
    content: "";
    position: absolute;
    inset: 2px 2px 4px 9px;
    border-radius: 50%;
    background: #0a0d12;
}

.modeGlyph-sunset::before {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: 4px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-radius: 50% 50% 0 0;
    background: linear-gradient(180deg, currentColor 0 48%, transparent 50%);
}

.modeGlyph-sunset::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 10px 0 -7px #0a0d12;
}

.modeGlyph-on::before {
    content: "";
    position: absolute;
    left: 4px;
    right: 3px;
    top: 8px;
    height: 13px;
    border-radius: 14px;
    background: currentColor;
    box-shadow: 7px -5px 0 -1px currentColor, 14px -2px 0 -4px currentColor;
}

.modeGlyph-on::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 22px;
    width: 3px;
    height: 6px;
    background: currentColor;
    box-shadow: 8px 0 0 currentColor, 16px 0 0 currentColor;
    transform: skewX(-18deg);
}

.modeGlyph-clear::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow:
        0 -10px 0 -6px currentColor,
        0 10px 0 -6px currentColor,
        10px 0 0 -6px currentColor,
        -10px 0 0 -6px currentColor,
        7px 7px 0 -6px currentColor,
        -7px -7px 0 -6px currentColor,
        7px -7px 0 -6px currentColor,
        -7px 7px 0 -6px currentColor;
}

.modeGlyph-rain::before {
    content: "";
    position: absolute;
    left: 4px;
    right: 3px;
    top: 8px;
    height: 13px;
    border-radius: 14px;
    background: currentColor;
    box-shadow: 7px -5px 0 -1px currentColor, 14px -2px 0 -4px currentColor;
}

.modeGlyph-rain::after {
    content: "";
    position: absolute;
    left: 9px;
    top: 22px;
    width: 3px;
    height: 6px;
    background: currentColor;
    box-shadow: 8px 0 0 currentColor, 16px 0 0 currentColor;
    transform: skewX(-18deg);
}

.modeGlyph-fog::before,
.modeGlyph-fog::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
}

.modeGlyph-fog::before {
    top: 8px;
    box-shadow: 7px 7px 0 currentColor;
}

.modeGlyph-fog::after {
    top: 18px;
    right: 8px;
    opacity: 0.72;
}

.modeLabel {
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
}

.startRaceButton {
    display: grid;
    grid-template-columns: 78px 1fr 24px;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 0 22px;
    color: #ffffff;
    border: 1px solid rgba(255, 75, 68, 0.9);
    border-radius: 5px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 36%),
        linear-gradient(90deg, #8f0507, #e01618 60%, #98070a);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.12),
        0 16px 32px rgba(120, 0, 0, 0.38);
    text-align: left;
}

.startButtonFlag {
    width: 56px;
    height: 32px;
    background:
        linear-gradient(45deg, #ffffff 25%, transparent 25% 50%, #ffffff 50% 75%, transparent 75%) 0 0 / 18px 18px,
        linear-gradient(45deg, transparent 25%, #ffffff 25% 50%, transparent 50% 75%, #ffffff 75%) 9px 9px / 18px 18px;
    transform: skewX(-14deg);
}

.startButtonCopy {
    display: grid;
    gap: 5px;
}

.startButtonText {
    font-size: clamp(25px, 2.7vw, 34px);
    font-style: italic;
    font-weight: 900;
    line-height: 0.9;
}

.startButtonSub {
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    font-weight: 900;
}

.startButtonArrow {
    width: 16px;
    height: 16px;
    border-top: 4px solid currentColor;
    border-right: 4px solid currentColor;
    transform: rotate(45deg);
}

@media (max-width: 1120px) {
    .raceMenuTop {
        grid-template-columns: 52px minmax(260px, 1fr);
        gap: 12px;
    }

    .raceMenuBrand strong,
    .raceMenuBrand span {
        font-size: clamp(34px, 5.4vw, 54px);
    }

    .raceMenuBrand small {
        margin-top: 6px;
        margin-left: 20px;
        font-size: 10px;
        letter-spacing: 4px;
    }

    .raceMenuGrid {
        grid-template-columns: minmax(240px, 280px) minmax(360px, 1fr) minmax(258px, 300px);
        grid-template-rows: minmax(230px, 0.55fr) minmax(285px, 1fr);
    }

    .stageSelectPanel {
        grid-row: 1 / 3;
    }

    .stageHeroPanel {
        grid-column: 2;
        grid-row: 1;
        min-height: 230px;
    }

    .stageHeroCopy {
        grid-template-columns: minmax(0, 1fr);
        max-width: none;
        padding: 18px 18px;
    }

    .stageHeroCopy h1 {
        font-size: clamp(32px, 5vw, 46px);
    }

    .stageHeroCopy h2 {
        font-size: clamp(19px, 2.8vw, 25px);
    }

    .stageHeroCopy p {
        margin-top: 10px;
        font-size: 14px;
        line-height: 1.3;
    }

    .stageFacts {
        gap: 14px;
        margin-top: 8px;
    }

    .garageSelect {
        grid-column: 2;
        grid-row: 2;
        min-height: 0;
    }

    .garageFeature {
        grid-template-columns: 0.48fr 1fr;
        min-height: 124px;
    }

    .garageHeader {
        padding: 9px 10px;
    }

    .garageHeader h2 {
        font-size: clamp(20px, 2.2vw, 28px);
        white-space: nowrap;
    }

    .garagePreview {
        height: 124px;
    }

    .garageCar {
        grid-template-rows: 46px auto;
        min-height: 90px;
    }

    .garageCarThumb {
        min-height: 46px;
    }

    .garageTelemetry {
        display: none;
    }

    .setupColumn {
        grid-column: 3;
        grid-row: 1 / 3;
        grid-template-columns: 1fr;
        align-content: start;
    }

    .setupPanel {
        min-height: 96px;
        padding: 7px;
    }

    .setupPanel .panelTitle {
        font-size: 13px;
    }

    .modeOption {
        min-height: 56px;
    }

    .startRaceButton {
        grid-column: auto;
    }

}

@media (max-width: 780px) {
    #startScreen {
        padding: 12px;
    }

    .raceMenuShell {
        gap: 10px;
        min-height: auto;
    }

    .raceMenuTop {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .menuIconButton {
        display: none;
    }

    .raceMenuBrand {
        min-width: 0;
    }

    .raceMenuBrand strong,
    .raceMenuBrand span {
        font-size: clamp(36px, 11vw, 58px);
    }

    .raceMenuBrand small {
        margin-left: 10px;
        font-size: 10px;
        letter-spacing: 3px;
    }

    .raceMenuGrid {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-rows: auto;
        gap: 10px;
    }

    .stageHeroPanel,
    .stageSelectPanel,
    .garageSelect,
    .setupColumn {
        grid-column: auto;
        grid-row: auto;
    }

    .stageHeroPanel {
        min-height: 430px;
        order: 0;
    }

    .stageHeroCopy {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "subtitle"
            "copy"
            "facts";
        column-gap: 0;
        align-content: start;
        max-width: 330px;
        padding: 24px 18px;
    }

    .stageHeroCopy h1 {
        font-size: clamp(42px, 13vw, 62px);
    }

    .stageHeroCopy h2 {
        font-size: clamp(24px, 7vw, 32px);
    }

    .stageHeroCopy p {
        max-width: 270px;
        font-size: 16px;
    }

    .stageSelectPanel {
        order: 1;
    }

    .stageCardSelect {
        grid-auto-flow: column;
        grid-auto-columns: minmax(136px, 1fr);
        overflow-x: auto;
        overflow-y: hidden;
    }

    .stageCard {
        min-height: 155px;
    }

    .stageCardCopy {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        padding: 0 10px 12px;
    }

    .garageSelect {
        order: 2;
    }

    .garageTelemetry {
        display: grid;
    }

    .garageFeature {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .garagePreview {
        height: 220px;
    }

    .setupColumn {
        order: 3;
        grid-template-columns: 1fr 1fr;
    }

    .setupPanel {
        min-width: 0;
    }

    .difficultyModeSelect,
    .assistModeSelect,
    .raceTypeModeSelect {
        grid-template-columns: 1fr;
    }

    .startRaceButton {
        grid-column: 1 / -1;
        min-height: 88px;
    }

}

@media (max-width: 500px) {
    .stageHeroPanel {
        min-height: 520px;
    }

    .stageFacts {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .garageTelemetry {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .setupColumn {
        grid-template-columns: 1fr;
    }

    .difficultyModeSelect,
    .assistModeSelect,
    .raceTypeModeSelect,
    .tileModeSelect {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tileModeSelect {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .startRaceButton {
        grid-template-columns: 56px 1fr 16px;
        gap: 12px;
        padding: 0 16px;
    }

    .startButtonFlag {
        width: 48px;
        height: 30px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}
