/* Horse Races - Coral style, portrait only */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

html, body {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

html {
    background: #17171B;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #17171B 0%, #3B3B43 100%);
    background-attachment: fixed;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Screens - only one visible at a time */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: visibility 0s;
}

.screen[style*="visibility: hidden"] {
    visibility: hidden;
    pointer-events: none;
}

/* ============ Screen 1: Choose horse ============ */
.screen-1 {
    justify-content: flex-start;
}

.screen1-header {
    position: relative;
    width: 100%;
    flex-shrink: 0;
    height: 8vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4vh;
    margin-bottom: 0.5vh;
    background: #FFDB01;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.screen1-header .logo-secondary {
    position: absolute;
    left: 0vh;
    top: 50%;
    transform: translateY(-50%) translateZ(0);
    -webkit-transform: translateY(-50%) translateZ(0);
    height: 4vh;
}

.screen1-header .logo-main {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    height: 5.5vh;
}

.logo-secondary {
    position: absolute;
    left: 3vh;
    top: 50%;
    transform: translateY(-50%) translateZ(0);
    -webkit-transform: translateY(-50%) translateZ(0);
    height: 7vh;
    width: auto;
    object-fit: contain;
}

.logo-main {
    height: 9vh;
    width: auto;
    object-fit: contain;
    transform: translateZ(0);
}

.choose-text {
    font-size: 4.5vh;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    margin-bottom: 3vh;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.horses-choice-wrap {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 1.5vh;
}

.horse-choice-item {
    position: relative;
    cursor: pointer;
    transform: translateZ(0) scale(1);
    -webkit-transform: translateZ(0) scale(1);
    transition: transform 0.2s ease-out;
}

.horse-choice-item.horse-choice-highlighted {
    animation: horseChoicePulse 1.2s ease-in-out infinite;
    will-change: transform;
}

@keyframes horseChoicePulse {
    0%, 100% { transform: translateZ(0) scale(1); -webkit-transform: translateZ(0) scale(1); }
    50% { transform: translateZ(0) scale(1.05); -webkit-transform: translateZ(0) scale(1.05); }
}

.horse-choice-item:active {
    transform: scale(0.98) translateZ(0);
    -webkit-transform: scale(0.98) translateZ(0);
}

.horse-choice-img {
    display: block;
    width: auto;
    height: 22vh;
    object-fit: contain;
}

.hand-wrap {
    position: absolute;
    left: 50%;
    bottom: -2vh;
    transform: translateX(-50%) translateZ(0);
    -webkit-transform: translateX(-50%) translateZ(0);
}

.hand-img {
    display: block;
    height: 6vh;
    width: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    animation: handBounce 0.8s ease-in-out infinite;
    will-change: transform;
}

.hand-img.hand-hidden {
    visibility: hidden;
    animation: none;
}

@keyframes handBounce {
    0%, 100% { transform: translateY(0) translateZ(0); -webkit-transform: translateY(0) translateZ(0); }
    50% { transform: translateY(-0.8vh) translateZ(0); -webkit-transform: translateY(-0.8vh) translateZ(0); }
}

/* ============ Screen 2: Race ============ */
.screen-2 {
    padding: 0;
    flex-direction: column;
}

.screen2-header {
    position: relative;
    width: 100%;
    flex-shrink: 0;
    height: 8vh;
    display: flex;
    align-items: center;
    padding: 0 4vh;
    background: #FFDB01;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.screen2-header .logo-secondary {
    position: absolute;
    left: 0vh;
    top: 50%;
    transform: translateY(-50%) translateZ(0);
    -webkit-transform: translateY(-50%) translateZ(0);
    height: 4vh;
}

.screen2-header .logo-main-race {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    height: 5.5vh;
}

.screen2-header .horse-preview {
    position: absolute;
    right: 4vh;
    top: 50%;
    transform: translateY(-50%) translateZ(0);
    -webkit-transform: translateY(-50%) translateZ(0);
}

.horse-preview {
    height: 6vh;
    width: auto;
    object-fit: contain;
    transform: translateZ(0);
}

.horse-preview.horse-preview-enter {
    animation: horsePreviewEnter 0.4s ease-out forwards;
}

@keyframes horsePreviewEnter {
    0% {
        opacity: 0;
        transform: translateY(calc(-50% - 2vh)) scale(0.5) translateZ(0);
        -webkit-transform: translateY(calc(-50% - 2vh)) scale(0.5) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1) translateZ(0);
        -webkit-transform: translateY(-50%) scale(1) translateZ(0);
    }
}

.race-track-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.race-bg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: auto;
    min-width: 100%;
    object-fit: cover;
    object-position: left center;
    transform: translateZ(0);
}

.horses-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.horse-wrap {
    position: absolute;
    left: 3%;
    margin-top: -6vh;
    transform: translateX(0) translateZ(0);
    -webkit-transform: translateX(0) translateZ(0);
}

.horse-wrap.horse-1 { top: 23.67%; }
.horse-wrap.horse-2 { top: 48%; }
.horse-wrap.horse-3 { top: 75.33%; }

.horse-wrap .horse-race {
    display: block;
    height: 12vh;
    width: auto;
    object-fit: contain;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transform-origin: center bottom;
    animation: horseRunSquash 0.6s ease-in-out infinite;
}

