/* chess_lobby.css — Satranç (chess lobby) sayfası stilleri */
/* Template: templates/data_manager/satranc.html'den çıkarıldı */

.chess-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* Dikeyde ortalamayı kaldır ki yukarıdan kesilmesin */
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    gap: 2rem;
    padding: 4rem 1rem 1rem 1rem; /* Sabit navbar'ın altına inmesi için üstten boşluk */
    min-height: calc(100vh - 120px);
}

.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    min-height: 0;
}

/* Board and Captured Pieces Wrapper */
.board-wrapper {
    position: relative; /* Modals için absolute referansı */
    display: grid;
    grid-template-columns: auto 72px 300px;
    grid-template-rows: min-content 1fr 1fr min-content;
    gap: 0.5rem 1.5rem;
    margin: 0 auto;
    justify-content: center;
}

/* Player Profiles */
.player-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: transparent;
    padding: 0.2rem 0;
}
.player-profile img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: var(--surface-color);
    border: 1px solid #496482;
    object-fit: cover;
}
.player-profile .player-name {
    font-weight: 600;
    color: #fff;
    font-size: 1.1rem;
}
.player-top {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: center;
    margin-bottom: 0.5rem;
}
.player-bottom {
    grid-column: 1;
    grid-row: 4;
    justify-self: start;
    align-self: center;
    margin-top: 0.5rem;
}

/* Board Area Wrapper (Modals and Board) */
.board-area {
    grid-column: 1;
    grid-row: 2 / 4;
    height: calc(100vh - 220px);
    max-height: 600px;
    min-height: 280px;
    width: auto;
    aspect-ratio: 1 / 1;
    position: relative; /* Modals bunun içinde mutlak konuma geçecek */
    border-radius: 4px;
    overflow: hidden; /* Kenar taşmalarını (sub-pixel bleed) çizgi çekmeden traşlar */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); /* Tahtanın tamamına hafif bir derinlik */
}

/* Chessground Responsive Container */
#myBoard.cg-wrap {
    width: 100%;
    height: 100%;
}

.captured-box {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 6px;
    display: grid;
    width: 72px;
    height: max-content;
    grid-template-columns: repeat(2, 28px);
    grid-template-rows: repeat(8, 28px);
    gap: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}
.captured-top {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
}
.captured-bottom {
    grid-column: 2;
    grid-row: 3;
    align-self: stretch;
}

.captured-piece-wrapper {
    position: relative !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 100% !important;
    height: 100% !important;
    margin-right: 0;
    transition: all 0.3s ease;
}
.captured-piece-wrapper.empty {
    opacity: 1;
    filter: grayscale(100%) brightness(0.6);
}
.captured-piece-wrapper.filled {
    opacity: 1;
    /* Üst üste eklenen yumuşak gölgeler sayesinde köşelerde kırılma yapmayan pürüzsüz mavi şerit/parlama efekti */
    filter: drop-shadow(0 0 1.5px var(--accent-color)) drop-shadow(0 0 1.5px var(--accent-color)) drop-shadow(0 0 2px rgba(0,0,0,0.5));
}
.captured-piece-wrapper.filled:hover {
    z-index: 10;
    transform: translateY(-2px);
}
.captured-piece-wrapper piece {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: cover;
}

/* Celikezor Custom Board Theme - Yüksek Kontrastlı Mavi/Gri Checkerboard (Sub-pixel perfect SVG) */
.cg-wrap cg-board {
    background-color: #496482;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><rect width='8' height='8' fill='%23496482'/><path d='M0,0h1v1h-1z M2,0h1v1h-1z M4,0h1v1h-1z M6,0h1v1h-1z M1,1h1v1h-1z M3,1h1v1h-1z M5,1h1v1h-1z M7,1h1v1h-1z M0,2h1v1h-1z M2,2h1v1h-1z M4,2h1v1h-1z M6,2h1v1h-1z M1,3h1v1h-1z M3,3h1v1h-1z M5,3h1v1h-1z M7,3h1v1h-1z M0,4h1v1h-1z M2,4h1v1h-1z M4,4h1v1h-1z M6,4h1v1h-1z M1,5h1v1h-1z M3,5h1v1h-1z M5,5h1v1h-1z M7,5h1v1h-1z M0,6h1v1h-1z M2,6h1v1h-1z M4,6h1v1h-1z M6,6h1v1h-1z M1,7h1v1h-1z M3,7h1v1h-1z M5,7h1v1h-1z M7,7h1v1h-1z' fill='%239cb2c7'/></svg>");
    background-size: 100% 100%;
    border-radius: 4px;
    /* Border ve shadow, chessground'un piksel hesaplamasını bozmasın diye #myBoard'a taşındı */
}


