@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800;900&display=swap');

:root {
    --success: #10b981; --danger: #ef4444; --warning: #f59e0b; --info: #0ea5e9;
    --text: #1e293b; --glass-bg: rgba(255, 255, 255, 0.95);
}

/* --- 1. ANA YAPI, SIFIRLAMA VE ARKA PLAN --- */
* {
    box-sizing: border-box; /* KRİTİK: Hiçbir kutunun taşmamasını ve margin/padding dengesini sağlar */
}

@keyframes gradientBG { 
    0% { background-position: 0% 50%; } 
    50% { background-position: 100% 50%; } 
    100% { background-position: 0% 50%; } 
}

body { 
    margin: 0; padding: 0; min-height: 100vh; display: flex; flex-direction: column;
    font-family: var(--theme-font, 'Inter', sans-serif); color: var(--text); 
    background-size: 400% 400%; animation: gradientBG 15s ease infinite; overflow-x: hidden;
}

/* --- 2. HEADER VE FOOTER (MASAÜSTÜ İÇİN JİLET GÖRÜNÜM) --- */
header { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 1rem 2rem; background: rgba(15, 23, 42, 0.5); 
    backdrop-filter: blur(10px); color: white; border-bottom: 1px solid rgba(255,255,255,0.1); 
    width: 100%; box-sizing: border-box; z-index: 10; position: relative;
}
header .logo { 
    font-size: 1.6rem; font-weight: 900; text-decoration: none; color: white; 
    display: flex; align-items: center; gap: 10px; white-space: nowrap; 
    text-shadow: 0 2px 5px rgba(0,0,0,0.3); transition: transform 0.3s;
}
header .logo:hover { transform: scale(1.05); }

header .nav-links { display: flex; gap: 10px; align-items: center; }

