/**
 * Kafatopu Oyunu Tasarım Sistemi
 * Buca Efeler Spor Kulübü
 */

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

/* GENEL STİLLER */
.kafatopu-body-wrapper {
    font-family: 'Inter', sans-serif;
    color: #f8f9fa;
    margin: 10px auto 50px auto;
    padding: 0 15px;
}

@media (max-width: 991px) {
    .kafatopu-body-wrapper {
        margin-top: 0px !important;
    }
    .kafatopu-body-wrapper .row {
        display: flex !important;
        flex-direction: column !important;
    }
    .kafatopu-body-wrapper .row > .col-md-5 {
        order: 2 !important;
    }
    .kafatopu-body-wrapper .row > .col-md-7 {
        order: 1 !important;
    }
}

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(13, 22, 51, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;

    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);

}

/* Başlıklar */
.kt-title {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    border-bottom: 2px solid rgba(29, 105, 232, 0.3);
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kt-title i {
    color: #86e7ff;
}

/* Karakter Kartları */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
}

/* Scrollbar Özelleştirme */
.character-grid::-webkit-scrollbar,
.lobby-players::-webkit-scrollbar {
    width: 6px;
}
.character-grid::-webkit-scrollbar-track,
.lobby-players::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
.character-grid::-webkit-scrollbar-thumb,
.lobby-players::-webkit-scrollbar-thumb {
    background: rgba(29, 105, 232, 0.4);
    border-radius: 3px;
}

.character-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.character-card:hover {
    background: rgba(29, 105, 232, 0.15);
    border-color: rgba(29, 105, 232, 0.4);
    transform: translateY(-3px);
}

.character-card.selected {
    background: rgba(19, 191, 9, 0.15);
    border-color: #13bf09;
    box-shadow: 0 0 15px rgba(19, 191, 9, 0.3);
}

/* Kilitli Karakter Kartı */
.kilitli-karakter {
    cursor: not-allowed !important;
    filter: saturate(0.3);
}

.kilitli-karakter:hover {
    background: rgba(245, 158, 11, 0.08) !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
    transform: none !important;
}

.kilitli-karakter .character-avatar-wrapper {
    position: relative;
}

.character-avatar-wrapper {
    width: 75px;
    height: 75px;
    margin: 0 auto 10px auto;
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle, #0d1633 0%, #05070e 100%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-avatar {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.character-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    margin-bottom: 2px;
}

.character-number {
    font-family: 'Oswald', sans-serif;
    font-size: 12px;
    color: #86e7ff;
}

/* Lobi Çevrimiçi Oyuncu Listesi */
.lobby-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 12px;
    transition: background 0.3s;
}

.lobby-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.player-details {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

.player-stats {
    font-size: 11px;
    color: #a0aec0;
}

/* Buton Tasarımları */
.kt-btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    font-size: 13px;
}

.kt-btn-primary {
    background: linear-gradient(135deg, #1d69e8 0%, #13bf09 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(29, 105, 232, 0.3);
}

.kt-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(19, 191, 9, 0.4);
}

.kt-btn-danger {
    background: #e74c3c;
    color: #fff;
}

.kt-btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.kt-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.kt-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Eş Zamanlı Oyun Ekranı */
.game-viewport-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    background: #000;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    flex-shrink: 0;
}

/* Tam Ekran Sarmalayıcı (hem canvas hem tuşları kapsar) */
.game-wrapper-fullscreen {
    width: 100%;
}

.game-wrapper-fullscreen:fullscreen,
.game-wrapper-fullscreen:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

.game-wrapper-fullscreen:fullscreen .glass-panel,
.game-wrapper-fullscreen:-webkit-full-screen .glass-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    min-height: 0;
}