/* Hamle sırası kimdeyse onun taşlarına mavi parlama efekti */
.cg-wrap.turn-white piece.white {
    filter: drop-shadow(0 0 3px var(--accent-color)) drop-shadow(0 0 1px var(--accent-color));
    transition: filter 0.3s ease;
}
.cg-wrap.turn-black piece.black {
    filter: drop-shadow(0 0 3px var(--accent-color)) drop-shadow(0 0 1px var(--accent-color));
    transition: filter 0.3s ease;
}

/* Koordinatları (harfler ve sayılar) tahtanın içine al ve Chess.com tarzı yap */
.cg-wrap coords {
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 11px;
    z-index: 10;
    pointer-events: none;
}
.cg-wrap coords.ranks {
    left: 2px !important;
    right: auto !important;
    top: 2px !important;
    width: 12px;
}
.cg-wrap coords.ranks coord {
    transform: none !important;
    display: flex;
    align-items: flex-start; /* Üste daya */
}
.cg-wrap coords.files {
    bottom: 0 !important;
    left: 0 !important;
    text-align: right !important; /* Sağa daya */
    text-transform: lowercase !important; /* a, b, c... */
}
.cg-wrap coords.files coord {
    padding-right: 3px;
    padding-left: 0 !important;
}

/* Koordinat renkleri (Zemin renginin zıttı olacak şekilde) */
.cg-wrap coords.ranks coord:nth-child(odd),
.cg-wrap coords.files coord:nth-child(odd) {
    color: #9cb2c7; /* Açık renk yazı (Koyu karenin üstünde) */
}
.cg-wrap coords.ranks coord:nth-child(even),
.cg-wrap coords.files coord:nth-child(even) {
    color: #496482; /* Koyu renk yazı (Açık karenin üstünde) */
}

/* Son hamle ve seçili taş vurgusu */
.cg-wrap cg-board square.last-move {
    background-color: rgba(0, 210, 255, 0.4) !important;
}
.cg-wrap cg-board square.selected {
    background-color: rgba(0, 210, 255, 0.5) !important;
}

/* Valid move destination markers */
.cg-wrap cg-board square.move-dest {
    background: radial-gradient(rgba(0, 210, 255, 0.5) 22%, transparent 0);
}
.cg-wrap cg-board square.move-dest:hover {
    background: rgba(0, 210, 255, 0.2);
}
.cg-wrap cg-board square.oc.move-dest {
    background: radial-gradient(transparent 0%, transparent 80%, rgba(255, 51, 51, 0.5) 80%);
}

/* Check highlight */
.cg-wrap cg-board square.check {
    background: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 0) 100%);
}

.info-wrapper {
    grid-column: 3;
    grid-row: 1 / 5;
    position: relative;
    width: 100%;
    height: 100%;
}

.info-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 25, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.status-box {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    flex-shrink: 0; /* Daralmasını engelle */
}

.status-text {
    color: var(--accent-color);
    font-size: 1.3rem;
    font-weight: 700;
}

.history-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Flex child overflow hack */
    overflow: hidden;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    gap: 0.8rem 0.5rem;
    align-content: start;
    font-family: monospace;
    font-size: 1.1rem;
    padding-right: 0.5rem;
    padding-bottom: 1rem;
}

.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: var(--bg-color); }
.history-list::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }

.history-row-num {
    color: var(--text-secondary);
    text-align: right;
    padding-right: 10px;
}

.history-move { 
    color: var(--text-primary); 
    cursor: pointer; 
    transition: color 0.2s;
    text-align: center; /* Eşit boşluk için ortala */
}
.history-move:hover { color: var(--accent-color); }
.history-move.active { color: var(--accent-color); font-weight: bold; }

