/* css/style.css */
:root {
    --bg-color: #050a0f;
}

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; background-color: var(--bg-color);
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
    touch-action: manipulation;
}

#game-container {
    position: relative; width: 100%; height: 100%;
    display: flex; justify-content: center;
    cursor: pointer;
}

/* ARKA PLAN */
#mountain {
    position: absolute;
    width: 100%; height: 100%;
    background: url('../assets/images/dag_resmi.jpg') center center / cover no-repeat;
    transform-origin: center top; 
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
}

/* KARAKTER */
#penguin {
    position: absolute;
    bottom: 10%; 
    width: 400px; height: 400px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    z-index: 10;
    pointer-events: auto; /* NONE olan yeri AUTO yaptık, artık tıklanabilir */
    transition: bottom 0.2s ease-out, transform 0.2s ease-out;
    cursor: pointer; /* Üstüne gelince el işareti çıksın */
}

.closed { background-image: url('../assets/images/penguen_kapali.png'); }
.open { background-image: url('../assets/images/penguen_acik.png'); }

/* UI */
#ui {
    position: absolute; top: 5%; text-align: center;
    width: 100%; z-index: 20; pointer-events: none;
}
#counter {
    color: white; font-size: clamp(2rem, 8vw, 5rem); font-weight: 900;
    text-shadow: 0 4px 8px rgba(0,0,0,0.7);
}

.subtitle {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.8px;
    margin-top: 12px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 
                 0 2px 8px rgba(0, 0, 0, 0.8),
                 0 0 15px rgba(52, 152, 219, 0.6);
    animation: subtleGlow 4s ease-in-out infinite;
}

@keyframes subtleGlow {
    0%, 100% { 
        text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 
                     0 2px 8px rgba(0, 0, 0, 0.8),
                     0 0 15px rgba(52, 152, 219, 0.6);
        opacity: 0.95;
    }
    50% { 
        text-shadow: 0 0 5px rgba(0, 0, 0, 0.9), 
                     0 2px 12px rgba(0, 0, 0, 0.8),
                     0 0 25px rgba(52, 152, 219, 0.8);
        opacity: 1;
    }
}

#audio-controls {
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 120;
}

#music-toggle {
    background: rgba(6, 22, 38, 0.75);
    border: 1px solid rgba(180, 210, 255, 0.5);
    color: #eaf2ff;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 6px 14px rgba(2, 10, 20, 0.35);
}

#milestone-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 64px;
    background: linear-gradient(180deg, rgba(33, 88, 136, 0.86), rgba(24, 73, 118, 0.84));
    border-bottom: 1px solid rgba(140, 192, 255, 0.45);
    color: #ebf4ff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 0 2px 10px rgba(4, 13, 28, 0.5);
    box-shadow: 0 6px 18px rgba(4, 14, 28, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    z-index: 100;
}

#top-leader-bar {
    position: absolute;
    top: 52px;
    left: 10px;
    right: 10px;
    padding: 9px 12px 8px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(10, 41, 68, 0.82), rgba(8, 32, 54, 0.78));
    border: 1px solid rgba(143, 192, 252, 0.32);
    box-shadow: 0 8px 24px rgba(2, 10, 22, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(10px);
    box-sizing: border-box;
    z-index: 99;
}

#top-leader-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
    color: #e7f2ff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

#top-leader-country {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 58%;
    letter-spacing: 0.3px;
}

#top-leader-country-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

#top-leader-flag {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    display: none;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

#top-leader-remaining {
    white-space: nowrap;
    color: #acd2ff;
    text-align: right;
}

#online-count {
    position: absolute;
    right: 10px;
    top: calc(100% + 6px);
    bottom: auto;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(143, 192, 252, 0.32);
    background: rgba(8, 32, 54, 0.6);
    color: #d7ecff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    white-space: nowrap;
    text-transform: uppercase;
}

#top-leader-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

#top-leader-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4aa3ff, #9ed0ff);
    box-shadow: 0 0 14px rgba(112, 181, 255, 0.35);
    transition: width 0.35s ease;
}

#top-leader-stats {
    margin-top: 7px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #c5ddff;
    letter-spacing: 0.2px;
}

#ui {
    margin-top: 124px;
}

#audio-controls {
    top: 6px;
    right: 10px;
    z-index: 120;
}

#overtake-bar {
    position: absolute;
    top: 6px;
    left: 10px;
    right: auto;
    transform: none;
    z-index: 120;
    width: auto;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.overtake-toggle {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(180, 210, 255, 0.5);
    background: rgba(6, 22, 38, 0.75);
    color: #ffb0b0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(2, 10, 20, 0.35);
}

.overtake-toggle.has-alert {
    animation: overtakePulse 1.4s ease-in-out infinite;
}

