/* ============================================
   SahinOS — Games Styles
   ============================================ */

/* ── Common Game Styles ── */
.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(0,0,0,0.8);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 2;
    position: relative;
}

.game-hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-value {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.game-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.85);
    z-index: 10;
}

.game-overlay-content {
    text-align: center;
    color: #fff;
}

.game-overlay-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.game-overlay-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: 3px;
}

.game-overlay-content p {
    color: rgba(255,255,255,0.6);
    margin: 0 0 20px;
    font-size: 14px;
}

.game-btn {
    padding: 10px 32px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.game-btn:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59,130,246,0.4);
}


/* ── Snake Game ── */
.game-snake-wrap {
    width: 100%;
    height: 100%;
    position: relative;
    background: #0a0e17;
    display: flex;
    flex-direction: column;
}

.game-snake-wrap canvas {
    flex: 1;
    display: block;
}


/* ── Minesweeper ── */
.game-minesweeper-wrap {
    width: 100%;
    height: 100%;
    background: #1e1e2e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mine-hud {
    justify-content: space-around;
}

.mine-face {
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    transition: background 0.2s;
}

.mine-face:hover {
    background: rgba(255,255,255,0.1);
}

.mine-difficulty {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    justify-content: center;
    background: rgba(0,0,0,0.3);
}

.mine-diff-btn {
    padding: 4px 16px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mine-diff-btn:hover {
    background: rgba(255,255,255,0.12);
}

.mine-diff-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.mine-grid-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12px;
}

.mine-grid {
    display: grid;
    gap: 1px;
    background: #333;
    border: 2px solid #555;
    border-radius: 4px;
}