.controls-box {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    flex-shrink: 0;
}

.game-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.9rem;
}

.game-btn:hover {
    background: rgba(0, 210, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.fullscreen-btn {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    padding: 0 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fullscreen-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: rgba(0, 210, 255, 0.1);
}

.chess-layout:fullscreen {
    background: var(--bg-color) !important;
    padding: 1rem !important;
    overflow-y: auto !important;
    min-height: 100vh !important;
    height: auto !important;
    display: flex !important;
}
.chess-layout:-webkit-full-screen {
    background: var(--bg-color) !important;
    padding: 1rem !important;
    overflow-y: auto !important;
    min-height: 100vh !important;
    height: auto !important;
    display: flex !important;
}

/* Chess Modal Overlays */
.chess-modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 15, 25, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 40;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.chess-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface-color);
    border: 1px solid var(--accent-color);
    padding: 2.5rem 3rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6), 0 0 25px rgba(0, 210, 255, 0.2);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chess-modal-overlay.show .modal-content {
    transform: translateY(0);
}
.modal-title {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 0.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}
.modal-message {
    font-size: 1.2rem;
    color: #9cb2c7;
    margin-bottom: 2rem;
}
.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.modal-buttons .primary-btn {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    font-weight: 700;
}
.modal-buttons .primary-btn:hover {
    background: #00b8e6;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}

.promo-pieces {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.promo-piece {
    width: 64px;
    height: 64px;
    background-color: #496482;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid transparent;
}
.promo-piece:hover {
    background-color: var(--surface-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.3);
    transform: translateY(-5px);
}
.promo-piece piece {
    width: 48px;
    height: 48px;
    background-size: cover;
    display: block;
    position: static;
}

.start-menu-content.hidden {
    display: none !important;
}
.start-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}
.start-menu-buttons .game-btn {
    padding: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.difficulty-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}
.diff-btn {
    background: var(--surface-color);
    border: 1px solid #496482;
    color: #9cb2c7;
    padding: 0.8rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.diff-btn:hover {
    background: rgba(0, 210, 255, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.color-selection {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}
.color-btn {
    flex: 1;
    background: transparent;
    border: 1px solid #496482;
    color: #9cb2c7;
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}
.color-btn i { font-size: 1.5rem; }
.color-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    color: #fff;
}

@media (max-width: 1024px) {
    .chess-layout { 
        flex-direction: column; 
        height: auto;
        padding: 4rem 0 1rem 0; 
        align-items: stretch; /* Mobilde ortalamayı iptal et */
    }
    .board-container { width: 100%; }
    
    .promo-piece {
        width: 50px;
        height: 50px;
    }
    .promo-piece piece {
        width: 40px;
        height: 40px;
    }
    .promo-pieces {
        gap: 0.5rem;
    }

    .info-wrapper { 
        grid-column: 1;
        grid-row: 6;
        width: 100%; 
        margin-top: 1rem; 
        height: 400px; /* Mobilde scroll olabilmesi için sabit yükseklik */
    }
    
    .board-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto auto;
        gap: 1rem 0;
        width: 100%;
    }
    .player-top { grid-column: 1; grid-row: 1; }
    .captured-top { grid-column: 1; grid-row: 2; }
    .board-area {
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        height: auto;
        max-height: none;
        max-width: 95vw; 
    }
    #myBoard.cg-wrap {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
    .captured-bottom { grid-column: 1; grid-row: 4; }
    .player-bottom { grid-column: 1; grid-row: 5; }
    .captured-box {
        width: max-content;
        height: auto;
        grid-template-columns: repeat(8, 30px);
        grid-template-rows: repeat(2, 30px);
        justify-content: center;
        margin: 0 auto;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 4px;
        padding: 1rem 0.5rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow-y: auto;
        box-sizing: border-box;
        border: 2px solid var(--accent-color);
    }
    .modal-title {
        font-size: 1.8rem;
        margin-bottom: 0.2rem;
    }
    .modal-message {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    .start-menu-buttons {
        max-width: 100%;
        width: 90%;
    }
    .start-menu-buttons .game-btn {
        padding: 0.8rem;
        font-size: 1rem;
    }
    .difficulty-grid {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    .diff-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}