.overtake-toggle-icon {
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.overtake-card {
    display: flex;
    align-items: center;
    position: relative;
    gap: 12px;
    padding: 10px 32px 10px 12px;
    width: min(430px, calc(100vw - 22px));
    border-radius: 14px;
    color: #ecf4ff;
    background:
        radial-gradient(circle at 14% 10%, rgba(147, 198, 255, 0.15), transparent 46%),
        linear-gradient(135deg, rgba(8, 28, 48, 0.92), rgba(6, 22, 38, 0.9));
    border: 1px solid rgba(156, 205, 255, 0.24);
    box-shadow: 0 14px 32px rgba(2, 10, 20, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(9px);
    animation: overtakeSlideIn 0.42s cubic-bezier(0.2, 0.86, 0.28, 1);
}

#overtake-panel[hidden] {
    display: none !important;
}

.overtake-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.overtake-eyebrow {
    flex-shrink: 0;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(154, 205, 255, 0.28);
    background: rgba(114, 178, 252, 0.16);
    color: #d9ebff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    white-space: nowrap;
}

.overtake-msg {
    flex: 1;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-wrap: balance;
}

.overtake-share-btn {
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 8px 11px;
    color: #e8fff1;
    background: linear-gradient(135deg, #20b758, #14934a);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 8px 16px rgba(19, 125, 65, 0.36);
}

.overtake-share-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 10px 18px rgba(20, 135, 70, 0.42);
}

.overtake-share-btn:active {
    transform: translateY(0);
}

@keyframes overtakeSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-8px) scale(0.99);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes overtakePulse {
    0%, 100% {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38), 0 0 0 0 rgba(220, 56, 56, 0.55);
    }
    50% {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38), 0 0 0 8px rgba(220, 56, 56, 0);
    }
}

@media (max-width: 768px) {
    #milestone-info {
        height: 48px;
        font-size: 12px;
        letter-spacing: 1.1px;
        padding: 0 56px;
    }

    #top-leader-bar {
        top: 50px;
        left: 8px;
        right: 8px;
        padding: 7px 9px;
        border-radius: 10px;
    }

    #top-leader-head {
        font-size: 11px;
        gap: 8px;
        margin-bottom: 6px;
    }

    #top-leader-track {
        height: 8px;
    }

    #top-leader-stats {
        font-size: 10px;
        margin-top: 6px;
    }

    #ui {
        margin-top: 110px;
    }

    #audio-controls {
        top: 6px;
        right: 10px;
    }

    #overtake-bar {
        top: 6px;
        left: 10px;
    }

    .overtake-card {
        width: min(390px, calc(100vw - 24px));
        gap: 9px;
        padding: 9px 30px 9px 10px;
    }

    .overtake-eyebrow {
        display: none;
    }

    .overtake-msg {
        font-size: 12px;
    }

    .overtake-share-btn {
        padding: 7px 9px;
        font-size: 11px;
    }
}

@media (max-width: 420px) {
    #milestone-info {
        height: 44px;
        font-size: 10.5px;
        letter-spacing: 0.9px;
        padding: 0 52px;
    }

    #top-leader-head {
        font-size: 10px;
    }

    #top-leader-country,
    #top-leader-remaining {
        max-width: 50%;
    }

    #ui {
        margin-top: 102px;
    }

    #overtake-bar {
        top: 6px;
        left: 8px;
    }

    .overtake-toggle {
        width: 30px;
        height: 30px;
    }

    .overtake-card {
        width: min(350px, calc(100vw - 24px));
        padding: 9px 30px 9px 10px;
    }

    #audio-controls {
        top: 6px;
        right: 8px;
    }
}

/* LEADERBOARD (ESKİ AYARLARINA SADIK) */
#leaderboard {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 340px; /* Orijinal genişliğin */
    max-width: 90vw;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    z-index: 1000;
}

#leaderboard.minimized {
    height: 45px;
}

#leaderboard-header {
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

#leaderboard-content {
    padding: 10px 15px;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Expanded hali için scroll */
#leaderboard.expanded #leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px; /* Sadece çok az boşluk ki rakama binmesin */
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    align-items: center;
}

/* YEŞİL ANİMASYON */
.score-val {
    color: white; 
    transition: color 0.2s;
}

/* Yeşil yanma animasyonu */
@keyframes greenFade {
    0% { 
        color: #2ecc71; /* Başlangıçta canlı yeşil */
        text-shadow: 0 0 15px #2ecc71;

    }
    100% { 
        color: white !important; /* Bitişte beyaza dön */
        text-shadow: none; 
    }
}

.score-update {
    animation: greenFade 3s ease-out !important;
}
/* SCROLLBAR GÜZELLEŞTİRME */
#leaderboard-list::-webkit-scrollbar {
    width: 5px;
}
#leaderboard-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 10px;
}

/* Arama Kutusu ve Senkron Bilgisi */
#country-search {
    width: 100%;
    padding: 6px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 4px;
    color: white;
}

#sync-info {
    font-size: 10px;
    color: #888;
    margin-top: 10px;
    text-align: right;
    font-style: italic;
}

