.car-with-wheels {
    position: relative;
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    align-self: flex-start;
    flex-shrink: 0;
    line-height: 0;
    vertical-align: middle;
    --car-sprite-height: 72px;
    /* Keep paint blend-modes from mixing with the page background. */
    isolation: isolate;
}

/* Hide until body + paint mask are decoded — avoids black→color flash. */
.car-with-wheels--paint-pending {
    opacity: 0;
}

.car-with-wheels--paint-ready {
    opacity: 1;
}

.car-with-wheels__body {
    display: block;
    height: var(--car-sprite-height);
    width: auto;
    position: relative;
    z-index: 1;
}

.car-with-wheels__paint {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background: #1e6bb8;
    /* Recolor hue/sat, keep body luminosity (panel lines, highlights). */
    mix-blend-mode: var(--paint-blend-mode, color);
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

/* Soft lift under the color layer for white/yellow (avoids flat hard-light wash). */
.car-with-wheels__paint--lift {
    z-index: 3;
}

.car-with-wheels__vinyl {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--vinyl-rotate, 0deg));
    pointer-events: none;
    height: auto;
    z-index: 4;
    opacity: var(--vinyl-opacity, 0.82);
}

.car-with-wheels__spoiler {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--spoiler-rotate, 0deg));
    pointer-events: none;
    height: auto;
    /* Под окрасом кузова и тонировкой */
    z-index: 2;
    object-fit: contain;
}

.car-with-wheels__vinyl--colorable {
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

.car-with-wheels__neon {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Underglow masks overlap opaque body pixels — must be above the sprite. */
    z-index: 5;
    background: var(--neon-glow, #00ffff);
    --neon-glow: #00ffff;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
    filter:
        brightness(1.75)
        saturate(1.45)
        drop-shadow(0 0 1px #fff)
        drop-shadow(0 0 2px #fff)
        drop-shadow(0 0 3px var(--neon-glow))
        drop-shadow(0 0 7px var(--neon-glow))
        drop-shadow(0 0 12px var(--neon-glow))
        drop-shadow(0 0 18px var(--neon-glow));
}

.car-with-wheels__tint {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
    background: #0a0a0a;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

.tint-color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 10px 0 4px;
}

.tint-color-swatch {
    width: 28px;
    height: 28px;
    border: 2px solid #636363;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    background-clip: padding-box;
}

.repaint-color-swatch {
    position: relative;
}

.repaint-color-swatch__num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 700;
    color: #111;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55), 0 1px 2px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    display: none;
}

.tint-color-swatch.is-selected {
    border-color: #fcd330;
    box-shadow: 0 0 0 1px #fcd330;
}

.tint-color-palette__label {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 0 0 2px;
}

.car-display-fallback {
    display: inline-block;
    width: auto;
    max-width: 100%;
    align-self: flex-start;
    flex-shrink: 0;
    height: var(--car-sprite-height, 72px);
    object-fit: contain;
    vertical-align: middle;
}

.car-with-wheels__wheel {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    height: auto;
    z-index: 7;
}

.car-with-wheels--mirrored {
    transform: scaleX(-1);
}

.wheel-calibrator {
    max-width: 640px;
}

.wheel-calibrator__stage {
    position: relative;
    display: inline-block;
    border: 2px solid #636363;
    background: #2a2a2a;
    touch-action: none;
    user-select: none;
}

.wheel-calibrator__body {
    display: block;
    max-width: 100%;
    height: auto;
}

.wheel-calibrator__wheel {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    touch-action: none;
}

.wheel-calibrator__legend {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 6px 0 0;
    font-size: 12px;
    color: #999;
    max-width: 100%;
}

.wheel-calibrator__legend span {
    flex: 1;
}

.wheel-calibrator__legend span:first-child {
    text-align: left;
}

.wheel-calibrator__legend span:last-child {
    text-align: right;
}

.wheel-calibrator__wheel.is-dragging {
    cursor: grabbing;
    z-index: 2;
}

.wheel-calibrator__controls {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.wheel-calibrator__values {
    font-family: monospace;
    font-size: 12px;
    color: #ccc;
    line-height: 1.5;
}

.wheel-calibrator__scale-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wheel-calibrator__scale-row input[type="range"] {
    flex: 1;
}

.wheel-calibrator__apply-hint {
    margin: 0 0 10px;
    font-size: 12px;
    color: #999;
    line-height: 1.4;
}

.wheel-shop-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.wheel-shop-list > li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #636363;
}

.wheel-shop-list > li:last-child {
    border-bottom: none;
}

.wheel-shop-list__preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: #2a2a2a;
    border: 1px solid #636363;
}

.wheel-shop-list__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wheel-shop-list__name {
    color: #fcd330;
    font-weight: bold;
}

.wheel-shop-list__price {
    font-size: 13px;
    color: #ccc;
}

.wheel-shop-list__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.wheel-shop-preview {
    margin: 12px 0;
    padding: 10px;
    background: #3e3e3e;
    border-top: 1px solid #636363;
    border-bottom: 1px solid #636363;
    text-align: center;
}

.wheel-shop-preview .car-with-wheels {
    display: inline-block;
}

.wheel-shop-preview__caption {
    margin-top: 6px;
    color: #ccc;
    font-size: 13px;
}

.wheel-shop-preview__hint {
    margin-top: 8px;
    color: #999;
    font-size: 12px;
}

.wheel-shop-buy-panel {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #636363;
}

.wheel-shop-buy-panel__title {
    color: #fcd330;
    font-weight: bold;
    margin-bottom: 8px;
}

.wheel-shop-buy-panel__actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.wheel-shop-buy-panel__cancel {
    background-color: #666 !important;
    color: #fff !important;
    padding: 2px 10px !important;
}

.race-history-detail-car--user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.race-history-detail-car--user .car-display-fallback,
.race-history-detail-car--user .car-with-wheels {
    align-self: flex-end;
}

.race-history-detail-car--user > div[style*="background-color: #333"] {
    margin: 5px 0 !important;
    float: none !important;
    align-self: flex-end;
}

.wheel-shop-list > li.is-previewing {
    background: rgba(252, 211, 48, 0.08);
    border-radius: 4px;
    padding-left: 4px;
    padding-right: 4px;
}

.vinyl-layer-tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 8px 0;
}

.vinyl-layer-tabs__btn {
    padding: 2px 10px !important;
}

.vinyl-layer-tabs__btn.is-active {
    background-color: #fcd330 !important;
    color: #000 !important;
}

.vinyl-admin-preview-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 12px;
    max-width: 640px;
}

