#page-race {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

.race-track-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 30vw;
    padding-top: 35vw;
    overflow: hidden;
}
.race-lane-start {
    flex: 0 0 22vw;
    height: 11vw;
    position: relative;
    transition: transform 0.8s linear;
}

.race-cat-holder {
    position: absolute;
    left: 0;
    bottom: 8.5vw;
    width: 0;
    height: 0;
    z-index: 4;
    pointer-events: none;
    transition: transform 0.8s ease-out;
}

.race-lane-cat {
    position: absolute;
    left: 0;
    bottom: 0;
    transform: translateX(-50%);
    width: 16vw;
    height: 16vw;
    z-index: 2;
}

.race-lane-cat img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.race-lane-point {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 22vw;
    height: 11vw;
    background: url('/startcat.webp') no-repeat center center;
    background-size: contain;
}

.race-lane-bot {
    position: absolute;
    bottom: 6vw;
    width: 10vw;
    height: 10vw;
    z-index: 1;
}

.race-lane-bot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.race-cell {
    flex: 0 0 11vw;
    height: 11vw;
    position: relative;
    background: url('/kletka.webp') no-repeat center center;
    background-size: 100% 100%;
}

.race-lane {
    position: relative;
    display: flex;
    align-items: flex-start;
}

.race-lane-cells {
    display: flex;
    align-items: flex-start;
    transition: transform 0.8s linear;
    position: relative;
}

.race-line {
    flex: 0 0 11vw;
    height: 11vw;
    margin: 0 -2vw;
    background: url('/dorojka.webp') no-repeat center top;
    background-size: 100% 4vw;
}

.race-cell.finish {
    background: url('/kletka.webp') no-repeat center center;
    background-size: 100% 100%;
    filter: brightness(1.3) sepia(1) hue-rotate(60deg);
}

.race-cell .race-cell-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    z-index: 3;
    pointer-events: none;
}

.race-stop-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 11vw;
    background: rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden;
    z-index: 99;
}

.race-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #fff;
    border-radius: 3px;
    transition: left 0.05s linear;
    z-index: 2;
}

.race-stop-btn {
    margin: 0 auto;
    margin-left: 10px;
    padding: 10px 24px;
    font-size: 16px;
    font-weight: bold;
    background: linear-gradient(135deg, #7a3fd1 0%, #4a1a8a 100%);
    color: #fff;
    border: 1px solid rgba(212, 164, 255, 0.5);
    border-radius: 16px;
}

.race-stop-btn:active {
    transform: scale(0.97);
}

.race-result {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 20;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
}

.race-result-title {
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 3px #000;
}

.race-result-btn {
    position: relative;
    width: 200px;
    height: 60px;
    cursor: pointer;
}

.race-result-btn img {
    width: 100%;
    height: 100%;
}

.race-result-btn span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
    white-space: nowrap;
}

.race-result-btn:active {
    transform: scale(0.95);
}

.race-wait-text {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 3px #000;
    padding: 20px;
}

.race-rematch-badge {
    font-size: 14px;
    font-weight: bold;
    color: #00ff44;
    text-shadow: 0 0 8px rgba(0, 255, 100, 1), 1px 1px 2px #000;
    pointer-events: none;
    white-space: nowrap;
    animation: raceRematchPulse 1s ease-in-out infinite;
}

@keyframes raceRematchPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.race-me-block {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 12px;
}

.race-me-ava {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.5);
}

.race-me-ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.race-me-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}
#race-game-view .pig-me-block {
    background: url('/knopkacat.webp') no-repeat center center;
    background-size: 100% 100%;
    position: relative;
}
#race-game-view {
    background: url('/foncat.webp') no-repeat center center;
    background-size: cover;
}
.race-picker-cat {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 64px;
    height: 64px;
    z-index: 20;
    cursor: pointer;
}

.race-picker-cat img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
    transform: scaleX(-1);
}
.race-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 16px 0;
}

.race-cat-option {
    text-align: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    border: 2px solid transparent;
}

.race-cat-option.selected {
    border-color: #FFD700;
}

.race-cat-option img {
    width: 100%;
    image-rendering: pixelated;
    pointer-events: none;
}

.race-cat-option span {
    display: block;
    font-size: 12px;
    color: #fff;
    margin-top: 4px;
}
.c-gray   { filter: grayscale(1) contrast(1.4) brightness(1.1); }
.c-yellow { filter: sepia(1) saturate(5) hue-rotate(15deg) brightness(1.2) contrast(1.1); }
.c-pink   { filter: sepia(1) saturate(5) hue-rotate(290deg) brightness(1.1) contrast(1.2); }
.c-purple { filter: sepia(1) saturate(5) hue-rotate(220deg) brightness(1.1) contrast(1.1); }
.c-blue   { filter: sepia(1) saturate(5) hue-rotate(180deg) brightness(1.1) contrast(1.1); }
.c-green  { filter: sepia(1) saturate(3) hue-rotate(80deg) brightness(1.0) contrast(1.3); }

#race-cat-picker-overlay .modal-content {
    background: linear-gradient(160deg, #2a0a4a 0%, #1a0033 60%, #0a0018 100%);
    border: 1px solid rgba(212, 164, 255, 0.4);
    border-radius: 20px;
    padding: 24px 20px;
    text-align: center;
}

#race-cat-picker-overlay .modal-content h2 {
    font-size: 20px;
    color: #FFD700;
    text-shadow: 0 0 12px rgba(212, 164, 255, 0.8);
    margin-bottom: 14px;
    letter-spacing: 1px;
}