.dot {
    height: 6px; width: 6px;
    background-color: #00ff00;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    animation: blink 2s infinite;
}

@keyframes blink {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}


.click-particle {
    position: absolute; /* fixed yerine absolute yapıyoruz */
    pointer-events: none;
    z-index: 10000000; /* Çok yüksek bir değer verelim */
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floatUpAndFade 0.8s ease-out forwards;
}

@keyframes floatUpAndFade {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-150px) scale(1.5);
        opacity: 0;
    }
}

#share-section button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
    transition: 0.2s;
}

/* --- REKLAM ALANI --- */
.ad-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: linear-gradient(135deg, rgba(15, 25, 45, 0.7), rgba(25, 40, 65, 0.7));
    border: 1px solid rgba(52, 152, 219, 0.2);
    border-radius: 12px;
    padding: 12px;
    z-index: 30;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
}

.ad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ad-title {
    font-size: 11px;
    color: #888;
    font-style: italic;
    flex: 1;
    margin-right: 10px;
}

.ad-contact-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.ad-contact-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.ad-contact-btn:hover {
    background: linear-gradient(135deg, #2980b9, #1f618d);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.5);
}

.ad-contact-email {
    color: #9fc9ff;
    font-size: 10px;
    text-decoration: none;
    line-height: 1;
    opacity: 0.9;
}

.ad-contact-email:hover {
    color: #c8e2ff;
    text-decoration: underline;
}

.ad-display {
    width: 100%;
    height: 140px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}

/* Overtake alert bar */
#overtake-bar { pointer-events: auto; }

/* Share card overlay */
#share-card-overlay { display:flex; }
#share-card { max-width:420px; }

/* Speech bubble */
.speech-bubble {
    position: absolute;
    max-width: 220px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 12px;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
    z-index: 9999;
}

/* Leader CTA small adjustments */
#leader-cta { display:flex; align-items:center; }


.ad-slide {
    width: 100%;
    height: 100%;
    position: relative;
}

#ad-content {
    animation: adFadeInOut 8s infinite;
    width: 100%;
    height: 100%;
}

@keyframes adFadeInOut {
    0% {
        opacity: 0;
    }
    5%, 95% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.ad-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.ad-caption {
    width: 100%;
    background: linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.25));
    border-radius: 6px;
    box-sizing: border-box;
}

.ad-text {
    max-width: 100%;
    word-wrap: break-word;
    font-size: 12px;
    line-height: 1.4;
    color: #ffffff;
    margin: 0;
    font-weight: 500;
}

.ad-title-text {
    font-size: 14px;
    color: #ffffff;
    font-weight: bold;
    margin-bottom: 5px;
}

.ad-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: #555;
}

.ad-dot {
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

/* Collapsed state: reklam yokken sadece header göster */
.ad-container.collapsed {
    position: absolute;
    bottom: 85px;
    left: 20px;
    right: auto;
    width: 340px;
    height: auto;
    max-width: 90vw;
    padding: 8px 12px;
    transform: none;
    top: auto;
    z-index: 35;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(52, 152, 219, 0.2);
    border-radius: 8px;
}

.ad-container.collapsed .ad-header {
    display: flex;
    padding: 0;
    border-bottom: none;
    gap: 10px;
    align-items: center;
}

.ad-container.collapsed .ad-title {
    font-size: 11px;
    color: #ffffff;
    flex: 1;
    margin: 0;
    font-style: italic;
}

.ad-container.collapsed .ad-contact-btn {
    padding: 5px 10px;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ad-container.collapsed .ad-contact-email {
    font-size: 9px;
}

.ad-container.collapsed .ad-display,
.ad-container.collapsed .ad-caption,
.ad-container.collapsed .ad-stats {
    display: none;
}

@media (max-width: 600px) {
    #leaderboard {
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }

    .ad-container {
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
        transform: none;
        bottom: 75px;
        padding: 8px;
        background: linear-gradient(135deg, rgba(15, 25, 45, 0.6), rgba(25, 40, 65, 0.6));
        z-index: 25;
    }

    .ad-header {
        margin-bottom: 6px;
        padding-bottom: 4px;
    }

    .ad-title {
        font-size: 9px;
        margin-right: 5px;
    }

    .ad-contact-btn {
        padding: 4px 8px;
        font-size: 9px;
    }

    .ad-contact-email {
        font-size: 8px;
    }

    .ad-display {
        height: 80px;
        margin-bottom: 6px;
    }

    .ad-caption {
        padding: 6px 8px;
    }

    .ad-title-text {
        font-size: 12px;
        margin-bottom: 3px;
    }

    .ad-text {
        font-size: 11px;
        line-height: 1.3;
    }

    .ad-stats {
        font-size: 9px;
        gap: 6px;
    }

    .ad-dot {
        width: 3px;
        height: 3px;
    }

    .ad-container.collapsed {
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }
}