.mine-cell {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: linear-gradient(145deg, #4a4a5e, #3a3a4e);
    cursor: pointer;
    user-select: none;
    border-radius: 2px;
    transition: background 0.1s;
}

.mine-cell:hover {
    background: linear-gradient(145deg, #5a5a6e, #4a4a5e);
}

.mine-cell.revealed {
    background: #2a2a3e;
    cursor: default;
}

.mine-cell.mine-boom {
    background: #7f1d1d !important;
}


/* ── Chess Game ── */
.chess-app {
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}

/* Player bars */
.chess-player-bar {
    display: flex; align-items: center;
    padding: 5px 12px; gap: 10px;
    background: rgba(0,0,0,0.3);
}
.chess-player-badge {
    display: flex; align-items: center; gap: 5px;
    padding: 2px 10px; border-radius: 6px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chess-player-badge.black-badge { background: rgba(30,30,30,0.8); color: #aaa; }
.chess-player-badge.white-badge { background: rgba(240,217,181,0.15); color: #f0d9b5; }
.badge-icon { font-size: 16px; }
.chess-captured-row {
    display: flex; flex-wrap: wrap; gap: 1px;
    font-size: 13px; color: rgba(255,255,255,0.55); flex: 1;
}
.chess-material-adv {
    font-size: 12px; font-weight: 700;
    color: rgba(255,255,255,0.45); min-width: 20px; text-align: right;
}

/* Board area */
.chess-board-area {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 2px 12px; min-height: 0;
}
.chess-board-col { display: flex; flex-direction: column; }
.chess-ranks {
    display: flex; flex-direction: column; justify-content: space-around; padding-right: 4px;
}
.chess-ranks span {
    display: flex; align-items: center; justify-content: center;
    height: 52px; width: 14px;
    font-size: 10px; color: rgba(255,255,255,0.3); font-weight: 600;
}
.chess-files { display: flex; justify-content: space-around; padding-top: 2px; }
.chess-files span {
    width: 52px; text-align: center;
    font-size: 10px; color: rgba(255,255,255,0.3); font-weight: 600;
}

/* Board grid */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 52px);
    grid-template-rows: repeat(8, 52px);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 4px; overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.chess-cell {
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative; user-select: none;
    transition: background 0.15s;
}
.chess-cell.light { background: #f0d9b5; }
.chess-cell.dark { background: #b58863; }
.chess-cell.selected { background: #7fc97f !important; }
.chess-cell.legal-move::after {
    content: ''; position: absolute;
    width: 14px; height: 14px;
    background: rgba(0,0,0,0.18); border-radius: 50%;
}
.chess-cell.legal-capture { box-shadow: inset 0 0 0 3px rgba(0,0,0,0.2); }
.chess-cell.last-move { background: rgba(255,255,100,0.4) !important; }
.chess-cell.check { background: rgba(231,76,60,0.7) !important; }

/* Piece rendering — FIX: clear white vs black */
.chess-piece {
    font-size: 36px; line-height: 1; pointer-events: none;
}
.chess-piece.white-piece {
    color: #ffffff;
    -webkit-text-stroke: 0.8px #666;
    paint-order: stroke fill;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}
.chess-piece.black-piece {
    color: #1c1c1c;
    -webkit-text-stroke: 0.3px #000;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

/* Bottom toolbar */
.chess-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px;
    background: rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.08);
}
.chess-turn-info { display: flex; align-items: center; gap: 8px; }
.chess-turn-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25); transition: background 0.3s;
}
.chess-turn-dot.w-turn { background: #f0d9b5; }
.chess-turn-dot.b-turn { background: #3a2a1a; }
.chess-turn-label {
    font-size: 13px; color: rgba(255,255,255,0.7); font-weight: 500;
}
.chess-actions { display: flex; gap: 4px; }
.chess-action-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px; color: rgba(255,255,255,0.6);
    font-size: 15px; cursor: pointer; transition: all 0.2s;
}
.chess-action-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.chess-action-btn.active {
    background: rgba(59,130,246,0.3);
    border-color: rgba(59,130,246,0.4); color: #60a5fa;
}

/* Status bar */
.chess-status {
    padding: 6px 12px; text-align: center;
    font-size: 13px; color: rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.3);
    border-top: 1px solid rgba(255,255,255,0.05);
    min-height: 28px;
}
.chess-status.check-text { color: #e74c3c; font-weight: 600; }
.chess-status.mate-text { color: #fbbf24; font-weight: 700; font-size: 15px; }

/* Leaderboard overlay */
.chess-lb-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 20;
}
.chess-lb-panel {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px; width: 90%; max-width: 400px;
    max-height: 85%; overflow: hidden;
    display: flex; flex-direction: column;
}
.chess-lb-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chess-lb-header h3 { margin: 0; color: #fbbf24; font-size: 15px; font-weight: 700; }
.chess-lb-close {
    background: none; border: none; color: rgba(255,255,255,0.5);
    font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.chess-lb-close:hover { color: #fff; }
.chess-lb-body { padding: 14px; overflow-y: auto; flex: 1; }

/* Stats grid */
.lb-stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px;
}
.lb-stat-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px; padding: 8px 6px; text-align: center;
}
.lb-stat-val { font-size: 20px; font-weight: 700; color: #fff; display: block; }
.lb-stat-lbl {
    font-size: 9px; color: rgba(255,255,255,0.35);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; display: block;
}
.lb-stat-card.win .lb-stat-val { color: #22c55e; }
.lb-stat-card.loss .lb-stat-val { color: #ef4444; }
.lb-stat-card.rate .lb-stat-val { color: #60a5fa; }

/* History */
.lb-section-title {
    font-size: 11px; color: rgba(255,255,255,0.35);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.lb-row {
    display: flex; align-items: center; padding: 7px 10px;
    border-radius: 6px; margin-bottom: 3px; font-size: 12px;
    gap: 10px; background: rgba(255,255,255,0.03);
}
.lb-row.win { border-left: 3px solid #22c55e; }
.lb-row.loss { border-left: 3px solid #ef4444; }
.lb-row.draw { border-left: 3px solid #f59e0b; }
.lb-row-icon { font-size: 14px; }
.lb-row-result { font-weight: 600; min-width: 36px; }
.lb-row.win .lb-row-result { color: #22c55e; }
.lb-row.loss .lb-row-result { color: #ef4444; }
.lb-row.draw .lb-row-result { color: #f59e0b; }
.lb-row-moves { color: rgba(255,255,255,0.4); flex: 1; }
.lb-row-date { color: rgba(255,255,255,0.25); font-size: 11px; }
.lb-empty {
    text-align: center; color: rgba(255,255,255,0.25);
    padding: 20px; font-size: 13px;
}

/* Promotion overlay */
.chess-promo-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center; z-index: 15;
}
.chess-promo-panel {
    background: #1e293b; padding: 14px;
    border-radius: 12px; border: 1px solid rgba(255,255,255,0.15);
    text-align: center;
}
.chess-promo-title {
    font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 10px;
}
.chess-promo-choices { display: flex; gap: 8px; }
.chess-promo-piece {
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; cursor: pointer; border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
    color: #fff; -webkit-text-stroke: 0.8px #555;
}
.chess-promo-piece:hover {
    background: rgba(255,255,255,0.15); transform: scale(1.1);
}


/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    /* Chess */
    .chess-board {
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
        width: min(calc(100vw - 56px), 384px);
    }
    .chess-cell { width: auto; height: auto; aspect-ratio: 1; }
    .chess-piece { font-size: clamp(22px, 6vw, 34px); }
    .chess-ranks span { height: auto; font-size: 9px; width: 12px; }
    .chess-files span { width: auto; font-size: 9px; }
    .chess-board-area { padding: 2px 4px; }
    .chess-player-bar { padding: 3px 8px; }
    .chess-toolbar { padding: 4px 8px; }
    .chess-action-btn { width: 28px; height: 28px; font-size: 13px; }
    .chess-turn-label { font-size: 11px; }
    .chess-captured-row { font-size: 11px; }

    /* Snake */
    .game-snake-wrap {
        touch-action: none;
    }

    /* Minesweeper */
    .mine-grid-container {
        padding: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .mine-cell {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .mine-difficulty {
        padding: 6px 8px;
    }

    .mine-diff-btn {
        padding: 4px 12px;
        font-size: 11px;
    }

    /* Common */
    .game-hud {
        padding: 6px 10px;
    }

    .hud-value {
        font-size: 16px;
    }

    .game-overlay-icon {
        font-size: 48px;
    }

    .game-overlay-content h2 {
        font-size: 22px;
    }
}

/* ── Light Theme ── */
[data-theme="light"] .game-hud {
    background: rgba(240, 242, 245, 0.95) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .hud-label {
    color: #888 !important;
}
[data-theme="light"] .hud-value {
    color: #1a1a2e !important;
}
[data-theme="light"] .game-overlay {
    background: rgba(255, 255, 255, 0.9) !important;
}
[data-theme="light"] .game-overlay-content {
    color: #1a1a2e !important;
}
[data-theme="light"] .game-overlay-content p {
    color: #555 !important;
}
[data-theme="light"] .chess-action-btn {
    color: #555 !important;
}
[data-theme="light"] .chess-action-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #1a1a2e !important;
}
[data-theme="light"] .chess-status {
    color: #555 !important;
}
[data-theme="light"] .chess-lb-close {
    color: #555 !important;
}
[data-theme="light"] .chess-lb-close:hover {
    color: #1a1a2e !important;
}
[data-theme="light"] .lb-stat-val {
    color: #1a1a2e !important;
}
[data-theme="light"] .lb-stat-label {
    color: #888 !important;
}
[data-theme="light"] .lb-header-label {
    color: #888 !important;
}
[data-theme="light"] .lb-row-moves {
    color: #555 !important;
}
[data-theme="light"] .lb-row-date {
    color: #888 !important;
}
[data-theme="light"] .lb-empty {
    color: #888 !important;
}
[data-theme="light"] .chess-difficulty-text {
    color: #555 !important;
}