.vinyl-admin-preview-btn {
    min-width: 28px;
    padding: 2px 6px !important;
    background-color: #555 !important;
    color: #fff !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
}

.vinyl-admin-preview-btn.is-active {
    background-color: #fcd330 !important;
    color: #000 !important;
}

.wheel-calibrator__vinyl {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--vinyl-rotate, 0deg));
    cursor: grab;
    touch-action: none;
    background: #ffffff;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
    border: 1px dashed rgba(252, 211, 48, 0.6);
    box-sizing: border-box;
}

.wheel-calibrator__vinyl.is-dragging {
    cursor: grabbing;
    z-index: 2;
    border-color: #fcd330;
}

.wheel-calibrator__vinyl--img {
    background: transparent !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;
    border: 1px dashed rgba(252, 211, 48, 0.45);
    height: auto;
    object-fit: contain;
}

.wheel-calibrator__spoiler {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--spoiler-rotate, 0deg));
    cursor: grab;
    touch-action: none;
    height: auto;
    object-fit: contain;
    border: none;
    outline: none;
    background: transparent;
    z-index: 2;
}

.wheel-calibrator__spoiler.is-dragging {
    cursor: grabbing;
}

.wheel-calibrator__paint {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    mix-blend-mode: var(--paint-blend-mode, color);
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

.wheel-calibrator__tint {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
}

.wheel-calibrator__stage .wheel-calibrator__wheel {
    z-index: 5;
    pointer-events: none;
}