#race-cat-picker-overlay .modal-close {
    background: linear-gradient(135deg, #7a3fd1 0%, #4a1a8a 100%);
    border: 1px solid rgba(212, 164, 255, 0.5);
    border-radius: 14px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 8px rgba(212, 164, 255, 0.7);
    width: 100%;
    margin-top: 12px;
}
.race-lane-mini {
    position: absolute;
    left: 50%;
    bottom: 20vw;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
    pointer-events: none;
    width: 12vw;
    height: 20vw;
}
#race-game-view .pig-ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.race-wait-circle {
    width: 12vw;
    height: 12vw;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    border: 2px dashed #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3vw;
    color: #fff;
    text-align: center;
}

#race-bet-info {
    position: fixed;
    top: 10px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: #FFFF00;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 20;
    pointer-events: none;
}

#race-bet-info img {
    width: 22px;
    height: 22px;
}
#race-game-view .race-lane-mini .pig-ava-wrap {
    width: 12vw;
    height: 12vw;
}

#race-game-view .race-lane-mini .pig-ava {
    width: 12vw;
    height: 12vw;
}

#race-game-view .race-lane-mini .pig-name {
    font-size: 3vw;
    max-width: 24vw;
}
.race-timer {
    margin-left: auto;
    color: #8A2BE2;
    font-size: 30px;
    font-weight: bold;
}

.race-lobby-buttons {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 60;
}

.race-rematch-timer {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 18px;
    font-size: 20px;
    font-weight: bold;
    color: #FF0000;
    text-shadow: 0 0 8px rgba(255, 50, 50, 1), 1px 1px 2px #000;
    pointer-events: none;
    white-space: nowrap;
}

.race-bot {
    position: absolute;
    bottom: 0;
    width: 24vw;
    height: 24vw;
    transform: translateX(-50%) scaleX(-1);
    pointer-events: none;
    z-index: 3;
}

.race-bot-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.race-offline {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 2px;
    font-size: 2.8vw;
    font-weight: bold;
    color: #ff5c5c;
    text-shadow: 0 0 6px rgba(255,80,80,0.9), 1px 1px 2px #000;
    white-space: nowrap;
    pointer-events: none;
}

.race-reconnect {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #fff;
    font-size: 16px;
    z-index: 9999;
}
.race-reconnect-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: raceReconnectSpin 0.9s linear infinite;
}
@keyframes raceReconnectSpin {
    to { transform: rotate(360deg); }
}
.race-fairy {
    position: absolute;
    bottom: 0;
    width: 18vw;
    height: 18vw;
    transform: translateX(-50%) scaleX(-1);
    pointer-events: none;
    z-index: 3;
}

.race-fairy-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    transform: rotate(-20deg);
}
#race-game-view .race-lane-mini .pig-name {
    font-size: 3vw;
    max-width: 24vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#race-info-overlay .modal-content {
    background: linear-gradient(160deg, #2a0a4a 0%, #1a0033 60%, #0a0018 100%);
    border: 1px solid rgba(212, 164, 255, 0.4);
    border-radius: 20px;
    padding: 20px;
    overflow: hidden;
}
#race-info-overlay .info-scroll {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 6px;
}
#race-info-overlay .modal-content h2 {
    font-size: 18px;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(212, 164, 255, 0.7);
    margin-top: 12px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}
#race-info-overlay .modal-content p {
    font-size: 13px;
    line-height: 1.6;
    color: #d4c4e4;
    margin-bottom: 8px;
    padding-left: 6px;
    padding-right: 6px;
}
#race-info-overlay .modal-content p b {
    color: #FFD700;
}
#race-create-room-overlay .modal-content {
    background: linear-gradient(160deg, #2a0a4a 0%, #1a0033 60%, #0a0018 100%);
    border: 1px solid rgba(212, 164, 255, 0.4);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    padding: 24px 20px;
}

#race-create-room-overlay .modal-content h2 {
    font-size: 20px;
    color: #FFD700;
    text-shadow: 0 0 12px rgba(212, 164, 255, 0.8);
    text-align: center;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

#race-create-room-overlay .create-room-size {
    background: linear-gradient(135deg, #7a3fd1 0%, #4a1a8a 100%);
    border: 1px solid rgba(212, 164, 255, 0.5);
    color: #fff;
    text-shadow: 0 0 8px rgba(212, 164, 255, 0.7);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    transition: 0.15s;
}

#race-create-room-overlay .create-room-size:active {
    transform: scale(0.92);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4), 0 0 20px rgba(180, 106, 255, 0.7);
}

#race-create-room-overlay .modal-close {
    background: linear-gradient(135deg, #7a3fd1 0%, #4a1a8a 100%);
    border: 1px solid rgba(212, 164, 255, 0.5);
    border-radius: 14px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 8px rgba(212, 164, 255, 0.7);
    transition: 0.15s;
}

#race-create-room-overlay .modal-close:active {
    transform: scale(0.96);
    box-shadow: 0 0 20px rgba(180, 106, 255, 0.7);
}

#race-create-room-overlay .cancel-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 164, 255, 0.25);
    color: #c4b4d4;
}
.race-stop-wrap {
    position: fixed;
    left: 5vw;
    right: 5vw;
    bottom: 4vh;
    height: 11vw;
    z-index: 99;
}
.race-stop-wrap { pointer-events: none; }
.race-stop-wrap .race-stop-bar { pointer-events: auto; }