header .nav-btn { 
    background: rgba(255,255,255,0.1); padding: 0.7rem 1.2rem; 
    border-radius: 0.8rem; color: white; text-decoration: none; font-weight: 700; 
    transition: all 0.2s; border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap !important; display: inline-flex; 
    align-items: center; justify-content: center;
}
header .nav-btn:hover { background: var(--theme-primary, #8b5cf6); border-color: var(--theme-primary, #8b5cf6); }

footer { background: rgba(15, 23, 42, 0.8); color: #cbd5e1; text-align: center; padding: 1.5rem 1rem; font-size: 0.9rem; margin-top: auto; width: 100%; }
footer p { margin: 5px 0; }
footer a { color: var(--theme-primary, #8b5cf6); text-decoration: none; font-weight: bold; }

/* --- 3. ANA OYUN KONTEYNERİ VE BUTONLAR --- */
main { flex: 1; display: flex; justify-content: center; align-items: center; padding: 2rem 1rem; }
#game-container { background: var(--glass-bg); backdrop-filter: blur(16px); border-radius: 1.5rem; width: 100%; max-width: 550px; text-align: center; padding: 2.5rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); position: relative;}

.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.4s ease-in-out; } 
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.action-btn { width: 100%; padding: 1rem; border:none; border-radius: 1rem; font-weight:900; cursor:pointer; color:white; transition: 0.2s; font-size: 1.1rem; display: inline-block; text-align: center; font-family: inherit;}
.action-btn:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1);}

/* --- 4. ANA MENÜ (Start Screen) --- */
.player-profile { background: rgba(139, 92, 246, 0.1); border: 2px dashed var(--theme-primary, #8b5cf6); border-radius: 1rem; padding: 1rem; margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: center; text-align: left; cursor: pointer; transition: 0.2s;}
.player-profile:hover { transform: translateY(-3px); background: rgba(139, 92, 246, 0.15); }
.streak-fire { background: var(--warning); padding: 0.5rem 1rem; border-radius: 1rem; color: white; font-weight: 800;}

.diff-container { display: flex; justify-content: center; gap: 0.8rem; margin-bottom: 1.5rem; }
.diff-btn { background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 1rem; padding: 0.8rem; font-weight: bold; cursor: pointer; color: #475569; transition: 0.2s; font-family: inherit; font-size: 0.9rem; flex: 1;}
.diff-btn:hover { background: #e2e8f0; }
.diff-btn.active { background: var(--theme-primary, #8b5cf6); color: white; border-color: var(--theme-primary, #8b5cf6); box-shadow: 0 4px 10px rgba(139,92,246,0.3); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem;}
.mode-btn { background: white; border: 2px solid #e2e8f0; border-radius: 1rem; padding: 1.5rem 0.5rem; cursor: pointer; font-weight: 800; color: var(--text); display:flex; flex-direction:column; align-items:center; justify-content:center; transition: 0.2s; gap: 8px; font-size: 1.1rem;}
.mode-btn:hover { border-color: var(--theme-primary, #8b5cf6); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.05); color: var(--theme-primary, #8b5cf6); }

/* --- 5. OYUN İÇİ EKRANI VE JOKERLER --- */
.top-hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.quit-btn { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: 2rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; transition: 0.2s; font-family: inherit;}
.quit-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(239,68,68,0.4); }
.combo-meter { background: var(--warning); color: white; padding: 0.5rem 1rem; border-radius: 2rem; font-weight: 900; opacity: 0; transition: 0.3s;}

.stats-bar { display: flex; justify-content: space-between; font-size: 1.1rem; font-weight: 800; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid rgba(0,0,0,0.1); }
.flag-container { height: 150px; display: flex; justify-content: center; align-items: center; margin-bottom: 1.5rem; }
.flag-container img { max-height: 100%; max-width: 100%; border-radius: 0.5rem; box-shadow: 0 5px 15px rgba(0,0,0,0.2); border: 1px solid #e2e8f0; object-fit: contain;}
#question { font-size: 1.5rem; font-weight: 900; margin-bottom: 2rem; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
button.opt-btn { background-color: var(--theme-primary, #8b5cf6); color: white; border: none; padding: 1.2rem; border-radius: 1rem; font-size: 1rem; font-weight: 800; cursor: pointer; transition: 0.2s; font-family: inherit;}
button.opt-btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); filter: brightness(1.1);}
.btn-correct { background-color: var(--success) !important; transform: scale(1.05); z-index: 10;} .btn-wrong { background-color: var(--danger) !important; }

.joker-container { display: flex; justify-content: center; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(0,0,0,0.05); }
.joker-btn { border: none; padding: 1rem 1.5rem; border-radius: 1rem; font-weight: 900; font-size: 1rem; cursor: pointer; display: flex; align-items: center; gap: 0.8rem; color: white; transition: 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.1); font-family: inherit; flex:1; justify-content: center;}
.joker-btn:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 10px 15px rgba(0,0,0,0.2); filter: brightness(1.1);}
.joker-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); transform: none; box-shadow: none; }
#joker-5050 { background: linear-gradient(135deg, #f59e0b, #d97706); } #joker-skip { background: linear-gradient(135deg, #0ea5e9, #0284c7); }

/* --- 6. OYUN BİTTİ EKRANI --- */
.game-over-box { background: rgba(248, 250, 252, 0.8); border-radius: 1.5rem; padding: 1.5rem; margin-bottom: 1.5rem; border: 2px solid #e2e8f0; text-align: center;}
.go-input-group { display: flex; gap: 0.5rem; margin-top: 1rem; }
.go-input-group input { flex: 1; padding: 1rem; border-radius: 1rem; border: 2px solid #cbd5e1; outline: none; font-weight: bold; font-family: inherit; font-size: 1rem;}
.go-input-group input:focus { border-color: var(--theme-primary, #8b5cf6); }
.go-input-group button { background: var(--theme-primary, #8b5cf6); color: white; border: none; padding: 0 1.5rem; border-radius: 1rem; font-weight: bold; cursor: pointer; transition: 0.2s; font-family: inherit;}
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* --- 7. MODALLAR (Profil, Pasaport, Rehber, Liderlik) KESİN ÇÖZÜMÜ --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.95); display: flex; justify-content: center; 
    align-items: center; z-index: 999; padding: 1.5rem; overflow-y: auto; 
}

.board-container { 
    background: white; width: 100%; max-width: 550px; border-radius: 1.5rem; 
    padding: 2.5rem; position: relative; margin: auto; 
    max-height: 90vh; overflow-y: auto; 
}

.gamer-card { 
    background: linear-gradient(145deg, #1e293b, #0f172a); color: white; 
    padding: 2.5rem; border-radius: 1.5rem; border: 2px solid rgba(139, 92, 246, 0.4); 
    width: 100%; max-width: 420px; text-align: center; position: relative; margin: auto;
}
.gc-xp-bar-bg { background: rgba(255, 255, 255, 0.1); height: 12px; border-radius: 6px; margin: 15px 0 10px 0; overflow: hidden; display: block; width: 100%; }
.gc-xp-bar-fill { background: linear-gradient(90deg, #8b5cf6, #0ea5e9); height: 100%; width: 0%; transition: width 1s ease-in-out; }
.gc-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 25px 0; }
.gc-stat-box { background: rgba(255, 255, 255, 0.05); padding: 15px 10px; border-radius: 1rem; border: 1px solid rgba(255, 255, 255, 0.08); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; }
.gc-stat-val { font-size: 1.8rem; font-weight: 900; color: #fff; line-height: 1; margin:0;}
.gc-stat-label { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; font-weight: bold; margin:0; letter-spacing: 0.5px;}

.ref-box { background: rgba(16, 185, 129, 0.1); padding: 1.5rem; border-radius: 1rem; border: 1px dashed #10b981; margin-bottom: 1.5rem;}
.ref-box input { width: 100%; padding: 12px; background: rgba(0,0,0,0.3); color: white; text-align: center; border: 1px solid rgba(255,255,255,0.2); border-radius: 0.5rem; font-size: 0.95rem; outline: none; font-family: inherit;}

/* Liderlik Tablosu & Rehber */
.rank-item { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid #e2e8f0; font-weight: 800; font-size: 1.1rem; border-radius: 0.5rem; margin-bottom: 8px;}
.rank-1 { background: rgba(245, 158, 11, 0.1); color: #d97706; border: 1px solid #f59e0b;}
.rank-me { background: rgba(139, 92, 246, 0.1); border: 2px solid var(--theme-primary, #8b5cf6); }
.guide-section { background: #f8fafc; padding: 1.2rem; border-radius: 1rem; margin-bottom: 1rem; text-align: left; border: 1px solid #e2e8f0;}
.guide-section h4 { margin: 0 0 10px 0; color: var(--theme-primary, #8b5cf6); font-size: 1.1rem;}
.guide-section ul { margin: 0; padding-left: 20px; color: #475569; line-height: 1.6; font-size: 0.95rem;}

/* PASAPORT */
.passport-header-area { background: #f8fafc; padding: 1.5rem; border-radius: 1rem; margin-bottom: 1.5rem; border: 1px solid #e2e8f0; text-align: left; }
.passport-progress-container { background: #e2e8f0; border-radius: 10px; height: 10px; width: 100%; margin: 10px 0; overflow: hidden; }
.passport-progress-fill { background: linear-gradient(90deg, var(--theme-primary, #8b5cf6), #10b981); height: 100%; width: 0%; transition: width 1s ease;}
.passport-grid-inner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.stamp-item { background: white; border: 1px solid #e2e8f0; border-radius: 1rem; padding: 15px 5px; text-align: center; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; position: relative; transition: 0.3s; box-shadow: 0 2px 5px rgba(0,0,0,0.02);}
.stamp-item:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.08); }
.stamp-item img.mini-flag { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #f1f5f9; }
.stamp-badge { position: absolute; top: -8px; right: -8px; background: white; width: 24px; height: 24px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1rem; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.stamp-gold { border-color: #f59e0b; background: #fffbeb; } .stamp-silver { border-color: #94a3b8; }

/* --- 8. MOBİL UYUMLULUK VE ORTALI HEADER TASARIMI --- */

@media (max-width: 600px) {
    /* Mobilde Header Yapısı: Logo üstte, Butonlar altta */
    header {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 1rem 0.5rem 0.5rem 0.5rem;
        gap: 12px;
    }
    header .logo {
        font-size: 2rem !important; /* Logo daha iddialı */
        width: 100%;
        justify-content: center; /* Tam ortaya hizala */
        margin-bottom: 5px;
    }
    header .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap; 
        gap: 8px;
    }
    header .nav-btn {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.85rem !important;
        flex-grow: 1; /* Ekranı eşit paylaşırlar */
        max-width: 110px; 
        height: 40px; 
    }
}

@media (max-width: 480px) { 
    .board-container { padding: 1.5rem; }
    #game-container { padding: 1.5rem; }
    .passport-grid-inner { grid-template-columns: repeat(2, 1fr); gap: 12px; } 
    .gamer-card { padding: 2rem 1.5rem; }
}

@media (max-width: 340px) {
    /* Çok dar ekranlı (iPhone SE gibi) cihazlar için güvenlik önlemi */
    header .nav-btn { font-size: 0.75rem !important; padding: 0.5rem !important; }
    header .logo { font-size: 1.6rem !important; }
}

/* ✅ NİHAİ ÇÖZÜM: YATAY KAYDIRMAYI KALDIRMAK VE BUTONU NETLEŞTİRMEK İÇİN */

/* 1. Modal Açıldığında Ana Ekranı Yatayda Kilitle (Tarayıcı Scroll'unu Engelle) */
body.modal-open {
    overflow-x: hidden;
}

/* 2. Modal Konteynerini ve Bindirmeyi Düzelt */
.modal-overlay {
    overflow-x: hidden; /* Bindirme içinde yatay scroll'u engelle */
    /* ...diğer mevcut stiller... */
}

/* 3. Modal Kutusunu Düzelt (Yatayda Taşmaması İçin) */
.modal-board {
    max-width: 90%; /* Mobilde ekrana sığması için */
    overflow-x: hidden; /* Kutu içinde yatay scroll'u engelle */
    position: relative; /* Kapatma butonunun konumlandırılması için */
    /* ...diğer mevcut stiller... */
}

/* 4. ✅ Kapatma Butonunu Netleştir */
.close-modal-top {
    display: flex; /* İçindeki '×' karakterini ortalamak için */
    align-items: center;
    justify-content: center;
    width: 30px; /* Tanımlı tıklama alanı */
    height: 30px; /* Tanımlı tıklama alanı */
    background: rgba(255,255,255,0.1); /* Hafif belirgin alan */
    border: none;
    border-radius: 50%; /* Dairesel buton */
    color: white; /* '×' karakterinin rengi */
    font-size: 1.5rem; /* '×' karakterinin boyutu */
    font-weight: bold;
    cursor: pointer;
    position: absolute; /* Kutuya göre konumlandır */
    top: 10px; /* Üstten padding */
    right: 10px; /* Sağdan padding */
    transition: background 0.2s, color 0.2s; /* Hover efekti için */
    z-index: 10; /* Diğer öğelerin üstünde kalması için */
}

.close-modal-top:hover {
    background: rgba(255,255,255,0.3); /* Hover efekti */
}