.game-wrapper-fullscreen:fullscreen .game-viewport-container,
.game-wrapper-fullscreen:-webkit-full-screen .game-viewport-container {
    flex: 1;
    border-radius: 0;
    border: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.game-wrapper-fullscreen:fullscreen #gameCanvas,
.game-wrapper-fullscreen:-webkit-full-screen #gameCanvas {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

/* Mobil Dokunmatik Kontroller Arayüzü */
.touch-controls {
    position: relative;
    bottom: auto;
    left: auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    pointer-events: none;
    z-index: 10;
    background: rgba(8, 14, 36, 0.85);
    border-radius: 0 0 15px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.touch-btn-group {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(220, 50, 50, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: transform 0.1s, background-color 0.1s;
}

.touch-btn:active {
    transform: scale(0.9);
    background: rgba(19, 191, 9, 0.85); /* Yeşil aktif efekti */
}

.touch-btn-blue {
    background: rgba(29, 105, 232, 0.7);
}

/* Liderlik Tablosu */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    font-family: 'Oswald', sans-serif;
    color: #a0aec0;
    padding: 12px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    text-transform: uppercase;
}

.leaderboard-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Giriş/Kayıt Modalı */
.modal-content-glass {
    background: rgba(13, 22, 51, 0.95) !important;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 20px !important;
    color: #fff !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.modal-header-glass {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.modal-footer-glass {
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.form-control-glass {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border-radius: 10px !important;
}

.form-control-glass:focus {
    background: rgba(0, 0, 0, 0.5) !important;
    border-color: #1d69e8 !important;
    box-shadow: 0 0 10px rgba(29, 105, 232, 0.3) !important;
}

/* Davet Popup Uyarısı */
.challenge-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: rgba(29, 105, 232, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 320px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.challenge-alert-title {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.challenge-alert-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Takım Tabları */
.team-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.team-tab {
    padding: 8px 20px;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 12px;
}

.team-tab.active {
    background: #1d69e8;
    color: #fff;
    border-color: #1d69e8;
    box-shadow: 0 4px 10px rgba(29, 105, 232, 0.3);
}

.google-btn-container {
    display: flex;
    justify-content: center;
    padding: 10px 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    margin-top: 15px;
}

/* Tam Ekran Butonu ve Modu */
.fullscreen-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 15;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.fullscreen-btn:hover {
    background: rgba(29, 105, 232, 0.85);
    border-color: #1d69e8;
    transform: scale(1.05);
}

.pause-btn {
    position: absolute;
    top: 15px;
    right: 130px;
    z-index: 15;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    display: none;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.pause-btn:hover {
    background: rgba(29, 105, 232, 0.85);
    border-color: #1d69e8;
    transform: scale(1.05);
}

.game-wrapper-fullscreen:fullscreen .touch-controls,
.game-wrapper-fullscreen:-webkit-full-screen .touch-controls {
    flex-shrink: 0;
    padding: 10px 40px;
    border-radius: 0;
}

/* Kontroller Bilgilendirme Overlay Stilleri */
.controls-info-overlay {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 22, 51, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 18px;
    border-radius: 20px;
    color: #e2e8f0;
    font-size: 11px;
    pointer-events: none;
    z-index: 11;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    font-family: 'Inter', sans-serif;
    transition: opacity 0.3s ease;
}
.controls-info-overlay b {
    color: #86e7ff;
}
/* Tam ekranda overlay pozisyonu */
.game-viewport-container:fullscreen .controls-info-overlay {
    bottom: 25px;
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 991px), (max-height: 600px), (pointer: coarse) {
    .controls-info-overlay {
        display: none !important;
    }
}

/* Oyun Başlangıç ve Karakter Seçim Overlay */
.game-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 14, 36, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow-y: auto;
}
/* Mobil cihazlarda başlangıç/bitiş overlay'lerini tam alan ve scrollable yapıyoruz */
@media (max-width: 991px) {
    .game-viewport-container.in-menu {
        min-height: 520px !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .game-viewport-container:not(.in-menu) {
        min-height: auto !important;
        height: auto !important;
    }

    .game-start-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        z-index: 50 !important;
        border-radius: 12px !important;
        display: flex;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        overflow-y: auto !important;
        padding: 12px 8px !important;
        box-sizing: border-box !important;
    }

    .game-start-overlay[style*="display: none"],
    .game-start-overlay[style*="display:none"] {
        display: none !important;
    }
    .game-start-content {
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 6px 4px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Oyun Bitiş ve Başlangıç Overlay'lerindeki Elemanları Mobil Ekranlara Göre Küçültüyoruz */
    .game-start-overlay .glass-panel {
        padding: 10px 12px !important;
        margin: 8px 0 !important;
    }
    .game-start-overlay img {
        width: 46px !important;
        height: 46px !important;
    }
    .game-start-overlay h1 {
        font-size: 26px !important;
        margin-top: 4px !important;
    }
    .game-start-overlay h2.game-start-title {
        font-size: 20px !important;
        margin-bottom: 2px !important;
    }
    .game-start-overlay h3 {
        font-size: 16px !important;
        margin-top: 4px !important;
    }
    .game-start-overlay h4 {
        font-size: 13px !important;
    }
    .game-start-overlay p {
        font-size: 11px !important;
        margin-bottom: 8px !important;
    }
    .game-start-overlay .character-grid-wrapper {
        padding: 8px 10px !important;
        margin-bottom: 12px !important;
    }
    .game-start-overlay .character-grid {
        max-height: 180px !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        overflow-y: auto !important;
    }
    .game-start-overlay .character-card {
        padding: 6px 4px !important;
    }
    .game-start-overlay .character-avatar-wrapper {
        width: 44px !important;
        height: 44px !important;
        margin-bottom: 4px !important;
    }
    .game-start-overlay .character-name {
        font-size: 9px !important;
    }
    .game-start-overlay .kt-btn {
        padding: 10px 16px !important;
        font-size: 13px !important;
        font-weight: 800 !important;
        border-radius: 20px !important;
    }
}

.game-start-content {
    width: 100%;
    max-width: 850px;
    padding: 20px;
}

.game-start-title {
    font-family: 'Oswald', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    text-align: center;
    margin: 0 0 5px 0;
    letter-spacing: 2px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #fff 30%, #86e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-start-subtitle {
    font-size: 13px;
    color: #a0aec0;
    text-align: center;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.character-grid-wrapper {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 20px;
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.5);
}

.game-start-overlay .character-grid {
    max-height: 260px;
    background: transparent;
    padding: 5px;
}

/* Mobil: sadece başlık küçülür, gerisi JS ile yönetilir */
@media (max-width: 768px) {
    .game-start-title {
        font-size: 24px;
    }
    .game-start-overlay .character-grid {
        max-height: 140px;
    }
    .game-start-content {
        padding: 14px;
    }
}

/* Mobil Yatay mod (Landscape) için Oyun Alanı ve Tuş Yerleşimi Ayarları */
@media (max-width: 1200px) and (orientation: landscape), (max-height: 600px) and (orientation: landscape) {
    /* Sayfa başlığı, navigasyon menüsü, alt bilgi (footer) ve lobi/liderlik tablosunu gizleyerek ekranda sadece oyuna yer bırakıyoruz */
    #sayfa_ana_div,
    header,
    #alt_menu_div,
    #leaderboardSection {
        display: none !important;
    }

    .container.wrapper {
        padding: 0 !important;
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .kafatopu-body-wrapper {
        margin: 0 auto !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    .glass-panel {
        padding: 0 !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    #gameWrapper {
        height: 100vh !important;
        height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
        background: #000 !important;
    }
    /* Dikey moddaki 520px'lik menü yüksekliği yatay ekrana sığmıyor; overlay kendi içinde kayar */
    .game-viewport-container.in-menu {
        min-height: 0 !important;
        height: auto !important;
    }
    .game-viewport-container {
        border-radius: 0 !important;
        border: none !important;
        height: auto !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        background: #000 !important;
        min-height: 0 !important;
    }
    #gameCanvas {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: calc(100vh - 85px) !important;
        object-fit: contain !important;
        margin: auto !important;
        flex: 1 !important;
    }
    /* Yatay mobilde tuşları alta konumlandırarak canvas'ın üstüne binmesini önlüyoruz. */
    .touch-controls {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 80px !important;
        background: rgba(8, 14, 36, 0.95) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding: 10px 40px !important;
        box-sizing: border-box !important;
        justify-content: space-between !important;
        pointer-events: auto !important;
        z-index: 99999 !important;
    }
    .touch-btn {
        width: 58px !important;
        height: 58px !important;
        font-size: 11px !important;
    }
    /* Tam ekran ve webkit tam ekran modlarında da geçerli olsun */
    .game-wrapper-fullscreen:fullscreen .touch-controls,
    .game-wrapper-fullscreen:-webkit-full-screen .touch-controls {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 80px !important;
        background: rgba(8, 14, 36, 0.95) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding: 10px 40px !important;
        box-sizing: border-box !important;
        justify-content: space-between !important;
        pointer-events: auto !important;
        z-index: 99999 !important;
    }
    .game-wrapper-fullscreen:fullscreen #gameCanvas,
    .game-wrapper-fullscreen:-webkit-full-screen #gameCanvas {
        max-height: calc(100vh - 85px) !important;
    }
}
