/* style.css */

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #333;
    color: #fff;
    margin: 0;
    overflow: hidden; 
}

#main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 1200px;
    width: 100%;
}

#main-content {
    display: flex; 
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
}

#left-panel, #right-panel {
    display: flex; /* DÜZELTME: Responsive yönetim için Flex eklenmeli */
    flex-direction: column; /* DÜZELTME: İçerik dikey sıralansın */
    width: 200px;
    padding: 15px;
    background-color: #444;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    height: 640px; 
}

#chessboard {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    grid-template-rows: repeat(8, 80px);
    border: 5px solid #222;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    width: 640px;
    height: 640px;
}

/* Genel kare stili */
.square {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 50px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.1s;
    outline: none !important;
    /* Bu, .light/.dark sınıflarının arkasına eklenebilir. */
    background-image: none !important; 
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: auto !important;
}

.square:focus,
.square:active {
    outline: none !important;
    box-shadow: none !important;
}


.light {
    background-color: #f0d9b5; /* Açık kahverengi */
}

.dark {
    background-color: #b58863; /* Koyu kahverengi */
}

/* TAŞLAR */
.piece {
    font-size: 55px; 
    line-height: 1;
}
.white-piece {
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.black-piece {
    color: #000;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* DURUM VURGULAMALARI */

/* 1. SEÇİLİ KARE (Tıklanan Taşın Bulunduğu Kare) */
.square.selected.light { /* Seçili açık kare */
    background-color: #f0d9b5 !important; /* Kendi açık rengini koru */
    background-image: none !important;
}
.square.selected.dark { /* Seçili koyu kare */
    background-color: #b58863 !important; /* Kendi koyu rengini koru */
    background-image: none !important;
}
.square.selected {
    /* Ortak çerçeve stili */
    box-shadow: 
        0 0 5px 2px #0f0, 
        0 0 10px 4px rgba(0, 255, 0, 0.6), 
        inset 0 0 5px 2px #0f0; 
}

/* 2. GİDİŞ NOKTALARI (Highlight) */
.square.highlighted.light { /* Vurgulanan açık kare */
    background-color: #f0d9b5 !important; /* Kendi açık rengini koru */
}
.square.highlighted.dark { /* Vurgulanan koyu kare */
    background-color: #b58863 !important; /* Kendi koyu rengini koru */
}
.square.highlighted {
    /* Ortak çerçeve ve nokta stili */
    box-shadow: 
        0 0 0 3px #13ff00 inset, 
        0 0 5px rgba(19, 255, 0, 0.5) inset; 
    
    background-image: radial-gradient(circle, #13ff00 25%, transparent 25%) !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 20px 20px !important; 
}


/* 3. YAKALAMA HEDEFLERİ (Capture Highlight) */
.square.capture-highlight {
    /* Bu stilin, .light ve .dark'tan sonra geldiğinden emin olmak için genel yaptık */
    box-shadow: 
        inset 0 0 0 5px #ff5252, 
        inset 0 0 0 300px rgba(255, 82, 82, 0.1); /* Hafif şeffaf kırmızı dolgu */
    background: none !important; /* Arka plan görüntüsü olmasın */
}

/* Bu özel durum için, capture-highlight stilinin .light ve .dark'ı geçersiz kılması gerekebilir. */
.square.capture-highlight.light {
    background-color: #f0d9b5 !important; /* Açık rengini korurken vurguyu ekle */
}
.square.capture-highlight.dark {
    background-color: #b58863 !important; /* Koyu rengini korurken vurguyu ekle */
}


.square.check {
    background-color: #ff0000 !important; /* Şah çekilen kare kırmızı olsun */
}

/* BAŞLANGIÇ VE MESAJ BÖLÜMLERİ */

#info-panel {
    width: 100%;
    margin-bottom: 20px;
    text-align: center;
    background-color: #222;
    padding: 10px;
    border-radius: 8px;
}

#turn-display {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.turn-indicator.white-turn {
    color: #f0d9b5;
}
.turn-indicator.black-turn {
    color: #b58863;
}

#message-display {
    min-height: 20px;
    font-style: italic;
    color: #aaa;
}

.check-alert {
    color: #ff0000;
    font-weight: bold;
}

/* ZAMANLAYICILAR */
.timer-display {
    font-size: 1.8em;
    font-weight: bold;
    padding: 5px 0;
    transition: color 0.3s, background-color 0.3s;
}
.active-timer {
    color: #4CAF50; 
}
.low-time {
    color: #FF5722; 
    animation: blinker 1s linear infinite;
}
@keyframes blinker {
    50% { opacity: 0.5; }
}


/* YAKALANAN TAŞLAR */

#white-captured-pieces, #black-captured-pieces {
    min-height: 50px;
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 5px; 
}

/* Taşların 4 sütuna sığması için boyutunu küçültme */
#white-captured-pieces .piece, 
#black-captured-pieces .piece {
    font-size: 35px; 
    line-height: 1;
}

