/* ---------- TAM EKRAN HİPODROM ---------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #2a5a3a;
    font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
    touch-action: none;
}

/* PİST (KAMERA GÖRÜNÜMÜ - dış çerçeve, taşan içeriği gizler) */
.race-track {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #2a5a3a;
    overflow: hidden;
    position: relative;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* PİST İÇERİĞİ (gerçek yarış alanı - dikey modda ekrandan geniş olabilir,
   bu durumda kamera bunu en öndeki atı takip edecek şekilde kaydırır) */
.track-content {
    position: relative;
    height: 100%;
    width: 100%; /* JS tarafından px olarak güncellenir */
    min-width: 100%;
    background: #4f7a3b;
    background-image: repeating-linear-gradient(90deg,
            #5f9047 0px, #5f9047 40px,
            #4f7a3b 40px, #4f7a3b 80px);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding:
        0
        max(20px, env(safe-area-inset-right))
        0
        max(20px, env(safe-area-inset-left));
    will-change: transform;
    transition: transform 0.08s linear;
}

/* BİTİŞ ÇİZGİSİ (.track-content içinde - sanal pistin gerçek sonunda durur) */
.finish-line {
    position: absolute;
    top: 0;
    right: 15px;
    width: 8px;
    height: 100%;
    background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
        linear-gradient(45deg, #fff 25%, #000 25%, #000 75%, #fff 75%, #fff);
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
    z-index: 10;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

/* AT KORIDORU */
.horse-row {
    position: relative;
    width: 100%;
    height: calc(100% / 5 - 8px);
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.2);
    margin: 2px 0;
}

/* AT ETİKETİ VE İSİMLERİ */
.horse-label {
    position: absolute;
    bottom: 4px;
    left: 10px;
    z-index: 5;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: clamp(0.6rem, 3.5vh, 0.9rem);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
    min-width: 160px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

.horse-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* AT GÖRSELİ */
.horse-figure {
    position: absolute;
    height: 90%;
    max-height: 90px;
    object-fit: contain;
    z-index: 4;
    transform: translateZ(0);
    filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.4));
    transition: left 0.05s linear;
}

/* KAZANAN PARILDAMASI */
.winner-glow {
    filter: drop-shadow(0 0 12px #ffd700) drop-shadow(0 0 4px #ff8c00) !important;
    animation: winnerJump 0.4s infinite alternate ease-in-out;
}

@keyframes winnerJump {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

/* SIRA ROZETİ */
.rank-badge {
    position: absolute;
    right: 35px;
    background: rgba(0, 0, 0, 0.75);
    color: #ffd700;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: clamp(0.7rem, 3.5vh, 1rem);
    font-weight: bold;
    min-width: 32px;
    text-align: center;
    border: 1px solid #ffd700;
    z-index: 5;
}

/* BAŞLAT BUTONU */
#startBtn {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #b3976c;
    border: 4px solid #1e1e1e;
    color: #1e1e1e;
    font-size: 2.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
}

#startBtn:hover {
    background: #c5ab80;
    transform: translate(-50%, -50%) scale(1.08);
}

#startBtn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* SONUÇ EKLETI/BİLDİRİM KUTUSU */
#resultMessage {
    position: fixed;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 190;
    background: rgba(20, 24, 33, 0.98);
    color: #ffd700;
    padding: 16px 28px;
    border-radius: 8px;
    font-size: 1.1rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.85);
    border: 2px solid #b3976c;
    text-align: center;
    min-width: 300px;
    opacity: 0;
    transition: opacity 0.4s ease;
    letter-spacing: 0.5px;
    pointer-events: auto;
    white-space: normal;
}

#resultMessage.show {
    opacity: 1;
}

/* YATAY MOBİL RÖTUŞLARI */
@media (max-height: 500px) and (orientation: landscape) {
    .race-track {
        padding: 4px 20px;
    }
    .horse-row {
        margin: 1px 0;
    }
    .horse-figure {
        max-height: 50px;
    }
    .horse-label {
        min-width: 140px;
        font-size: clamp(0.5rem, 4vh, 0.85rem);
        padding: 1px 8px;
        bottom: 2px;
        left: 6px;
    }
    #resultMessage {
        bottom: 2%;
        font-size: 0.95rem;
        padding: 8px 16px;
    }
}

/* UFAK EKRAN DİKEY RÖTUŞLARI */
@media (max-width: 500px) {
    .horse-label {
        min-width: 120px;
        font-size: 0.7rem;
        padding: 1px 6px;
    }
    .rank-badge {
        right: 20px;
    }
}