@keyframes horseRunSquash {
    0%, 100% {
        transform: scaleY(1) scaleX(1) translateZ(0);
        -webkit-transform: scaleY(1) scaleX(1) translateZ(0);
    }
    50% {
        transform: scaleY(0.97) scaleX(1.02) translateZ(0);
        -webkit-transform: scaleY(0.97) scaleX(1.02) translateZ(0);
    }
}

/* ============ Overlay: Big Win ============ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.bigwin-overlay {
    background: rgba(0,0,0,0.5);
}

.bigwin-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bigwin-content.bigwin-pop {
    animation: bigwinPop 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform: scale(0.2) translateZ(0);
    -webkit-transform: scale(0.2) translateZ(0);
    transform-origin: center center;
}

@keyframes bigwinPop {
    0% {
        transform: scale(0.2) translateZ(0);
        -webkit-transform: scale(0.2) translateZ(0);
        opacity: 0.9;
    }
    75% {
        transform: scale(1.04) translateZ(0);
        -webkit-transform: scale(1.04) translateZ(0);
        opacity: 1;
    }
    90% {
        transform: scale(0.98) translateZ(0);
        -webkit-transform: scale(0.98) translateZ(0);
    }
    100% {
        transform: scale(1) translateZ(0);
        -webkit-transform: scale(1) translateZ(0);
        opacity: 1;
    }
}

.bigwin-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bigwin-amount {
    position: absolute;
    left: 50%;
    top: 70%;
    transform: translate(-50%, -50%) translateZ(0);
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    font-size: 5vh;
    font-weight: 800;
    color: #2ecc71;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.bigwin-img {
    max-width: 110%;
    max-height: 80vh;
    width: 110vw;
    height: auto;
    object-fit: contain;
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

.confetti-piece {
    position: absolute;
    width: 1.5vh;
    height: 1vh;
    top: -5vh;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.confetti-piece.confetti-fall {
    animation: confettiFall var(--cd, 2.2s) ease-in forwards;
    animation-delay: var(--cdel, 0s);
}

@keyframes confettiFall {
    0% {
        transform: translate(0, 0) rotate(0deg) translateZ(0);
        opacity: 1;
    }
    100% {
        transform: translate(var(--cdx, 0), 120vh) rotate(var(--crot, 540deg)) translateZ(0);
        opacity: 0.15;
    }
}

/* ============ Screen 3: Final ============ */
.screen-3 {
    justify-content: center;
    position: relative;
    z-index: 1;
}

.screen-3-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #17171B 0%, #3B3B43 100%);
    z-index: 1;
}

.screen-3-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 55;
    pointer-events: none;
}

.screen-3-content .btn-claim {
    pointer-events: auto;
}

/* Initial state – animations only when .final-enter on parent */
.screen-3-content .final-logo,
.screen-3-content .final-text,
.screen-3-content .final-trophy-wrap,
.screen-3-content .btn-claim {
    opacity: 0;
}

.screen-3-content.final-enter .final-logo {
    animation: finalLogoEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) 0s forwards;
}

.screen-3-content.final-enter .final-text {
    animation: finalFadeIn 0.4s ease-out 0.2s forwards;
}

.screen-3-content.final-enter .final-trophy-wrap {
    animation: finalFadeIn 0.4s ease-out 0.35s forwards;
}


.final-logo {
    height: 10vh;
    width: auto;
    object-fit: contain;
    margin-bottom: 2vh;
    transform: translateZ(0);
}

@keyframes finalLogoEnter {
    0% {
        opacity: 0;
        transform: translateY(-15vh) translateZ(0);
        -webkit-transform: translateY(-15vh) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
        -webkit-transform: translateY(0) translateZ(0);
    }
}

.final-text .final-won {
    color: #6dda4c;
    text-shadow: 0 0 8px #6cf442;
}

.final-text {
    font-size: 5.2vh;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2vh;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    text-transform: uppercase;
    line-height: 1.15;
}

.final-trophy-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.5vh;
    margin-bottom: 3vh;
}

.trophy-img {
    height: 25vh;
    width: auto;
    object-fit: contain;
}

.final-jockey {
    height: 30vh;
    width: auto;
    object-fit: contain;
}

@keyframes finalFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.btn-claim {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
}

@keyframes finalBtnEnter {
    0% {
        opacity: 0;
        transform: translateY(12vh) translateZ(0);
        -webkit-transform: translateY(12vh) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
        -webkit-transform: translateY(0) translateZ(0);
    }
}

.btn-claim .btn-claim-img {
    display: block;
    height: 16vh;
    width: auto;
    object-fit: contain;
}

.screen-3-content.final-enter .btn-claim {
    animation: finalBtnEnter 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) 0.55s forwards, btnClaimPulse 1.5s ease-in-out 1.05s infinite;
}

@keyframes btnClaimPulse {
    0%, 100% {
        transform: translateY(0) scale(1) translateZ(0);
        -webkit-transform: translateY(0) scale(1) translateZ(0);
    }
    50% {
        transform: translateY(0) scale(1.06) translateZ(0);
        -webkit-transform: translateY(0) scale(1.06) translateZ(0);
    }
}

.btn-claim .btn-claim-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    font-size: 3.5vh;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    pointer-events: none;
    white-space: nowrap;
}

.btn-claim:active {
    animation: none !important;
    transform: translateY(0) scale(0.96) translateZ(0) !important;
    -webkit-transform: translateY(0) scale(0.96) translateZ(0) !important;
}