#white-captured-pieces h4, #black-captured-pieces h4 {
    margin: 5px 0;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    width: 100%; 
    grid-column: 1 / span 4; 
}

/* OYUN BAŞLANGIÇ POP-UP'I */

#time-selection-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#selection-content {
    background-color: #333;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
    text-align: center;
    width: 350px;
}

#selection-content h2 {
    color: #f0d9b5;
    margin-top: 0;
}

.input-group {
    margin-bottom: 15px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

select, input[type="number"], button {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #555;
    background-color: #555;
    color: white;
    box-sizing: border-box;
}

button#start-game-button {
    margin-top: 20px;
    background-color: #4CAF50;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

button#start-game-button:hover {
    background-color: #45a049;
}

#custom-time-inputs {
    display: flex;
    gap: 10px;
}
#custom-time-inputs input {
    width: 50%;
}

/* SES KONTROL DÜĞMESİ İÇİN EK KURAL */
#toggle-sound-button {
    background-color: #666;
    margin-top: 15px; /* Panelin altındaki diğer elemanlardan ayırmak için */
}

/* ========================================================== */
/* RESPONSIVE TASARIM (Media Queries) */
/* ========================================================== */

/* Tablet ve küçük masaüstü ekranlar (Maksimum genişlik 1024px) */
@media (max-width: 1024px) {
    /* Ana içerik dikey panelleri sığdırmak için sıkıştır */
    #left-panel, #right-panel {
        width: 150px; /* Panelleri daralt */
        height: 600px; /* Tahtanın yeni boyutuna uyum sağla */
        padding: 10px;
    }
    
    #chessboard {
        grid-template-columns: repeat(8, 75px);
        grid-template-rows: repeat(8, 75px);
        width: 600px; /* Tahtayı küçült: 8 * 75px = 600px */
        height: 600px;
    }

    .square {
        font-size: 45px; /* Taş boyutunu küçült */
    }
    
    .piece {
        font-size: 50px; /* Taş sembolü boyutunu küçült */
    }

    /* Yakalanan taşların boyutunu ayarlama */
    #white-captured-pieces .piece, 
    #black-captured-pieces .piece {
        font-size: 30px; 
    }
}

/* Telefon ekranları (Maksimum genişlik 768px) */
@media (max-width: 768px) {
    
    /* Ana içeriği dikey düzenle (Panelleri tahtanın altına al) */
    #main-content {
        flex-direction: column; /* Yataydan dikeye geçiş */
        align-items: center; /* Tahtayı ortala */
        gap: 15px;
    }

    /* Tahtayı sığacak şekilde daha da küçült (Örn: 50px/kare) */
    #chessboard {
        grid-template-columns: repeat(8, 48px);
        grid-template-rows: repeat(8, 48px);
        width: 384px; /* Tahtayı küçült: 8 * 48px = 384px */
        height: 384px;
        border-width: 3px;
    }
    
    .square {
        font-size: 28px;
    }

    .piece {
        font-size: 32px;
    }

    /* Yan panelleri (sol ve sağ) tahtanın genişliğine yay */
    #left-panel, #right-panel {
        width: 384px; /* Tahta ile aynı genişlikte yap */
        min-height: auto;
        height: auto;
        order: -1; /* Sol paneli (Bilgi) en üste taşı */
    }

    #right-panel {
        order: 1; /* Sağ paneli (Yakalanan Taşlar/Ses) en alta taşı */
    }

    /* ZAMANLAYICI VE YAKALANAN TAŞLARDAN SONRA GELEN SES BUTONUNU EN ALTA İTME */
    #toggle-sound-button {
        /* Flex öğesi içinde bu kural, butonu otomatik olarak en alta iter */
        margin-top: auto !important; 
        margin-bottom: 0 !important;
        border-top: 1px solid #555; /* Ayırmak için çizgi */
        padding-top: 15px;
    }
    
    /* Zamanlayıcılar ve Bilgi Paneli */
    #info-panel {
        margin-top: 10px;
        width: 100%; /* Kapsayıcı genişliğini kullan */
    }
    
    /* Yakalanan taşların görünümünü yatayda optimize et */
    #white-captured-pieces, #black-captured-pieces {
        grid-template-columns: repeat(auto-fit, minmax(30px, 1fr)); /* Daha fazla sütun kullan */
        gap: 2px;
    }
    #white-captured-pieces h4, #black-captured-pieces h4 {
        grid-column: 1 / -1; /* Başlıklar tüm sütunlara yayılsın */
    }
    
    /* Zamanlayıcı fontunu küçült */
    .timer-display {
        font-size: 1.4em;
    }
}

/* En küçük telefonlar için (Örn: 420px altı) */
@media (max-width: 420px) {
    /* Tahtayı daha da küçült */
    #chessboard {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
        width: 320px; 
        height: 320px;
    }

    #left-panel, #right-panel {
        width: 320px; 
    }
    
    .piece {
        font-size: 28px;
    }
}